1 | function output = callqp_cplex(interfacedata) |
---|
2 | |
---|
3 | % Author Johan Löfberg |
---|
4 | % $Id: callmiqp_cplex.m,v 1.2 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 | Q = interfacedata.Q; |
---|
11 | K = interfacedata.K; |
---|
12 | x0 = interfacedata.x0; |
---|
13 | integer_variables = interfacedata.integer_variables; |
---|
14 | binary_variables = interfacedata.binary_variables; |
---|
15 | ub = interfacedata.ub; |
---|
16 | lb = interfacedata.lb; |
---|
17 | |
---|
18 | showprogress('Calling CPLEXINT',options.showprogress); |
---|
19 | |
---|
20 | % Notation used |
---|
21 | C = full(c); |
---|
22 | if ~isempty(F_struc) |
---|
23 | A = (-F_struc(:,2:end)); |
---|
24 | B = full(F_struc(:,1)); |
---|
25 | else |
---|
26 | A = zeros(0,length(c)) |
---|
27 | B = zeros(0,0); |
---|
28 | end |
---|
29 | CTYPE = repmat('L',K.l+K.f,1); % Standard variables |
---|
30 | CTYPE(1:K.f) = 'E'; % Equality constrained variables |
---|
31 | |
---|
32 | VARTYPE = repmat('C',length(C),1); % Standard variables |
---|
33 | VARTYPE(integer_variables) = 'I'; |
---|
34 | VARTYPE(binary_variables) = 'B'; |
---|
35 | |
---|
36 | % Call mex-interface |
---|
37 | solvertime = clock; |
---|
38 | |
---|
39 | if options.savedebug |
---|
40 | save cplexdebug |
---|
41 | end |
---|
42 | |
---|
43 | try |
---|
44 | [x,FMIN,QPSOLVED,STATUS,SLACK] = miqp_cplex(1,2*(Q),C,A,B,CTYPE,lb,ub,[],VARTYPE,[],[],options.verbose); |
---|
45 | D_struc = []; |
---|
46 | catch |
---|
47 | D_struc = []; |
---|
48 | x = nan*ones(length(c),1); |
---|
49 | STATUS = 32201; |
---|
50 | FMIN = []; |
---|
51 | SLACK = []; |
---|
52 | end |
---|
53 | solvertime = etime(clock,solvertime); |
---|
54 | problem = 0; |
---|
55 | |
---|
56 | % Check, currently not exhaustive... |
---|
57 | switch STATUS |
---|
58 | case {1,101,102} |
---|
59 | problem = 0; |
---|
60 | case {0,3} |
---|
61 | problem = 1; |
---|
62 | case {2} |
---|
63 | problem = 2; |
---|
64 | case {4,119} |
---|
65 | problem = 12; |
---|
66 | case 32201 |
---|
67 | problem = -5; |
---|
68 | otherwise |
---|
69 | problem = -1; |
---|
70 | end |
---|
71 | infostr = yalmiperror(problem,'CPLEXINT'); |
---|
72 | |
---|
73 | % Save all data sent to solver? |
---|
74 | if options.savesolverinput |
---|
75 | solverinput.SENSE = 1; |
---|
76 | solverinput.A = A; |
---|
77 | solverinput.C = C; |
---|
78 | solverinput.B = B; |
---|
79 | solverinput.CTYPE = CTYPE; |
---|
80 | solverinput.LB = []; |
---|
81 | solverinput.UB = []; |
---|
82 | solverinput.X0 = []; |
---|
83 | solverinput.SLACK = []; |
---|
84 | else |
---|
85 | solverinput = []; |
---|
86 | end |
---|
87 | |
---|
88 | % Save all data from the solver? |
---|
89 | if options.savesolveroutput |
---|
90 | solveroutput.XMIN = x; |
---|
91 | solveroutput.FMIN = FMIN; |
---|
92 | solveroutput.QPSOLVED = QPSOLVED; |
---|
93 | solveroutput.STATUS = STATUS; |
---|
94 | solveroutput.SLACK = SLACK; |
---|
95 | else |
---|
96 | solveroutput = []; |
---|
97 | end |
---|
98 | |
---|
99 | % Standard interface |
---|
100 | output.Primal = x(:); |
---|
101 | output.Dual = D_struc; |
---|
102 | output.Slack = []; |
---|
103 | output.problem = problem; |
---|
104 | output.infostr = infostr; |
---|
105 | output.solverinput = solverinput; |
---|
106 | output.solveroutput= solveroutput; |
---|
107 | output.solvertime = solvertime; |
---|