API Reference
Model
COSMO.Model — Type
Model{T <: AbstractFloat}()Initializes an empty COSMO model that can be filled with problem data using assemble!(model, P, q,constraints; [settings, x0, s0, y0]).
COSMO.assemble! — Function
assemble!(model, P, q, constraint(s); [settings, x0, y0, s0])Assembles a COSMO.Model with a cost function defind by P and q, and a number of constraints.
The positive semidefinite matrix P and vector q are used to specify the cost function of the optimization problem:
min 1/2 x'Px + q'x
s.t. Ax + b ∈ Cconstraints is a COSMO.Constraint or an array of COSMO.Constraint objects that are used to describe the constraints on x.
The optional keyword argument settings can be used to pass custom solver settings:
custom_settings = COSMO.Settings(verbose = true);
assemble!(model, P, q, constraints, settings = custom_settings)The optional keyword arguments x0 and y0 can be used to provide the solver with warm starting values for the primal variable x and the dual variable y.
x_0 = [1.0; 5.0; 3.0]
COSMO.assemble!(model, P, q, constraints, x0 = x_0)COSMO.set! — Function
set!(model, P, q, A, b, convex_sets, [settings])Sets model data directly based on provided fields.
COSMO.empty_model! — Function
empty_model!(model)Resets all the fields of model to that of a model created with COSMO.Model() (apart from the settings).
COSMO.warm_start_primal! — Function
warm_start_primal!(model, x0, [ind])Provides the COSMO.Model with warm starting values for the primal variable x. ind can be used to warm start certain components of x.
COSMO.warm_start_slack! — Function
warm_start_slack!(model, s0, [ind])Provides the COSMO.Model with warm starting values for the primal slack variable s. ind can be used to warm start certain components of s.
COSMO.warm_start_dual! — Function
warm_start_dual!(model, y0, [ind])Provides the COSMO.Model with warm starting values for the dual variable y. ind can be used to warm start certain components of y.
Constraints
COSMO.Constraint — Type
Constraint{T <: AbstractFloat}(A, b, convex_set_type, dim = 0, indices = 0:0)Creates a COSMO constraint: Ax + b ∈ convex_set.
By default the following convex set types are supported: ZeroSet, Nonnegatives, SecondOrderCone, PsdCone, PsdConeTriangle.
Examples
julia> COSMO.Constraint([1 0;0 1], zeros(2), COSMO.Nonnegatives)
Constraint
Size of A: (2, 2)
ConvexSet: COSMO.Nonnegatives{Float64}For convex sets that require their own data, it is possible to pass the pass the instantiated object directly rather than the type name.
Examples
julia> COSMO.Constraint([1 0;0 1], zeros(2), COSMO.Box([-1.;-1.],[1.;1.]))
Constraint
Size of A: (2, 2)
ConvexSet: COSMO.Box{Float64}The optional arguments dim and indices can be used to specify A and b for subparts of variable x. If x has dimension dim = 4, then x[2] and x[3] can be constrained to the zero cone in the following way:
Examples
julia> c = COSMO.Constraint([1 0;0 1], zeros(2), COSMO.ZeroSet, 4, 2:3)
Constraint
Size of A: (2, 4)
ConvexSet: COSMO.ZeroSet{Float64}Notice that extra columns of A have been added automatically.
julia>Matrix(c.A)
2×4 Array{Float64,2}:
0.0 1.0 0.0 0.0
0.0 0.0 1.0 0.0COSMO.ZeroSet — Type
ZeroSet(dim)Creates the zero set $\{ 0 \}^{dim}$ of dimension dim. If x ∈ ZeroSet then all entries of x are zero.
COSMO.Nonnegatives — Type
Nonnegatives(dim)Creates the nonnegative orthant $\{ x \in \mathbb{R}^{dim} : x \ge 0 \}$ of dimension dim.
COSMO.SecondOrderCone — Type
SecondOrderCone(dim)Creates the second-order cone (or Lorenz cone) $\{ (t,x) \in \mathrm{R}^{dim} : || x ||_2 \leq t \}$.
COSMO.PsdCone — Type
PsdCone(dim)Creates the cone of symmetric positive semidefinite matrices $\mathcal{S}_+^{dim}$. The entries of the matrix X are stored column-by-column in the vector x of dimension dim. Accordingly $X \in \mathbb{S}_+ \Rightarrow x \in \mathcal{S}_+^{dim}$, where $X = \text{mat}(x)$.
COSMO.PsdConeTriangle — Type
PsdConeTriangle{T, R}(dim) where {T <: Real, R <: Union{T, Complex{T}}}Creates the cone of real (when R == T) or complex (when R == Complex{T}) Hermitian positive semidefinite matrices. The entries of the upper-triangular part of matrix X are stored in the vector x of dimension dim. A $r \times r$ real matrix has $r(r+1)/2$ upper triangular elements and results in a vector of $\mathrm{dim} = r(r+1)/2$. A $r \times r$ complex matrix has $r^2$ upper triangular elements and results in a vector of $\mathrm{dim} = r^2$.
Examples
The real matrix
\[\begin{bmatrix} x_1 & x_2 & x_4\\ x_2 & x_3 & x_5\\ x_4 & x_5 & x_6 \end{bmatrix}\]
is transformed to the vector $[x_1, \sqrt{2}x_2, x_3, \sqrt{2}x_4, \sqrt{2}x_5, x_6]^\top$ with corresponding constraint PsdConeTriangle{T, T}(6).
The complex matrix
\[\begin{bmatrix} x_1 & x_2 & x_4\\ x_2 & x_3 & x_5\\ x_4 & x_5 & x_6 \end{bmatrix}\]
is transformed to the vector $[x_1, \sqrt{2}\operatorname{re}(x_2), x_3, \sqrt{2}\operatorname{re}(x_4), \sqrt{2}\operatorname{re}(x_5), x_6, \sqrt{2}\operatorname{im}(x_2), \sqrt{2}\operatorname{im}(x_4), \sqrt{2}\operatorname{im}(x_5)]^\top$ with corresponding constraint PsdConeTriangle{T, Complex{T}}(9).
COSMO.ExponentialCone — Type
ExponentialCone(MAX_ITERS = 100, EXP_TOL = 1e-8)Creates the exponential cone $\mathcal{K}_{exp} = \{(x, y, z) \mid y \geq 0 ye^{x/y} ≤ z\} \cup \{ (x,y,z) \mid x \leq 0, y = 0, z \geq 0 \}$
COSMO.DualExponentialCone — Type
DualExponentialCone(MAX_ITERS::Int = 100, EXP_TOL = 1e-8)Creates the dual exponential cone $\mathcal{K}^*_{exp} = \{(x, y, z) \mid x < 0, -xe^{y/x} \leq e^1 z \} \cup \{ (0,y,z) \mid y \geq 0, z \geq 0 \}$
COSMO.PowerCone — Type
PowerCone(alpha::Float64, MAX_ITERS::Int = 20, POW_TOL = 1e-8)Creates the 3-d power cone $\mathcal{K}_{pow} = \{(x, y, z) \mid x^\alpha y^{(1-\alpha)} \geq \|z\|, x \geq 0, y \geq 0 \}$ with $0 < \alpha < 1$
COSMO.DualPowerCone — Type
DualPowerCone(alpha::Float64, MAX_ITERS::Int = 20, POW_TOL = 1e-8)Creates the 3-d dual power cone $\mathcal{K}^*_{pow} = \{(u, v, w) \mid \left( \frac{u}{\alpha}\right)^\alpha \left( \frac{v}{1-\alpha}\right)^{(1-\alpha)} \geq \|w\|, u \geq 0, v \geq 0 \}$ with $0 < \alpha < 1$