source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/modules/global/lpbmitighten.m @ 37

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

Added original make3d

File size: 2.5 KB
Line 
1% *************************************************************************
2% Bound strengthening, here is where we actually solve LPs
3% *************************************************************************
4function [p,feasible,lower] = lpbmitighten(p,lower,upper,lpsolver)
5
6% Construct problem with only linear terms
7% and add cuts from lower/ upper bounds
8
9p_test = p;
10p_test.F_struc = p.lpcuts;
11p_test.K.l = size(p.lpcuts,2);
12p_test.K.f = 0;
13p_test.K.s = 0;
14p_test.K.q = 0;
15if ~isnan(lower)
16    p_test.F_struc = [-(p.lower-abs(p.lower)*0.01)+p.f p_test.c';p_test.F_struc];
17end
18if upper < inf
19    p_test.F_struc = [upper+abs(upper)*0.01-p.f -p_test.c';p_test.F_struc];
20end
21if ~isempty(p.bilinears)
22    p_test = addmcgormick(p_test);
23end
24
25%aa = p_test.F_struc(7,:);;
26%p_test.F_struc = [];%p_test.F_struc(7,:);
27
28p_test.K.l = size(p_test.F_struc,1);
29p_test.F_struc = [p.F_struc(1:1:p.K.f,:);p_test.F_struc];
30p_test.K.f = p.K.f;
31
32feasible = 1;
33
34% Perform reduction on most violating approximations at current solution
35if p.options.bmibnb.lpreduce ~= 1
36    n = ceil(max(p.options.bmibnb.lpreduce*length(p_test.linears),1));
37    res = zeros(length(p.lb),1);
38    for i = 1:size(p.bilinears,1)
39        res(p.bilinears(i,2)) = res(p.bilinears(i,2)) + abs( p.x0(p.bilinears(i,1))-p.x0(p.bilinears(i,2)).*p.x0(p.bilinears(i,3)));
40        res(p.bilinears(i,3)) = res(p.bilinears(i,3)) + abs( p.x0(p.bilinears(i,1))-p.x0(p.bilinears(i,2)).*p.x0(p.bilinears(i,3)));
41    end
42    res = res(p.linears);
43    [ii,jj] = sort(abs(res));
44    jj = jj(end-n+1:end);
45else
46    jj=1:length(p_test.linears);
47end
48
49j = 1;
50while feasible & j<=length(jj)
51    i = p_test.linears(jj(j));
52    if abs(p.ub(i)-p.lb(i)>0.1)
53        p_test.c = eyev(length(p_test.c),i);
54
55        output = feval(lpsolver,p_test);
56        if output.problem == 0
57            if p_test.lb(i) < output.Primal(i)-1e-5
58                p_test.lb(i) = output.Primal(i);
59                p_test = updateonenonlinearbound(p_test,i);
60            end
61            p_test.c = -p_test.c;
62            output = feval(lpsolver,p_test);
63            if output.problem == 0
64                if p_test.ub(i) > output.Primal(i)+1e-5
65                    p_test.ub(i) = output.Primal(i);
66                    p_test = updateonenonlinearbound(p_test,i);
67                end
68            end
69            if output.problem == 1
70                feasible = 0;
71            end
72        end
73        if output.problem == 1
74            feasible = 0;
75        end
76    end
77    j = j + 1;
78end
79p_test = clean_bounds(p_test);
80p.lb = p_test.lb;
81p.ub = p_test.ub;
Note: See TracBrowser for help on using the repository browser.