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