[37] | 1 | function output = callclp(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: callclp.m,v 1.15 2006/05/30 18:25:32 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 | ub = interfacedata.ub; |
---|
| 12 | lb = interfacedata.lb; |
---|
| 13 | Q = interfacedata.Q; |
---|
| 14 | |
---|
| 15 | n = length(c); |
---|
| 16 | |
---|
| 17 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
| 18 | |
---|
| 19 | if K.f>0 |
---|
| 20 | Aeq = -F_struc(1:K.f,2:end); |
---|
| 21 | beq = F_struc(1:K.f,1); |
---|
| 22 | else |
---|
| 23 | Aeq = []; |
---|
| 24 | beq = []; |
---|
| 25 | end |
---|
| 26 | |
---|
| 27 | if K.l > 0 |
---|
| 28 | A = -F_struc(1+K.f:end,2:end); |
---|
| 29 | b = F_struc(1+K.f:end,1); |
---|
| 30 | else |
---|
| 31 | A = []; |
---|
| 32 | b = []; |
---|
| 33 | end |
---|
| 34 | |
---|
| 35 | % Fix for bug in mexclp or clp |
---|
| 36 | fixed = 0; |
---|
| 37 | if size(A,1)==0 & size(Aeq,2)==0 |
---|
| 38 | A = [ones(1,length(c))]; |
---|
| 39 | if ~isempty(ub) |
---|
| 40 | A(isinf(ub)) = 0; |
---|
| 41 | dummy = ub; |
---|
| 42 | dummy(isinf(ub)) = 0; |
---|
| 43 | b = sum(dummy); |
---|
| 44 | else |
---|
| 45 | b = 1e8; |
---|
| 46 | end |
---|
| 47 | fixed = 1; |
---|
| 48 | options.saveduals = 0; |
---|
| 49 | end |
---|
| 50 | |
---|
| 51 | ops = options.clp; |
---|
| 52 | ops.verbose = options.verbose; |
---|
| 53 | |
---|
| 54 | if options.savedebug |
---|
| 55 | save clpdebug |
---|
| 56 | end |
---|
| 57 | |
---|
| 58 | % Call mex-interfacec |
---|
| 59 | solvertime = clock; |
---|
| 60 | [x,lambda,problem] = clp(2*Q,c,A,b,Aeq,beq,lb,ub,ops);%,interfacedata.integer_variables); |
---|
| 61 | if interfacedata.getsolvertime solvertime = etime(clock,solvertime);else solvertime = 0;end |
---|
| 62 | |
---|
| 63 | if options.saveduals |
---|
| 64 | D_struc = -lambda; |
---|
| 65 | else |
---|
| 66 | D_struc = []; |
---|
| 67 | end |
---|
| 68 | |
---|
| 69 | infostr = yalmiperror(problem,interfacedata.solver.tag); |
---|
| 70 | |
---|
| 71 | % Save all data sent to solver? |
---|
| 72 | if options.savesolverinput |
---|
| 73 | solverinput = []; |
---|
| 74 | else |
---|
| 75 | solverinput = []; |
---|
| 76 | end |
---|
| 77 | |
---|
| 78 | % Save all data from the solver? |
---|
| 79 | if options.savesolveroutput |
---|
| 80 | solveroutput = []; |
---|
| 81 | else |
---|
| 82 | solveroutput = []; |
---|
| 83 | end |
---|
| 84 | |
---|
| 85 | % Standard interface |
---|
| 86 | output.Primal = x; |
---|
| 87 | output.Dual = D_struc; |
---|
| 88 | output.Slack = []; |
---|
| 89 | output.problem = problem; |
---|
| 90 | output.infostr = infostr; |
---|
| 91 | output.solverinput = solverinput; |
---|
| 92 | output.solveroutput= solveroutput; |
---|
| 93 | output.solvertime = solvertime; |
---|