Cones
The cone \(\mathcal{K}\) can be any Cartesian product of the following primitive cones.
Name 
Description 
Entries in ScsCone 
Number of rows in \(A, b\) 

Zero cone 
\(\{s \mid s = 0 \}\) 


Positive (or linear) cone 
\(\{s \mid s \geq 0 \}\) 


Box cone 
\(\{(t, s) \in \mathbf{R} \times \mathbf{R}^k \mid t l \leq s \leq t u \}\) 


Secondorder cone 
\(\{(t, s) \in \mathbf{R} \times \mathbf{R}^k \mid \s\_2 \leq t \}\) 

\(\displaystyle \sum_{i=1}^{\text{qsize}} q_i\) 
Positive semidefinite cone 
\(\{ s \in \mathbf{R}^{k(k+1)/2} \mid \text{mat}(s) \succeq 0 \}\) (See note) 

\(\displaystyle \sum_{i=1}^{\text{ssize}} \frac{s_i(s_i+1)}{2}\) 
Exponential cone 
\(\{ (x,y,z) \in \mathbf{R}^3 \mid y e^{x/y} \leq z, y>0 \}\) 

\(3 \times\) 
Dual exponential cone 
\(\{ (u,v,w)\in \mathbf{R}^3 \mid u e^{v/u} \leq e w, u<0 \}\) 

\(3 \times\) 
Power cone 
\(\{ (x,y,z) \in \mathbf{R}^3 \mid x^p y^{1p} \geq z\}\) 

\(3 \times\) 
Dual power cone 
\(\{ (u,v,w)\in \mathbf{R}^3 \mid \left(\frac{u}{p}\right)^p \left(\frac{v}{1p}\right)^{1p} \geq w\}\) 

\(3 \times\) 
Note: The rows of the data matrix \(A\) correspond to the cones in \(\mathcal{K}\). The rows of \(A\) must be in the order of the cones given above, i.e., first come the rows that correspond to the zero cones, then those that correspond to the positive orthants, then the box cone, etc.
Within a cone the rows should be ordered to agree with the mathematical
description of the cone as given above. For instance, the box cone is defined
as \(\{(t, s) \in \mathbf{R} \times \mathbf{R}^k \mid t l \leq s \leq t u
\}\) and consequently the variable vector is stacked as [t;s]
, ie,
t
comes first then s
. Similarly, the exponential cone is
defined as \(\{ (x,y,z) \in \mathbf{R}^3 \mid y e^{x/y} \leq z, y>0 \}\)
and therefore the variable vector is stacked as [x, y, z]
, etc.
Semidefinite cones
The symmetric positive semidefinite cone of matrices is the set
and for short we use \(S \succeq 0\) to denote membership. SCS vectorizes this cone in a special way which we detail here.
SCS assumes that the input data corresponding to semidefinite cones have been vectorized by scaling the offdiagonal entries by \(\sqrt{2}\) and stacking the lower triangular elements columnwise. For a \(k \times k\) matrix variable (or data matrix) this operation would create a vector of length \(k(k+1)/2\). Scaling by \(\sqrt{2}\) is required to preserve the innerproduct.
This must be done for the rows of both \(A\) and \(b\) that correspond to semidefinite cones and must be done independently for each semidefinite cone.
More explicitly, we want to express \(\text{Trace}(Y S)\) as \(\text{vec}(Y)^\top \text{vec}(S)\), where the \(\text{vec}\) operation takes the (assumed to be symmetric) \(k \times k\) matrix
and produces a vector consisting of the lower triangular elements scaled and arranged as
To recover the matrix solution this operation must be inverted on the components of the vectors returned by SCS corresponding to each semidefinite cone. That is, the offdiagonal entries must be scaled by \(1/\sqrt{2}\) and the upper triangular entries are filled in by copying the values of lower triangular entries. Explicitly, the inverse operation takes vector \(s \in \mathbf{R}^{k(k+1)/2}\) and produces the matrix
So the cone definition that SCS uses is
Example
For a concrete example in python see LowRank Matrix Completion. Here we consider the symmetric positive semidefinite cone constraint over variables \(x \in \mathbf{R}^n\) and \(S \in \mathbf{R}^{k \times k}\)
where data \(B, \mathcal{A}_1, \ldots, \mathcal{A}_n \in \mathbf{R}^{k \times k}\) are symmetric. We can write this in the canonical form over a new variable \(s \in \mathcal{S}_+^k\):
using the fact that \(\text{vec}\) is linear, where \(b = \text{vec}(B)\) and
i.e., the vectors \(\text{vec}(\mathcal{A}_i)\) stacked columnwise. This is in a form that we can input into SCS. To recover the matrix solution from the optimal solution returned by SCS, we simply use \(S^\star = \text{mat}(s^\star)\).