[37] | 1 | function output = callnage04mbf(varargin) |
---|
| 2 | % Author Johan Löfberg |
---|
| 3 | % $Id: callnage04mbf.m,v 1.6 2006/04/10 08:08:47 joloef Exp $ |
---|
| 4 | |
---|
| 5 | % Retrieve needed data |
---|
| 6 | interfacedata = varargin{1}; |
---|
| 7 | options = interfacedata.options; |
---|
| 8 | F_struc = interfacedata.F_struc; |
---|
| 9 | c = interfacedata.c; |
---|
| 10 | K = interfacedata.K; |
---|
| 11 | x0 = interfacedata.x0; |
---|
| 12 | Q = 2*interfacedata.Q; |
---|
| 13 | ub = interfacedata.ub; |
---|
| 14 | lb = interfacedata.lb; |
---|
| 15 | |
---|
| 16 | bigbnd = options.nag.bigbnd; |
---|
| 17 | sent_bounds = 1; |
---|
| 18 | if isempty(ub) |
---|
| 19 | sent_bounds = 0; |
---|
| 20 | ub = bigbnd*ones(length(c),1); |
---|
| 21 | lb = -bigbnd*ones(length(c),1); |
---|
| 22 | end |
---|
| 23 | |
---|
| 24 | showprogress('Calling NAG',options.showprogress); |
---|
| 25 | |
---|
| 26 | if ~isempty(F_struc) |
---|
| 27 | A =-F_struc(1:end,2:end); |
---|
| 28 | beq = F_struc(1:1:K.f,1); |
---|
| 29 | b = F_struc(K.f+1:end,1); |
---|
| 30 | |
---|
| 31 | ub = full([ub;beq;b]); |
---|
| 32 | lb = full([lb;beq;-bigbnd*ones(length(b),1)]); |
---|
| 33 | else |
---|
| 34 | A=zeros(1,length(c)); |
---|
| 35 | end |
---|
| 36 | |
---|
| 37 | lp = 0; |
---|
| 38 | cold = 1; |
---|
| 39 | istate = zeros(length(ub),1); |
---|
| 40 | featol = options.nag.featol*ones(length(ub),1); |
---|
| 41 | switch options.verbose |
---|
| 42 | case 0 |
---|
| 43 | msglev = -1; |
---|
| 44 | ifail = 1; |
---|
| 45 | case 1 |
---|
| 46 | msglev = 2; |
---|
| 47 | ifail = -1; |
---|
| 48 | otherwise |
---|
| 49 | msglev = 5*options.verbose; |
---|
| 50 | ifail = -1; |
---|
| 51 | end |
---|
| 52 | solvertime = clock; |
---|
| 53 | [x,istate,objlp,clambda,ifail] = e04mbf(full(lb),full(ub),zeros(length(c),1),full(c),full(A),msglev,options.nag.itmax,ifail);%options.nag.bigbnd,options.nag.orthog); |
---|
| 54 | solvertime = etime(clock,solvertime); |
---|
| 55 | problem = 0; |
---|
| 56 | |
---|
| 57 | % Internal format for duals |
---|
| 58 | %if sent_bounds |
---|
| 59 | % D_struc_bound = -clambda(1:length(c)); |
---|
| 60 | % D_struc = -clambda(length(c)+1:end); |
---|
| 61 | % D_struc = [repmat(inf,length(c)*2,1);D_struc]; |
---|
| 62 | %else |
---|
| 63 | D_struc = -clambda(length(c)+1:end); |
---|
| 64 | %end |
---|
| 65 | |
---|
| 66 | switch ifail |
---|
| 67 | case {-1,0} |
---|
| 68 | problem = 0; |
---|
| 69 | case 1 |
---|
| 70 | problem = 1; |
---|
| 71 | case 2 |
---|
| 72 | problem = 2; |
---|
| 73 | case 3 |
---|
| 74 | problem = 4; |
---|
| 75 | case 4 |
---|
| 76 | problem = 3; |
---|
| 77 | case 5 |
---|
| 78 | problem = 7; |
---|
| 79 | otherwise |
---|
| 80 | problem = -1; |
---|
| 81 | end |
---|
| 82 | infostr = yalmiperror(problem,'NAG'); |
---|
| 83 | |
---|
| 84 | % Save all data sent to solver? |
---|
| 85 | if options.savesolverinput |
---|
| 86 | solverinput.bl = full(lb); |
---|
| 87 | solverinput.bu = full(ub); |
---|
| 88 | solverinput.X = zeros(length(c),1); |
---|
| 89 | solverinput.cvec = full(c); |
---|
| 90 | solverinput.A = full(A); |
---|
| 91 | else |
---|
| 92 | solverinput = []; |
---|
| 93 | end |
---|
| 94 | |
---|
| 95 | % Save all data from the solver? |
---|
| 96 | if options.savesolveroutput |
---|
| 97 | solveroutput.x = x; |
---|
| 98 | solveroutput.objlp = objlp; |
---|
| 99 | solveroutput.clambda=clambda; |
---|
| 100 | solveroutput.istate=istate; |
---|
| 101 | solveroutput.ifail=ifail; |
---|
| 102 | else |
---|
| 103 | solveroutput = []; |
---|
| 104 | end |
---|
| 105 | |
---|
| 106 | % Standard interface |
---|
| 107 | output.Primal = x; |
---|
| 108 | output.Dual = D_struc; |
---|
| 109 | output.Slack = []; |
---|
| 110 | output.problem = problem; |
---|
| 111 | output.infostr = infostr; |
---|
| 112 | output.solverinput = solverinput; |
---|
| 113 | output.solveroutput= solveroutput; |
---|
| 114 | output.solvertime = solvertime; |
---|