1 | function output = callqsopt(interfacedata) |
---|
2 | |
---|
3 | % Author Johan Löfberg |
---|
4 | % $Id: callqsopt.m,v 1.3 2005/05/07 13:53:20 joloef Exp $ |
---|
5 | |
---|
6 | % Retrieve needed data |
---|
7 | options = interfacedata.options; |
---|
8 | F_struc = interfacedata.F_struc; |
---|
9 | c = interfacedata.c; |
---|
10 | K = interfacedata.K; |
---|
11 | ub = interfacedata.ub; |
---|
12 | lb = interfacedata.lb; |
---|
13 | |
---|
14 | n = length(c); |
---|
15 | % Bounded variables converted to constraints |
---|
16 | if ~isempty(ub) |
---|
17 | % TODO : MAKE SURE SIZES ARE CORRECT |
---|
18 | lb(lb==-inf) = -1e30; |
---|
19 | ub(ub==inf) = 1e30; |
---|
20 | else |
---|
21 | lb=repmat(-1e30,n,1); % just for sure |
---|
22 | ub=repmat(1e30,n,1); |
---|
23 | end |
---|
24 | |
---|
25 | if options.showprogress;showprogress('Calling QSOPT',options.showprogress);end |
---|
26 | |
---|
27 | options.qsopt.verbose = options.verbose; |
---|
28 | |
---|
29 | % Call mex-interface |
---|
30 | if options.savedebug |
---|
31 | save qsoptdebug |
---|
32 | end |
---|
33 | solvertime = clock; |
---|
34 | |
---|
35 | [x,lambda,STATUS] = qsopt(c,-F_struc(1+K.f:end,2:end),F_struc(1+K.f:end,1),-F_struc(1:K.f,2:end),F_struc(1:K.f,1),lb,ub,options.qsopt); |
---|
36 | solvertime = etime(clock,solvertime); |
---|
37 | problem = 0; |
---|
38 | |
---|
39 | if options.saveduals |
---|
40 | D_struc = -lambda; |
---|
41 | else |
---|
42 | D_struc = []; |
---|
43 | end |
---|
44 | |
---|
45 | % Check, currently not exhaustive... |
---|
46 | switch STATUS |
---|
47 | case 1 |
---|
48 | problem = 0; |
---|
49 | case 2 |
---|
50 | problem = 1; |
---|
51 | case 3 |
---|
52 | problem = 2; |
---|
53 | case 4 |
---|
54 | problem = 3; |
---|
55 | case {5,6} |
---|
56 | problem = 4; |
---|
57 | otherwise |
---|
58 | problem = -1; |
---|
59 | end |
---|
60 | infostr = yalmiperror(problem,'QSOPT'); |
---|
61 | |
---|
62 | % Save all data sent to solver? |
---|
63 | if options.savesolverinput |
---|
64 | solverinput = []; |
---|
65 | else |
---|
66 | solverinput = []; |
---|
67 | end |
---|
68 | |
---|
69 | % Save all data from the solver? |
---|
70 | if options.savesolveroutput |
---|
71 | solveroutput = []; |
---|
72 | else |
---|
73 | solveroutput = []; |
---|
74 | end |
---|
75 | |
---|
76 | % Standard interface |
---|
77 | output.Primal = x(:); |
---|
78 | output.Dual = D_struc; |
---|
79 | output.Slack = []; |
---|
80 | output.problem = problem; |
---|
81 | output.infostr = infostr; |
---|
82 | output.solverinput = solverinput; |
---|
83 | output.solveroutput= solveroutput; |
---|
84 | output.solvertime = solvertime; |
---|