![]() |
SuperSCS
1.3.2
|
A conic problem is described by the tuple \((A,b,c,\mathcal{K})\) where \(A\) is an \(m\times n\) sparse matrix and \(\mathcal{K}\) is a cone.
These data can be saved in a YAML file from which they can be accessed from MATLAB, C, R, Java, Python and any other programming language.
YAML files are easy to parse and are human- and machine-readable.
Let us consider the following second-order cone program:
\begin{eqnarray*} &&\mathrm{Minimize}\ \langle c, x \rangle\\ &&Ax + s = b\\ &&s\in\mathcal{K}, \end{eqnarray*}
where \(x\in\mathbb{R}^3\), \(A\in\mathbb{R}^{4\times 3}\) is the following sparse matrix
\begin{eqnarray*} A &=& \begin{bmatrix} 0.3\\ & 0.7\\ && 0.2\\ -0.5 & 0.9 \end{bmatrix} \end{eqnarray*}
and \(c\in\mathbb{R}^3\) and \(b\in\mathbb{R}^4\) are the vectors
\begin{eqnarray*} c &=& \begin{bmatrix} 1 & -2 & -3 \end{bmatrix}^{\top} \end{eqnarray*}
and
\begin{eqnarray*} b &=& \begin{bmatrix} 0.2 & 0.1 & -0.1 & 0.1 \end{bmatrix}^{\top}. \end{eqnarray*}
Let \(\mathcal{K}\) be the second-order cone in \(\mathbb{R}^4\).
The YAML representation of this problem is as follows (download):
In MATLAB, you may serialize your problem using problem_to_yaml
.
In MATLAB the data of a conic optimization problem are stored in a structure called data
with fields A
, b
and c
and another structure called K
containing the cone specifications.
To save the contents of data
and K
in my_problem.yml
run:
To print the YAML-serialized problem data to the standard output run:
To print the YAML representation to some other output stream, e.g., a stream to a file created using fopen
run:
Retrieving data from a YAML file is as simple as
Here is a full example of saving and loading data:
A large YAML file can be found here.
In C, loading a YAML file is supported by SuperSCS's YAML parser.
To load a YAML file use scs_from_YAML.
Here is an example:
To save a problem (data and cones) in a YAML file, use scs_to_YAML.
Alongside, you need to provide some metadata for your problem.
Here is an example: