17.2 Data Structures and Notation¶
The data structures employed by MOSEK are discussed in this section, along with the used notation.
The data structures and types used are the following:
prob
names
cones
barc
bara
solver_solutions
solution
res
prisen
cprisen
vprisen
duasen
info
symbcon
callback
17.2.1 Notation¶
MOSEK solves linear, quadratic, quadratically constrained, and conic optimization problems. The simplest of those is a linear problem, which is posed in MOSEK as
An extension is a linear conic problem where the variables can belong to quadratic or semidefinite cones. A conic problem in MOSEK has the form
where the conic constraint
means that a partitioning of \(x\) belongs to a set of quadratic cones (elaborated below). Further, the problem has \(p\) symmetric positive semidefinite variables \(\barX_j\in \PSD^{r_j}\) of dimension \(r_j\) with symmetric coefficient matrices \(\barC_j\in \Symm^{r_j}\) and \(\barA_{i,j}\in \Symm^{r_j}\).
Alternatively, MOSEK can solve convex quadratically constrained quadratic problems
The matrix
must be symmetric positive semidefinite and the matrix
must be either symmetric negative semidefinite with the \(i\)th constraint
or \(Q^i\) must be symmetric positive semidefinite with the \(i\)th constraint
Note that the if the quadratic terms \(Q^i\) are absent, the problem reduces to a standard quadratic optimization problem.
Finally, some variables may be integerconstrained, i.e.,
where \(x_j\) (and possibly \(\barX_j\)) are the decision variables and all the other quantities are the parameters of the problem and they are presented below:
 Since \(Q^o\) and \(Q^i\) are symmetric, only the lower triangular part should be specified.
 The coefficients \(c_j\) are coefficients for the linear term \(c_j x_j\) in the objective.
 \(c^f\) is a constant term in the objective, i.e., independent of all variables.
 The constraint matrix \(A\) is given by
In MOSEK it is assumed that \(A\) is a sparse matrix, i.e. most of the coefficients in \(A\) are zero. Therefore, only nonzeros elements in \(A\) are stored and worked with. This usually saves a lot of storage and speeds up the computations.
The symmetric matrices \(\barC_j\) are coefficient matrices for the linear term \(\mathrm{tr}(\barC_j \barX_j)\) in the objective for semidefinite problems. The matrices are specified in triplet format discarding zero elements, and since they are symmetric, only the lower triangular parts should be specified.
The constraint matrices \(\barA_{ij}\) are symmetric matrices used in the constraints
\[l_i^c \leq \sum_{j=1}^n a_{ij} x_j + \sum_{j=1}^p \left\langle \barA_{ij}, \barX_j\right\rangle \leq u_i^c, \quad i = 1, \ldots, m,\]for semidefinite problems. The matrices are specifed in triplet format discard zero elements, and since they are symmetric only the lower triangulars should be specified.
 \(l^c\) specifies the lower bounds of the constraints.
 \(u^c\) specifies the upper bounds of the constraints.
 \(l^x\) specifies the lower bounds on the variables \(x\).
 \(u^x\) specifies the upper bounds on the variables \(x\).
In conic problems, a partitioning of \(x\) belongs to a set of free variables and quadratic cones. Let
\[x^t \in \real^{n^t}, \quad t=1,\ldots ,k\]be vectors comprised of disjoint subsets of the decision variables \(x\) (each decision variable is a field of exactly one \(x^t\)), e.g.,
\[\begin{split}x^1 = \left[ \begin{array}{c} x_1 \\ x_4 \\ x_7 \end{array} \right] \mbox{ and } x^2 = \left[ \begin{array} {c} x_6 \\ x_5 \\ x_3 \\ x_2 \end{array} \right].\end{split}\]Next, define
\[\K := \left\lbrace x \in \real^n: \quad x^t \in \K_t,\quad t=1,\ldots ,k \right\rbrace\]where \(\K_t\) must have one of the following forms
Free variables:
\[\K_t = \{ x \in \real^{n^t} \}.\]Quadratic cones:
\[\K_t = \left\lbrace x \in \real^{n^{t}}: x_1 \geq \sqrt{\sum_{j=2}^{n^t} x_j^2} \right\rbrace.\]Rotated quadratic cones:
\[\K_t = \left\lbrace x \in \real^{n^t}: 2 x_1 x_2 \geq \sum_{j=3}^{n^t} x_j^2,\quad x_1,x_2 \geq 0 \right\rbrace.\]
The parameters of the optimization problem are stored using one or more subfields of the prob
structure using the naming convention in Table 17.1.
Field name  Type  Dimension  Optional  Problem parameter 

qosubi 
int 
length(qoval) 
Yes  \(q_{ij}^o\) 
qosubj 
int 
length(qoval) 
Yes  \(q_{ij}^o\) 
qoval 
double 
length(qoval) 
Yes  \(q_{ij}^o\) 
c 
double 
\(n\)  Yes  \(c_j\) 
qcsubk 
int 
length(qcval) 
Yes  \(q_{ij}^p\) 
qcsubi 
int 
length(qcval) 
Yes  \(q_{ij}^p\) 
qcsubj 
int 
length(qcval) 
Yes  \(q_{ij}^p\) 
qcval 
double 
length(qcval) 
Yes  \(q_{ij}^p\) 
a 
Sparse matrix  \(m ×n\)  No  \(a_{ij}\) 
bardim 
int 
\(p\)  Yes  \(r_j\) 
barc 
MATLAB struct  Yes  \(\barC_j\)  
bara 
MATLAB struct  Yes  \(\barA_{ij}\)  
blc 
double 
\(m\)  Yes  \(l_k^c\) 
buc 
double 
\(m\)  Yes  \(u_k^c\) 
blx 
double 
\(n\)  Yes  \(l_k^x\) 
bux 
double 
\(n\)  Yes  \(u_k^x\) 
ints 
MATLAB struct  \(\mathcal{j}\)  Yes  \(\mathcal{j}\) 
cones 
MATLAB cell  \(k\)  Yes  \(\K\) 
In Table 17.1 all the parameters are listed with their corresponding type. The int
type indicates that the field must contain an integer value, double
indicates a real number. The relationship between \(Q^o\) and \(Q^p\) and the subfields of the prob
structure is as follows:
The quadratic terms in the objective:
(3)\[q_{\mathtt{qosubi(t)},\mathtt{qoval(t)} }^o = \mathtt{qoval(t)},\quad t=1,2,\ldots ,\mathtt{length(qoval)}.\]Since \(Q^o\) by assumption is symmetric, all elements are assumed to belong to the lower triangular part. If an element is specified multiple times, the different elements are added together.
The quadratic terms in the constraints:
(4)\[q_{\mathtt{qcsubi(t)},\mathtt{qcsubj(t)}}^{\mathtt{qcsubk(t)}} = \mathtt{qcval(t)},\quad t=1,2,\ldots ,\mathtt{length(qcval)}.\]Since \(Q^p\) by assumption is symmetric, all elements are assumed to belong to the lower triangular part. If an element is specified multiple times, the different elements are added together.
17.2.2 Data Types and Structures¶

prob
¶ The
prob
data structure is used to communicate an optimization problem to MOSEK or for MOSEK to return an optimization problem to the user. It defines an optimization problem using a number of subfields.Fields:
(string) – A structure which contains the problem name, the name of the objective, and so forth.names
(int[]) – \(i\) subscript for element \(q_{ij}^o\) in \(Q^o\). See (3).qosubi
(int[]) – \(j\) subscript for element \(q_{ij}^o\) in \(Q^o\). See (3).qosubj
(double[]) – Numerical value for element \(q_{ij}^o\) in \(Q^o\). See (3).qoval
(int[]) – \(k\) subscript for element \(q_{ij}^p\) in \(Q^p\). See (4)qcsubk
(int[]) – \(i\) subscript for element \(q_{ij}^p\) in \(Q^p\). See (4)qcsubi
(double[]) – \(j\) subscript for element \(q_{ij}^p\) in \(Q^p\). See (4)qcsubj
(double[]) – Numerical value for element \(q_{ij}^p\) in \(Q^p\). See (4)qcval
(double[]) – Linear term in the objective.c
(double[][]) – The constraint matrix. It must be a sparse matrix having the number of rows and columns equivalent to the number of constraints and variables in the problem. This field should always be defined, even if the problem does not have any constraints. In that case a sparse matrix having zero rows and the correct number of columns is the appropriate definition of the field.a
(double[]) – Lower bounds of the constraints. \(\infty\) denotes an infinite lower bound. If the field is not defined orblc
blc==[]
, then all the lower bounds are assumed to be equal to \(\infty\).
(int[]) – A list with the dimensions of the semidefinite variables.bardim
(barc) – A structure for specifying \(\barC_j\).barc
(bara) – A structure for specifying \(\barA_{ij}\).bara
(double[]) – Upper bounds of the constraints. \(\infty\) denotes an infinite upper bound. If the field is not defined orbuc
buc==[]
, then all the upper bounds are assumed to be equal to \(\infty\).
(double[]) – Lower bounds on the variables. \(\infty\) denotes an infinite lower bound. If the field is not defined orblx
blx==[]
, then all the lower bounds are assumed to be equal to \(\infty\).
(double[]) – Upper bounds on the variables. \(\infty\) denotes an infinite upper bound. If the field is not defined orbux
bux==[]
, then all the upper bounds are assumed to be equal to \(\infty\).
(struct) –ints
A structure which has the subfields
.sub
A onedimensional array containing the indexes of the integerconstrained variables.ints.sub
is identical to the set \(\mathcal{j}\) in (2)..pri
A one dimensional array of the same length asints.sub
. Theints.pri(k)
is the branching priority assigned to variable indexints.sub(k)
.
(cones) – A structure defining the conic constraints (1).cones
(solver_solutions) – A structure containing a guess on the optimal solution which some of the optimizers in MOSEK may exploit.sol
(struct) –primalrepair
A structure used for primal feasibility repair which can optimally contain either of the subfields:
.wlc
Weights for lower bounds on constraints..wuc
Weights for upper bounds on constraints..wlx
Weights for lower bounds on variables..wlc
Weights for upper bounds on variables.
If either of the subfields is missing, it assumed to be a vector with value 1 of appropriate dimension.
(prisen) – A structure which has the subfields:prisen

res
¶ Fields:
(solver_solutions) – A structure holding available solutions (if any)sol
(struct) – A structure containing the task information database which contains various task related information such as the number of iterations used to solve the problem. However, this field is only defined if info appeared in the cmd command wheninfo
mosekopt
is invoked.
(list) – A structure which contain the complete MOSEK parameter database. However, this field is defined only if the param command is present inparam
cmd
whenmosekopt
is invoked.
(prob) – Contains the problem data if the problem data was read from a file.prob

names
¶ This structure is used to store all the names of individual items in the optimization problem such as the constraints and the variables.
Fields:
(string) – contains the problem name.name
(string) – contains the name of the objective.obj
(cell) – a cell array wherecon
names.con{i}
contains the name of the \(i\)th constraint.
(cell) – a cell array wherevar
names.var{j}
contains the name of the \(j\)th variable.
(cell) – a cell array wherebarvar
names.barvar{j}
contains the name of the \(j\)th semidefinite variable.
(cell) – a cell array wherecone
names.cone{t}
contains the name of the \(t\)th conic constraint.

cones
¶ A MATLAB structure representing details about cones.
For example the quadratic cone
\[x_5 \geq \sqrt{ {x_3}^2 + {x_1}^2}\]and rotated quadratic cone
\[2 x_6 x_4 \geq x_2^2 + x_7^2\]would be specified using the two arrays
cones.type = [0, 1]; cones.sub = [5, 3, 1, 6, 4, 2, 7]; cones.subptr = [1, 4];
Fields:
(list) – An array with the cone types for each cone;type
"MSK_CT_QUAD"
or"MSK_CT_RQUAD"
, indicating if the cone is a quadratic cone or a rotated quadratic cone.
(int[]) – An array of variable indexes specifying which variables are fields of the cones. The array is a concatenation of index lists of all the cones.sub
(int[]) – An array of pointers intosubptr
cones.sub
indicating the beginning of the different cone indexsets.

barc
¶ Together with field
bardim
this structure specifies the symmetric matrices \(\barC_j\) in the objective for semidefinite problems.The symmetric matrices are specified in blocktriplet format as
\[[\barC_{\mathtt{barc.subj(t)}}]_{\mathtt{barc.subk(t)},\mathtt{barc.subl(t)}} = \mathtt{barc.val(t)},\quad t=1,2,\ldots ,\mathtt{length(barc.subj)}.\]Only the lower triangular parts of \(\barC_j\) are specified, i.e., it is required that
\[\mathtt{barc.subk(t)} \geq \mathtt{barc.subl(t)},\quad t=1,2,\ldots ,\mathtt{length(barc.subk)},\]and that
\[1 \leq \mathtt{barc.subk(t)} \leq \mathtt{bardim(barc.subj(t))}, \quad t=1,2,\ldots ,\mathtt{length(barc.subj)}.,\]All the structure fields must be arrays of the same length.
Fields:
(int[]) – Semidefinite variable indices \(j\).subj
(int[]) – Subscripts of nonzeros elements.subk
(int[]) – Subscripts of nonzeros elements.subl
(double) – Numerical values.val

bara
¶ Together with the field
bardim
this structure specifies the symmetric matrices \(\barA_{ij}\) in the constraints of semidefinite problems.The symmetric matrices are specified in blocktriplet format as
\[[\barA_{\mathtt{bara.subi(t)},\mathtt{bara.subj(t)}}]_{\mathtt{bara.subk(t)},\mathtt{bara.subl(t)}} = \mathtt{bara.val(t)},\quad t=1,2,\ldots ,\mathtt{length(bara.subi)}.\]Only the lower triangular parts of \(\barA_{ij}\) are specified, i.e., it is required that
\[\mathtt{bara.subk(t)} \geq \mathtt{bara.subl(t)},\quad t=1,2,\ldots ,\mathtt{length(bara.subk)},\]and that
\[1 \leq \mathtt{bara.subk(t)} \leq \mathtt{bardim(bara.subj(t))}, \quad t=1,2,\ldots ,\mathtt{length(bara.subj)},\]Fields:
(int) – Constraint indices \(i\).subi
(int) – Semidefinite variable indices \(j\).subj
(int[]) – Subscripts of nonzeros elements.subk
(int[]) – Subscripts of nonzeros elements.subl
(double[]) – Numerical values.val

solver_solutions
¶ A structure used to store one or more solutions to an optimization problem. The structure has one subfield for each possible solution type.
Fields:
(solution) – Interior (point) solution computed by the interiorpoint optimizer.itr
(solution) – Basic solution computed by the simplex optimizers and basis identification procedure.bas
(solution) – Integer solution computed by the mixedinteger optimizer.int

solution
¶ Stores information about a solution returned by the solve.
The fields
.skn
and.snx
cannot occur in the.bas
and.int
solutions. In addition the fields.y
,.slc
,.suc
,.slx
, and.sux
cannot occur in the.int
solution since integer problems does not have a welldefined dual problem, and hence no dual solution.Fields:
(prosta) – Problem status.prosta
(solsta) – Solution status.solsta
(stakey) – Enumraint status keys.skc
(stakey) – Variable status keys.skx
(stakey) – Conic status keys.skn
(double[]) – Constraint activities, i.e., \(x_c = Ax\) where \(x\) is the optimal solution.xc
(double[]) – The optimal \(x\) solution.xx
(list) – The optimal solution of \(\barX_j, \quad j=1, 2, \ldots, \mathtt{length(bardim)}\).barx
(list) – The optimal solution of \(\barS_j, \quad j=1, 2, \ldots, \mathtt{length(bardim)}\).bars
(double[]) – Identical toy
sol.slcsol.suc
.
(double[]) – Dual solution corresponding to the lower constraint bounds.slc
(double[]) – Dual solution corresponding to the upper constraint bounds.suc
(double[]) – Dual solution corresponding to the lower variable bounds.slx
(double[]) – Dual solution corresponding to the upper variable bounds.sux
(double[]) – Dual solution corresponding to the conic constraint.snx
(double) – The primal objective value.pobjval

prisen
¶ Results of the primal sensitivity analysis.
Fields:
(cprisen) – Constraints shadow prices.cons
(vprisen) – Variable shadow pricesvar
(int[]) – Index of variables where coefficients are analysed for sensitivity.sub

cprisen
¶ A structure holding information about constraint shadow prices.
Fields:
(double) – Left value \(\beta_1\) in the linearity interval for a lower bound.lr_bl
(double) – Right value \(\beta_2\) in the linearity interval for a lower bound.rr_bl
(double) – Left shadow price \(s_l\) for a lower bound.ls_bl
(double) – Right shadow price \(s_r\) for a lower bound.rs_bl
(double) – Left value \(\beta_1\) in the linearity interval for an upper bound.lr_bu
(double) – Right value \(\beta_2\) in the linearity interval for an upper bound.rr_bu
(double) – Left shadow price \(s_l\) for an upper bound.ls_bu
(double) – Right shadow price \(s_r\) for an upper bound.rs_bu

vprisen
¶ A structure holding information about variable shadow prices.
Fields:
(double) – Left value \(\beta_1\) in the linearity interval for a lower bound on a variablelr_bl
(double) – Right value \(\beta_2\) in the linearity interval for a lower bound on a variablerr_bl
(double) – Left shadow price \(s_l\) for a lower bound on a variablels_bl
(double) – Right shadow price \(s_r\) for a lower bound on a variablers_bl
(double) – Left value \(\beta_1\) in the linearity interval for an upper bound on a variablelr_bu
(double) – Right value \(\beta_2\) in the linearity interval for an upper bound on a variablerr_bu
(double) – Left shadow price \(s_l\) for an upper bound on a variablels_bu
(double) – Right shadow price \(s_r\) for an upper bound on a variable.rs_bu

duasen
¶ Results of dual the sensitivity analysis.
Fields:
(double) – Left value \(\beta_1\) in linearity interval for an objective coefficientlr_c
(double) – Right value \(\beta_2\) in linearity interval for an objective coefficientrr_c
(double) – Left shadow price \(s_l\) for an objective coefficientls_c
(double) – Right shadow price \(s_r\) for an objective coefficientrs_c

info
¶ info
is a MATLAB structure containing a subfield for each item in the MOSEK optimization task database, e.g., theinfo.dinfitem.bi_time
field specifies the amount of time spent in the basis identification in the last optimization. Seedinfitem
andiinfitem
for all the items in the task information database are listed.

symbcon
¶ A MATLAB structure containing a subfield for each MOSEK symbolic constant, e.g., the field
symbcon.dinfitem.bi_time
specifies the value of the symbolic constant"MSK_DINF_BI_TIME"
. In Section 17.6 allthe symbolic constants are listed.

callback
¶ A structure containing callback information (all subfields are optional).
Fields:
(struct) – A data structure or justloghandle
[]
.
(string) –log
The name of a userdefined function which must accept two input arguments, e.g.,
function myfunc(handle,str)
where
handle
will be identical tocallback.handle
whenmyfunc
is called, andstr
is a string of text from the log file.
(struct) – A data structure or justiterhandle
[]
.
(string) –iter
The name of a userdefined function which must accept three input arguments,
function myfunc(handle,where,info)
where
handle
will be identical tocallback.iterhandle
whenmyfunc
is called,where
indicates the current progress of the colver andinfo
is the current information database. Seeinfo
for further details.