15.5 The PTF Format¶
The PTF format is a human-readable, natural text format that supports all linear, conic and mixed-integer features.
15.5.1 The overall format¶
The format is indentation based, where each section is started by a head line and followed by a section body with deeper indentation that the head line. For example:
Header line
Body line 1
Body line 1
Body line 1
Section can also be nested:
Header line A
Body line in A
Header line A.1
Body line in A.1
Body line in A.1
Body line in A
The indentation of blank lines is ignored, so a subsection can contain
a blank line with no indentation. The character #
defines a line
comment and anything between the #
character and the end of the
line is ignored.
In a PTF file, the first section must be a Task
section. The order
of the remaining section is arbitrary, and sections may occur multiple
times or not at all.
MOSEK will ignore any top-level section it does not recognize.
15.5.1.1 Names¶
In the description of the format we use following definitions for name strings:
NAME: PLAIN_NAME | QUOTED_NAME
PLAIN_NAME: [a-zA-Z_] [a-zA-Z0-9_-.!|]
QUOTED_NAME: "'" ( [^'\\\r\n] | "\\" ( [\\rn] | "x" [0-9a-fA-F] [0-9a-fA-F] ) )* "'"
15.5.1.2 Expressions¶
An expression is a sum of terms. A term is either a linear term (a coefficient and a variable name, where the coefficient can be left out if it is 1.0), or a matrix inner product.
An expression:
EXPR: EMPTY | ( [+-] TERM )*
TERM: LINEAR_TERM | MATRIX_TERM
A linear term
LINEAR_TERM: FLOAT? NAME
A matrix term
MATRIX_TERM: "<" ( [+-] FLOAT? NAME)* ";" NAME ">"
Here the right-hand name is the name of a (semidefinite) matrix variable, and the left-hand side is a sum of symmetric matrices. The actual matrices are defined in a separate section.
Expressions can span multiple lines by giving subsequent lines a deeper indentation.
For example following two section are equivalent:
# Everything on one line:
+ x1 + x2 + x3 + x4
# Split into multiple lines:
+ x1
+ x2
+ x3
+ x4
15.5.2 Task
section¶
The first section of the file must be a Task
. The text in this
section is not used and may contain comments, or meta-information from
the writer or about the content.
Format:
Task NAME
Anything goes here...
NAME
is a the task name.
15.5.3 Objective
section¶
The Objective
section defines the objective name, sense and function. The format:
"Objective" NAME?
( "Minimize" | "Maximize" ) EXPR
For example:
Objective 'obj'
Minimize + x1 + 0.2 x2 + < M1 ; X1 >
15.5.4 Constraints
section¶
The constraints section defines a series of constraints. A constraint
defines a term \(A\cdot x + b\in K\). For linear constraints A
is just one row, while for conic constraints it can be multiple
rows. If a constraint spans multiple rows these can either be written
inline separated by semi-colons, or each expression in a separete
sub-section.
Simple linear constraints:
"Constraints"
NAME? "[" [-+] (FLOAT | "inf") (";" [-+] (FLOAT | "inf") )? "]" EXPR
If the brackets contain two values, they are used as upper and lower bounds. It they contain one value the constraint is an equality.
For example:
Constraints
# Ranged constraint
'c1' [0;10] + x1 + x2 + x3
# Fixed constraint, expression equals to 0
[0] + x1 + x2 + x3
# Nonnegative constraint
[0;+inf] + x1 + x2 + x3
Constraint blocks put the expression either in a subsection or inline. The cone type (domain) is written in the brackets, and MOSEK currently supports following types:
- Major (primal) cones:
QUAD(N)
orSOC(N)
: Second order cone of dimensionN
.RQUAD(N)
orRSOC(N)
: Rotated second order cone of dimensionN
.PEXP
: Primal exponential cone of dimension 3.PPOW(N,P)
: Primal power cone of dimensionN
with parameterP
(float between 0 and 1).PPOW(N;ALPHA)
: Primal power cone of dimensionN
with exponent sequenceALPHA
(comma-separated list of floats).PGEOMEAN(N)
: Primal geometric mean cone of domensionN
.SVECPSD(N)
: Vectorized symmetric positive semidefinite cone of dimensionN
(N
must be of the formD*(D+1)/2
).
- Dual cones:
DEXP
: Dual exponential cone of dimension 3.DPOW(N,P)
: Dual power cone of dimensionN
with parameterP
(float between 0 and 1).DPOW(N;ALPHA)
: Dual power cone of dimensionN
with exponent sequenceALPHA
(comma-separated list of floats).DGEOMEAN(N)
: Dual geometric mean cone of domensionN
.
- Linear cones:
FREE(N)
The free (unbounded) cone of dimensionN
.POSITIVE(N)
The non-negative cone of dimensionN
.NEGATIVE(N)
The non-positive cone of dimensionN
.ZERO(N)
The zero-cone of dimensionN
.
See Sec. 14.9 (Supported domains) for definitions of the parameters.
"Constraints"
NAME? "[" DOMAIN "]" EXPR_LIST
For example:
Constraints
'K1' [PPOW(5;3,1)]
+ x1 + x2
+ x2 + x3
+ 1.0
+ x1
+ x3
'K2' [RQUAD(3)]
+ x1 + x2
+ x2 + x3
+ x3 + x1
15.5.5 Variables
section¶
Any variable used in an expression must be defined in a variable section. The variable section defines each variable domain.
"Variables"
NAME "[" [-+] (FLOAT | "inf") (";" [-+] (FLOAT | "inf") )? "]"
NAME "[" "PSD" (INT) "]"
For example, a linear variable
Variables
# Nonnegative variable
x1 [0;inf]
# Ranged variable
x2 [0;1]
# Fixed variable
x3 [5.0]
# 5-dimensional symmetric matrix variable
X [PSD(5)]
15.5.6 Integer
section¶
This section contains a list of variables that are integral. For example:
Integer
x1 x2 x3
15.5.7 SymmetricMatrixes
section¶
This section defines the symmetric matrixes used for matrix coefficients in matrix inner product terms. The section lists named matrixes, each with a size and a number of non-zeros. Only non-zeros in the lower triangular part should be defined.
"SymmetricMatrixes"
NAME "SYMMAT" "(" INT ")" ( "(" INT "," INT "," FLOAT ")" )*
...
For example:
SymmetricMatrixes
M1 SYMMAT(3) (0,0,1.0) (1,1,2.0) (2,1,0.5)
M2 SYMMAT(3)
(0,0,1.0)
(1,1,2.0)
(2,1,0.5)
15.5.8 Solutions
section¶
Each subsection defines a solution. A solution defines for each constraint and for each variable exactly one primal value and either one (for conic domains) or two (for linear domains) dual values. The values follow the same logic as in the MOSEK C API. A primal and a dual solution status defines the meaning of the values primal and dual (solution, certificate, unknown, etc.)
The format is this:
"Solutions"
"Solution" WHICHSOL
"ProblemStatus" PROSTA PROSTA?
"SolutionStatus" SOLSTA SOLSTA?
"Objective" FLOAT FLOAT_OR_NONE
"Variables"
# Linear variable status: level, slx, sux
NAME "[" STATUS "]" FLOAT FLOAT_OR_NONE FLOAT_OR_NONE
"Constraints"
# Linear variable status: level, slx, sux
NAME "[" STATUS "]" FLOAT FLOAT_OR_NONE FLOAT_OR_NONE
# Conic constraint status: level, doty
NAME
"[" STATUS "]" FLOAT FLOAT_OR_NONE
Nonexistent values (for example, dual values for an integer solution) are replaced with a single dot (.
):
FLOAT_OR_NONE = FLOAT | .
Following values for WHICHSOL
are supported:
interior
Interior solution, the result of an interior-point solver.basic
Basic solution, as produced by a simplex solver.integer
Integer solution, the solution to a mixed-integer problem. This does not define a dual solution.
Following values for PROSTA
are supported:
unknown
The problem status is unknownfeasible
The problem has been proven feasibleinfeasible
The problem has been proven infeasibleillposed
The problem has been proved to be ill posedinfeasible_or_unbounded
The problem is infeasible or unbounded
Following values for SOLSTA
are supported:
unknown
The solution status is unknownfeasible
The solution is feasibleoptimal
The solution is optimalinfeas_cert
The solution is a certificate of infeasibilityillposed_cert
The solution is a certificate of illposedness
Following values for STATUS
are supported:
unknown
The value is unknownsuper_basic
The value is super basicat_lower
The value is basic and at its lower boundat_upper
The value is basic and at its upper boundfixed
The value is basic fixedinfinite
The value is at infinity
15.5.9 Examples¶
Linear example lo1.ptf
Task ''
# Written by MOSEK v10.0.13
# problemtype: Linear Problem
# number of linear variables: 4
# number of linear constraints: 3
# number of old-style A nonzeros: 9
Objective obj
Maximize + 3 x1 + x2 + 5 x3 + x4
Constraints
c1 [3e+1] + 3 x1 + x2 + 2 x3
c2 [1.5e+1;+inf] + 2 x1 + x2 + 3 x3 + x4
c3 [-inf;2.5e+1] + 2 x2 + 3 x4
Variables
x1 [0;+inf]
x2 [0;1e+1]
x3 [0;+inf]
x4 [0;+inf]
Conic quadratic example cqo1.ptf
Task ''
# Written by MOSEK v10.0.17
# problemtype: Conic Problem
# number of linear variables: 6
# number of linear constraints: 1
# number of old-style cones: 0
# number of positive semidefinite variables: 0
# number of positive semidefinite matrixes: 0
# number of affine conic constraints: 2
# number of disjunctive constraints: 0
# number scalar affine expressions/nonzeros : 6/6
# number of old-style A nonzeros: 3
Objective obj
Minimize + x4 + x5 + x6
Constraints
c1 [1] + x1 + x2 + 2 x3
k1 [QUAD(3)]
@ac1: + x4
@ac2: + x1
@ac3: + x2
k2 [RQUAD(3)]
@ac4: + x5
@ac5: + x6
@ac6: + x3
Variables
x4
x1 [0;+inf]
x2 [0;+inf]
x5
x6
x3 [0;+inf]
Power cone example cqo1.ptf
Task ''
Objective ''
Maximize - x0 + x3 + x4
Constraints
c0 [2] + x0 + x1 + 5e-1 x2
C1 [PPOW(3,2e-1)]
+ x0
+ x1
+ x3
C2 [PPOW(3;4.0,6.0)]
+ x2
+ x5
+ x4
Variables
x0
x1
x2
x3
x4
x5 [1.0]
Disjunctive example djc1.ptf
Task djc1
Objective ''
Minimize + 2 'x[0]' + 'x[1]' + 3 'x[2]' + 'x[3]'
Constraints
@c0 [-10;+inf] + 'x[0]' + 'x[1]' + 'x[2]' + 'x[3]'
@D0 [OR]
[AND]
[NEGATIVE(1)]
+ 'x[0]' - 2 'x[1]' + 1
[ZERO(2)]
+ 'x[2]'
+ 'x[3]'
[AND]
[NEGATIVE(1)]
+ 'x[2]' - 3 'x[3]' + 2
[ZERO(2)]
+ 'x[0]'
+ 'x[1]'
@D1 [OR]
[ZERO(1)]
+ 'x[0]' - 2.5
[ZERO(1)]
+ 'x[1]' - 2.5
[ZERO(1)]
+ 'x[2]' - 2.5
[ZERO(1)]
+ 'x[3]' - 2.5
Variables
'x[0]'
'x[1]'
'x[2]'
'x[3]'
Semidefinite example sdo1.ptf
Task ''
# Written by MOSEK v10.0.17
# problemtype: Conic Problem
# number of linear variables: 3
# number of linear constraints: 0
# number of old-style cones: 0
# number of positive semidefinite variables: 1
# number of positive semidefinite matrixes: 3
# number of affine conic constraints: 2
# number of disjunctive constraints: 0
# number scalar affine expressions/nonzeros : 5/6
# number of old-style A nonzeros: 0
Objective ''
Minimize + @x0 + <M0;@X0>
Constraints
@C0 [ZERO(2)]
@ac0: + @x0 + < + M1;@X0> - 1
@ac1: + @x1 + @x2 + < + M2;@X0> - 0.5
@C1 [QUAD(3)]
@ac2: + @x0
@ac3: + @x1
@ac4: + @x2
Variables
@x0
@x1
@x2
@X0 [PSD(3)]
SymmetricMatrixes
M0 SYMMAT(3) (0,0,2) (1,0,1) (1,1,2) (2,1,1) (2,2,2)
M1 SYMMAT(3) (0,0,1) (1,1,1) (2,2,1)
M2 SYMMAT(3) (0,0,1) (1,0,1) (1,1,1) (2,0,1) (2,1,1) (2,2,1)