[37] | 1 | function output = callsdpt3302(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: callsdpt3302.m,v 1.8 2006/03/20 19:32:21 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,30); |
---|
| 22 | |
---|
| 23 | options.sdpt3.printyes=double(options.verbose); |
---|
| 24 | |
---|
| 25 | if options.savedebug |
---|
| 26 | sdpt3options = options.sdpt3; |
---|
| 27 | save sdpt3debug blk A C b sdpt3options x0 |
---|
| 28 | end |
---|
| 29 | |
---|
| 30 | solvertime = clock; |
---|
| 31 | showprogress('Calling SDPT3',options.showprogress); |
---|
| 32 | if options.verbose==0 % SDPT3 does not run silent despite printyes=0! |
---|
| 33 | evalc('[obj,X,y,Z,info,runhist,Xiter,yiter,Ziter] = sqlp(blk,A,C,b,options.sdpt3,[],x0,[]);'); |
---|
| 34 | else |
---|
| 35 | [obj,X,y,Z,info,runhist,Xiter,yiter,Ziter] = sqlp(blk,A,C,b,options.sdpt3,[],x0,[]); |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | % Create variables in internal format |
---|
| 39 | % A bit messy ... |
---|
| 40 | Dual = []; |
---|
| 41 | Slack = []; |
---|
| 42 | top = 1; |
---|
| 43 | if K.f>0 |
---|
| 44 | Dual = [Dual;X{top}(:)]; |
---|
| 45 | Slack = [Slack;Z{top}(:)]; |
---|
| 46 | top = top+1; |
---|
| 47 | end |
---|
| 48 | if K.l>0 |
---|
| 49 | Dual = [Dual;X{top}(:)]; |
---|
| 50 | Slack = [Slack;Z{top}(:)]; |
---|
| 51 | top = top + 1; |
---|
| 52 | end |
---|
| 53 | if K.q(1)>0 |
---|
| 54 | Dual = [Dual;Z{top}(:)]; |
---|
| 55 | Slack = [Slack;Z{top}(:)]; |
---|
| 56 | top = top + 1; |
---|
| 57 | end |
---|
| 58 | if K.s(1)>0 |
---|
| 59 | % Messy format in SDPT3 to block and sort small SDPs |
---|
| 60 | u = blk(:,1); |
---|
| 61 | u = find([u{:}]=='s'); |
---|
| 62 | s = 1; |
---|
| 63 | for top = u |
---|
| 64 | ns = blk(top,2);ns = ns{1}; |
---|
| 65 | k = 1; |
---|
| 66 | for i = 1:length(ns) |
---|
| 67 | Xi{oldKs(s)} = X{top}(k:k+ns(i)-1,k:k+ns(i)-1); |
---|
| 68 | Zi{oldKs(s)} = Z{top}(k:k+ns(i)-1,k:k+ns(i)-1); |
---|
| 69 | s = s + 1; |
---|
| 70 | k = k+ns(i); |
---|
| 71 | end |
---|
| 72 | end |
---|
| 73 | for i = 1:length(Xi) |
---|
| 74 | Dual = [Dual;Xi{i}(:)]; |
---|
| 75 | Slack = [Slack;Zi{i}(:)]; |
---|
| 76 | end |
---|
| 77 | end |
---|
| 78 | |
---|
| 79 | solvertime = etime(clock,solvertime); |
---|
| 80 | x = -y; % Our notation does not coincide ... |
---|
| 81 | |
---|
| 82 | % Convert error code |
---|
| 83 | switch info(1) |
---|
| 84 | case 0 |
---|
| 85 | problem = 0; % No problems detected |
---|
| 86 | case {-1,-5} |
---|
| 87 | problem = 5; % Lack of progress |
---|
| 88 | case {-2,-3,-4,-7} |
---|
| 89 | problem = 4; % Numerical problems |
---|
| 90 | case -6 |
---|
| 91 | problem = 3; % Maximum iterations exceeded |
---|
| 92 | case -10 |
---|
| 93 | problem = 7; % YALMIP sent incorrect input to solver |
---|
| 94 | case 1 |
---|
| 95 | problem = 2; % Dual feasibility |
---|
| 96 | case 2 |
---|
| 97 | problem = 1; % Primal infeasibility |
---|
| 98 | otherwise |
---|
| 99 | problem = -1; % Unknown error |
---|
| 100 | end |
---|
| 101 | infostr = yalmiperror(problem,interfacedata.solver.tag); |
---|
| 102 | |
---|
| 103 | if options.savesolveroutput |
---|
| 104 | solveroutput.obj = obj; |
---|
| 105 | solveroutput.X = X; |
---|
| 106 | solveroutput.y = y; |
---|
| 107 | solveroutput.Z = Z; |
---|
| 108 | solveroutput.info = info; |
---|
| 109 | solveroutput.runhist = runhist; |
---|
| 110 | solveroutput.Xiter = Xiter; |
---|
| 111 | solveroutput.yiter = yiter; |
---|
| 112 | solveroutput.Ziter = Ziter; |
---|
| 113 | else |
---|
| 114 | solveroutput = []; |
---|
| 115 | end |
---|
| 116 | |
---|
| 117 | if options.savesolverinput |
---|
| 118 | solverinput.blk = blk; |
---|
| 119 | solverinput.A = A; |
---|
| 120 | solverinput.C = C; |
---|
| 121 | solverinput.b = b; |
---|
| 122 | solverinput.X0 = []; |
---|
| 123 | solverinput.y0 = x0; |
---|
| 124 | solverinput.Z0 = []; |
---|
| 125 | solverinput.options = options.sdpt3; |
---|
| 126 | else |
---|
| 127 | solverinput = []; |
---|
| 128 | end |
---|
| 129 | |
---|
| 130 | % Standard interface |
---|
| 131 | output.Primal = x; |
---|
| 132 | output.Dual = Dual; |
---|
| 133 | output.Slack = Slack; |
---|
| 134 | output.problem = problem; |
---|
| 135 | output.infostr = infostr; |
---|
| 136 | output.solverinput = solverinput; |
---|
| 137 | output.solveroutput= solveroutput; |
---|
| 138 | output.solvertime = solvertime; |
---|