source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/solvers/calllmilab.m @ 37

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

Added original make3d

File size: 2.4 KB
Line 
1function output = calllmilab(interfacedata)
2
3% Author Johan Löfberg
4% $Id: calllmilab.m,v 1.4 2005/05/07 13:53:20 joloef Exp $
5
6% Retrieve needed data
7options = interfacedata.options;
8F_struc = interfacedata.F_struc;
9c       = interfacedata.c;
10K       = interfacedata.K;
11x0      = interfacedata.x0;
12ub      = interfacedata.ub;
13lb      = interfacedata.lb;
14
15% Bounded variables converted to constraints
16if ~isempty(ub)
17    [F_struc,K] = addbounds(F_struc,K,ub,lb);
18end
19
20% Define lmilab variables (is this the way to do it?)
21setlmis([])
22for i = 1:length(c)
23    [X,ndec,Xdec] = lmivar(2,[1 1]);
24end
25 
26% Can't linear constraints be defined more easily?
27lmicount = 1;
28top = 1;
29if K.l>0
30    for i = 1:K.l
31        lmiterm([-lmicount 1 1 0],F_struc(i,1));
32        for j = 1:length(c)
33            lmiterm([-lmicount 1 1 j],F_struc(i,j+1),1);
34        end
35        lmicount = lmicount+1;
36    end
37    top = top + K.l;
38end
39
40% The LMIs
41if K.s(1)>0       
42    for i = 1:length(K.s)
43        n = K.s(i);
44        lmiterm([-lmicount 1 1 0],full(reshape(F_struc(top:top+n^2-1,1),n,n)));
45        for j = 1:length(c)
46           lmiterm([-lmicount 1 1 j],full(reshape(F_struc(top:top+n^2-1,j+1),n,n)),1);
47        end
48        top = top+n^2;
49        lmicount = lmicount+1;
50    end
51end
52lmisys=getlmis;
53
54% Convert options
55ops = struct2cell(options.lmilab);ops = [ops{1:end}];
56if options.verbose>0
57    ops = [ops 0];
58else
59    ops = [ops 1];
60end
61
62if options.savedebug
63    save lmilabdebug lmisys c ops
64end
65
66% Solve...
67if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end
68solvertime = clock;
69if nnz(c)==0
70    [copt,x]=feasp(lmisys,ops);
71else
72    [copt,x]=mincx(lmisys,full(c),ops);
73end
74solvertime = etime(clock,solvertime);
75
76% No status
77if isempty(x)
78    problem = 1;
79    x = repmat(nan,length(c),1);
80else
81    problem = 0;
82end
83infostr = yalmiperror(problem,interfacedata.solver.tag);
84
85% No duals...
86D_struc = [];
87
88if options.savesolveroutput
89        solveroutput.copt = copt;
90        solveroutput.x = x;
91else
92        solveroutput = [];
93end
94
95if options.savesolverinput
96        solverinput.lmisys = lmisys;
97        solverinput.c = c;
98        solverinput.ops = ops;
99else
100        solverinput = [];
101end
102
103% Standard interface
104output.Primal      = x;
105output.Dual        = D_struc;
106output.Slack       = [];
107output.problem     = problem;
108output.infostr     = infostr;
109output.solverinput = solverinput;
110output.solveroutput= solveroutput;
111output.solvertime  = solvertime;
Note: See TracBrowser for help on using the repository browser.