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