[37] | 1 | function output = calldsdp(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: calldsdp5.m,v 1.7 2005/04/28 13:59:18 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 SeDuMi format |
---|
| 21 | [b,AC] = sedumi2dsdp5(F_struc,c,K); |
---|
| 22 | |
---|
| 23 | options.dsdp.printyes = (options.verbose>0); |
---|
| 24 | options.dsdp.print = (options.verbose>0); |
---|
| 25 | |
---|
| 26 | solvertime = clock; |
---|
| 27 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
| 28 | |
---|
| 29 | if options.savedebug |
---|
| 30 | pars = options.dsdp; |
---|
| 31 | save dsdpdebug AC b pars |
---|
| 32 | end |
---|
| 33 | |
---|
| 34 | if isempty(x0) |
---|
| 35 | if options.saveduals | options.savesolveroutput | options.dimacs |
---|
| 36 | [STAT,y,X] = dsdp(b,AC,options.dsdp); |
---|
| 37 | else |
---|
| 38 | [STAT,y] = dsdp(b,AC,options.dsdp); |
---|
| 39 | end |
---|
| 40 | else |
---|
| 41 | if options.saveduals | options.savesolveroutput | options.dimacs |
---|
| 42 | [STAT,y,X] = dsdp(b,AC,options.dsdp,x0); |
---|
| 43 | else |
---|
| 44 | [STAT,y] = dsdp(b,AC,options.dsdp,x0); |
---|
| 45 | end |
---|
| 46 | end |
---|
| 47 | solvertime = etime(clock,solvertime); |
---|
| 48 | |
---|
| 49 | % Create dual variable in internal format |
---|
| 50 | if options.saveduals | options.dimacs |
---|
| 51 | Dual = []; |
---|
| 52 | for i = 1:length(X) |
---|
| 53 | if isequal('SDP',AC{i,1}) |
---|
| 54 | XX = dmat(X{i}); |
---|
| 55 | else |
---|
| 56 | XX = X{i}; |
---|
| 57 | end |
---|
| 58 | Dual = [Dual;XX(:)]; |
---|
| 59 | end |
---|
| 60 | else |
---|
| 61 | Dual = []; |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | Primal = y; % Our notation do not coincide ... |
---|
| 65 | |
---|
| 66 | % Backwards compatibility |
---|
| 67 | if isfield(STAT,'dual') |
---|
| 68 | switch STAT.dual |
---|
| 69 | case 'Infeasible' |
---|
| 70 | STAT.termcode = 2; |
---|
| 71 | case 'Unbounded' |
---|
| 72 | STAT.termcode = 1; |
---|
| 73 | otherwise |
---|
| 74 | end |
---|
| 75 | end |
---|
| 76 | |
---|
| 77 | switch STAT.termcode |
---|
| 78 | case 0 |
---|
| 79 | if STAT.iterates>=options.dsdp.maxit |
---|
| 80 | problem = 3; |
---|
| 81 | else |
---|
| 82 | problem = 0; |
---|
| 83 | end |
---|
| 84 | case 1 |
---|
| 85 | problem = 2; |
---|
| 86 | case 2 |
---|
| 87 | problem = 1; |
---|
| 88 | case -3 |
---|
| 89 | problem = 4; |
---|
| 90 | otherwise |
---|
| 91 | problem = -1; |
---|
| 92 | end |
---|
| 93 | |
---|
| 94 | if options.savesolveroutput |
---|
| 95 | solveroutput.STAT = STAT; |
---|
| 96 | solveroutput.X = X; |
---|
| 97 | solveroutput.y = y; |
---|
| 98 | else |
---|
| 99 | solveroutput = []; |
---|
| 100 | end |
---|
| 101 | |
---|
| 102 | if options.savesolverinput |
---|
| 103 | solverinput.AC = AC; |
---|
| 104 | solverinput.b = b; |
---|
| 105 | solverinput.pars = options.dsdp; |
---|
| 106 | else |
---|
| 107 | solverinput = []; |
---|
| 108 | end |
---|
| 109 | |
---|
| 110 | % Standard interface |
---|
| 111 | output.Primal = Primal; |
---|
| 112 | output.Dual = Dual; |
---|
| 113 | output.Slack = []; |
---|
| 114 | output.problem = problem; |
---|
| 115 | output.solverinput = solverinput; |
---|
| 116 | output.solveroutput= solveroutput; |
---|
| 117 | output.solvertime = solvertime; |
---|