[37] | 1 | function output = callpensdpm(interfacedata); |
---|
| 2 | |
---|
| 3 | % Retrieve needed data |
---|
| 4 | options = interfacedata.options; |
---|
| 5 | F_struc = interfacedata.F_struc; |
---|
| 6 | c = interfacedata.c; |
---|
| 7 | K = interfacedata.K; |
---|
| 8 | x0 = interfacedata.x0; |
---|
| 9 | ub = interfacedata.ub; |
---|
| 10 | lb = interfacedata.lb; |
---|
| 11 | |
---|
| 12 | % Bounded variables converted to constraints |
---|
| 13 | if ~isempty(ub) |
---|
| 14 | [F_struc,K] = addbounds(F_struc,K,ub,lb); |
---|
| 15 | end |
---|
| 16 | |
---|
| 17 | % ******************************* |
---|
| 18 | % CONVERT FROM INTERNAL FORMAT |
---|
| 19 | % ******************************* |
---|
| 20 | penstruct = sedumi2pen(F_struc,K,c,x0); |
---|
| 21 | |
---|
| 22 | % ************************** |
---|
| 23 | % COPY OPTIONS |
---|
| 24 | % ************************** |
---|
| 25 | ops = struct2cell(options.pensdp);ops = [ops{1:end}]; |
---|
| 26 | penstruct.ioptions = ops(1:8); |
---|
| 27 | penstruct.foptions = ops(9:end); |
---|
| 28 | penstruct.ioptions(4) = max(0,min(3,options.verbose+1)); |
---|
| 29 | if penstruct.ioptions(4)==1 |
---|
| 30 | penstruct.ioptions(4)=0; |
---|
| 31 | end |
---|
| 32 | |
---|
| 33 | % FIX |
---|
| 34 | if penstruct.mconstr == 0 |
---|
| 35 | penstruct.msizes = []; |
---|
| 36 | end |
---|
| 37 | |
---|
| 38 | if options.savedebug |
---|
| 39 | save pensdpdebug penstruct |
---|
| 40 | end |
---|
| 41 | |
---|
| 42 | %************************** |
---|
| 43 | % CALL PENSDP |
---|
| 44 | %************************** |
---|
| 45 | showprogress('Calling PENSDP',options.showprogress); |
---|
| 46 | solvertime = clock; |
---|
| 47 | [x, fx, u, iresults, fresults, iflag] = pen(penstruct); |
---|
| 48 | solvertime = etime(clock,solvertime); |
---|
| 49 | |
---|
| 50 | % Get dual variable (this must be possible to do easier...) |
---|
| 51 | u = u(:); |
---|
| 52 | D_struc = u(1:1:K.l); |
---|
| 53 | if length(K.s)>0 |
---|
| 54 | if K.s(1)>0 |
---|
| 55 | pos = K.l+1; |
---|
| 56 | for i = 1:length(K.s) |
---|
| 57 | temp = zeros(K.s(i),K.s(i)); |
---|
| 58 | vecZ = u(pos:pos+0.5*K.s(i)*(K.s(i)+1)-1); |
---|
| 59 | top = 1; |
---|
| 60 | for j = 1:K.s(i) |
---|
| 61 | len = K.s(i)-j+1; |
---|
| 62 | temp(j:end,j)=vecZ(top:top+len-1);top=top+len; |
---|
| 63 | end |
---|
| 64 | temp = (temp+temp');j = find(speye(K.s(i)));temp(j)=temp(j)/2; |
---|
| 65 | D_struc = [D_struc;temp(:)]; |
---|
| 66 | pos = pos + (K.s(i)+1)*K.s(i)/2; |
---|
| 67 | end |
---|
| 68 | end |
---|
| 69 | end |
---|
| 70 | |
---|
| 71 | switch iflag |
---|
| 72 | case 0 |
---|
| 73 | problem = 0; |
---|
| 74 | case 1 |
---|
| 75 | problem = 4; |
---|
| 76 | case 2 |
---|
| 77 | problem = 1; |
---|
| 78 | case 3 |
---|
| 79 | problem = 4; |
---|
| 80 | case 4 |
---|
| 81 | problem = 3; |
---|
| 82 | case 5 |
---|
| 83 | problem = 7; |
---|
| 84 | case 6 |
---|
| 85 | problem = 11; |
---|
| 86 | case 7 |
---|
| 87 | problem = 9; |
---|
| 88 | otherwise |
---|
| 89 | problem = -1; |
---|
| 90 | end |
---|
| 91 | infostr = yalmiperror(problem,'PENSDP/TOMLAB'); |
---|
| 92 | |
---|
| 93 | if options.savesolveroutput |
---|
| 94 | solveroutput.f = f; |
---|
| 95 | solveroutput.x = x; |
---|
| 96 | solveroutput.u = u; |
---|
| 97 | solveroutput.iflag = iflag; |
---|
| 98 | solveroutput.niter = niter; |
---|
| 99 | solveroutput.feas = feas; |
---|
| 100 | else |
---|
| 101 | solveroutput = []; |
---|
| 102 | end |
---|
| 103 | if options.savesolverinput |
---|
| 104 | solverinput.penstruct = penstruct; |
---|
| 105 | else |
---|
| 106 | solverinput = []; |
---|
| 107 | end |
---|
| 108 | |
---|
| 109 | % Standard interface |
---|
| 110 | output.Primal = x(:); |
---|
| 111 | output.Dual = D_struc; |
---|
| 112 | output.Slack = []; |
---|
| 113 | output.problem = problem; |
---|
| 114 | output.infostr = infostr; |
---|
| 115 | output.solverinput = solverinput; |
---|
| 116 | output.solveroutput= solveroutput; |
---|
| 117 | output.solvertime = solvertime; |
---|
| 118 | |
---|
| 119 | |
---|
| 120 | |
---|
| 121 | |
---|