1 | function 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 |
---|
7 | options = interfacedata.options; |
---|
8 | F_struc = interfacedata.F_struc; |
---|
9 | c = interfacedata.c; |
---|
10 | K = interfacedata.K; |
---|
11 | x0 = interfacedata.x0; |
---|
12 | ub = interfacedata.ub; |
---|
13 | lb = interfacedata.lb; |
---|
14 | |
---|
15 | % Bounded variables converted to constraints |
---|
16 | if ~isempty(ub) |
---|
17 | [F_struc,K] = addbounds(F_struc,K,ub,lb); |
---|
18 | end |
---|
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 | |
---|
23 | options.sdpt3.printyes=double(options.verbose); |
---|
24 | options.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 |
---|
28 | if 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; |
---|
33 | end |
---|
34 | |
---|
35 | if options.savedebug |
---|
36 | ops = options.sdpt3; |
---|
37 | save sdpt3debug blk A C b ops x0 -v6 |
---|
38 | end |
---|
39 | |
---|
40 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
41 | solvertime = clock; |
---|
42 | if 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,[]);'); |
---|
44 | else |
---|
45 | [obj,X,y,Z,info,runhist] = sqlp(blk,A,C,b,options.sdpt3,[],x0,[]); |
---|
46 | end |
---|
47 | |
---|
48 | % Create YALMIP dual variable and slack |
---|
49 | Dual = []; |
---|
50 | Slack = []; |
---|
51 | top = 1; |
---|
52 | if K.f>0 |
---|
53 | Dual = [Dual;X{top}(:)]; |
---|
54 | Slack = [Slack;Z{top}(:)]; |
---|
55 | top = top+1; |
---|
56 | end |
---|
57 | if K.l>0 |
---|
58 | Dual = [Dual;X{top}(:)]; |
---|
59 | Slack = [Slack;Z{top}(:)]; |
---|
60 | top = top + 1; |
---|
61 | end |
---|
62 | if K.q(1)>0 |
---|
63 | Dual = [Dual;X{top}(:)]; |
---|
64 | Slack = [Slack;Z{top}(:)]; |
---|
65 | top = top + 1; |
---|
66 | end |
---|
67 | if 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 |
---|
86 | end |
---|
87 | |
---|
88 | solvertime = etime(clock,solvertime); |
---|
89 | Primal = -y; % Primal variable in YALMIP |
---|
90 | |
---|
91 | % Convert error code |
---|
92 | switch 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 |
---|
109 | end |
---|
110 | infostr = yalmiperror(problem,interfacedata.solver.tag); |
---|
111 | |
---|
112 | if 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 = []; |
---|
121 | end |
---|
122 | |
---|
123 | if 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; |
---|
132 | else |
---|
133 | solverinput = []; |
---|
134 | end |
---|
135 | |
---|
136 | % Standard interface |
---|
137 | output.Primal = Primal; |
---|
138 | output.Dual = Dual; |
---|
139 | output.Slack = Slack; |
---|
140 | output.problem = problem; |
---|
141 | output.infostr = infostr; |
---|
142 | output.solverinput = solverinput; |
---|
143 | output.solveroutput= solveroutput; |
---|
144 | output.solvertime = solvertime; |
---|