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