cpl(c, F[, G, h[, dims[, A, b[, kktsolver]]]])
Solves a convex optimization problem with a linear objective
c is a real single-column dense matrix.
F is a function that evaluates the nonlinear constraint functions. It must handle the following calling sequences.
If F is called with two arguments, it can be assumed that x is in the domain of f.
The linear inequalities are with respect to a cone C defined as a Cartesian product of a nonnegative orthant, a number of second-order cones, and a number of positive semidefinite cones:
with
Here vec(u) denotes a symmetric matrix u stored as a vector in column major order.
The arguments h and b are real single-column dense matrices. G and A are real dense or sparse matrices. The default values for A and b are sparse matrices with zero rows, meaning that there are no equality constraints. The number of rows of G and h is equal to
The columns of G and h are vectors in
where the last N components represent symmetric matrices stored in column major order. The strictly upper triangular entries of these matrices are not accessed (i.e., the symmetric matrices are stored in the ’L’-type column major order used in the blas and lapack modules).
The argument dims is a dictionary with the dimensions of the cones. It has three fields.
The default value of dims is {’l’: h.size[0], ’q’: [], ’s’: []}, i.e., the default assumption is that the linear inequalities are componentwise inequalities.
The role of the optional argument kktsolver is explained in section 8.4.
cpl() returns a dictionary that contains the result and information about the accuracy of the solution. The most important fields have keys ’status’, ’x’, ’snl’, ’sl’, ’y’, ’znl’, ’zl’. The possible values of the ’status’ key are:
The other entries in the output dictionary describe the accuracy of the solution. The entries ’primal objective’, ’dual objective’, ’gap’, and ’relative gap’, give the primal objective cTx, the dual objective calculated as
the duality gap
and the relative gap. The relative gap is defined as
and None otherwise. The entry with key ’primal infeasibility’ gives the residual in the primal constraints,
where x0 is the point returned by F(). The entry with key ’dual infeasibility’ gives the residual
cpl() requires that the problem is strictly primal and dual feasible and that
for all x and all positive z.
This example is the floor planning problem of section 8.8.2 in the book Convex Optimization:
This problem has 22 variables
5 nonlinear inequality constraints, and 26 linear inequality constraints. The code belows defines a function floorplan() that solves the problem by calling cp(), then applies it to 4 instances, and creates a figure.