source: proiecte/pmake3d/make3d_original/Make3dSingleImageStanford_version0.1/third_party/opt/yalmip/solvers/callnage04naf.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 = callnage04naf(varargin)
2% Author Johan Löfberg
3% $Id: callnage04naf.m,v 1.12 2006/04/10 09:34:47 joloef Exp $
4
5% Hack for NAG
6persistent Q
7
8if nargin>1
9    output = Q*varargin{6};
10    return
11end
12
13% Retrieve needed data
14interfacedata = varargin{1};
15options = interfacedata.options;
16F_struc = interfacedata.F_struc;
17c       = interfacedata.c;
18K       = interfacedata.K;
19x0      = interfacedata.x0;
20Q       = 2*interfacedata.Q;
21ub      = interfacedata.ub;
22lb      = interfacedata.lb;
23
24bigbnd = options.nag.bigbnd;
25if isempty(ub)
26    ub =  bigbnd*ones(length(c),1);
27    lb = -bigbnd*ones(length(c),1);
28end
29
30% NAG fails on semidefinite
31if nnz(Q)>0
32    ii = find(diag(Q)==0);
33    if ~isempty(ii)
34        d = zeros(length(Q),1);
35        d(ii) = sqrt(eps);
36        Q = Q + diag(d);
37    end
38end
39
40showprogress('Calling NAG',options.showprogress);
41
42if ~isempty(F_struc)
43    A =-F_struc(1:end,2:end);
44    beq = F_struc(1:1:K.f,1);
45    b = F_struc(K.f+1:end,1);   
46   
47    ub = full([ub;beq;b]);
48    lb = full([lb;beq;-bigbnd*ones(length(b),1)]);
49elseif ~isempty(lb)% NAG stinks on problems with no A<b constraints
50    A  = eye(length(c));
51    ub = full([ub;ub]);
52    lb = full([lb;lb]);
53else
54    A  = zeros(1,length(c));
55    ub = full([ub;1]);
56    lb = full([lb;0]);   
57end
58
59% Bug prevents lp=full(nnz(...
60if nnz(Q)==0
61    lp = 1;
62else
63    lp = 0;
64end
65
66cold = 1;
67istate = zeros(length(ub),1);
68featol = options.nag.featol*ones(length(ub),1);
69switch options.verbose
70case 0
71    msglev = -1;
72    ifail = 1;
73case 1
74    msglev = 2;
75    ifail = -1;
76otherwise
77    msglev = 5*options.verbose;
78    ifail = -1;
79end
80solvertime = clock;
81
82[x,iter,obj,clambda,istate,ifail] = e04naf(full(lb),full(ub),'callnage04naf',zeros(length(c),1),full(c),full(A),0,lp, cold,istate,featol,msglev,options.nag.itmax,options.nag.bigbnd,options.nag.orthog,ifail);
83
84solvertime = etime(clock,solvertime);
85problem = 0;
86
87% Internal format for duals
88D_struc = -clambda(length(c)+1:end);
89
90switch ifail
91case {-1,0,1,3}
92    problem = 0;
93case 2
94    problem = 2;
95case {4,7}
96    problem = 4;
97case {5,8}
98    problem = 3;
99case 6
100    problem = 1;
101otherwise
102    problem = 9;
103end   
104infostr = yalmiperror(problem,'NAG');       
105
106% Save all data sent to solver?
107if options.savesolverinput
108    solverinput.bl = full(lb);
109    solverinput.bu = full(ub);
110    solverinput.X = zeros(length(c),1);
111    solverinput.cvec = full(c);
112    solverinput.A = full(A);
113else
114    solverinput = [];
115end
116
117% Save all data from the solver?
118if options.savesolveroutput
119    solveroutput.x = x;
120    solveroutput.iter = iter;
121    solveroutput.obj = obj;
122    solveroutput.clambda=clambda;
123    solveroutput.istate=istate; 
124    solveroutput.ifail=ifail; 
125else
126    solveroutput = [];
127end
128
129% Standard interface
130output.Primal      = x;
131output.Dual        = D_struc;
132output.Slack       = [];
133output.problem     = problem;
134output.infostr     = infostr;
135output.solverinput = solverinput;
136output.solveroutput= solveroutput;
137output.solvertime  = solvertime;
138
139
140% NAG-hack
141clear Q
Note: See TracBrowser for help on using the repository browser.