1 | function output = callbpmpd(interfacedata) |
---|
2 | |
---|
3 | % Author Johan Löfberg |
---|
4 | % $Id: callbpmpd.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 | Q = interfacedata.Q; |
---|
13 | lb = interfacedata.lb; |
---|
14 | ub = interfacedata.ub; |
---|
15 | |
---|
16 | if ~isempty(F_struc) |
---|
17 | A =-F_struc(1:end,2:end); |
---|
18 | b = F_struc(1:end,1); |
---|
19 | e = [zeros(K.f,1);-ones(K.l,1)]; |
---|
20 | else |
---|
21 | A = []; |
---|
22 | b = []; |
---|
23 | e = []; |
---|
24 | end |
---|
25 | |
---|
26 | if isempty(ub) | all(isinf(lb)) |
---|
27 | llist = []; |
---|
28 | lval = []; |
---|
29 | else |
---|
30 | llist = find(~isinf(lb)); |
---|
31 | lval = lb(llist); |
---|
32 | end |
---|
33 | |
---|
34 | if isempty(ub) | all(isinf(ub)) |
---|
35 | ulist = []; |
---|
36 | uval = []; |
---|
37 | else |
---|
38 | ulist = find(~isinf(ub)); |
---|
39 | uval = ub(ulist); |
---|
40 | end |
---|
41 | |
---|
42 | Q = 2*Q; |
---|
43 | b = full(b); |
---|
44 | c = full(c); |
---|
45 | |
---|
46 | if nnz(Q)==0 |
---|
47 | Q = []; |
---|
48 | end |
---|
49 | |
---|
50 | opts = options.bpmpd.opts; |
---|
51 | if options.savedebug |
---|
52 | ops = options.quadprog; |
---|
53 | save bpmpdebug Q A b c e llist lval ulist uval opts |
---|
54 | end |
---|
55 | |
---|
56 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
57 | solvertime = clock; |
---|
58 | [x,y,s,w,how] = bp(Q, A, b, c, e,llist,lval,ulist,uval,opts); |
---|
59 | if interfacedata.getsolvertime solvertime = etime(clock,solvertime);else solvertime = 0;end |
---|
60 | |
---|
61 | problem = 0; |
---|
62 | |
---|
63 | % Internal format for duals |
---|
64 | D_struc = -y; |
---|
65 | |
---|
66 | switch how |
---|
67 | case 'optimal solution' |
---|
68 | problem = 0; |
---|
69 | case 'infeasible primal' |
---|
70 | problem = 1; |
---|
71 | case 'infeasible dual' |
---|
72 | problem = 2; |
---|
73 | otherwise |
---|
74 | problem = 11; |
---|
75 | end |
---|
76 | |
---|
77 | % Save all data sent to solver? |
---|
78 | if options.savesolverinput |
---|
79 | solverinput.A = A; |
---|
80 | solverinput.b = b; |
---|
81 | solverinput.c = c; |
---|
82 | solverinput.Q = Q; |
---|
83 | solverinput.e = e; |
---|
84 | solverinput.llist = llist; |
---|
85 | solverinput.lval = lval; |
---|
86 | solverinput.ulist = ulist; |
---|
87 | solverinput.uval = uval; |
---|
88 | solverinput.bpoptss = bpopt; |
---|
89 | else |
---|
90 | solverinput = []; |
---|
91 | end |
---|
92 | |
---|
93 | % Save all data from the solver? |
---|
94 | if options.savesolveroutput |
---|
95 | solveroutput.x = x; |
---|
96 | solveroutput.y = y; |
---|
97 | solveroutput.s = s; |
---|
98 | solveroutput.w = w; |
---|
99 | solveroutput.how=how; |
---|
100 | else |
---|
101 | solveroutput = []; |
---|
102 | end |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | % Standard interface |
---|
107 | output.Primal = x; |
---|
108 | output.Dual = D_struc; |
---|
109 | output.Slack = []; |
---|
110 | output.problem = problem; |
---|
111 | output.solverinput = solverinput; |
---|
112 | output.solveroutput= solveroutput; |
---|
113 | output.solvertime = solvertime; |
---|