source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/solvers/calllpsolve.m @ 37

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

Added original make3d

File size: 3.3 KB
Line 
1function output = calllpsolve(interfacedata)
2
3% Author Johan Löfberg
4% $Id: calllpsolve.m,v 1.9 2006/05/23 14:15:22 joloef Exp $
5
6% Retrieve needed data
7options = interfacedata.options;
8F_struc = interfacedata.F_struc;
9c       = interfacedata.c;
10K       = interfacedata.K;
11integer_variables = interfacedata.integer_variables;
12binary_variables = interfacedata.binary_variables;
13ub      = interfacedata.ub;
14lb      = interfacedata.lb;
15
16n = length(c);
17% Bounded variables converted to constraints
18if ~isempty(ub)
19    LB = lb;
20    UB = ub;
21   % LB(isinf(LB)) = -1e12;
22   % UB(isinf(UB)) = 1e12;
23else
24    if isempty(integer_variables) & isempty(binary_variables)         
25        LB = -ones(n,1)*inf;;%-ones(n,1)*0;
26        UB = ones(n,1)*inf;;%[];%ones(n,1)*500;
27    else
28        %LP_SOLVE FAILS IF BOUNDS NOT EXPLICIT
29        [LB,UB,used_rows] = findulb(F_struc,K);
30        LB(isinf(LB)) = -1e12;
31        UB(isinf(UB)) = 1e12;
32        F_struc(K.f+used_rows,:)=[];
33        K.l = K.l - length(used_rows);
34        LB(binary_variables) = max(LB(binary_variables),0);
35        UB(binary_variables) = min(UB(binary_variables),0);
36    end
37end
38
39if options.showprogress;showprogress('Calling LPSOLVE',options.showprogress);end
40
41f = - full(c);            % Must be full
42A = - F_struc(:,2:end);
43b = full(F_struc(:,1));   % Must be full
44e = -ones(size(A,1),1);
45e(1:K.f) = 0;
46
47xint = uniquestripped([integer_variables binary_variables]);
48
49% Call mex-interface
50solvertime = clock;
51if options.savedebug
52    save mxlpsolvedebug f A b e UB LB xint
53end
54
55lp = create_lp_solve_model(A,b,f,xint,LB,UB,e,options);
56
57try
58    solvertime = clock;
59    if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end
60    result=mxlpsolve('solve', lp);
61    solvertime = etime(clock,solvertime);
62    if result == 0 | result == 1 | result == 11 | result == 12
63        [obj, x, duals] = mxlpsolve('get_solution', lp);
64    else
65        obj = [];
66        x = zeros(length(c),1);
67        duals = [];
68    end
69    mxlpsolve('delete_lp', lp);
70catch
71    obj = [];
72    x = zeros(length(c),1);
73    duals = [];
74    result = -1;
75    mxlpsolve('delete_lp', lp);
76end
77
78if options.saveduals & isempty(integer_variables)
79    D_struc = duals;
80else
81    D_struc = [];
82end
83
84switch result
85    case 0
86        problem = 0; % OPTIMAL
87    case 2
88        problem = 1; % INFEASIBLE
89    case 3
90        problem = 2; % UNBOUNDED
91    case {1,7,12,13}
92        problem = 3; % RUN OUT OF TIME OR SIMILIAR
93    case 5
94        problem = 4;
95    case {-2,10,11}
96        problem = 11;
97    otherwise
98        problem = -1;
99end
100       
101infostr = yalmiperror(problem,interfacedata.solver.tag);
102
103% Save all data sent to solver?
104if options.savesolverinput
105        solverinput.A = A;
106        solverinput.f = f;
107        solverinput.b = b;     
108        solverinput.LB = LB;
109        solverinput.UB = UB;   
110    solverinput.xint = xint;   
111else
112        solverinput = [];
113end
114
115% Save all data from the solver?
116if options.savesolveroutput
117        solveroutput.x = x;
118    solveroutput.obj = obj;
119    solveroutput.duals = duals; 
120    solveroutput.result = result; 
121else
122        solveroutput = [];
123end
124
125
126% Standard interface
127output.Primal      = x;
128output.Dual        = D_struc;
129output.Slack       = [];
130output.problem     = problem;
131output.infostr     = infostr;
132output.solverinput = solverinput;
133output.solveroutput= solveroutput;
134output.solvertime  = solvertime;
Note: See TracBrowser for help on using the repository browser.