Reading and writing¶
We provide some helper functions in the qics.io
module to read and write
conic problems. We currently support the SDPA sparse and Conic Benchmark
Library formats, which we have modified to account support problems with complex
Hermitian variables and the additional cones which QICS supports.
SDPA sparse¶
The SDPA sparse file format *.dat-s
is used to encode sparse semidefinite
programs in standard form
We refer to [1] for additional details about this file
format. To account for complex semidefinite programs, we introduce the complex
SDPA sparse file format *.dat-c
, which is a straightforward modification
of the original format which allows values corresponding to \(F_i\) to be
complex.
For example, the problem
can be stored as the following *.dat-c
file.
3 = mDIM
1 = nBLOCK
2 = bLOCKsTRUCTURE
48.0 -8.0 20.0
0 1 1 1 -11-0j
0 1 1 2 23-0j
1 1 1 1 10+0j
1 1 1 2 4j
2 1 2 2 -8+0j
3 1 1 2 -8-2j
3 1 2 2 2+0j
To read this file, we can use the qics.io.read_sdpa()
function as follows.
import qics
model = qics.io.read_sdpa("example.dat-c")
solver = qics.Solver(model)
solver.solve()
Similarly, we can write a semidefinite program represented by a
qics.Model
to a file by calling
qics.io.write_sdpa(model, "example.dat-c")
which writes a semidefinite program in the SDPA sparse format into the file
example.dat-c
.
Note
The SDPA sparse format only supports standard form semidefinite programs.
Therefore, qics.io.write_sdpa()
must be used with a
qics.Model
which is initialized like
qics.Model(c, A=A, b=b, cones=cones)
qics.Model(c, G=G, h=h, cones=cones)
i.e., in standard primal or dual form.
Conic Benchmark Format¶
The Conic Benchmark Format (CBF) file format *.cbf
is used to encode
conic programs of a general standardized form which encompasses the standard
form conic program used by QICS
We refer to [2] for details about this format. The advantage of the CBF format is that it provides flexibility in how the cone \(\mathcal{K}\) is defined by using keywords to define the type and structure of a Cartesian product of cones. Notable examples of cones currently supported by CBF are listed below.
Name |
CBF name |
Description |
---|---|---|
Positive orthant |
|
\(\{ x \in \mathbb{R}^n : x \geq 0 \}\) |
Quadratic cone |
|
\(\{(t, x)\in\mathbb{R}\times\mathbb{R}^{n}:t\geq\|x\|_2\}.\) |
Semidefinite cone |
|
\(\{ X \in \mathbb{S}^n : X \succeq 0 \}\) |
We note that the SVECPSD
cone is a symmetric vector form of the positive
semidefinite cone which represents matrices using the compact vectorization
described in Representing matrices, i.e., the SVECPSD
cone is actually
Following this convention, we define new cones in the CBF format for all cones supported by QICS.
Name |
CBF name |
Description |
---|---|---|
Complex semidefinite cone |
|
\(\{ X \in \mathbb{H}^n : X \succeq 0 \}\) |
Classical entropy cone |
|
\(\text{cl}\{ (t, u, x) \in \mathbb{R} \times \mathbb{R}_{++} \times \mathbb{R}^n_{++} : t \geq -u H(x / u) \}\) |
Classical relative entropy cone |
|
\(\text{cl}\{ (t, x, y) \in \mathbb{R} \times \mathbb{R}^n_{++} \times \mathbb{R}^n_{++} : t \geq H(x \| y) \}\) |
Quantum entropy cone |
|
\(\text{cl}\{ (t, u, X) \in \mathbb{R} \times \mathbb{R}_{++} \times \mathbb{S}^n_{++} : t \geq -u S(X / u) \}\) |
Complex quantum entropy cone |
|
\(\text{cl}\{ (t, u, X) \in \mathbb{R} \times \mathbb{R}_{++} \times \mathbb{H}^n_{++} : t \geq -u S(X / u) \}\) |
Quantum relative entropy cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{S}^n_{++} \times \mathbb{S}^n_{++} : t \geq S(X \| Y) \}\) |
Complex quantum relative entropy cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{H}^n_{++} \times \mathbb{H}^n_{++} : t \geq S(X \| Y) \}\) |
Operator relative entropy cone |
|
\(\text{cl}\{ (T, X, Y) \in \mathbb{S}^n \times \mathbb{S}^n_{++} \times \mathbb{S}^n_{++} : T \succeq -P_{\log}(X, Y) \}\) |
Complex operator relative entropy cone |
|
\(\text{cl}\{ (T, X, Y) \in \mathbb{H}^n \times \mathbb{H}^n_{++} \times \mathbb{H}^n_{++} : T \succeq -P_{\log}(X, Y) \}\) |
Trace operator relative entropy cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{S}^n_{++} \times \mathbb{S}^n_{++} : t \geq -\text{tr}[P_{\log}(X, Y)] \}\) |
Complex trace operator relative entropy cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{H}^n_{++} \times \mathbb{H}^n_{++} : t \geq -\text{tr}[P_{\log}(X, Y)] \}\) |
Name |
CBF name |
Description |
---|---|---|
Quantum conditional entropy cone |
|
\(\text{cl}\{ (t, X) \in \mathbb{R} \times \mathbb{S}^{n}_{++} : t \geq -S(X) + S(\text{tr}_i(X)) \}\) |
Complex quantum conditional entropy cone |
|
\(\text{cl}\{ (t, X) \in \mathbb{R} \times \mathbb{H}^{n}_{++} : t \geq -S(X) + S(\text{tr}_i(X)) \}\) |
Quantum key distribution cone |
|
\(\text{cl}\{ (t, X) \in \mathbb{R} \times \mathbb{S}^n_{++} : t \geq -S(\mathcal{G}(X)) + S(\mathcal{Z}(\mathcal{G}(X))) \}\) |
Complex quantum key distribution cone |
|
\(\text{cl}\{ (t, X) \in \mathbb{R} \times \mathbb{H}^n_{++} : t \geq -S(\mathcal{G}(X)) + S(\mathcal{Z}(\mathcal{G}(X))) \}\) |
Matrix geometric mean cone |
|
\(\text{cl}\{ (T, X, Y) \in \mathbb{S}^n \times \mathbb{S}^n_{++} \times \mathbb{S}^n_{++} : T \succeq P_{\alpha}(X, Y) \}\) |
Complex matrix geometric mean cone |
|
\(\text{cl}\{ (T, X, Y) \in \mathbb{H}^n \times \mathbb{H}^n_{++} \times \mathbb{H}^n_{++} : T \succeq P_{\alpha}(X, Y) \}\) |
Trace matrix geometric mean cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{S}^n_{++} \times \mathbb{S}^n_{++} : t \geq \text{tr}[P_{\alpha}(X, Y)] \}\) |
Complex trace matrix geometric mean cone |
|
\(\text{cl}\{ (t, X, Y) \in \mathbb{R} \times \mathbb{H}^n_{++} \times \mathbb{H}^n_{++} : t \geq \text{tr}[P_{\alpha}(X, Y)] \}\) |
We also introduce the following new keywords to describe the above parametric cones.
Keyword |
Description |
---|---|
|
Defines a lookup table for quantum conditional entropy cones.
|
|
Defines a lookup table for quantum key distribution cones.
|
|
Defines a lookup table for matrix geometric mean cones.
|
To read a file in the CBF format, we can use the qics.io.read_cbf()
function as follows.
import qics
model = qics.io.read_sdpa("example.cbf")
solver = qics.Solver(model)
solver.solve()
Similarly, we can write a semidefinite program represented by a
qics.Model
to a file by calling
qics.io.write_cbf(model, "example.cbf")
which writes a semidefinite program in the SDPA sparse format into the file
my_arch0.cbf
.
Warning
The support for the CBF format by QICS is currently quite limited, and it is recommended that reading and writing using file format is restricted to problems generated by QICS.
References¶
“SDPA (SemiDefinite Programming Algorithm) User’s Manual – Version 6.2.0.”, K. Fujisawa, M. Kojima, K. Nakata, and M. Yamashita, Research Reports on Mathematical and Computing Sciences Series B : Operations Research, 2002.
“CBLIB 2014: a benchmark library for conic mixed-integer and continuous optimization,” H. A. Friberg, Mathematical Programming Computation 8 (2016): 191-214.