source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/extras/milppresolve.m @ 37

Last change on this file since 37 was 37, checked in by (none), 14 years ago

Added original make3d

File size: 2.4 KB
Line 
1function [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
10if nargin < 5
11    integer_variables = [];
12end
13if nargin < 6
14    binary_variables = [];
15end
16if nargin < 7
17    changed_bounds = [];
18end
19
20ubnew = ub;
21lbnew = lb;
22goon = 1;
23
24AL0A  = (A>0).*A;
25AG0A  = (A<0).*A;
26
27At = A';
28use_indicies=ones(length(b),1);
29used = full(any(A(:,find(changed_bounds)),2));
30isbinary  = ismembc(1:length(lb),binary_variables);
31isinteger = ismembc(1:length(lb),binary_variables);
32
33goon = all(lb<=ub);
34infeasible = ~goon;
35if ~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);
92else
93    redundant=[];
94end
95psstruct.AL0A = AL0A;
96psstruct.AG0A = AG0A;
97
98
Note: See TracBrowser for help on using the repository browser.