source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/imagemodel.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.7 KB
Line 
1function [Fimage,objimage,x,y] = imagemodel(F,obj)
2% IMAGEMODEL Explicitely removes equality constraints from model.
3%
4% [Fi,hi,x,y] = imagemodel(F,h)
5%
6% Input
7%  F   : Constraint in form F(x)>0, Ax=b
8%  h   : objective function h(x)
9%
10% Output
11%  Fi  : Constraints in form F(y)>0
12%  hi  : objective function h(y)
13%  x   : original variables
14%  z   : old variables expressed in basis y
15%
16% To obtain a solution in the original variables x, use assign(x,double(y))
17%
18% Note that this reduction is automatically done when you call solvesdp and use
19% a solver that cannot handle equality constraints. Hence, there is typically no
20% reason to use this command, unless some further manipulations are going
21% to be done.
22%
23% See also DUALIZE, PRIMALIZE
24
25% Author Johan Löfberg
26% $Id: imagemodel.m,v 1.3 2005/04/29 08:05:01 joloef Exp $
27
28% Check for unsupported problems
29err = 0;
30p1 = ~(isreal(F) & isreal(obj));
31p2 = ~(islinear(F) & islinear(obj));
32p3 = any(is(F,'integer')) | any(is(F,'binary'));
33if p1 | p2 | p3
34    if nargout == 5
35        Fdual = set([]);objdual = [];y = []; X = []; t = []; err = 1;
36    else
37        problems = {'Cannot imagalize complex-valued problems','Cannot imagalize nonlinear problems','Cannot imagalize discrete problems'};
38        error(problems{min(find([p1 p2 p3]))});
39    end
40end
41
42if any(is(F,'equality'))
43    [model,recoverdata,solver,diagnostic,F] = compileinterfacedata(F,[],[],obj,sdpsettings('solver','sedumi','remove',1),0);
44    if isfield(diagnostic,'problem')
45        if diagnostic.problem == 1
46            warning('Problem is infeasible');
47            Fimage = [];
48            objimage = [];
49            x = [];
50            y = [];
51            return
52        end
53    end
54    if isempty(model)
55            Fimage = [];
56            objimage = [];
57            x = [];
58            y = [];
59            warning('Reduced problem does not have free variables. Optimal solution computed');
60            return
61    end
62else
63    Fimage = F;
64    objimage = obj;
65    x  = recover(unique([depends(obj) depends(F)]));
66    y = x;
67    return
68end
69
70y = sdpvar(length(model.c),1);
71
72vecF = model.F_struc*[1;y];
73K = model.K;
74Fimage = set([]);
75start = 1;
76if model.K.l > 0
77    Fimage = Fimage + set(vecF(start:start+K.l-1) > 0);
78    start = start + K.l;
79end
80
81if model.K.q(1) > 0
82    for i = 1:length(model.K.q)
83        z = vecF(start:start+K.q(i)-1)
84        Fimage = Fimage + set(cone(z(2:end),z(1)));
85        start = start + K.q(i);
86    end
87end
88
89if model.K.s(1)>0
90    for i = 1:length(model.K.s)
91        z = vecF(start:start+K.s(i)^2-1);
92        Fimage = Fimage + set(reshape(z,K.s(i),K.s(i)));
93        start = start + K.s(i)^2;
94    end
95end
96
97objimage = model.c'*y+y'*model.Q*y+model.f;
98
99x = recover(recoverdata.used_variables);
100y = recoverdata.H*y+recoverdata.x_equ;
Note: See TracBrowser for help on using the repository browser.