Functions for writing optimization problems to a file.



Create a matrix from a symmetric vectorization.

picos.modeling.file_out.write(picos_problem, filename, writer='picos')[source]

Write an optimization problem to a file.

  • P (Problem) – The problem to write.

  • filename (str) –

    Path and name of the output file. The export format is inferred from the file extension. Supported extensions and their associated format are:

    • '.cbf' – Conic Benchmark Format.

      This format is suitable for optimization problems involving second order and/or semidefinite cone constraints. This is a standard choice for conic optimization problems. Visit the website of The Conic Benchmark Library or read A benchmark library for conic mixed-integer and continuous optimization by Henrik A. Friberg for more information.

    • '.lp'LP format.

      This format handles only linear constraints, unless the writer 'cplex' is used. In the latter case the extended CPLEX LP format is used instead.

    • '.mps'MPS format.

      As the writer, you need to choose one of 'cplex', 'gurobi' or 'mosek'.

    • '.opf'OPF format.

      As the writer, you need to choose 'mosek'.

    • '.dat-s'Sparse SDPA format.

      This format is suitable for semidefinite programs. Second order cone constraints are stored as semidefinite constraints on an arrow shaped matrix.

  • writer (str) – The default 'picos' denotes PICOS’ internal writer, which can export to LP, CBF, and Sparse SDPA formats. If CPLEX, Gurobi or MOSEK is installed, you can choose 'cplex', 'gurobi', or 'mosek', respectively, to make use of that solver’s export function and get access to more formats.


For problems involving a symmetric matrix variable X (typically, semidefinite programs), the expressions involving X are stored in PICOS as a function of svec(X), the symmetric vectorized form of X (see Dattorro, ch., and are also exported in that form. As a result, using an external solver on a problem description file exported by PICOS will also yield a solution in this symmetric vectorized form.

The CBF writer tries to write symmetric variables X in the section PSDVAR of the .cbf file. However, this is possible only if the constraint X \succeq 0 appears in the problem, and no other LMI involves X. If these two conditions are not satisfied, then the symmetric vectorization of X is used as a (free) variable of the section VAR in the .cbf file, as explained in the previous paragraph.


This function is severly outdated and may fail or not function as advertised.



A number deemed too large to appear in practice.

Default value