[37] | 1 | function [lb,ub,redundant,psstruct,infeasible] = milppresolve(A,b,lb,ub,integer_variables,binary_variables,changed_bounds); |
---|
| 2 | %MILPPRESOLVE Internal function for presolving MILPs |
---|
| 3 | |
---|
| 4 | % Author Johan Löfberg |
---|
| 5 | % $Id: milppresolve.m,v 1.3 2005/10/05 14:54:55 joloef Exp $ |
---|
| 6 | |
---|
| 7 | % Simple bound pre-processing (paper by Savelsbergh) |
---|
| 8 | % No code optimization at all |
---|
| 9 | |
---|
| 10 | if nargin < 5 |
---|
| 11 | integer_variables = []; |
---|
| 12 | end |
---|
| 13 | if nargin < 6 |
---|
| 14 | binary_variables = []; |
---|
| 15 | end |
---|
| 16 | if nargin < 7 |
---|
| 17 | changed_bounds = []; |
---|
| 18 | end |
---|
| 19 | |
---|
| 20 | ubnew = ub; |
---|
| 21 | lbnew = lb; |
---|
| 22 | goon = 1; |
---|
| 23 | |
---|
| 24 | AL0A = (A>0).*A; |
---|
| 25 | AG0A = (A<0).*A; |
---|
| 26 | |
---|
| 27 | At = A'; |
---|
| 28 | use_indicies=ones(length(b),1); |
---|
| 29 | used = full(any(A(:,find(changed_bounds)),2)); |
---|
| 30 | isbinary = ismembc(1:length(lb),binary_variables); |
---|
| 31 | isinteger = ismembc(1:length(lb),binary_variables); |
---|
| 32 | |
---|
| 33 | goon = all(lb<=ub); |
---|
| 34 | infeasible = ~goon; |
---|
| 35 | if ~infeasible |
---|
| 36 | |
---|
| 37 | bi_up = AL0A*ub+AG0A*lb; |
---|
| 38 | bi_dn = AL0A*lb+AG0A*ub; |
---|
| 39 | |
---|
| 40 | while goon |
---|
| 41 | |
---|
| 42 | bminusbdn=b-bi_dn; |
---|
| 43 | for i = find(use_indicies & used)' |
---|
| 44 | |
---|
| 45 | [ii,jj,kk] = find(At(:,i)); |
---|
| 46 | |
---|
| 47 | Cp = ii(kk>0); |
---|
| 48 | if ~isempty(Cp) |
---|
| 49 | new1=lbnew(Cp)+bminusbdn(i)./At(Cp,i); |
---|
| 50 | ubnew(Cp)=min(ubnew(Cp),new1); |
---|
| 51 | end |
---|
| 52 | |
---|
| 53 | Cm = ii(kk<0); |
---|
| 54 | if ~isempty(Cm) |
---|
| 55 | new2=ubnew(Cm)+bminusbdn(i)./At(Cm,i); |
---|
| 56 | lbnew(Cm)=max(lbnew(Cm),new2); |
---|
| 57 | end |
---|
| 58 | |
---|
| 59 | if any(lbnew>ubnew) |
---|
| 60 | infeasible = 1; |
---|
| 61 | break |
---|
| 62 | end |
---|
| 63 | |
---|
| 64 | end |
---|
| 65 | |
---|
| 66 | if ~infeasible |
---|
| 67 | |
---|
| 68 | lbnew(integer_variables) = round(lbnew(integer_variables)+0.49999); |
---|
| 69 | ubnew(integer_variables) = round(ubnew(integer_variables)-0.49999); |
---|
| 70 | |
---|
| 71 | lbnew(binary_variables) = round(lbnew(binary_variables)+0.49999); |
---|
| 72 | ubnew(binary_variables) = round(ubnew(binary_variables)-0.49999); |
---|
| 73 | |
---|
| 74 | goon = (~all((lb==lbnew) & (ub==ubnew))) & all(lbnew<=ubnew); |
---|
| 75 | |
---|
| 76 | used = (lb~=lbnew) | (ub~=ubnew); |
---|
| 77 | used = full(any(A(:,find(used)),2)); |
---|
| 78 | |
---|
| 79 | lb = lbnew; |
---|
| 80 | ub = ubnew; |
---|
| 81 | |
---|
| 82 | bi_up = AL0A*ub+AG0A*lb; |
---|
| 83 | bi_dn = AL0A*lb+AG0A*ub; |
---|
| 84 | redundant = find(bi_up<=b); |
---|
| 85 | |
---|
| 86 | use_indicies = use_indicies & bi_up>b; |
---|
| 87 | else |
---|
| 88 | goon = 0; |
---|
| 89 | end |
---|
| 90 | end |
---|
| 91 | redundant = find(bi_up<=b); |
---|
| 92 | else |
---|
| 93 | redundant=[]; |
---|
| 94 | end |
---|
| 95 | psstruct.AL0A = AL0A; |
---|
| 96 | psstruct.AG0A = AG0A; |
---|
| 97 | |
---|
| 98 | |
---|