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

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

Added original make3d

File size: 3.1 KB
Line 
1function output = callmexpress(interfacedata)
2
3% Author Johan Löfberg
4% $Id: callmexpress.m,v 1.7 2005/05/07 13:53:20 joloef Exp $
5
6% Retrieve needed data
7options = interfacedata.options;
8F_struc = interfacedata.F_struc;
9c       = interfacedata.c;
10Q       = interfacedata.Q;
11K       = interfacedata.K;
12x0      = interfacedata.x0;
13integer_variables = interfacedata.integer_variables;
14binary_variables = interfacedata.binary_variables;
15UB      = interfacedata.ub;
16LB      = interfacedata.lb;
17
18showprogress('Calling XPRESS',options.showprogress);
19
20SENSE = 1;     
21C = full(c);   
22if isempty(F_struc)
23    A = zeros(1,length(c));A(1)=1;
24    B = 1e6;
25else
26    A =-(F_struc(:,2:end));
27    B = full(F_struc(:,1));           
28end
29
30% XPRESS complains about large bounds
31if isempty(LB)
32  %  LB = repmat(-2147483647,length(c),1);
33else
34    LB(LB<-2147483647) = -2147483647;
35end
36if isempty(UB)
37  %  UB = repmat(2147483647,length(c),1);
38else
39    UB(UB>2147483647) = 2147483647;
40end
41
42CTYPE = repmat('L',K.l+K.f,1);  % Inequalities
43CTYPE(1:K.f) = 'E';             % Equality constraints
44VARTYPE = repmat('C',size(A,2),1);
45VARTYPE(integer_variables)='I'; % Integer variables
46VARTYPE(binary_variables) ='B'; % Binary variables
47
48H = full(2*Q);
49if nnz(Q)==0
50    H = [];
51end
52
53if options.verbose==0
54    options.xpress.msglev = 0;
55else
56    options.xpress.msglev = 1;
57end
58
59if options.savedebug
60    save mexpressdebug SENSE H C A B CTYPE LB UB VARTYPE options
61end
62
63% Call mex-interface
64solvertime = clock;
65[x,FMIN,STATUS,EXTRA] = mexpress(SENSE,H,C,A,B,CTYPE,LB,UB,VARTYPE,options.xpress,0);
66solvertime = etime(clock,solvertime);
67problem = 0;
68if isstruct(EXTRA)
69    D_struc = -EXTRA.lambda;   
70else
71    D_struc = [];
72end
73
74% Check (error code depends on problem type!)
75if isempty(union(binary_variables,integer_variables))
76    switch STATUS
77        case 1
78            problem = 0;
79        case 2
80            problem = 1;
81        case 5
82            problem = 2;
83        case 4
84            problem = 3;
85        case {0,3,6}
86            problem = 11;
87        otherwise
88            problem = -1;
89    end
90else
91    switch STATUS
92        case 6
93            problem = 0;
94        case 5
95            problem = 1;
96        case 4
97            problem = 2;
98        case {4,3}
99            problem = 3;
100        case {0,1,2}
101            problem = 11;
102        otherwise
103            problem = -1;
104    end
105   
106end
107infostr = yalmiperror(problem,'MEXPRESS');     
108
109% Save all data sent to solver?
110if options.savesolverinput
111        solverinput.H = H;
112    solverinput.A = A;
113        solverinput.C = C;
114        solverinput.B = B;
115        solverinput.CTYPE = CTYPE;
116        solverinput.LB = LB;
117        solverinput.UB = UB;
118else
119        solverinput = [];
120end
121
122% Save all data from the solver?
123if options.savesolveroutput
124        solveroutput.x = x;
125    solveroutput.FMIN = FMIN;
126    solveroutput.STATUS = STATUS;
127    solveroutput.EXTRA=EXTRA;
128else
129        solveroutput = [];
130end
131
132
133% Standard interface
134output.Primal      = x;
135output.Dual        = D_struc;
136output.Slack       = [];
137output.problem     = problem;
138output.infostr     = infostr;
139output.solverinput = solverinput;
140output.solveroutput= solveroutput;
141output.solvertime  = solvertime;
Note: See TracBrowser for help on using the repository browser.