[37] | 1 | function output = callmpt(interfacedata) |
---|
| 2 | |
---|
| 3 | % Author Johan Löfberg |
---|
| 4 | % $Id: callmplcp.m,v 1.1 2006/03/30 13:28:06 joloef Exp $ |
---|
| 5 | |
---|
| 6 | % Speeds up solving LPs in mpmilp |
---|
| 7 | global mptOptions |
---|
| 8 | if ~isstruct(mptOptions) |
---|
| 9 | mpt_error |
---|
| 10 | end |
---|
| 11 | |
---|
| 12 | % Convert to MPT |
---|
| 13 | Matrices = yalmip2mpt(interfacedata); |
---|
| 14 | |
---|
| 15 | % % Convert to colin |
---|
| 16 | % parametric = find(~any(Matrices.G,2) & any(Matrices.E,2)); |
---|
| 17 | % nonparametric = find(~(~any(Matrices.G,2) & any(Matrices.E,2))); |
---|
| 18 | % [M,Q,q,T,Tth,t] = lcp_mpqp(Matrices.H,Matrices.F',Matrices.Cf',Matrices.G(nonparametric,:),Matrices.E(nonparametric,:),Matrices.W(nonparametric,:)); |
---|
| 19 | % Ht = [Matrices.E(parametric,:) Matrices.W(parametric)]; |
---|
| 20 | % [BB,dPiv,dkPiv] = mplcp(M,q,Q,[Matrices.E(parametric,:) Matrices.W(parametric)]); |
---|
| 21 | |
---|
| 22 | % |
---|
| 23 | % m = size(M,1); |
---|
| 24 | % A = [eye(m) -M]; |
---|
| 25 | % [At,bt] = a2s(Ht); |
---|
| 26 | % bases = BB.bases; |
---|
| 27 | % for i=[1:size(bases,1)] |
---|
| 28 | % iB = inv(A(:,bases(i,:))); |
---|
| 29 | % P(i) = polytope([At;-iB*Q],[bt;iB*q]); |
---|
| 30 | % end; |
---|
| 31 | % |
---|
| 32 | % model{1}.Pn = P; |
---|
| 33 | |
---|
| 34 | %model = mpt_solvenode(Matrices,Matrices.lb,Matrices.ub,Matrices,[],options); |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | % Get some MPT options |
---|
| 38 | options = interfacedata.options; |
---|
| 39 | options.mpt.lpsolver = mptOptions.lpsolver; |
---|
| 40 | options.mpt.milpsolver = mptOptions.milpsolver; |
---|
| 41 | options.mpt.verbose = options.verbose; |
---|
| 42 | |
---|
| 43 | if options.savedebug |
---|
| 44 | save mptdebug Matrices |
---|
| 45 | end |
---|
| 46 | |
---|
| 47 | if isempty(Matrices.binary_var_index) |
---|
| 48 | |
---|
| 49 | showprogress('Calling MPT',options.showprogress); |
---|
| 50 | solvertime = clock; |
---|
| 51 | if options.mp.presolve |
---|
| 52 | [Matrices.lb,Matrices.ub] = mpt_detect_and_improve_bounds(Matrices,Matrices.lb,Matrices.ub,Matrices.binary_var_index,options); |
---|
| 53 | end |
---|
| 54 | |
---|
| 55 | model = mpt_solvenode(Matrices,Matrices.lb,Matrices.ub,Matrices,[],options); |
---|
| 56 | solvertime = etime(clock,solvertime); |
---|
| 57 | |
---|
| 58 | else |
---|
| 59 | % Pre-solve required on binary problems |
---|
| 60 | options.mp.presolve = 1; |
---|
| 61 | |
---|
| 62 | solvertime = clock; |
---|
| 63 | switch options.mp.algorithm |
---|
| 64 | case 1 |
---|
| 65 | showprogress('Calling MPT via enumeration',options.showprogress); |
---|
| 66 | model = mpt_enumeration_mpmilp(Matrices,options); |
---|
| 67 | case 2 |
---|
| 68 | showprogress('Calling MPT via parametric B&B',options.showprogress); |
---|
| 69 | model = bb_mpmilp(Matrices,Matrices,[],options) |
---|
| 70 | case 3 |
---|
| 71 | showprogress('Calling MPT via delayed enumeration',options.showprogress); |
---|
| 72 | model = mpt_de_mpmilp(Matrices,options,[]); |
---|
| 73 | |
---|
| 74 | otherwise |
---|
| 75 | end |
---|
| 76 | solvertime = etime(clock,solvertime); |
---|
| 77 | end |
---|
| 78 | |
---|
| 79 | if isempty(model) |
---|
| 80 | model = {model}; |
---|
| 81 | end |
---|
| 82 | |
---|
| 83 | if options.verbose |
---|
| 84 | if ~isempty(model{1}) |
---|
| 85 | disp(['-> Generated ' num2str(length(model)) ' partitions.']) |
---|
| 86 | end |
---|
| 87 | end |
---|
| 88 | |
---|
| 89 | |
---|
| 90 | problem = 0; |
---|
| 91 | infostr = yalmiperror(problem,'MPT'); |
---|
| 92 | |
---|
| 93 | % Save all data sent to solver? |
---|
| 94 | if options.savesolverinput |
---|
| 95 | solverinput.Matrices = Matrices; |
---|
| 96 | solverinput.options = []; |
---|
| 97 | else |
---|
| 98 | solverinput = []; |
---|
| 99 | end |
---|
| 100 | |
---|
| 101 | % Save all data from the solver? |
---|
| 102 | % This always done |
---|
| 103 | if options.savesolveroutput |
---|
| 104 | solveroutput.model = model; |
---|
| 105 | solveroutput.U = interfacedata.used_variables(Matrices.free_var); |
---|
| 106 | solveroutput.x = interfacedata.used_variables(Matrices.param_var); |
---|
| 107 | else |
---|
| 108 | solveroutput = []; |
---|
| 109 | end |
---|
| 110 | |
---|
| 111 | % Standard interface |
---|
| 112 | output.Primal = nan*ones(length(interfacedata.c),1); |
---|
| 113 | output.Dual = []; |
---|
| 114 | output.Slack = []; |
---|
| 115 | output.problem = problem; |
---|
| 116 | output.infostr = infostr; |
---|
| 117 | output.solverinput = solverinput; |
---|
| 118 | output.solveroutput= solveroutput; |
---|
| 119 | output.solvertime = solvertime; |
---|
| 120 | |
---|
| 121 | |
---|
| 122 | |
---|
| 123 | |
---|