-
Notifications
You must be signed in to change notification settings - Fork 138
/
callpiqp.m
69 lines (59 loc) · 1.53 KB
/
callpiqp.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
function output = callpiqp(interfacedata)
options = interfacedata.options;
model = yalmip2piqp(interfacedata);
if options.savedebug
save debugfile model
end
if options.showprogress;showprogress(['Calling ' interfacedata.solver.tag],options.showprogress);end
% Define verbose option
options.piqp.verbose = options.verbose;
% Determine whether problem is sparse
is_sparse = issparse(model.P) || issparse(model.A) || issparse(model.G);
% Solve with PIQP
if is_sparse
PIQPSolver = piqp('sparse');
else
PIQPSolver = piqp('dense');
end
PIQPSolver.setup(model.P, model.c, ...
model.A, model.b, ...
model.G, model.h, ...
model.x_lb, model.x_ub, ...
options.piqp);
results = PIQPSolver.solve();
switch results.info.status_val
case 1
problem = 0;
case -1
problem = 3;
case -2
problem = 1;
case -3
problem = 1;
case -8
problem = 4;
case -9
problem = 7;
case -10
problem = 7;
otherwise
problem = -1;
end
% Solver time
solvertime = results.info.run_time;
% Standard interface
Primal = results.x(:);
Dual = [results.y; results.z];
infostr = yalmiperror(problem,interfacedata.solver.tag);
if ~options.savesolverinput
solverinput = [];
else
solverinput = model;
end
if ~options.savesolveroutput
solveroutput = [];
else
solveroutput = results;
end
% Standard interface
output = createOutputStructure(Primal,Dual,[],problem,infostr,solverinput,solveroutput,solvertime);