c, G, h[, A, b[, solver[, primalstart[, dualstart]]]]) |
The solver argument is used to choose among three solvers.
When it is omitted or None
, the default CVXOPT solver is used.
The external solvers GLPK and MOSEK (if installed) can be selected by
setting solver='glpk'
or
solver='mosek'
; see section 8.8.
The optional arguments primalstart and dualstart are only
referenced by the default solver.
primalstart is a dictionary with keys 'x'
and 's'
,
used as an optional primal starting point.
dualstart is a dictionary with keys 'y'
and 'z'
,
used as an optional dual starting point.
lp() returns a dictionary with keys 'status'
,
'x'
, 's'
, 'y'
, 'z'
.
The possible values of the 'status'
item are as follows.
'optimal'.
'x'
, 's'
,
'y'
and 'z'
entries contain the primal and dual solutions,
which approximately satisfy
'primal infeasible'.
'x'
and 's'
entries are None
, and the 'y'
,
'z'
entries provide an approximate certificate of
infeasibility, i.e., vectors that approximately satisfy
'glpk'
option, no proof of infeasibility is returned
(all entries of the dictionary are None
).
'dual infeasible'.
'y'
and 'z'
entries are None
, and the 'x'
and 's'
entries contain an approximate certificate of dual
infeasibility
'glpk'
option, no proof of dual infeasibility is
returned.
'unknown'
.'x'
, 's'
, 'y'
,
'z'
entries are None
.
As a simple example we solve the LP
>>> from cvxopt.base import matrix >>> from cvxopt import solvers >>> c = matrix([-4., -5.]) >>> G = matrix([[2., 1., -1., 0.], [1., 2., 0., -1.]]) >>> h = matrix([3., 3., 0., 0.]) >>> sol = solvers.lp(c,G,h) >>> print sol['x'] 1.0000e-00 1.0000e-00