[37] | 1 | function output = calllmirank(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: calllmirank.m,v 1.10 2005/06/06 16:42:13 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 | ub = interfacedata.ub; |
---|
| 13 | lb = interfacedata.lb; |
---|
| 14 | |
---|
| 15 | % Bounded variables converted to constraints |
---|
| 16 | if ~isempty(ub) |
---|
| 17 | [F_struc,K] = addbounds(F_struc,K,ub,lb); |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | pars = options.lmirank; |
---|
| 21 | pars.fid = double(options.verbose); |
---|
| 22 | |
---|
| 23 | if ~options.usex0 |
---|
| 24 | interfacedata.options.verbose = max(0,interfacedata.options.verbose - 1); |
---|
| 25 | initialsolver = eval(['@' interfacedata.solver.initialsolver.call]); |
---|
| 26 | start = K.l; |
---|
| 27 | b = zeros(size(F_struc,2)-1,1); |
---|
| 28 | for j=1:length(K.s) |
---|
| 29 | if K.s(j)~=K.rank(j) |
---|
| 30 | ind = find(speye(K.s(j))); |
---|
| 31 | for i=1:size(F_struc,2)-1 |
---|
| 32 | b(i,1) = b(i,1) + sum(F_struc(start+ind,1+i)); |
---|
| 33 | end |
---|
| 34 | end |
---|
| 35 | start=start+K.s(j)^2; |
---|
| 36 | end |
---|
| 37 | interfacedata.c = b; |
---|
| 38 | interfacedata.solver = interfacedata.solver.initialsolver; |
---|
| 39 | output = feval(initialsolver,interfacedata); |
---|
| 40 | if output.problem ~= 1 |
---|
| 41 | options.usex0 = 1; |
---|
| 42 | x0 = output.Primal; |
---|
| 43 | else |
---|
| 44 | return; |
---|
| 45 | end |
---|
| 46 | end |
---|
| 47 | |
---|
| 48 | if options.savedebug |
---|
| 49 | At = -F_struc(:,2:end); |
---|
| 50 | C = F_struc(:,1); |
---|
| 51 | save lmirankdebug C At K pars x0 |
---|
| 52 | end |
---|
| 53 | |
---|
| 54 | if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end |
---|
| 55 | solvertime = clock; |
---|
| 56 | if options.usex0 |
---|
| 57 | [y,info] = lmirank(-F_struc(:,2:end),F_struc(:,1),K,pars,x0); |
---|
| 58 | else |
---|
| 59 | [y,info] = lmirank(-F_struc(:,2:end),F_struc(:,1),K,pars); |
---|
| 60 | end |
---|
| 61 | x = y; |
---|
| 62 | solvertime = etime(clock,solvertime); |
---|
| 63 | |
---|
| 64 | |
---|
| 65 | switch info.solved |
---|
| 66 | case 1 |
---|
| 67 | problem = 0; |
---|
| 68 | otherwise |
---|
| 69 | problem = 11; |
---|
| 70 | end |
---|
| 71 | |
---|
| 72 | % Duals not computed |
---|
| 73 | D_struc = []; |
---|
| 74 | |
---|
| 75 | % Save ALL data sent to solver |
---|
| 76 | if options.savesolverinput |
---|
| 77 | solverinput.At = -F_struc(:,2:end); |
---|
| 78 | solverinput.c = F_struc(:,1); |
---|
| 79 | solverinput.K = K; |
---|
| 80 | solverinput.pars = pars; |
---|
| 81 | solverinput.x0 = x0; |
---|
| 82 | else |
---|
| 83 | solverinput = []; |
---|
| 84 | end |
---|
| 85 | |
---|
| 86 | % Save ALL data from the solution? |
---|
| 87 | if options.savesolveroutput |
---|
| 88 | solveroutput.y = y; |
---|
| 89 | solveroutput.info = info; |
---|
| 90 | else |
---|
| 91 | solveroutput = []; |
---|
| 92 | end |
---|
| 93 | |
---|
| 94 | % Standard interface |
---|
| 95 | output.Primal = x; |
---|
| 96 | output.Dual = []; |
---|
| 97 | output.Slack = []; |
---|
| 98 | output.problem = problem; |
---|
| 99 | output.solverinput = solverinput; |
---|
| 100 | output.solveroutput= solveroutput; |
---|
| 101 | output.solvertime = solvertime; |
---|