[37] | 1 | function output = callquadprog(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: callooqp.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 | K = interfacedata.K; |
---|
| 11 | x0 = interfacedata.x0; |
---|
| 12 | Q = interfacedata.Q; |
---|
| 13 | lb = interfacedata.lb; |
---|
| 14 | ub = interfacedata.ub; |
---|
| 15 | |
---|
| 16 | switch options.verbose |
---|
| 17 | case 0 |
---|
| 18 | options.quadprog.Display = 'off'; |
---|
| 19 | case 1 |
---|
| 20 | options.quadprog.Display = 'final'; |
---|
| 21 | otherwise |
---|
| 22 | options.quadprog.Display = 'iter'; |
---|
| 23 | end |
---|
| 24 | |
---|
| 25 | showprogress('Calling QUADPROG',options.showprogress); |
---|
| 26 | |
---|
| 27 | if ~isempty(F_struc) |
---|
| 28 | A = -F_struc(1:1:K.f,2:end); |
---|
| 29 | dA = full(F_struc(1:1:K.f,1)); |
---|
| 30 | C =-F_struc(K.f+1:end,2:end); |
---|
| 31 | cupp = full(F_struc(K.f+1:end,1)); |
---|
| 32 | clow = full(-ones(size(C,1),1)*1e4); |
---|
| 33 | else |
---|
| 34 | A = []; |
---|
| 35 | dA = []; |
---|
| 36 | C = []; |
---|
| 37 | cupp = []; |
---|
| 38 | clow = []; |
---|
| 39 | end |
---|
| 40 | |
---|
| 41 | n = length(c); |
---|
| 42 | if isempty(lb) |
---|
| 43 | xlow = -ones(n,1)*1e6; |
---|
| 44 | xupp = ones(n,1)*1e6; |
---|
| 45 | else |
---|
| 46 | xlow = lb; |
---|
| 47 | xupp = ub; |
---|
| 48 | end |
---|
| 49 | |
---|
| 50 | if options.verbose==0 |
---|
| 51 | doprint = 'no'; |
---|
| 52 | else |
---|
| 53 | doprint = 'yes'; |
---|
| 54 | end |
---|
| 55 | solvertime = clock; |
---|
| 56 | [status, x, gamma, phi, y, z, lambda, pi] = ooqp( c, 2*Q, xlow, xupp, A, dA, C, clow, cupp, doprint); |
---|
| 57 | solvertime = etime(clock,solvertime); |
---|
| 58 | |
---|
| 59 | problem = 0; |
---|
| 60 | |
---|
| 61 | % Internal format for duals |
---|
| 62 | D_struc = -[y;z]; |
---|
| 63 | |
---|
| 64 | % Check, currently not exhaustive... |
---|
| 65 | switch status |
---|
| 66 | case 0 |
---|
| 67 | problem = 0; |
---|
| 68 | otherwise |
---|
| 69 | problem = 13; |
---|
| 70 | end |
---|
| 71 | infostr = yalmiperror(problem,'OOQP'); |
---|
| 72 | |
---|
| 73 | % Save all data sent to solver? |
---|
| 74 | if options.savesolverinput |
---|
| 75 | solverinput.A = A; |
---|
| 76 | solverinput.b = b; |
---|
| 77 | solverinput.Aeq = Aq; |
---|
| 78 | solverinput.beq = beq; |
---|
| 79 | solverinput.c = c; |
---|
| 80 | solverinput.H = Q; |
---|
| 81 | solverinput.options = options.quadprog; |
---|
| 82 | else |
---|
| 83 | solverinput = []; |
---|
| 84 | end |
---|
| 85 | |
---|
| 86 | % Save all data from the solver? |
---|
| 87 | if options.savesolveroutput |
---|
| 88 | solveroutput.x = x; |
---|
| 89 | solveroutput.fmin = fmin; |
---|
| 90 | solveroutput.flag = flag; |
---|
| 91 | solveroutput.output=output; |
---|
| 92 | solveroutput.lambda=lambda; |
---|
| 93 | else |
---|
| 94 | solveroutput = []; |
---|
| 95 | end |
---|
| 96 | |
---|
| 97 | |
---|
| 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; |
---|