Python
Import
The QOCO can be imported as follows
import qoco
Setup
QOCO is initialized by creating a QOCO object as follows
solver = qoco.QOCO()
The problem is specified in the setup phase by running
solver.setup(n, m, p, P, c, A, b, G, h, l, nsoc, q, **settings)
The arguments c
, b
and q
are numpy arrays, and P
, A
, and G
are scipy sparse matrices in CSC format. The matrix P
can be either complete or just the upper triangular part, but QOCO will only use the upper triangular part.
If you do not have equality constraints, pass in None
for A
and b
. Pass in None
for G
and h
if you do not have inequality or second-order cone constraints, and pass in None
for q
and 0
for nsoc
if you do not have second-order cone constraints.
The keyword arguments **settings
specify the solver settings. The allowed parameters are defined in settings.
Solve
To solve the problem, run
results = solver.solve()
The results
object contains the following
Member |
Description |
---|---|
|
Primal solution |
|
Slack variable for conic constraints |
|
Dual solution for equality constraints |
|
Dual solution for conic constraints |
|
Solve status see exitflags |
|
Objective value |
|
Number of iterations |
|
Setup time in seconds |
|
Solve time in seconds |
|
Primal residual |
|
Dual residual |
|
Duality gap |