1 | function output = callcdd(interfacedata) |
---|
2 | |
---|
3 | % Author Johan Löfberg |
---|
4 | % $Id: callcdd.m,v 1.3 2005/05/07 13:53:20 joloef Exp $ |
---|
5 | |
---|
6 | % Standard input interface |
---|
7 | options = interfacedata.options; |
---|
8 | F_struc = interfacedata.F_struc; |
---|
9 | c = interfacedata.c; |
---|
10 | K = interfacedata.K; |
---|
11 | Q = interfacedata.Q; |
---|
12 | ub = interfacedata.ub; |
---|
13 | lb = interfacedata.lb; |
---|
14 | |
---|
15 | if ~isempty(ub) |
---|
16 | [F_struc,K] = addbounds(F_struc,K,ub,lb); |
---|
17 | end |
---|
18 | |
---|
19 | IN = struct('obj',full(c(:))','A',full(-F_struc(:,2:end)),'B',full(F_struc(:,1))); |
---|
20 | if K.f>0 |
---|
21 | IN.lin = 1:K.f; |
---|
22 | end |
---|
23 | |
---|
24 | % % CDD does not check this.. |
---|
25 | % % Fix the duals... |
---|
26 | % valid_constraints = find(any(IN.A')); |
---|
27 | % IN.A = IN.A(valid_constraints,:); |
---|
28 | % IN.B = IN.B(valid_constraints,:); |
---|
29 | |
---|
30 | showprogress('Calling CDD',options.showprogress); |
---|
31 | solvertime = clock; |
---|
32 | |
---|
33 | if options.savedebug |
---|
34 | save cdddebug IN |
---|
35 | end |
---|
36 | |
---|
37 | switch options.cdd.method |
---|
38 | case 'criss-cross' |
---|
39 | OUT = cddmex('solve_lp',IN); |
---|
40 | case 'dual-simplex' |
---|
41 | OUT = cddmex('solve_lp_DS',IN); |
---|
42 | otherwise |
---|
43 | end |
---|
44 | solvertime = etime(clock,solvertime); |
---|
45 | problem = 0; |
---|
46 | |
---|
47 | % Internal format for duals |
---|
48 | D_struc = [-OUT.lambda]; |
---|
49 | |
---|
50 | switch OUT.how |
---|
51 | case 1 |
---|
52 | problem = 0; |
---|
53 | case {2,7} |
---|
54 | problem = 1; |
---|
55 | case {3,6} |
---|
56 | problem = 2; |
---|
57 | case {0,4,5} |
---|
58 | problem = 11; |
---|
59 | otherwise |
---|
60 | problem = -1; |
---|
61 | end |
---|
62 | infostr = yalmiperror(problem,'CDD'); |
---|
63 | |
---|
64 | % Save all data sent to solver? |
---|
65 | if options.savesolverinput |
---|
66 | solverinput.IN = IN; |
---|
67 | else |
---|
68 | solverinput = []; |
---|
69 | end |
---|
70 | |
---|
71 | % Save all data from the solver? |
---|
72 | if options.savesolveroutput |
---|
73 | solveroutput.OUT = OUT; |
---|
74 | else |
---|
75 | solveroutput = []; |
---|
76 | end |
---|
77 | |
---|
78 | % Standard interface |
---|
79 | output.Primal = OUT.xopt; |
---|
80 | output.Dual = D_struc; |
---|
81 | output.Slack = []; |
---|
82 | output.problem = problem; |
---|
83 | output.infostr = infostr; |
---|
84 | output.solverinput = solverinput; |
---|
85 | output.solveroutput= solveroutput; |
---|
86 | output.solvertime = solvertime; |
---|