[37] | 1 | function output = calldsdp(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: calldsdp.m,v 1.4 2005/05/07 13:53:20 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 | [C,A,b,blk] = sedumi2dsdp(F_struc,c,K); |
---|
| 22 | |
---|
| 23 | % Quadratic not yet implemented? |
---|
| 24 | options.dsdp.dual_quadratic=spalloc(length(c),length(c),0); |
---|
| 25 | |
---|
| 26 | options.dsdp.printyes = (options.verbose>0); |
---|
| 27 | solvertime = clock; |
---|
| 28 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
| 29 | |
---|
| 30 | if options.savedebug |
---|
| 31 | save dsdpdebug A C b options.dsdp |
---|
| 32 | end |
---|
| 33 | |
---|
| 34 | if isempty(x0) |
---|
| 35 | if options.saveduals | options.savesolveroutput |
---|
| 36 | [STAT,y,X] = dsdp(A,C,b,options.dsdp); |
---|
| 37 | else |
---|
| 38 | [STAT,y] = dsdp(A,C,b,options.dsdp); |
---|
| 39 | end |
---|
| 40 | else |
---|
| 41 | if options.saveduals | options.savesolveroutput |
---|
| 42 | [STAT,y,X] = dsdp(A,C,b,options.dsdp,x0); |
---|
| 43 | else |
---|
| 44 | [STAT,y] = dsdp(A,C,b,options.dsdp,x0); |
---|
| 45 | end |
---|
| 46 | end |
---|
| 47 | solvertime = etime(clock,solvertime); |
---|
| 48 | |
---|
| 49 | % Create dual variable in internal format |
---|
| 50 | if options.saveduals |
---|
| 51 | D_struc = []; |
---|
| 52 | for i = 1:length(X) |
---|
| 53 | D_struc = [D_struc;X{i}(:)]; |
---|
| 54 | end |
---|
| 55 | else |
---|
| 56 | D_struc = []; |
---|
| 57 | end |
---|
| 58 | |
---|
| 59 | x = y; % Our notation do not coincide ... |
---|
| 60 | switch STAT.termcode |
---|
| 61 | case 0 |
---|
| 62 | if STAT.iterates>=options.dsdp.maxit |
---|
| 63 | problem = 3; |
---|
| 64 | else |
---|
| 65 | problem = 0; |
---|
| 66 | end |
---|
| 67 | % if STAT.gaphist (end) > options.dsdp.gaptol |
---|
| 68 | % problem = 5; |
---|
| 69 | % end |
---|
| 70 | case 1 |
---|
| 71 | problem = 2; |
---|
| 72 | case 2 |
---|
| 73 | problem = 1; |
---|
| 74 | case -3 |
---|
| 75 | problem = 3; |
---|
| 76 | otherwise |
---|
| 77 | problem = -1; |
---|
| 78 | end |
---|
| 79 | infostr = yalmiperror(problem,interfacedata.solver.tag); |
---|
| 80 | |
---|
| 81 | if options.savesolveroutput |
---|
| 82 | solveroutput.STAT = STAT; |
---|
| 83 | solveroutput.X = X; |
---|
| 84 | solveroutput.y = y; |
---|
| 85 | else |
---|
| 86 | solveroutput = []; |
---|
| 87 | end |
---|
| 88 | |
---|
| 89 | if options.savesolverinput |
---|
| 90 | solverinput.A = A; |
---|
| 91 | solverinput.C = C; |
---|
| 92 | solverinput.b = c; |
---|
| 93 | solverinput.pars = options.dsdp; |
---|
| 94 | else |
---|
| 95 | solverinput = []; |
---|
| 96 | end |
---|
| 97 | |
---|
| 98 | % Standard interface |
---|
| 99 | output.Primal = x; |
---|
| 100 | output.Dual = D_struc; |
---|
| 101 | output.Slack = []; |
---|
| 102 | output.problem = problem; |
---|
| 103 | output.infostr = infostr; |
---|
| 104 | output.solverinput = solverinput; |
---|
| 105 | output.solveroutput= solveroutput; |
---|
| 106 | output.solvertime = solvertime; |
---|