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

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

Added original make3d

File size: 2.9 KB
Line 
1function output = callgpposy(interfacedata)
2
3% Author Johan Löfberg
4% $Id: callgpposy.m,v 1.10 2006/03/27 15:11:17 joloef Exp $
5
6% Retrieve needed data
7options = interfacedata.options;
8F_struc = interfacedata.F_struc;
9c       = interfacedata.c;
10Q       = interfacedata.Q;
11K       = interfacedata.K;
12extended_variables = interfacedata.extended_variables;
13ub      = interfacedata.ub;
14lb      = interfacedata.lb;
15mt      = interfacedata.monomtable;
16variabletype = interfacedata.variabletype;
17
18% *********************************
19% What type of variables do we have
20% *********************************
21if isempty(variabletype)
22    linear_variables = find((sum(abs(mt),2)==1) & (any(mt==1,2)));
23else
24    linear_variables = find(variabletype == 0);
25end
26
27% Same for fmincon,mosek,gpposy (for gpposy, we do not add bound constraints)
28[prob,problem] = yalmip2geometric(options,F_struc,c,Q,K,[],[],mt,linear_variables,extended_variables);
29
30if problem == 0
31   
32    % Account for numerical problems in gpposy
33    if ~isempty(lb);
34        lb=lb(linear_variables);
35        lb(lb<0)=1e-100;
36        lb(lb==0) = 1e-100;
37    end
38    if ~isempty(ub);
39        ub=ub(linear_variables);
40        ub(isinf(ub))=1e100;
41    end
42
43    % Convert to gpposy
44    A=prob.A;
45    b=prob.b;
46    G = prob.G;
47    h = prob.h;
48    szs=[];
49    for i=0:max(prob.map)
50        szs=[szs;nnz(find(i==prob.map))];
51    end
52   
53    if szs(1) == 0
54        % Feasibility problem not supported by GPPOSY
55        % Just minimize sum of all variables
56        A = [eye(size(A,2));A];
57        b = [ones(size(A,2),1);b];
58        szs(1) = size(A,2);
59    end
60
61    if options.savedebug
62        save gpposydebug A b szs
63    end
64       
65    if interfacedata.getsolvertime solvertime = clock; end
66    [x,status,lambda,nu] = gpposy(A,b,szs,G,h,lb,ub,double(options.verbose)==0);
67    if interfacedata.getsolvertime solvertime = etime(clock,solvertime);else solvertime = 0;end
68
69    Primal = zeros(length(c),1);
70
71    % Check, currently not exhaustive...
72    switch lower(status)
73        case 'solved'
74            problem = 0;
75            Primal(linear_variables) = x;
76        case 'infeasible'
77            problem = 1;
78        case 'failed'
79            problem = 4;
80        otherwise
81            problem = 9;
82    end
83else
84    Primal = [];
85    solvertime = [];
86end
87
88
89% Internal format for duals
90Dual = [];
91
92
93infostr = yalmiperror(problem,interfacedata.solver.tag);
94
95if options.savesolverinput
96    solverinput.A   = A;
97    solverinput.b   = b;
98    solverinput.szs = szs;
99else
100    solverinput = [];
101end
102
103% Save all data from the solver?
104if options.savesolveroutput
105    solveroutput.x = x;
106    solveroutput.status = status;
107else
108    solveroutput = [];
109end
110
111% Standard interface
112output.Primal      = Primal;
113output.Dual        = Dual;
114output.Slack       = [];
115output.problem     = problem;
116output.infostr     = infostr;
117output.solverinput = solverinput;
118output.solveroutput= solveroutput;
119output.solvertime  = solvertime;
Note: See TracBrowser for help on using the repository browser.