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

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

Added original make3d

File size: 3.7 KB
Line 
1function output = callsdpt34(interfacedata)
2
3% Author Johan Löfberg
4% $Id: callsdpt34.m,v 1.2 2006/07/26 18:53:47 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% Convert from internal (sedumi-like) format
21[blk,A,C,b,oldKs]=sedumi2sdpt3(F_struc(:,1),F_struc(:,2:end),c,K,options.sdpt3.smallblkdim);
22
23options.sdpt3.printyes=double(options.verbose);
24options.sdpt3.expon=options.sdpt3.expon(1);
25
26% Setup the logarithmic barrier cost. We exploit the fact that we know that
27% the only logaritmic cost is in the last SDP constraint
28if K.m > 0
29    for i = 1:size(blk,1)
30        options.sdpt3.parbarrier{i,1} = 0*blk{i,2};
31    end
32    options.sdpt3.parbarrier{i,end}(end) = 1;
33end
34
35if options.savedebug
36    ops = options.sdpt3;
37    save sdpt3debug blk A C b ops x0 -v6
38end
39
40if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end
41solvertime = clock;
42if options.verbose==0 % SDPT3 does not run silent despite printyes=0!
43   evalc('[obj,X,y,Z,info,runhist] =  sqlp(blk,A,C,b,options.sdpt3,[],x0,[]);');
44else
45    [obj,X,y,Z,info,runhist] =  sqlp(blk,A,C,b,options.sdpt3,[],x0,[]);   
46end
47
48% Create YALMIP dual variable and slack
49Dual = [];
50Slack = [];
51top = 1;
52if K.f>0
53    Dual = [Dual;X{top}(:)];
54    Slack = [Slack;Z{top}(:)];
55    top = top+1;
56end
57if K.l>0
58    Dual = [Dual;X{top}(:)];
59    Slack = [Slack;Z{top}(:)];
60    top = top + 1;
61end
62if K.q(1)>0
63    Dual = [Dual;X{top}(:)];
64    Slack = [Slack;Z{top}(:)];
65    top = top + 1;
66end
67if K.s(1)>0 
68    % Messy format in SDPT3 to block and sort small SDPs
69    u = blk(:,1);
70    u = find([u{:}]=='s');
71    s = 1;
72    for top = u
73        ns = blk(top,2);ns = ns{1};
74        k = 1;
75        for i = 1:length(ns)
76            Xi{oldKs(s)} = X{top}(k:k+ns(i)-1,k:k+ns(i)-1);
77            Zi{oldKs(s)} = Z{top}(k:k+ns(i)-1,k:k+ns(i)-1);
78            s = s + 1;                 
79            k = k+ns(i);
80        end
81    end
82    for i = 1:length(Xi)
83        Dual = [Dual;Xi{i}(:)];     
84        Slack = [Slack;Zi{i}(:)];     
85    end
86end
87
88solvertime = etime(clock,solvertime);
89Primal = -y;  % Primal variable in YALMIP
90
91% Convert error code
92switch info.termcode
93    case 0
94        problem = 0; % No problems detected
95    case {-1,-5}
96        problem = 5; % Lack of progress
97    case {-2,-3,-4,-7}
98        problem = 4; % Numerical problems
99    case -6
100        problem = 3; % Maximum iterations exceeded
101    case -10
102        problem = 7; % YALMIP sent incorrect input to solver
103    case 1
104        problem = 2; % Dual feasibility
105    case 2
106        problem = 1; % Primal infeasibility
107    otherwise
108        problem = -1; % Unknown error
109end
110infostr = yalmiperror(problem,interfacedata.solver.tag);
111
112if options.savesolveroutput
113    solveroutput.obj = obj;
114    solveroutput.X = X;
115    solveroutput.y = y;
116    solveroutput.Z = Z;
117    solveroutput.info = info;
118    solveroutput.runhist = runhist;
119 else
120    solveroutput = [];
121end
122
123if options.savesolverinput
124    solverinput.blk = blk;
125    solverinput.A   = A;
126    solverinput.C   = C;
127    solverinput.b   = b;
128    solverinput.X0   = [];
129    solverinput.y0   = x0;
130    solverinput.Z0   = [];
131    solverinput.options   = options.sdpt3;
132else
133    solverinput = [];
134end
135
136% Standard interface
137output.Primal      = Primal;
138output.Dual        = Dual;
139output.Slack       = Slack;
140output.problem     = problem;
141output.infostr     = infostr;
142output.solverinput = solverinput;
143output.solveroutput= solveroutput;
144output.solvertime  = solvertime;
Note: See TracBrowser for help on using the repository browser.