15.4 Class Task¶
- mosek.Task¶
Represents an optimization task.
- Task.Task¶
Task()
Task(env)
Task(env, numcon, numvar)
Task(task)
Constructor of a new optimization task.
- Parameters:
- Groups:
- Task.__del__¶
__del__()
Free the underlying native allocation.
- Groups:
- Task.analyzenames¶
analyzenames(whichstream,nametype)
The function analyzes the names and issues an error if a name is invalid.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)nametype
(mosek.nametype
) – The type of names e.g. valid in MPS or LP files. (input)
- Groups:
- Task.analyzeproblem¶
analyzeproblem(whichstream)
The function analyzes the data of a task and writes out a report.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)- Groups:
- Task.analyzesolution¶
analyzesolution(whichstream,whichsol)
Print information related to the quality of the solution and other solution statistics.
By default this function prints information about the largest infeasibilites in the solution, the primal (and possibly dual) objective value and the solution status.
Following parameters can be used to configure the printed statistics:
iparam.ana_sol_basis
enables or disables printing of statistics specific to the basis solution (condition number, number of basic variables etc.). Default is on.iparam.ana_sol_print_violated
enables or disables listing names of all constraints (both primal and dual) which are violated by the solution. Default is off.dparam.ana_sol_infeas_tol
is the tolerance defining when a constraint is considered violated. If a constraint is violated more than this, it will be listed in the summary.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)
- Groups:
- Task.appendacc¶
appendacc(domidx,afeidxlist,b)
Appends an affine conic constraint to the task. The affine constraint has the form a sequence of affine expressions belongs to a domain.
The domain index is specified with
domidx
and should refer to a domain previously appended with one of theappend...domain
functions.The length of the affine expression list
afeidxlist
must be equal to the dimension \(n\) of the domain. The elements ofafeidxlist
are indexes to the store of affine expressions, i.e. the affine expressions appearing in the affine conic constraint are:\[F_{\mathtt{afeidxlist}[k],:}x + g_{\mathtt{afeidxlist}[k]} \quad \mathrm{for}\ k=\idxbeg,\ldots,\idxend{n}.\]If an optional vector
b
of the same length asafeidxlist
is specified then the expressions appearing in the affine constraint will instead be taken as:\[F_{\mathtt{afeidxlist}[k],:}x + g_{\mathtt{afeidxlist}[k]} - b_k \quad \mathrm{for}\ k=\idxbeg,\ldots,\idxend{n}.\]- Parameters:
domidx
(int64
) – Domain index. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.appendaccs¶
appendaccs(domidxs,afeidxlist,b)
Appends
numaccs
affine conic constraint to the task. Each single affine conic constraint should be specified as inTask.appendacc
and the input of this function should contain the concatenation of all these descriptions.In particular, the length of
afeidxlist
must equal the sum of dimensions of domains indexed indomainsidxs
.- Parameters:
domidxs
(int64
[]
) – Domain indices. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.appendaccseq¶
appendaccseq(domidx,afeidxfirst,b)
Appends an affine conic constraint to the task, as in
Task.appendacc
. The function assumes the affine expressions forming the constraint are sequential. The affine constraint has the form a sequence of affine expressions belongs to a domain.The domain index is specified with
domidx
and should refer to a domain previously appended with one of theappend...domain
functions.The number of affine expressions should be equal to the dimension \(n\) of the domain. The affine expressions forming the affine constraint are arranged sequentially in a contiguous block of the affine expression store starting from position
afeidxfirst
. That is, the affine expressions appearing in the affine conic constraint are:\[F_{\mathtt{afeidxfirst}+k,:}x + g_{\mathtt{afeidxfirst}+k} \quad \mathrm{for}\ k=\idxbeg,\ldots,\idxend{n}.\]If an optional vector
b
of lengthnumafeidx
is specified then the expressions appearing in the affine constraint will instead be taken as\[F_{\mathtt{afeidxfirst}+k,:}x + g_{\mathtt{afeidxfirst}+k} - b_k \quad \mathrm{for}\ k=\idxbeg,\ldots,\idxend{n}.\]- Parameters:
domidx
(int64
) – Domain index. (input)afeidxfirst
(int64
) – Index of the first affine expression. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.appendaccsseq¶
appendaccsseq(domidxs,numafeidx,afeidxfirst,b)
Appends
numaccs
affine conic constraint to the task. It is the block variant ofTask.appendaccs
, that is it assumes that the affine expressions appearing in the affine conic constraints are sequential in the affine expression store, starting from positionafeidxfirst
.- Parameters:
domidxs
(int64
[]
) – Domain indices. (input)numafeidx
(int64
) – Number of affine expressions in the affine expression list (must equal the sum of dimensions of the domains). (input)afeidxfirst
(int64
) – Index of the first affine expression. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.appendafes¶
appendafes(num)
Appends a number of empty affine expressions to the task.
- Parameters:
num
(int64
) – Number of empty affine expressions which should be appended. (input)- Groups:
- Task.appendbarvars¶
appendbarvars(dim)
Appends positive semidefinite matrix variables of dimensions given by
dim
to the problem.- Parameters:
dim
(int32
[]
) – Dimensions of symmetric matrix variables to be added. (input)- Groups:
- Task.appendcone Deprecated¶
appendcone(ct,conepar,submem)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Appends a new conic constraint to the problem. Hence, add a constraint
\[\hat{x} \in \K\]to the problem, where \(\K\) is a convex cone. \(\hat{x}\) is a subset of the variables which will be specified by the argument
submem
. Cone type is specified byct
.Define
\[\hat{x} = x_{\mathtt{submem}[1]},\ldots,x_{\mathtt{submem}[\mathtt{nummem}]}.\]Depending on the value of
ct
this function appends one of the constraints:Quadratic cone (
conetype.quad
, requires \(\mathtt{nummem}\geq 1\)):\[\hat{x}_0 \geq \sqrt{\sum_{i=1}^{i<\mathtt{nummem}} \hat{x}_i^2}\]Rotated quadratic cone (
conetype.rquad
, requires \(\mathtt{nummem}\geq 2\)):\[2 \hat{x}_0 \hat{x}_1 \geq \sum_{i=2}^{i<\mathtt{nummem}} \hat{x}^2_i, \quad \hat{x}_{0}, \hat{x}_1 \geq 0\]Primal exponential cone (
conetype.pexp
, requires \(\mathtt{nummem}=3\)):\[\hat{x}_0 \geq \hat{x}_1\exp(\hat{x}_2/\hat{x}_1), \quad \hat{x}_0,\hat{x}_1 \geq 0\]Primal power cone (
conetype.ppow
, requires \(\mathtt{nummem}\geq 2\)):\[\hat{x}_0^\alpha \hat{x}_1^{1-\alpha} \geq \sqrt{\sum_{i=2}^{i<\mathtt{nummem}} \hat{x}^2_i}, \quad \hat{x}_{0}, \hat{x}_1 \geq 0\]where \(\alpha\) is the cone parameter specified by
conepar
.Dual exponential cone (
conetype.dexp
, requires \(\mathtt{nummem}=3\)):\[\hat{x}_0 \geq -\hat{x}_2 e^{-1}\exp(\hat{x}_1/\hat{x}_2), \quad \hat{x}_2\leq 0,\hat{x}_0 \geq 0\]Dual power cone (
conetype.dpow
, requires \(\mathtt{nummem}\geq 2\)):\[\left(\frac{\hat{x}_0}{\alpha}\right)^\alpha \left(\frac{\hat{x}_1}{1-\alpha}\right)^{1-\alpha} \geq \sqrt{\sum_{i=2}^{i<\mathtt{nummem}} \hat{x}^2_i}, \quad \hat{x}_{0}, \hat{x}_1 \geq 0\]where \(\alpha\) is the cone parameter specified by
conepar
.Zero cone (
conetype.zero
):\[\hat{x}_i = 0 \ \textrm{for all}\ i\]
Please note that the sets of variables appearing in different conic constraints must be disjoint.
For an explained code example see Sec. 6.3 (Conic Quadratic Optimization), Sec. 6.5 (Conic Exponential Optimization) or Sec. 6.4 (Power Cone Optimization).
- Parameters:
ct
(mosek.conetype
) – Specifies the type of the cone. (input)conepar
(float
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0. (input)submem
(int32
[]
) – Variable subscripts of the members in the cone. (input)
- Groups:
- Task.appendconeseq Deprecated¶
appendconeseq(ct,conepar,nummem,j)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Appends a new conic constraint to the problem, as in
Task.appendcone
. The function assumes the members of cone are sequential where the first member has indexj
and the lastj+nummem-1
.- Parameters:
ct
(mosek.conetype
) – Specifies the type of the cone. (input)conepar
(float
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0. (input)nummem
(int32
) – Number of member variables in the cone. (input)j
(int32
) – Index of the first variable in the conic constraint. (input)
- Groups:
- Task.appendconesseq Deprecated¶
appendconesseq(ct,conepar,nummem,j)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Appends a number of conic constraints to the problem, as in
Task.appendcone
. The \(k\)th cone is assumed to be of dimensionnummem[k]
. Moreover, it is assumed that the first variable of the first cone has index \(j\) and starting from there the sequentially following variables belong to the first cone, then to the second cone and so on.- Parameters:
ct
(mosek.conetype
[]
) – Specifies the type of the cone. (input)conepar
(float
[]
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0. (input)nummem
(int32
[]
) – Numbers of member variables in the cones. (input)j
(int32
) – Index of the first variable in the first cone to be appended. (input)
- Groups:
- Task.appendcons¶
appendcons(num)
Appends a number of constraints to the model. Appended constraints will be declared free. Please note that MOSEK will automatically expand the problem dimension to accommodate the additional constraints.
- Parameters:
num
(int32
) – Number of constraints which should be appended. (input)- Groups:
- Task.appenddjcs¶
appenddjcs(num)
Appends a number of empty disjunctive constraints to the task.
- Parameters:
num
(int64
) – Number of empty disjunctive constraints which should be appended. (input)- Groups:
- Task.appenddualexpconedomain¶
appenddualexpconedomain() -> (domidx)
Appends the dual exponential cone \(\left\{ x\in \real^3 ~:~ x_0 \geq -x_2 e^{-1} e^{x_1/x_2},\ x_0> 0,\ x_2< 0 \right\}\) to the list of domains.
- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appenddualgeomeanconedomain¶
appenddualgeomeanconedomain(n) -> (domidx)
Appends the dual geometric mean cone \(\left\{ x\in \real^n ~:~ (n-1) \left(\prod_{i=0}^{n-2} x_i\right)^{1/(n-1)} \geq |x_{n-1}|,\ x_0,\ldots,x_{n-2}\geq 0 \right\}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appenddualpowerconedomain¶
appenddualpowerconedomain(n,alpha) -> (domidx)
Appends the dual power cone domain of dimension \(n\), with \(n_\ell\) variables appearing on the left-hand side, where \(n_\ell\) is the length of \(\alpha\), and with a homogenous sequence of exponents \(\alpha_0,\ldots,\alpha_{n_\ell-1}\).
Formally, let \(s = \sum_i \alpha_i\) and \(\beta_i = \alpha_i / s\), so that \(\sum_i \beta_i=1\). Then the dual power cone is defined as follows:
\[\left\{ x\in \real^n ~:~ \prod_{i=0}^{n_\ell-1} \left(\frac{x_i}{\beta_i}\right)^{\beta_i} \geq \sqrt{\sum_{j=n_\ell}^{n-1}x_j^2},\ x_0\ldots,x_{n_\ell-1}\geq 0 \right\}\]- Parameters:
n
(int64
) – Dimension of the domain. (input)alpha
(float
[]
) – The sequence proportional to exponents. Must be positive. (input)
- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendprimalexpconedomain¶
appendprimalexpconedomain() -> (domidx)
Appends the primal exponential cone \(\left\{ x\in \real^3 ~:~ x_0 \geq x_1 e^{x_2/x_1},\ x_0,x_1> 0 \right\}\) to the list of domains.
- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendprimalgeomeanconedomain¶
appendprimalgeomeanconedomain(n) -> (domidx)
Appends the primal geometric mean cone \(\left\{ x\in \real^n ~:~ \left(\prod_{i=0}^{n-2} x_i\right)^{1/(n-1)} \geq |x_{n-1}|,\ x_0\ldots,x_{n-2}\geq 0 \right\}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendprimalpowerconedomain¶
appendprimalpowerconedomain(n,alpha) -> (domidx)
Appends the primal power cone domain of dimension \(n\), with \(n_\ell\) variables appearing on the left-hand side, where \(n_\ell\) is the length of \(\alpha\), and with a homogenous sequence of exponents \(\alpha_0,\ldots,\alpha_{n_\ell-1}\).
Formally, let \(s = \sum_i \alpha_i\) and \(\beta_i = \alpha_i / s\), so that \(\sum_i \beta_i=1\). Then the primal power cone is defined as follows:
\[\left\{ x\in \real^n ~:~ \prod_{i=0}^{n_\ell-1} x_i^{\beta_i} \geq \sqrt{\sum_{j=n_\ell}^{n-1}x_j^2},\ x_0\ldots,x_{n_\ell-1}\geq 0 \right\}\]- Parameters:
n
(int64
) – Dimension of the domain. (input)alpha
(float
[]
) – The sequence proportional to exponents. Must be positive. (input)
- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendquadraticconedomain¶
appendquadraticconedomain(n) -> (domidx)
Appends the \(n\)-dimensional quadratic cone \(\left\{x\in\real^n~:~x_0 \geq \sqrt{\sum_{i=1}^{n-1} x_i^2}\right\}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendrdomain¶
appendrdomain(n) -> (domidx)
Appends the \(n\)-dimensional real space \(\{ x \in \real^n \}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendrminusdomain¶
appendrminusdomain(n) -> (domidx)
Appends the \(n\)-dimensional negative orthant \(\{ x \in \real^n: \, x \leq 0 \}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendrplusdomain¶
appendrplusdomain(n) -> (domidx)
Appends the \(n\)-dimensional positive orthant \(\{ x \in \real^n: \, x \geq 0 \}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendrquadraticconedomain¶
appendrquadraticconedomain(n) -> (domidx)
Appends the \(n\)-dimensional rotated quadratic cone \(\left\{x\in\real^n~:~2 x_0 x_1 \geq \sum_{i=2}^{n-1} x_i^2,\ x_0,x_1\geq 0\right\}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendrzerodomain¶
appendrzerodomain(n) -> (domidx)
Appends the zero in \(n\)-dimensional real space \(\{ x \in \real^n: \, x = 0 \}\) to the list of domains.
- Parameters:
n
(int64
) – Dimension of the domain. (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendsparsesymmat¶
appendsparsesymmat(dim,subi,subj,valij) -> (idx)
MOSEK maintains a storage of symmetric data matrices that is used to build \(\barC\) and \(\barA\). The storage can be thought of as a vector of symmetric matrices denoted \(E\). Hence, \(E_i\) is a symmetric matrix of certain dimension.
This function appends a general sparse symmetric matrix on triplet form to the vector \(E\) of symmetric matrices. The vectors
subi
,subj
, andvalij
contains the row subscripts, column subscripts and values of each element in the symmetric matrix to be appended. Since the matrix that is appended is symmetric, only the lower triangular part should be specified. Moreover, duplicates are not allowed.Observe the function reports the index (position) of the appended matrix in \(E\). This index should be used for later references to the appended matrix.
- Parameters:
dim
(int32
) – Dimension of the symmetric matrix that is appended. (input)subi
(int32
[]
) – Row subscript in the triplets. (input)subj
(int32
[]
) – Column subscripts in the triplets. (input)valij
(float
[]
) – Values of each triplet. (input)
- Return:
idx
(int64
) – Unique index assigned to the inputted matrix that can be used for later reference.- Groups:
- Task.appendsparsesymmatlist¶
appendsparsesymmatlist(dims,nz,subi,subj,valij,idx)
appendsparsesymmatlist(dims,nz,subi,subj,valij) -> (idx)
MOSEK maintains a storage of symmetric data matrices that is used to build \(\barC\) and \(\barA\). The storage can be thought of as a vector of symmetric matrices denoted \(E\). Hence, \(E_i\) is a symmetric matrix of certain dimension.
This function appends general sparse symmetric matrixes on triplet form to the vector \(E\) of symmetric matrices. The vectors
subi
,subj
, andvalij
contains the row subscripts, column subscripts and values of each element in the symmetric matrix to be appended. Since the matrix that is appended is symmetric, only the lower triangular part should be specified. Moreover, duplicates are not allowed.Observe the function reports the index (position) of the appended matrix in \(E\). This index should be used for later references to the appended matrix.
- Parameters:
dims
(int32
[]
) – Dimensions of the symmetric matrixes. (input)nz
(int64
[]
) – Number of nonzeros for each matrix. (input)subi
(int32
[]
) – Row subscript in the triplets. (input)subj
(int32
[]
) – Column subscripts in the triplets. (input)valij
(float
[]
) – Values of each triplet. (input)idx
(int64
[]
) – Unique index assigned to the inputted matrix that can be used for later reference. (output)
- Return:
idx
(int64
[]
) – Unique index assigned to the inputted matrix that can be used for later reference.- Groups:
- Task.appendsvecpsdconedomain¶
appendsvecpsdconedomain(n) -> (domidx)
Appends the domain consisting of vectors of length \(n=d(d+1)/2\) defined as follows
\[\{(x_1,\ldots,x_{d(d+1)/2})\in \real^n~:~ \mathrm{sMat}(x)\in\PSD^d\} = \{\mathrm{sVec}(X)~:~X\in\PSD^d\},\]where
\[\mathrm{sVec}(X) = (X_{11},\sqrt{2}X_{21},\ldots,\sqrt{2}X_{d1},X_{22},\sqrt{2}X_{32},\ldots,X_{dd}),\]and
\[\begin{split}\mathrm{sMat}(x) = \left[\begin{array}{cccc}x_1 & x_2/\sqrt{2} & \cdots & x_{d}/\sqrt{2} \\ x_2/\sqrt{2} & x_{d+1} & \cdots & x_{2d-1}/\sqrt{2} \\ \cdots & \cdots & \cdots & \cdots \\ x_{d}/\sqrt{2} & x_{2d-1}/\sqrt{2} & \cdots & x_{d(d+1)/2}\end{array}\right].\end{split}\]In other words, the domain consists of vectorizations of the lower-triangular part of a positive semidefinite matrix, with the non-diagonal elements additionally rescaled.
This domain is a self-dual cone.
- Parameters:
n
(int64
) – Dimension of the domain, must be of the form \(d(d+1)/2\). (input)- Return:
domidx
(int64
) – Index of the domain.- Groups:
- Task.appendvars¶
appendvars(num)
Appends a number of variables to the model. Appended variables will be fixed at zero. Please note that MOSEK will automatically expand the problem dimension to accommodate the additional variables.
- Parameters:
num
(int32
) – Number of variables which should be appended. (input)- Groups:
- Task.asyncgetresult¶
asyncgetresult(address,accesstoken,token) -> (respavailable,resp,trm)
Request a solution from a remote job identified by the argument
token
. For other arguments seeTask.asyncoptimize
. If the solution is available it will be retrieved and loaded into the local task.- Parameters:
address
(str
) – Address of the OptServer. (input)accesstoken
(str
) – Access token. (input)token
(str
) – The task token. (input)
- Return:
respavailable
(bool
) – Indicates if a remote response is available. If this is not true,resp
andtrm
should be ignored.resp
(mosek.rescode
) – Is the response code from the remote solver.trm
(mosek.rescode
) – Is eitherrescode.ok
or a termination response code.
- Groups:
- Task.asyncoptimize¶
asyncoptimize(address,accesstoken) -> (token)
Offload the optimization task to an instance of OptServer specified by
addr
, which should be a valid URL, for examplehttp://server:port
orhttps://server:port
. The call will exit immediately.If the server requires authentication, the authentication token can be passed in the
accesstoken
argument.If the server requires encryption, the keys can be passed using one of the solver parameters
sparam.remote_tls_cert
orsparam.remote_tls_cert_path
.The function returns a token which should be used in future calls to identify the task.
- Parameters:
address
(str
) – Address of the OptServer. (input)accesstoken
(str
) – Access token. (input)
- Return:
token
(str
) – Returns the task token.- Groups:
- Task.asyncpoll¶
asyncpoll(address,accesstoken,token) -> (respavailable,resp,trm)
Requests information about the status of the remote job identified by the argument
token
. For other arguments seeTask.asyncoptimize
.- Parameters:
address
(str
) – Address of the OptServer. (input)accesstoken
(str
) – Access token. (input)token
(str
) – The task token. (input)
- Return:
respavailable
(bool
) – Indicates if a remote response is available. If this is not true,resp
andtrm
should be ignored.resp
(mosek.rescode
) – Is the response code from the remote solver.trm
(mosek.rescode
) – Is eitherrescode.ok
or a termination response code.
- Groups:
- Task.asyncstop¶
asyncstop(address,accesstoken,token)
Request that the remote job identified by
token
is terminated. For other arguments seeTask.asyncoptimize
.- Parameters:
address
(str
) – Address of the OptServer. (input)accesstoken
(str
) – Access token. (input)token
(str
) – The task token. (input)
- Groups:
- Task.basiscond¶
basiscond() -> (nrmbasis,nrminvbasis)
If a basic solution is available and it defines a nonsingular basis, then this function computes the 1-norm estimate of the basis matrix and a 1-norm estimate for the inverse of the basis matrix. The 1-norm estimates are computed using the method outlined in [Ste98], pp. 388-391.
By definition the 1-norm condition number of a matrix \(B\) is defined as
\[\kappa_1(B) := \|B\|_1 \|B^{-1}\|_1.\]Moreover, the larger the condition number is the harder it is to solve linear equation systems involving \(B\). Given estimates for \(\|B\|_1\) and \(\|B^{-1}\|_1\) it is also possible to estimate \(\kappa_1(B)\).
- Return:
nrmbasis
(float
) – An estimate for the 1-norm of the basis.nrminvbasis
(float
) – An estimate for the 1-norm of the inverse of the basis.
- Groups:
- Task.checkmem¶
checkmem(file,line)
Checks the memory allocated by the task.
- Parameters:
file
(str
) – File from which the function is called. (input)line
(int32
) – Line in the file from which the function is called. (input)
- Groups:
- Task.chgconbound¶
chgconbound(i,lower,finite,value)
Changes a bound for one constraint.
If
lower
is non-zero, then the lower bound is changed as follows:\[\begin{split}\mbox{new lower bound} = \left\{ \begin{array}{ll} - \infty, & \mathtt{finite}=0, \\ \mathtt{value} & \mbox{otherwise}. \end{array} \right.\end{split}\]Otherwise if
lower
is zero, then\[\begin{split}\mbox{new upper bound} = \left\{ \begin{array}{ll} \infty, & \mathtt{finite}=0, \\ \mathtt{value} & \mbox{otherwise}. \end{array} \right.\end{split}\]Please note that this function automatically updates the bound key for the bound, in particular, if the lower and upper bounds are identical, the bound key is changed to
fixed
.- Parameters:
i
(int32
) – Index of the constraint for which the bounds should be changed. (input)lower
(int32
) – If non-zero, then the lower bound is changed, otherwise the upper bound is changed. (input)finite
(int32
) – If non-zero, thenvalue
is assumed to be finite. (input)value
(float
) – New value for the bound. (input)
- Groups:
Problem data - bounds, Problem data - constraints, Problem data - linear part
- Task.chgvarbound¶
chgvarbound(j,lower,finite,value)
Changes a bound for one variable.
If
lower
is non-zero, then the lower bound is changed as follows:\[\begin{split}\mbox{new lower bound} = \left\{ \begin{array}{ll} - \infty, & \mathtt{finite}=0, \\ \mathtt{value} & \mbox{otherwise}. \end{array} \right.\end{split}\]Otherwise if
lower
is zero, then\[\begin{split}\mbox{new upper bound} = \left\{ \begin{array}{ll} \infty, & \mathtt{finite}=0, \\ \mathtt{value} & \mbox{otherwise}. \end{array} \right.\end{split}\]Please note that this function automatically updates the bound key for the bound, in particular, if the lower and upper bounds are identical, the bound key is changed to
fixed
.- Parameters:
j
(int32
) – Index of the variable for which the bounds should be changed. (input)lower
(int32
) – If non-zero, then the lower bound is changed, otherwise the upper bound is changed. (input)finite
(int32
) – If non-zero, thenvalue
is assumed to be finite. (input)value
(float
) – New value for the bound. (input)
- Groups:
Problem data - bounds, Problem data - variables, Problem data - linear part
- Task.commitchanges¶
commitchanges()
Commits all cached problem changes to the task. It is usually not necessary to call this function explicitly since changes will be committed automatically when required.
- Groups:
- Task.deletesolution¶
deletesolution(whichsol)
Undefine a solution and free the memory it uses.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Groups:
- Task.dualsensitivity¶
dualsensitivity(subj, leftpricej, rightpricej, leftrangej, rightrangej)
dualsensitivity(subj) -> (leftpricej, rightpricej, leftrangej, rightrangej)
Calculates sensitivity information for objective coefficients. The indexes of the coefficients to analyze are
\[\{\mathtt{subj}[i] ~|~ i = \idxbeg,\ldots,\idxend{\mathtt{numj}}\}\]The type of sensitivity analysis to perform (basis or optimal partition) is controlled by the parameter
iparam.sensitivity_type
.For an example, please see Section Example: Sensitivity Analysis.
- Parameters:
subj
(int32
[]
) – Indexes of objective coefficients to analyze. (input)leftpricej
(float
[]
) – \(\mathtt{leftpricej}[j]\) is the left shadow price for the coefficient with index \(\mathtt{subj[j]}\). (output)rightpricej
(float
[]
) – \(\mathtt{rightpricej}[j]\) is the right shadow price for the coefficient with index \(\mathtt{subj[j]}\). (output)leftrangej
(float
[]
) – \(\mathtt{leftrangej}[j]\) is the left range \(\beta_1\) for the coefficient with index \(\mathtt{subj[j]}\). (output)rightrangej
(float
[]
) – \(\mathtt{rightrangej}[j]\) is the right range \(\beta_2\) for the coefficient with index \(\mathtt{subj[j]}\). (output)
- Return:
leftpricej
(float
[]
) – \(\mathtt{leftpricej}[j]\) is the left shadow price for the coefficient with index \(\mathtt{subj[j]}\).rightpricej
(float
[]
) – \(\mathtt{rightpricej}[j]\) is the right shadow price for the coefficient with index \(\mathtt{subj[j]}\).leftrangej
(float
[]
) – \(\mathtt{leftrangej}[j]\) is the left range \(\beta_1\) for the coefficient with index \(\mathtt{subj[j]}\).rightrangej
(float
[]
) – \(\mathtt{rightrangej}[j]\) is the right range \(\beta_2\) for the coefficient with index \(\mathtt{subj[j]}\).
- Groups:
- Task.emptyafebarfrow¶
emptyafebarfrow(afeidx)
Clears a row in \(\barF\) i.e. sets \(\barF_{\mathrm{afeidx},*} = 0\).
- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.emptyafebarfrowlist¶
emptyafebarfrowlist(afeidxlist)
Clears a number of rows in \(\barF\) i.e. sets \(\barF_{i,*} = 0\) for all indices \(i\) in
afeidxlist
.- Parameters:
afeidxlist
(int64
[]
) – Indices of rows in \(\barF\) to clear. (input)- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.emptyafefcol¶
emptyafefcol(varidx)
Clears one column in the affine constraint matrix \(F\), that is sets \(F_{*,\mathrm{varidx}}=0\).
- Parameters:
varidx
(int32
) – Index of a variable (column in \(F\)). (input)- Groups:
- Task.emptyafefcollist¶
emptyafefcollist(varidx)
Clears a number of columns in \(F\) i.e. sets \(F_{*,j} = 0\) for all indices \(j\) in
varidx
.- Parameters:
varidx
(int32
[]
) – Indices of variables (columns) in \(F\) to clear. (input)- Groups:
- Task.emptyafefrow¶
emptyafefrow(afeidx)
Clears one row in the affine constraint matrix \(F\), that is sets \(F_{\mathrm{afeidx},*}=0\).
- Parameters:
afeidx
(int64
) – Index of a row in \(F\). (input)- Groups:
- Task.emptyafefrowlist¶
emptyafefrowlist(afeidx)
Clears a number of rows in \(F\) i.e. sets \(F_{i,*} = 0\) for all indices \(i\) in
afeidx
.- Parameters:
afeidx
(int64
[]
) – Indices of rows in \(F\) to clear. (input)- Groups:
- Task.evaluateacc¶
evaluateacc(whichsol,accidx,activity)
evaluateacc(whichsol,accidx) -> (activity)
Evaluates the activity of an affine conic constraint.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)accidx
(int64
) – The index of the affine conic constraint. (input)activity
(float
[]
) – The activity of the affine conic constraint. The array should have length equal to the dimension of the constraint. (output)
- Return:
activity
(float
[]
) – The activity of the affine conic constraint. The array should have length equal to the dimension of the constraint.- Groups:
- Task.evaluateaccs¶
evaluateaccs(whichsol,activity)
evaluateaccs(whichsol) -> (activity)
Evaluates the activities of all affine conic constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)activity
(float
[]
) – The activity of affine conic constraints. The array should have length equal to the sum of dimensions of all affine conic constraints. (output)
- Return:
activity
(float
[]
) – The activity of affine conic constraints. The array should have length equal to the sum of dimensions of all affine conic constraints.- Groups:
- Task.generateaccnames¶
generateaccnames(sub,fmt,dims,sp,namedaxisidxs,names)
Internal.
- Parameters:
sub
(int64
[]
) – Indexes of the affine conic constraints. (input)fmt
(str
) – The variable name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
- Task.generatebarvarnames¶
generatebarvarnames(subj,fmt,dims,sp,namedaxisidxs,names)
Internal.
- Parameters:
subj
(int32
[]
) – Indexes of the variables. (input)fmt
(str
) – The variable name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
- Task.generateconenames Deprecated¶
generateconenames(subk,fmt,dims,sp,namedaxisidxs,names)
Internal, deprecated.
- Parameters:
subk
(int32
[]
) – Indexes of the cone. (input)fmt
(str
) – The cone name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
- Task.generateconnames¶
generateconnames(subi,fmt,dims,sp,namedaxisidxs,names)
Internal.
- Parameters:
subi
(int32
[]
) – Indexes of the constraints. (input)fmt
(str
) – The constraint name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
Names, Problem data - constraints, Problem data - linear part
- Task.generatedjcnames¶
generatedjcnames(sub,fmt,dims,sp,namedaxisidxs,names)
Internal.
- Parameters:
sub
(int64
[]
) – Indexes of the disjunctive constraints. (input)fmt
(str
) – The variable name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
- Task.generatevarnames¶
generatevarnames(subj,fmt,dims,sp,namedaxisidxs,names)
Internal.
- Parameters:
subj
(int32
[]
) – Indexes of the variables. (input)fmt
(str
) – The variable name formatting string. (input)dims
(int32
[]
) – Dimensions in the shape. (input)sp
(int64
[]
) – Items that should be named. (input)namedaxisidxs
(int32
[]
) – List if named index axes (input)names
(str
[]
) – All axis names. (input)
- Groups:
- Task.getaccafeidxlist¶
getaccafeidxlist(accidx,afeidxlist)
getaccafeidxlist(accidx) -> (afeidxlist)
Obtains the list of affine expressions appearing in the affine conic constraint.
- Parameters:
accidx
(int64
) – Index of the affine conic constraint. (input)afeidxlist
(int64
[]
) – List of indexes of affine expressions appearing in the constraint. (output)
- Return:
afeidxlist
(int64
[]
) – List of indexes of affine expressions appearing in the constraint.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccb¶
getaccb(accidx,b)
getaccb(accidx) -> (b)
Obtains the additional constant term vector appearing in the affine conic constraint.
- Parameters:
accidx
(int64
) – Index of the affine conic constraint. (input)b
(float
[]
) – The vector b appearing in the constraint. (output)
- Return:
b
(float
[]
) – The vector b appearing in the constraint.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccbarfblocktriplet¶
getaccbarfblocktriplet(acc_afe,bar_var,blk_row,blk_col,blk_val) -> (numtrip)
getaccbarfblocktriplet() -> (numtrip, acc_afe, bar_var, blk_row, blk_col, blk_val)
Obtains \(\barF\), implied by the ACCs, in block triplet form. If the AFEs passed to the ACCs were out of order, then this function can be used to obtain the barF as seen by the ACCs.
- Parameters:
acc_afe
(int64
[]
) – Index of the AFE within the concatenated list of AFEs in ACCs. (output)bar_var
(int32
[]
) – Symmetric matrix variable index. (output)blk_row
(int32
[]
) – Block row index. (output)blk_col
(int32
[]
) – Block column index. (output)blk_val
(float
[]
) – The numerical value associated with each block triplet. (output)
- Return:
numtrip
(int64
) – Number of elements in the block triplet form.acc_afe
(int64
[]
) – Index of the AFE within the concatenated list of AFEs in ACCs.bar_var
(int32
[]
) – Symmetric matrix variable index.blk_row
(int32
[]
) – Block row index.blk_col
(int32
[]
) – Block column index.blk_val
(float
[]
) – The numerical value associated with each block triplet.
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.getaccbarfnumblocktriplets¶
getaccbarfnumblocktriplets() -> (numtrip)
Obtains an upper bound on the number of elements in the block triplet form of \(\barF\), as used within the ACCs.
- Return:
numtrip
(int64
) – An upper bound on the number of elements in the block triplet form of \(\barF.\), as used within the ACCs.- Groups:
Problem data - semidefinite, Problem data - affine conic constraints, Inspecting the task
- Task.getaccdomain¶
getaccdomain(accidx) -> (domidx)
Obtains the domain appearing in the affine conic constraint.
- Parameters:
accidx
(int64
) – The index of the affine conic constraint. (input)- Return:
domidx
(int64
) – The index of domain in the affine conic constraint.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccdoty¶
getaccdoty(whichsol,accidx,doty)
getaccdoty(whichsol,accidx) -> (doty)
Obtains the \(\dot{y}\) vector for a solution (the dual values of an affine conic constraint).
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)accidx
(int64
) – The index of the affine conic constraint. (input)doty
(float
[]
) – The dual values for this affine conic constraint. The array should have length equal to the dimension of the constraint. (output)
- Return:
doty
(float
[]
) – The dual values for this affine conic constraint. The array should have length equal to the dimension of the constraint.- Groups:
- Task.getaccdotys¶
getaccdotys(whichsol,doty)
getaccdotys(whichsol) -> (doty)
Obtains the \(\dot{y}\) vector for a solution (the dual values of all affine conic constraint).
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)doty
(float
[]
) – The dual values of affine conic constraints. The array should have length equal to the sum of dimensions of all affine conic constraints. (output)
- Return:
doty
(float
[]
) – The dual values of affine conic constraints. The array should have length equal to the sum of dimensions of all affine conic constraints.- Groups:
- Task.getaccfnumnz¶
getaccfnumnz() -> (accfnnz)
If the AFEs are not added sequentially to the ACCs, then the present function gives the number of nonzero elements in the F matrix that would be implied by the ordering of AFEs within ACCs.
- Return:
accfnnz
(int64
) – Number of non-zeros in \(F\) implied by ACCs.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccftrip¶
getaccftrip(frow,fcol,fval)
getaccftrip() -> (frow,fcol,fval)
Obtains the \(F\) (that would be implied by the ordering of the AFEs within the ACCs) in triplet format.
- Parameters:
frow
(int64
[]
) – Row indices of nonzeros in the implied F matrix. (output)fcol
(int32
[]
) – Column indices of nonzeros in the implied F matrix. (output)fval
(float
[]
) – Values of nonzero entries in the implied F matrix. (output)
- Return:
frow
(int64
[]
) – Row indices of nonzeros in the implied F matrix.fcol
(int32
[]
) – Column indices of nonzeros in the implied F matrix.fval
(float
[]
) – Values of nonzero entries in the implied F matrix.
- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccgvector¶
getaccgvector(g)
getaccgvector() -> (g)
If the AFEs are passed out of sequence to the ACCs, then this function can be used to obtain the vector \(g\) of constant terms used within the ACCs.
- Parameters:
g
(float
[]
) – The \(g\) used within the ACCs as a dense vector. The length is sum of the dimensions of the ACCs. (output)- Return:
g
(float
[]
) – The \(g\) used within the ACCs as a dense vector. The length is sum of the dimensions of the ACCs.- Groups:
Inspecting the task, Problem data - affine conic constraints
- Task.getaccn¶
getaccn(accidx) -> (n)
Obtains the dimension of the affine conic constraint.
- Parameters:
accidx
(int64
) – The index of the affine conic constraint. (input)- Return:
n
(int64
) – The dimension of the affine conic constraint (equal to the dimension of its domain).- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccname¶
getaccname(accidx) -> (name)
Obtains the name of an affine conic constraint.
- Parameters:
accidx
(int64
) – Index of an affine conic constraint. (input)- Return:
name
(str
) – Returns the required name.- Groups:
Names, Problem data - affine conic constraints, Inspecting the task
- Task.getaccnamelen¶
getaccnamelen(accidx) -> (len)
Obtains the length of the name of an affine conic constraint.
- Parameters:
accidx
(int64
) – Index of an affine conic constraint. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
Names, Problem data - affine conic constraints, Inspecting the task
- Task.getaccntot¶
getaccntot() -> (n)
Obtains the total dimension of all affine conic constraints (the sum of all their dimensions).
- Return:
n
(int64
) – The total dimension of all affine conic constraints.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getaccs¶
getaccs(domidxlist,afeidxlist,b)
getaccs() -> (domidxlist,afeidxlist,b)
Obtains full data of all affine conic constraints. The output array
domainidxlist
must have at least length determined byTask.getnumacc
. The output arraysafeidxlist
andb
must have at least length determined byTask.getaccntot
.- Parameters:
domidxlist
(int64
[]
) – The list of domains appearing in all affine conic constraints. (output)afeidxlist
(int64
[]
) – The concatenation of index lists of affine expressions appearing in all affine conic constraints. (output)b
(float
[]
) – The concatenation of vectors b appearing in all affine conic constraints. (output)
- Return:
domidxlist
(int64
[]
) – The list of domains appearing in all affine conic constraints.afeidxlist
(int64
[]
) – The concatenation of index lists of affine expressions appearing in all affine conic constraints.b
(float
[]
) – The concatenation of vectors b appearing in all affine conic constraints.
- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getacol¶
getacol(j,subj,valj) -> (nzj)
getacol(j) -> (nzj,subj,valj)
Obtains one column of \(A\) in a sparse format.
- Parameters:
j
(int32
) – Index of the column. (input)subj
(int32
[]
) – Row indices of the non-zeros in the column obtained. (output)valj
(float
[]
) – Numerical values in the column obtained. (output)
- Return:
nzj
(int32
) – Number of non-zeros in the column obtained.subj
(int32
[]
) – Row indices of the non-zeros in the column obtained.valj
(float
[]
) – Numerical values in the column obtained.
- Groups:
- Task.getacolnumnz¶
getacolnumnz(i) -> (nzj)
Obtains the number of non-zero elements in one column of \(A\).
- Parameters:
i
(int32
) – Index of the column. (input)- Return:
nzj
(int32
) – Number of non-zeros in the \(j\)-th column of \(A\).- Groups:
- Task.getacolslice¶
getacolslice(first,last,ptrb,ptre,sub,val)
getacolslice(first,last) -> (ptrb,ptre,sub,val)
Obtains a sequence of columns from \(A\) in sparse format.
- Parameters:
first
(int32
) – Index of the first column in the sequence. (input)last
(int32
) – Index of the last column in the sequence plus one. (input)ptrb
(int64
[]
) –ptrb[t]
is an index pointing to the first element in the \(t\)-th column obtained. (output)ptre
(int64
[]
) –ptre[t]
is an index pointing to the last element plus one in the \(t\)-th column obtained. (output)sub
(int32
[]
) – Contains the row subscripts. (output)val
(float
[]
) – Contains the coefficient values. (output)
- Return:
ptrb
(int64
[]
) –ptrb[t]
is an index pointing to the first element in the \(t\)-th column obtained.ptre
(int64
[]
) –ptre[t]
is an index pointing to the last element plus one in the \(t\)-th column obtained.sub
(int32
[]
) – Contains the row subscripts.val
(float
[]
) – Contains the coefficient values.
- Groups:
- Task.getacolslicenumnz¶
getacolslicenumnz(first,last) -> (numnz)
Obtains the number of non-zeros in a slice of columns of \(A\).
- Parameters:
first
(int32
) – Index of the first column in the sequence. (input)last
(int32
) – Index of the last column plus one in the sequence. (input)
- Return:
numnz
(int64
) – Number of non-zeros in the slice.- Groups:
- Task.getacolslicetrip¶
getacolslicetrip(first,last,subi,subj,val)
getacolslicetrip(first,last) -> (subi,subj,val)
Obtains a sequence of columns from \(A\) in sparse triplet format. The function returns the content of all columns whose index
j
satisfiesfirst <= j < last
. The triplets corresponding to nonzero entries are stored in the arrayssubi
,subj
andval
.- Parameters:
first
(int32
) – Index of the first column in the sequence. (input)last
(int32
) – Index of the last column in the sequence plus one. (input)subi
(int32
[]
) – Constraint subscripts. (output)subj
(int32
[]
) – Column subscripts. (output)val
(float
[]
) – Values. (output)
- Return:
subi
(int32
[]
) – Constraint subscripts.subj
(int32
[]
) – Column subscripts.val
(float
[]
) – Values.
- Groups:
- Task.getafebarfblocktriplet¶
getafebarfblocktriplet(afeidx,barvaridx,subk,subl,valkl) -> (numtrip)
getafebarfblocktriplet() -> (numtrip, afeidx, barvaridx, subk, subl, valkl)
Obtains \(\barF\) in block triplet form.
- Parameters:
afeidx
(int64
[]
) – Constraint index. (output)barvaridx
(int32
[]
) – Symmetric matrix variable index. (output)subk
(int32
[]
) – Block row index. (output)subl
(int32
[]
) – Block column index. (output)valkl
(float
[]
) – The numerical value associated with each block triplet. (output)
- Return:
numtrip
(int64
) – Number of elements in the block triplet form.afeidx
(int64
[]
) – Constraint index.barvaridx
(int32
[]
) – Symmetric matrix variable index.subk
(int32
[]
) – Block row index.subl
(int32
[]
) – Block column index.valkl
(float
[]
) – The numerical value associated with each block triplet.
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.getafebarfnumblocktriplets¶
getafebarfnumblocktriplets() -> (numtrip)
Obtains an upper bound on the number of elements in the block triplet form of \(\barF\).
- Return:
numtrip
(int64
) – An upper bound on the number of elements in the block triplet form of \(\barF.\)- Groups:
- Task.getafebarfnumrowentries¶
getafebarfnumrowentries(afeidx) -> (numentr)
Obtains the number of nonzero entries in one row of \(\barF\), that is the number of \(j\) such that \(\barF_{\mathrm{afeidx},j}\) is not the zero matrix.
- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)- Return:
numentr
(int32
) – Number of nonzero entries in a row of \(\barF\).- Groups:
Problem data - affine expressions, Problem data - semidefinite, Inspecting the task
- Task.getafebarfrow¶
getafebarfrow(afeidx, barvaridx, ptrterm, numterm, termidx, termweight)
getafebarfrow(afeidx) -> (barvaridx, ptrterm, numterm, termidx, termweight)
Obtains all nonzero entries in one row \(\barF_{\mathrm{afeidx},*}\) of \(\barF\). For every \(k\) there is a nonzero entry \(\barF_{\mathrm{afeidx}, \mathrm{barvaridx}[k]}\), which is represented as a weighted sum of \(\mathrm{numterm}[k]\) terms. The indices in the matrix store \(E\) and their weights for the \(k\)-th entry appear in the arrays
termidx
andtermweight
in positions\[\mathrm{ptrterm}[k],\ldots,\mathrm{ptrterm}[k]+(\mathrm{numterm}[k]-1).\]The arrays should be long enough to accommodate the data; their required lengths can be obtained with
Task.getafebarfrowinfo
.- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)barvaridx
(int32
[]
) – Semidefinite variable indices of nonzero entries in the row of \(\barF\). (output)ptrterm
(int64
[]
) – Pointers to the start of each entry’s description. (output)numterm
(int64
[]
) – Number of terms in the weighted sum representation of each entry. (output)termidx
(int64
[]
) – Indices of semidefinite matrices from the matrix store \(E\). (output)termweight
(float
[]
) – Weights appearing in the weighted sum representations of all entries. (output)
- Return:
barvaridx
(int32
[]
) – Semidefinite variable indices of nonzero entries in the row of \(\barF\).ptrterm
(int64
[]
) – Pointers to the start of each entry’s description.numterm
(int64
[]
) – Number of terms in the weighted sum representation of each entry.termidx
(int64
[]
) – Indices of semidefinite matrices from the matrix store \(E\).termweight
(float
[]
) – Weights appearing in the weighted sum representations of all entries.
- Groups:
Problem data - affine expressions, Problem data - semidefinite, Inspecting the task
- Task.getafebarfrowinfo¶
getafebarfrowinfo(afeidx) -> (numentr,numterm)
Obtains information about one row of \(\barF\): the number of nonzero entries, that is the number of \(j\) such that \(\barF_{\mathrm{afeidx},j}\) is not the zero matrix, as well as the total number of terms in the representations of all these entries as weighted sums of matrices from \(E\). This information provides the data sizes required for a call to
Task.getafebarfrow
.- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)- Return:
numentr
(int32
) – Number of nonzero entries in a row of \(\barF\).numterm
(int64
) – Number of terms in the weighted sums representation of the row of \(\barF\).
- Groups:
Problem data - affine expressions, Problem data - semidefinite, Inspecting the task
- Task.getafefnumnz¶
getafefnumnz() -> (numnz)
Obtains the total number of nonzeros in \(F\).
- Return:
numnz
(int64
) – Number of non-zeros in \(F\).- Groups:
- Task.getafefrow¶
getafefrow(afeidx,varidx,val) -> (numnz)
getafefrow(afeidx) -> (numnz,varidx,val)
Obtains one row of \(F\) in sparse format.
- Parameters:
afeidx
(int64
) – Index of a row in \(F\). (input)varidx
(int32
[]
) – Column indices of the non-zeros in the row obtained. (output)val
(float
[]
) – Values of the non-zeros in the row obtained. (output)
- Return:
numnz
(int32
) – Number of non-zeros in the row obtained.varidx
(int32
[]
) – Column indices of the non-zeros in the row obtained.val
(float
[]
) – Values of the non-zeros in the row obtained.
- Groups:
- Task.getafefrownumnz¶
getafefrownumnz(afeidx) -> (numnz)
Obtains the number of nonzeros in one row of \(F\).
- Parameters:
afeidx
(int64
) – Index of a row in \(F\). (input)- Return:
numnz
(int32
) – Number of non-zeros in rowafeidx
of \(F\).- Groups:
- Task.getafeftrip¶
getafeftrip(afeidx,varidx,val)
getafeftrip() -> (afeidx,varidx,val)
Obtains the \(F\) in triplet format.
- Parameters:
afeidx
(int64
[]
) – Row indices of nonzeros. (output)varidx
(int32
[]
) – Column indices of nonzeros. (output)val
(float
[]
) – Values of nonzero entries. (output)
- Return:
afeidx
(int64
[]
) – Row indices of nonzeros.varidx
(int32
[]
) – Column indices of nonzeros.val
(float
[]
) – Values of nonzero entries.
- Groups:
- Task.getafeg¶
getafeg(afeidx) -> (g)
Obtains a single coefficient in \(g\).
- Parameters:
afeidx
(int64
) – Index of an element in \(g\). (input)- Return:
g
(float
) – The value of \(g_{\mathrm{afeidx}}\).- Groups:
- Task.getafegslice¶
getafegslice(first,last,g)
getafegslice(first,last) -> (g)
Obtains a sequence of elements from the vector \(g\) of constant terms in the affine expressions list.
- Parameters:
first
(int64
) – First index in the sequence. (input)last
(int64
) – Last index plus 1 in the sequence. (input)g
(float
[]
) – The slice \(g\) as a dense vector. The length islast-first
. (output)
- Return:
g
(float
[]
) – The slice \(g\) as a dense vector. The length islast-first
.- Groups:
- Task.getaij¶
getaij(i,j) -> (aij)
Obtains a single coefficient in \(A\).
- Parameters:
i
(int32
) – Row index of the coefficient to be returned. (input)j
(int32
) – Column index of the coefficient to be returned. (input)
- Return:
aij
(float
) – The required coefficient \(a_{i,j}\).- Groups:
- Task.getapiecenumnz¶
getapiecenumnz(firsti,lasti,firstj,lastj) -> (numnz)
Obtains the number non-zeros in a rectangular piece of \(A\), i.e. the number of elements in the set
\[\{ (i,j)~:~ a_{i,j} \neq 0,~ \mathtt{firsti} \leq i \leq \mathtt{lasti}-1, ~\mathtt{firstj} \leq j \leq \mathtt{lastj}-1\}\]This function is not an efficient way to obtain the number of non-zeros in one row or column. In that case use the function
Task.getarownumnz
orTask.getacolnumnz
.- Parameters:
firsti
(int32
) – Index of the first row in the rectangular piece. (input)lasti
(int32
) – Index of the last row plus one in the rectangular piece. (input)firstj
(int32
) – Index of the first column in the rectangular piece. (input)lastj
(int32
) – Index of the last column plus one in the rectangular piece. (input)
- Return:
numnz
(int32
) – Number of non-zero \(A\) elements in the rectangular piece.- Groups:
- Task.getarow¶
getarow(i,subi,vali) -> (nzi)
getarow(i) -> (nzi,subi,vali)
Obtains one row of \(A\) in a sparse format.
- Parameters:
i
(int32
) – Index of the row. (input)subi
(int32
[]
) – Column indices of the non-zeros in the row obtained. (output)vali
(float
[]
) – Numerical values of the row obtained. (output)
- Return:
nzi
(int32
) – Number of non-zeros in the row obtained.subi
(int32
[]
) – Column indices of the non-zeros in the row obtained.vali
(float
[]
) – Numerical values of the row obtained.
- Groups:
- Task.getarownumnz¶
getarownumnz(i) -> (nzi)
Obtains the number of non-zero elements in one row of \(A\).
- Parameters:
i
(int32
) – Index of the row. (input)- Return:
nzi
(int32
) – Number of non-zeros in the \(i\)-th row of \(A\).- Groups:
- Task.getarowslice¶
getarowslice(first,last,ptrb,ptre,sub,val)
getarowslice(first,last) -> (ptrb,ptre,sub,val)
Obtains a sequence of rows from \(A\) in sparse format.
- Parameters:
first
(int32
) – Index of the first row in the sequence. (input)last
(int32
) – Index of the last row in the sequence plus one. (input)ptrb
(int64
[]
) –ptrb[t]
is an index pointing to the first element in the \(t\)-th row obtained. (output)ptre
(int64
[]
) –ptre[t]
is an index pointing to the last element plus one in the \(t\)-th row obtained. (output)sub
(int32
[]
) – Contains the column subscripts. (output)val
(float
[]
) – Contains the coefficient values. (output)
- Return:
ptrb
(int64
[]
) –ptrb[t]
is an index pointing to the first element in the \(t\)-th row obtained.ptre
(int64
[]
) –ptre[t]
is an index pointing to the last element plus one in the \(t\)-th row obtained.sub
(int32
[]
) – Contains the column subscripts.val
(float
[]
) – Contains the coefficient values.
- Groups:
- Task.getarowslicenumnz¶
getarowslicenumnz(first,last) -> (numnz)
Obtains the number of non-zeros in a slice of rows of \(A\).
- Parameters:
first
(int32
) – Index of the first row in the sequence. (input)last
(int32
) – Index of the last row plus one in the sequence. (input)
- Return:
numnz
(int64
) – Number of non-zeros in the slice.- Groups:
- Task.getarowslicetrip¶
getarowslicetrip(first,last,subi,subj,val)
getarowslicetrip(first,last) -> (subi,subj,val)
Obtains a sequence of rows from \(A\) in sparse triplet format. The function returns the content of all rows whose index
i
satisfiesfirst <= i < last
. The triplets corresponding to nonzero entries are stored in the arrayssubi
,subj
andval
.- Parameters:
first
(int32
) – Index of the first row in the sequence. (input)last
(int32
) – Index of the last row in the sequence plus one. (input)subi
(int32
[]
) – Constraint subscripts. (output)subj
(int32
[]
) – Column subscripts. (output)val
(float
[]
) – Values. (output)
- Return:
subi
(int32
[]
) – Constraint subscripts.subj
(int32
[]
) – Column subscripts.val
(float
[]
) – Values.
- Groups:
- Task.getatrip¶
getatrip(subi,subj,val)
getatrip() -> (subi,subj,val)
Obtains \(A\) in sparse triplet format. The triplets corresponding to nonzero entries are stored in the arrays
subi
,subj
andval
.- Parameters:
subi
(int32
[]
) – Constraint subscripts. (output)subj
(int32
[]
) – Column subscripts. (output)val
(float
[]
) – Values. (output)
- Return:
subi
(int32
[]
) – Constraint subscripts.subj
(int32
[]
) – Column subscripts.val
(float
[]
) – Values.
- Groups:
- Task.getatruncatetol¶
getatruncatetol(tolzero)
getatruncatetol() -> (tolzero)
Obtains the tolerance value set with
Task.putatruncatetol
.- Parameters:
tolzero
(float
[]
) – All elements \(|a_{i,j}|\) less than this tolerance is truncated to zero. (output)- Return:
tolzero
(float
[]
) – All elements \(|a_{i,j}|\) less than this tolerance is truncated to zero.- Groups:
- Task.getbarablocktriplet¶
getbarablocktriplet(subi,subj,subk,subl,valijkl) -> (num)
getbarablocktriplet() -> (num,subi,subj,subk,subl,valijkl)
Obtains \(\barA\) in block triplet form.
- Parameters:
subi
(int32
[]
) – Constraint index. (output)subj
(int32
[]
) – Symmetric matrix variable index. (output)subk
(int32
[]
) – Block row index. (output)subl
(int32
[]
) – Block column index. (output)valijkl
(float
[]
) – The numerical value associated with each block triplet. (output)
- Return:
num
(int64
) – Number of elements in the block triplet form.subi
(int32
[]
) – Constraint index.subj
(int32
[]
) – Symmetric matrix variable index.subk
(int32
[]
) – Block row index.subl
(int32
[]
) – Block column index.valijkl
(float
[]
) – The numerical value associated with each block triplet.
- Groups:
- Task.getbaraidx¶
getbaraidx(idx,sub,weights) -> (i,j,num)
getbaraidx(idx) -> (i,j,num,sub,weights)
Obtains information about an element in \(\barA\). Since \(\barA\) is a sparse matrix of symmetric matrices, only the nonzero elements in \(\barA\) are stored in order to save space. Now \(\barA\) is stored vectorized i.e. as one long vector. This function makes it possible to obtain information such as the row index and the column index of a particular element of the vectorized form of \(\barA\).
Please observe if one element of \(\barA\) is inputted multiple times then it may be stored several times in vectorized form. In that case the element with the highest index is the one that is used.
- Parameters:
idx
(int64
) – Position of the element in the vectorized form. (input)sub
(int64
[]
) – A list indexes of the elements from symmetric matrix storage that appear in the weighted sum. (output)weights
(float
[]
) – The weights associated with each term in the weighted sum. (output)
- Return:
i
(int32
) – Row index of the element at positionidx
.j
(int32
) – Column index of the element at positionidx
.num
(int64
) – Number of terms in weighted sum that forms the element.sub
(int64
[]
) – A list indexes of the elements from symmetric matrix storage that appear in the weighted sum.weights
(float
[]
) – The weights associated with each term in the weighted sum.
- Groups:
- Task.getbaraidxij¶
getbaraidxij(idx) -> (i,j)
Obtains information about an element in \(\barA\). Since \(\barA\) is a sparse matrix of symmetric matrices, only the nonzero elements in \(\barA\) are stored in order to save space. Now \(\barA\) is stored vectorized i.e. as one long vector. This function makes it possible to obtain information such as the row index and the column index of a particular element of the vectorized form of \(\barA\).
Please note that if one element of \(\barA\) is inputted multiple times then it may be stored several times in vectorized form. In that case the element with the highest index is the one that is used.
- Parameters:
idx
(int64
) – Position of the element in the vectorized form. (input)- Return:
i
(int32
) – Row index of the element at positionidx
.j
(int32
) – Column index of the element at positionidx
.
- Groups:
- Task.getbaraidxinfo¶
getbaraidxinfo(idx) -> (num)
Each nonzero element in \(\barA_{ij}\) is formed as a weighted sum of symmetric matrices. Using this function the number of terms in the weighted sum can be obtained. See description of
Task.appendsparsesymmat
for details about the weighted sum.- Parameters:
idx
(int64
) – The internal position of the element for which information should be obtained. (input)- Return:
num
(int64
) – Number of terms in the weighted sum that form the specified element in \(\barA\).- Groups:
- Task.getbarasparsity¶
getbarasparsity(idxij) -> (numnz)
getbarasparsity() -> (numnz,idxij)
The matrix \(\barA\) is assumed to be a sparse matrix of symmetric matrices. This implies that many of the elements in \(\barA\) are likely to be zero matrices. Therefore, in order to save space, only nonzero elements in \(\barA\) are stored on vectorized form. This function is used to obtain the sparsity pattern of \(\barA\) and the position of each nonzero element in the vectorized form of \(\barA\). From the index detailed information about each nonzero \(\barA_{i,j}\) can be obtained using
Task.getbaraidxinfo
andTask.getbaraidx
.- Parameters:
idxij
(int64
[]
) – Position of each nonzero element in the vectorized form of \(\barA\). (output)- Return:
numnz
(int64
) – Number of nonzero elements in \(\barA\).idxij
(int64
[]
) – Position of each nonzero element in the vectorized form of \(\barA\).
- Groups:
- Task.getbarcblocktriplet¶
getbarcblocktriplet(subj,subk,subl,valjkl) -> (num)
getbarcblocktriplet() -> (num,subj,subk,subl,valjkl)
Obtains \(\barC\) in block triplet form.
- Parameters:
subj
(int32
[]
) – Symmetric matrix variable index. (output)subk
(int32
[]
) – Block row index. (output)subl
(int32
[]
) – Block column index. (output)valjkl
(float
[]
) – The numerical value associated with each block triplet. (output)
- Return:
num
(int64
) – Number of elements in the block triplet form.subj
(int32
[]
) – Symmetric matrix variable index.subk
(int32
[]
) – Block row index.subl
(int32
[]
) – Block column index.valjkl
(float
[]
) – The numerical value associated with each block triplet.
- Groups:
- Task.getbarcidx¶
getbarcidx(idx,sub,weights) -> (j,num)
getbarcidx(idx) -> (j,num,sub,weights)
Obtains information about an element in \(\barC\).
- Parameters:
idx
(int64
) – Index of the element for which information should be obtained. (input)sub
(int64
[]
) – Elements appearing the weighted sum. (output)weights
(float
[]
) – Weights of terms in the weighted sum. (output)
- Return:
j
(int32
) – Row index in \(\barC\).num
(int64
) – Number of terms in the weighted sum.sub
(int64
[]
) – Elements appearing the weighted sum.weights
(float
[]
) – Weights of terms in the weighted sum.
- Groups:
- Task.getbarcidxinfo¶
getbarcidxinfo(idx) -> (num)
Obtains the number of terms in the weighted sum that forms a particular element in \(\barC\).
- Parameters:
idx
(int64
) – Index of the element for which information should be obtained. The value is an index of a symmetric sparse variable. (input)- Return:
num
(int64
) – Number of terms that appear in the weighted sum that forms the requested element.- Groups:
- Task.getbarcidxj¶
getbarcidxj(idx) -> (j)
Obtains the row index of an element in \(\barC\).
- Parameters:
idx
(int64
) – Index of the element for which information should be obtained. (input)- Return:
j
(int32
) – Row index in \(\barC\).- Groups:
- Task.getbarcsparsity¶
getbarcsparsity(idxj) -> (numnz)
getbarcsparsity() -> (numnz,idxj)
Internally only the nonzero elements of \(\barC\) are stored in a vector. This function is used to obtain the nonzero elements of \(\barC\) and their indexes in the internal vector representation (in
idx
). From the index detailed information about each nonzero \(\barC_j\) can be obtained usingTask.getbarcidxinfo
andTask.getbarcidx
.- Parameters:
idxj
(int64
[]
) – Internal positions of the nonzeros elements in \(\barC\). (output)- Return:
numnz
(int64
) – Number of nonzero elements in \(\barC\).idxj
(int64
[]
) – Internal positions of the nonzeros elements in \(\barC\).
- Groups:
- Task.getbarsj¶
getbarsj(whichsol,j,barsj)
getbarsj(whichsol,j) -> (barsj)
Obtains the dual solution for a semidefinite variable. Only the lower triangular part of \(\barS_j\) is returned because the matrix by construction is symmetric. The format is that the columns are stored sequentially in the natural order.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)j
(int32
) – Index of the semidefinite variable. (input)barsj
(float
[]
) – Value of \(\barS_j\). (output)
- Return:
barsj
(float
[]
) – Value of \(\barS_j\).- Groups:
- Task.getbarsslice¶
getbarsslice(whichsol,first,last,slicesize,barsslice)
getbarsslice(whichsol,first,last,slicesize) -> (barsslice)
Obtains the dual solution for a sequence of semidefinite variables. The format is that matrices are stored sequentially, and in each matrix the columns are stored as in
Task.getbarsj
.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – Index of the first semidefinite variable in the slice. (input)last
(int32
) – Index of the last semidefinite variable in the slice plus one. (input)slicesize
(int64
) – Denotes the length of the arraybarsslice
. (input)barsslice
(float
[]
) – Dual solution values of symmetric matrix variables in the slice, stored sequentially. (output)
- Return:
barsslice
(float
[]
) – Dual solution values of symmetric matrix variables in the slice, stored sequentially.- Groups:
- Task.getbarvarname¶
getbarvarname(i) -> (name)
Obtains the name of a semidefinite variable.
- Parameters:
i
(int32
) – Index of the variable. (input)- Return:
name
(str
) – The requested name is copied to this buffer.- Groups:
- Task.getbarvarnameindex¶
getbarvarnameindex(somename) -> (asgn,index)
Obtains the index of semidefinite variable from its name.
- Parameters:
somename
(str
) – The name of the variable. (input)- Return:
asgn
(int32
) – Non-zero if the namesomename
is assigned to some semidefinite variable.index
(int32
) – The index of a semidefinite variable with the namesomename
(if one exists).
- Groups:
- Task.getbarvarnamelen¶
getbarvarnamelen(i) -> (len)
Obtains the length of the name of a semidefinite variable.
- Parameters:
i
(int32
) – Index of the variable. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
- Task.getbarxj¶
getbarxj(whichsol,j,barxj)
getbarxj(whichsol,j) -> (barxj)
Obtains the primal solution for a semidefinite variable. Only the lower triangular part of \(\barX_j\) is returned because the matrix by construction is symmetric. The format is that the columns are stored sequentially in the natural order.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)j
(int32
) – Index of the semidefinite variable. (input)barxj
(float
[]
) – Value of \(\barX_j\). (output)
- Return:
barxj
(float
[]
) – Value of \(\barX_j\).- Groups:
- Task.getbarxslice¶
getbarxslice(whichsol,first,last,slicesize,barxslice)
getbarxslice(whichsol,first,last,slicesize) -> (barxslice)
Obtains the primal solution for a sequence of semidefinite variables. The format is that matrices are stored sequentially, and in each matrix the columns are stored as in
Task.getbarxj
.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – Index of the first semidefinite variable in the slice. (input)last
(int32
) – Index of the last semidefinite variable in the slice plus one. (input)slicesize
(int64
) – Denotes the length of the arraybarxslice
. (input)barxslice
(float
[]
) – Solution values of symmetric matrix variables in the slice, stored sequentially. (output)
- Return:
barxslice
(float
[]
) – Solution values of symmetric matrix variables in the slice, stored sequentially.- Groups:
- Task.getc¶
getc(c)
getc() -> (c)
Obtains all objective coefficients \(c\).
- Parameters:
c
(float
[]
) – Linear terms of the objective as a dense vector. The length is the number of variables. (output)- Return:
c
(float
[]
) – Linear terms of the objective as a dense vector. The length is the number of variables.- Groups:
Problem data - linear part, Inspecting the task, Problem data - variables
- Task.getcfix¶
getcfix() -> (cfix)
Obtains the fixed term in the objective.
- Return:
cfix
(float
) – Fixed term in the objective.- Groups:
- Task.getcj¶
getcj(j) -> (cj)
Obtains one coefficient of \(c\).
- Parameters:
j
(int32
) – Index of the variable for which the \(c\) coefficient should be obtained. (input)- Return:
cj
(float
) – The value of \(c_j\).- Groups:
Problem data - linear part, Inspecting the task, Problem data - variables
- Task.getclist¶
getclist(subj,c)
getclist(subj) -> (c)
Obtains a sequence of elements in \(c\).
- Parameters:
subj
(int32
[]
) – A list of variable indexes. (input)c
(float
[]
) – Linear terms of the requested list of the objective as a dense vector. (output)
- Return:
c
(float
[]
) – Linear terms of the requested list of the objective as a dense vector.- Groups:
- Task.getconbound¶
getconbound(i) -> (bk,bl,bu)
Obtains bound information for one constraint.
- Parameters:
i
(int32
) – Index of the constraint for which the bound information should be obtained. (input)- Return:
bk
(mosek.boundkey
) – Bound keys.bl
(float
) – Values for lower bounds.bu
(float
) – Values for upper bounds.
- Groups:
Problem data - linear part, Inspecting the task, Problem data - bounds, Problem data - constraints
- Task.getconboundslice¶
getconboundslice(first,last,bk,bl,bu)
getconboundslice(first,last) -> (bk,bl,bu)
Obtains bounds information for a slice of the constraints.
- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bk
(mosek.boundkey
[]
) – Bound keys. (output)bl
(float
[]
) – Values for lower bounds. (output)bu
(float
[]
) – Values for upper bounds. (output)
- Return:
bk
(mosek.boundkey
[]
) – Bound keys.bl
(float
[]
) – Values for lower bounds.bu
(float
[]
) – Values for upper bounds.
- Groups:
Problem data - linear part, Inspecting the task, Problem data - bounds, Problem data - constraints
- Task.getcone Deprecated¶
getcone(k,submem) -> (ct,conepar,nummem)
getcone(k) -> (ct,conepar,nummem,submem)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
k
(int32
) – Index of the cone. (input)submem
(int32
[]
) – Variable subscripts of the members in the cone. (output)
- Return:
ct
(mosek.conetype
) – Specifies the type of the cone.conepar
(float
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0.nummem
(int32
) – Number of member variables in the cone.submem
(int32
[]
) – Variable subscripts of the members in the cone.
- Groups:
- Task.getconeinfo Deprecated¶
getconeinfo(k) -> (ct,conepar,nummem)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
k
(int32
) – Index of the cone. (input)- Return:
ct
(mosek.conetype
) – Specifies the type of the cone.conepar
(float
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0.nummem
(int32
) – Number of member variables in the cone.
- Groups:
- Task.getconename Deprecated¶
getconename(i) -> (name)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
i
(int32
) – Index of the cone. (input)- Return:
name
(str
) – The required name.- Groups:
Names, Problem data - cones (deprecated), Inspecting the task
- Task.getconenameindex Deprecated¶
getconenameindex(somename) -> (asgn,index)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Checks whether the name
somename
has been assigned to any cone. If it has been assigned to a cone, then the index of the cone is reported.- Parameters:
somename
(str
) – The name which should be checked. (input)- Return:
asgn
(int32
) – Is non-zero if the namesomename
is assigned to some cone.index
(int32
) – If the namesomename
is assigned to some cone, thenindex
is the index of the cone.
- Groups:
Names, Problem data - cones (deprecated), Inspecting the task
- Task.getconenamelen Deprecated¶
getconenamelen(i) -> (len)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
i
(int32
) – Index of the cone. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
Names, Problem data - cones (deprecated), Inspecting the task
- Task.getconname¶
getconname(i) -> (name)
Obtains the name of a constraint.
- Parameters:
i
(int32
) – Index of the constraint. (input)- Return:
name
(str
) – The required name.- Groups:
Names, Problem data - linear part, Problem data - constraints, Inspecting the task
- Task.getconnameindex¶
getconnameindex(somename) -> (asgn,index)
Checks whether the name
somename
has been assigned to any constraint. If so, the index of the constraint is reported.- Parameters:
somename
(str
) – The name which should be checked. (input)- Return:
asgn
(int32
) – Is non-zero if the namesomename
is assigned to some constraint.index
(int32
) – If the namesomename
is assigned to a constraint, thenindex
is the index of the constraint.
- Groups:
Names, Problem data - linear part, Problem data - constraints, Inspecting the task
- Task.getconnamelen¶
getconnamelen(i) -> (len)
Obtains the length of the name of a constraint.
- Parameters:
i
(int32
) – Index of the constraint. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
Names, Problem data - linear part, Problem data - constraints, Inspecting the task
- Task.getcslice¶
getcslice(first,last,c)
getcslice(first,last) -> (c)
Obtains a sequence of elements in \(c\).
- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)c
(float
[]
) – Linear terms of the requested slice of the objective as a dense vector. The length islast-first
. (output)
- Return:
c
(float
[]
) – Linear terms of the requested slice of the objective as a dense vector. The length islast-first
.- Groups:
- Task.getdimbarvarj¶
getdimbarvarj(j) -> (dimbarvarj)
Obtains the dimension of a symmetric matrix variable.
- Parameters:
j
(int32
) – Index of the semidefinite variable whose dimension is requested. (input)- Return:
dimbarvarj
(int32
) – The dimension of the \(j\)-th semidefinite variable.- Groups:
- Task.getdjcafeidxlist¶
getdjcafeidxlist(djcidx,afeidxlist)
getdjcafeidxlist(djcidx) -> (afeidxlist)
Obtains the list of affine expression indexes in a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (output)
- Return:
afeidxlist
(int64
[]
) – List of affine expression indexes.- Groups:
- Task.getdjcb¶
getdjcb(djcidx,b)
getdjcb(djcidx) -> (b)
Obtains the optional constant term vector of a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)b
(float
[]
) – The vector b. (output)
- Return:
b
(float
[]
) – The vector b.- Groups:
- Task.getdjcdomainidxlist¶
getdjcdomainidxlist(djcidx,domidxlist)
getdjcdomainidxlist(djcidx) -> (domidxlist)
Obtains the list of domain indexes in a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)domidxlist
(int64
[]
) – List of term sizes. (output)
- Return:
domidxlist
(int64
[]
) – List of term sizes.- Groups:
- Task.getdjcname¶
getdjcname(djcidx) -> (name)
Obtains the name of a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of a disjunctive constraint. (input)- Return:
name
(str
) – Returns the required name.- Groups:
Names, Problem data - disjunctive constraints, Inspecting the task
- Task.getdjcnamelen¶
getdjcnamelen(djcidx) -> (len)
Obtains the length of the name of a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of a disjunctive constraint. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
Names, Problem data - disjunctive constraints, Inspecting the task
- Task.getdjcnumafe¶
getdjcnumafe(djcidx) -> (numafe)
Obtains the number of affine expressions in the disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)- Return:
numafe
(int64
) – Number of affine expressions in the disjunctive constraint.- Groups:
- Task.getdjcnumafetot¶
getdjcnumafetot() -> (numafetot)
Obtains the total number of affine expressions in all disjunctive constraints.
- Return:
numafetot
(int64
) – Number of affine expressions in all disjunctive constraints.- Groups:
- Task.getdjcnumdomain¶
getdjcnumdomain(djcidx) -> (numdomain)
Obtains the number of domains in the disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)- Return:
numdomain
(int64
) – Number of domains in the disjunctive constraint.- Groups:
- Task.getdjcnumdomaintot¶
getdjcnumdomaintot() -> (numdomaintot)
Obtains the total number of domains in all disjunctive constraints.
- Return:
numdomaintot
(int64
) – Number of domains in all disjunctive constraints.- Groups:
- Task.getdjcnumterm¶
getdjcnumterm(djcidx) -> (numterm)
Obtains the number terms in the disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)- Return:
numterm
(int64
) – Number of terms in the disjunctive constraint.- Groups:
- Task.getdjcnumtermtot¶
getdjcnumtermtot() -> (numtermtot)
Obtains the total number of terms in all disjunctive constraints.
- Return:
numtermtot
(int64
) – Total number of terms in all disjunctive constraints.- Groups:
- Task.getdjcs¶
getdjcs(domidxlist, afeidxlist, b, termsizelist, numterms)
getdjcs() -> (domidxlist, afeidxlist, b, termsizelist, numterms)
Obtains full data of all disjunctive constraints. The output arrays must have minimal lengths determined by the following methods:
domainidxlist
byTask.getdjcnumdomaintot
,afeidxlist
andb
byTask.getdjcnumafetot
,termsizelist
byTask.getdjcnumtermtot
andnumterms
byTask.getnumdomain
.- Parameters:
domidxlist
(int64
[]
) – The concatenation of index lists of domains appearing in all disjunctive constraints. (output)afeidxlist
(int64
[]
) – The concatenation of index lists of affine expressions appearing in all disjunctive constraints. (output)b
(float
[]
) – The concatenation of vectors b appearing in all disjunctive constraints. (output)termsizelist
(int64
[]
) – The concatenation of lists of term sizes appearing in all disjunctive constraints. (output)numterms
(int64
[]
) – The number of terms in each of the disjunctive constraints. (output)
- Return:
domidxlist
(int64
[]
) – The concatenation of index lists of domains appearing in all disjunctive constraints.afeidxlist
(int64
[]
) – The concatenation of index lists of affine expressions appearing in all disjunctive constraints.b
(float
[]
) – The concatenation of vectors b appearing in all disjunctive constraints.termsizelist
(int64
[]
) – The concatenation of lists of term sizes appearing in all disjunctive constraints.numterms
(int64
[]
) – The number of terms in each of the disjunctive constraints.
- Groups:
- Task.getdjctermsizelist¶
getdjctermsizelist(djcidx,termsizelist)
getdjctermsizelist(djcidx) -> (termsizelist)
Obtains the list of term sizes in a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)termsizelist
(int64
[]
) – List of term sizes. (output)
- Return:
termsizelist
(int64
[]
) – List of term sizes.- Groups:
- Task.getdomainn¶
getdomainn(domidx) -> (n)
Obtains the dimension of the domain.
- Parameters:
domidx
(int64
) – Index of the domain. (input)- Return:
n
(int64
) – Dimension of the domain.- Groups:
- Task.getdomainname¶
getdomainname(domidx) -> (name)
Obtains the name of a domain.
- Parameters:
domidx
(int64
) – Index of a domain. (input)- Return:
name
(str
) – Returns the required name.- Groups:
- Task.getdomainnamelen¶
getdomainnamelen(domidx) -> (len)
Obtains the length of the name of a domain.
- Parameters:
domidx
(int64
) – Index of a domain. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
- Task.getdomaintype¶
getdomaintype(domidx) -> (domtype)
Returns the type of the domain.
- Parameters:
domidx
(int64
) – Index of the domain. (input)- Return:
domtype
(mosek.domaintype
) – The type of the domain.- Groups:
- Task.getdouinf¶
getdouinf(whichdinf) -> (dvalue)
Obtains a double information item from the task information database.
- Parameters:
whichdinf
(mosek.dinfitem
) – Specifies a double information item. (input)- Return:
dvalue
(float
) – The value of the required double information item.- Groups:
- Task.getdouparam¶
getdouparam(param) -> (parvalue)
Obtains the value of a double parameter.
- Parameters:
param
(mosek.dparam
) – Which parameter. (input)- Return:
parvalue
(float
) – Parameter value.- Groups:
- Task.getdualobj¶
getdualobj(whichsol) -> (dualobj)
Computes the dual objective value associated with the solution. Note that if the solution is a primal infeasibility certificate, then the fixed term in the objective value is not included.
Moreover, since there is no dual solution associated with an integer solution, an error will be reported if the dual objective value is requested for the integer solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
dualobj
(float
) – Objective value corresponding to the dual solution.- Groups:
- Task.getdualproblem¶
getdualproblem() -> (dualtask)
Returns the dual problem as a task. The dual computed by this function is intended for demonstration, educational and debugging purposes. It closely follows the dual form introduced in the documentation, but need not exactly reflect dualization taking place internally in the solver.
The function attempts to detect sparse LMIs and remove redundant linear constraints, trying to formulate the most efficient dual LMI (i.e. SDP in primal form), unless
iparam.getdual_convert_lmis
is turned off.Problems with quadratic objective or constraints are not supported. Integer variables and disjunctive constraints are ignored and only a warning is issued.
- Return:
dualtask
(mosek.Task
) – A new task containing the dualized problem.- Groups:
- Task.getdualsolutionnorms¶
getdualsolutionnorms(whichsol) -> (nrmy, nrmslc, nrmsuc, nrmslx, nrmsux, nrmsnx, nrmbars)
Compute norms of the dual solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
nrmy
(float
) – The norm of the \(y\) vector.nrmslc
(float
) – The norm of the \(s_l^c\) vector.nrmsuc
(float
) – The norm of the \(s_u^c\) vector.nrmslx
(float
) – The norm of the \(s_l^x\) vector.nrmsux
(float
) – The norm of the \(s_u^x\) vector.nrmsnx
(float
) – The norm of the \(s_n^x\) vector.nrmbars
(float
) – The norm of the \(\barS\) vector.
- Groups:
- Task.getdviolacc¶
getdviolacc(whichsol,accidxlist,viol)
getdviolacc(whichsol,accidxlist) -> (viol)
Let \((s_n^x)^*\) be the value of variable \((s_n^x)\) for the specified solution. For simplicity let us assume that \(s_n^x\) is a member of a quadratic cone, then the violation is computed as follows
\[\begin{split}\left\{ \begin{array}{ll} \max(0,(\|s_n^x\|_{2:n}^*-(s_n^x)_1^*) / \sqrt{2}, & (s_n^x)^* \geq -\|(s_n^x)_{2:n}^*\|, \\ \|(s_n^x)^*\|, & \mbox{otherwise.} \end{array} \right.\end{split}\]Both when the solution is a certificate of primal infeasibility or when it is a dual feasible solution the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)accidxlist
(int64
[]
) – An array of indexes of conic constraints. (input)viol
(float
[]
) –viol[k]
is the violation of the dual solution associated with the conic constraintsub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the dual solution associated with the conic constraintsub[k]
.- Groups:
- Task.getdviolbarvar¶
getdviolbarvar(whichsol,sub,viol)
getdviolbarvar(whichsol,sub) -> (viol)
Let \((\barS_j)^*\) be the value of variable \(\barS_j\) for the specified solution. Then the dual violation of the solution associated with variable \(\barS_j\) is given by
\[\max(-\lambda_{\min}(\barS_j),\ 0.0).\]Both when the solution is a certificate of primal infeasibility and when it is dual feasible solution the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of \(\barX\) variables. (input)viol
(float
[]
) –viol[k]
is the violation of the solution for the constraint \(\barS_{\mathtt{sub}[k]} \in \PSD\). (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the solution for the constraint \(\barS_{\mathtt{sub}[k]} \in \PSD\).- Groups:
- Task.getdviolcon¶
getdviolcon(whichsol,sub,viol)
getdviolcon(whichsol,sub) -> (viol)
The violation of the dual solution associated with the \(i\)-th constraint is computed as follows
\[\max( \rho( (s_l^c)_i^*,(b_l^c)_i ),\ \rho( (s_u^c)_i^*, -(b_u^c)_i ),\ |-y_i+(s_l^c)_i^*-(s_u^c)_i^*| )\]where
\[\begin{split}\rho(x,l) = \left\{ \begin{array}{ll} -x, & l > -\infty , \\ |x|, & \mbox{otherwise}.\\ \end{array} \right.\end{split}\]Both when the solution is a certificate of primal infeasibility or it is a dual feasible solution the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of constraints. (input)viol
(float
[]
) –viol[k]
is the violation of dual solution associated with the constraintsub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of dual solution associated with the constraintsub[k]
.- Groups:
- Task.getdviolcones Deprecated¶
getdviolcones(whichsol,sub,viol)
getdviolcones(whichsol,sub) -> (viol)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Let \((s_n^x)^*\) be the value of variable \((s_n^x)\) for the specified solution. For simplicity let us assume that \(s_n^x\) is a member of a quadratic cone, then the violation is computed as follows
\[\begin{split}\left\{ \begin{array}{ll} \max(0,(\|s_n^x\|_{2:n}^*-(s_n^x)_1^*) / \sqrt{2}, & (s_n^x)^* \geq -\|(s_n^x)_{2:n}^*\|, \\ \|(s_n^x)^*\|, & \mbox{otherwise.} \end{array} \right.\end{split}\]Both when the solution is a certificate of primal infeasibility or when it is a dual feasible solution the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of conic constraints. (input)viol
(float
[]
) –viol[k]
is the violation of the dual solution associated with the conic constraintsub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the dual solution associated with the conic constraintsub[k]
.- Groups:
- Task.getdviolvar¶
getdviolvar(whichsol,sub,viol)
getdviolvar(whichsol,sub) -> (viol)
The violation of the dual solution associated with the \(j\)-th variable is computed as follows
\[\max \left(\rho((s_l^x)_j^*,(b_l^x)_j),\ \rho((s_u^x)_j^*,-(b_u^x)_j),\ |\sum_{i=\idxbeg}^{\idxend{\mathtt{numcon}}} a_{ij} y_i+(s_l^x)_j^*-(s_u^x)_j^* - \tau c_j| \right)\]where
\[\begin{split}\rho(x,l) = \left\{ \begin{array}{ll} -x, & l > -\infty , \\ |x|, & \mbox{otherwise} \end{array} \right.\end{split}\]and \(\tau=0\) if the solution is a certificate of primal infeasibility and \(\tau=1\) otherwise. The formula for computing the violation is only shown for the linear case but is generalized appropriately for the more general problems. Both when the solution is a certificate of primal infeasibility or when it is a dual feasible solution the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of \(x\) variables. (input)viol
(float
[]
) –viol[k]
is the violation of dual solution associated with the variablesub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of dual solution associated with the variablesub[k]
.- Groups:
- Task.getinfeasiblesubproblem¶
getinfeasiblesubproblem(whichsol) -> (inftask)
Given the solution is a certificate of primal or dual infeasibility then a primal or dual infeasible subproblem is obtained respectively. The subproblem tends to be much smaller than the original problem and hence it is easier to locate the infeasibility inspecting the subproblem than the original problem.
For the procedure to be useful it is important to assign meaningful names to constraints, variables etc. in the original task because those names will be duplicated in the subproblem.
The function is only applicable to linear and conic quadratic optimization problems.
For more information see Sec. 8.3 (Debugging infeasibility) and Sec. 14.2 (Automatic Repair of Infeasible Problems).
- Parameters:
whichsol
(mosek.soltype
) – Which solution to use when determining the infeasible subproblem. (input)- Return:
inftask
(mosek.Task
) – A new task containing the infeasible subproblem.- Groups:
- Task.getintinf¶
getintinf(whichiinf) -> (ivalue)
Obtains an integer information item from the task information database.
- Parameters:
whichiinf
(mosek.iinfitem
) – Specifies an integer information item. (input)- Return:
ivalue
(int32
) – The value of the required integer information item.- Groups:
- Task.getintparam¶
getintparam(param) -> (parvalue)
Obtains the value of an integer parameter.
- Parameters:
param
(mosek.iparam
) – Which parameter. (input)- Return:
parvalue
(int32
) – Parameter value.- Groups:
- Task.getlenbarvarj¶
getlenbarvarj(j) -> (lenbarvarj)
Obtains the length of the \(j\)-th semidefinite variable i.e. the number of elements in the lower triangular part.
- Parameters:
j
(int32
) – Index of the semidefinite variable whose length if requested. (input)- Return:
lenbarvarj
(int64
) – Number of scalar elements in the lower triangular part of the semidefinite variable.- Groups:
- Task.getlintinf¶
getlintinf(whichliinf) -> (ivalue)
Obtains a long integer information item from the task information database.
- Parameters:
whichliinf
(mosek.liinfitem
) – Specifies a long information item. (input)- Return:
ivalue
(int64
) – The value of the required long integer information item.- Groups:
- Task.getlintparam¶
getlintparam(param) -> (parvalue)
Obtains the value of an integer parameter.
- Parameters:
param
(mosek.iparam
) – Which parameter. (input)- Return:
parvalue
(int64
) – Parameter value.- Groups:
- Task.getmaxnumanz¶
getmaxnumanz() -> (maxnumanz)
Obtains number of preallocated non-zeros in \(A\). When this number of non-zeros is reached MOSEK will automatically allocate more space for \(A\).
- Return:
maxnumanz
(int64
) – Number of preallocated non-zero linear matrix elements.- Groups:
- Task.getmaxnumbarvar¶
getmaxnumbarvar() -> (maxnumbarvar)
Obtains maximum number of symmetric matrix variables for which space is currently preallocated.
- Return:
maxnumbarvar
(int32
) – Maximum number of symmetric matrix variables for which space is currently preallocated.- Groups:
- Task.getmaxnumcon¶
getmaxnumcon() -> (maxnumcon)
Obtains the number of preallocated constraints in the optimization task. When this number of constraints is reached MOSEK will automatically allocate more space for constraints.
- Return:
maxnumcon
(int32
) – Number of preallocated constraints in the optimization task.- Groups:
Inspecting the task, Problem data - linear part, Problem data - constraints
- Task.getmaxnumcone Deprecated¶
getmaxnumcone() -> (maxnumcone)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Obtains the number of preallocated cones in the optimization task. When this number of cones is reached MOSEK will automatically allocate space for more cones.
- Return:
maxnumcone
(int32
) – Number of preallocated conic constraints in the optimization task.- Groups:
- Task.getmaxnumqnz¶
getmaxnumqnz() -> (maxnumqnz)
Obtains the number of preallocated non-zeros for \(Q\) (both objective and constraints). When this number of non-zeros is reached MOSEK will automatically allocate more space for \(Q\).
- Return:
maxnumqnz
(int64
) – Number of non-zero elements preallocated in quadratic coefficient matrices.- Groups:
- Task.getmaxnumvar¶
getmaxnumvar() -> (maxnumvar)
Obtains the number of preallocated variables in the optimization task. When this number of variables is reached MOSEK will automatically allocate more space for variables.
- Return:
maxnumvar
(int32
) – Number of preallocated variables in the optimization task.- Groups:
Inspecting the task, Problem data - linear part, Problem data - variables
- Task.getmemusage¶
getmemusage() -> (meminuse,maxmemuse)
Obtains information about the amount of memory used by a task.
- Return:
meminuse
(int64
) – Amount of memory currently used by thetask
.maxmemuse
(int64
) – Maximum amount of memory used by thetask
until now.
- Groups:
- Task.getnumacc¶
getnumacc() -> (num)
Obtains the number of affine conic constraints.
- Return:
num
(int64
) – The number of affine conic constraints.- Groups:
Problem data - affine conic constraints, Inspecting the task
- Task.getnumafe¶
getnumafe() -> (numafe)
Obtains the number of affine expressions.
- Return:
numafe
(int64
) – Number of affine expressions.- Groups:
- Task.getnumanz¶
getnumanz() -> (numanz)
Obtains the number of non-zeros in \(A\).
- Return:
numanz
(int64
) – Number of non-zero elements in the linear constraint matrix.- Groups:
- Task.getnumbarablocktriplets¶
getnumbarablocktriplets() -> (num)
Obtains an upper bound on the number of elements in the block triplet form of \(\barA\).
- Return:
num
(int64
) – An upper bound on the number of elements in the block triplet form of \(\barA.\)- Groups:
- Task.getnumbaranz¶
getnumbaranz() -> (nz)
Get the number of nonzero elements in \(\barA\).
- Return:
nz
(int64
) – The number of nonzero block elements in \(\barA\) i.e. the number of \(\barA_{ij}\) elements that are nonzero.- Groups:
- Task.getnumbarcblocktriplets¶
getnumbarcblocktriplets() -> (num)
Obtains an upper bound on the number of elements in the block triplet form of \(\barC\).
- Return:
num
(int64
) – An upper bound on the number of elements in the block triplet form of \(\barC.\)- Groups:
- Task.getnumbarcnz¶
getnumbarcnz() -> (nz)
Obtains the number of nonzero elements in \(\barC\).
- Return:
nz
(int64
) – The number of nonzeros in \(\barC\) i.e. the number of elements \(\barC_j\) that are nonzero.- Groups:
- Task.getnumbarvar¶
getnumbarvar() -> (numbarvar)
Obtains the number of semidefinite variables.
- Return:
numbarvar
(int32
) – Number of semidefinite variables in the problem.- Groups:
- Task.getnumcon¶
getnumcon() -> (numcon)
Obtains the number of constraints.
- Return:
numcon
(int32
) – Number of constraints.- Groups:
Problem data - linear part, Problem data - constraints, Inspecting the task
- Task.getnumcone Deprecated¶
getnumcone() -> (numcone)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Return:
numcone
(int32
) – Number of conic constraints.- Groups:
- Task.getnumconemem Deprecated¶
getnumconemem(k) -> (nummem)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
k
(int32
) – Index of the cone. (input)- Return:
nummem
(int32
) – Number of member variables in the cone.- Groups:
- Task.getnumdjc¶
getnumdjc() -> (num)
Obtains the number of disjunctive constraints.
- Return:
num
(int64
) – The number of disjunctive constraints.- Groups:
- Task.getnumdomain¶
getnumdomain() -> (numdomain)
Obtain the number of domains defined.
- Return:
numdomain
(int64
) – Number of domains in the task.- Groups:
- Task.getnumintvar¶
getnumintvar() -> (numintvar)
Obtains the number of integer-constrained variables.
- Return:
numintvar
(int32
) – Number of integer variables.- Groups:
- Task.getnumparam¶
getnumparam(partype) -> (numparam)
Obtains the number of parameters of a given type.
- Parameters:
partype
(mosek.parametertype
) – Parameter type. (input)- Return:
numparam
(int32
) – The number of parameters of typepartype
.- Groups:
- Task.getnumqconknz¶
getnumqconknz(k) -> (numqcnz)
Obtains the number of non-zero quadratic terms in a constraint.
- Parameters:
k
(int32
) – Index of the constraint for which the number quadratic terms should be obtained. (input)- Return:
numqcnz
(int64
) – Number of quadratic terms.- Groups:
Inspecting the task, Problem data - constraints, Problem data - quadratic part
- Task.getnumqobjnz¶
getnumqobjnz() -> (numqonz)
Obtains the number of non-zero quadratic terms in the objective.
- Return:
numqonz
(int64
) – Number of non-zero elements in the quadratic objective terms.- Groups:
- Task.getnumsymmat¶
getnumsymmat() -> (num)
Obtains the number of symmetric matrices stored in the vector \(E\).
- Return:
num
(int64
) – The number of symmetric sparse matrices.- Groups:
- Task.getnumvar¶
getnumvar() -> (numvar)
Obtains the number of variables.
- Return:
numvar
(int32
) – Number of variables.- Groups:
- Task.getobjname¶
getobjname() -> (objname)
Obtains the name assigned to the objective function.
- Return:
objname
(str
) – Assigned the objective name.- Groups:
- Task.getobjnamelen¶
getobjnamelen() -> (len)
Obtains the length of the name assigned to the objective function.
- Return:
len
(int32
) – Assigned the length of the objective name.- Groups:
- Task.getobjsense¶
getobjsense() -> (sense)
Gets the objective sense of the task.
- Return:
sense
(mosek.objsense
) – The returned objective sense.- Groups:
- Task.getpowerdomainalpha¶
getpowerdomainalpha(domidx,alpha)
getpowerdomainalpha(domidx) -> (alpha)
Obtains the exponent vector \(\alpha\) of a primal or dual power cone domain.
- Parameters:
domidx
(int64
) – Index of the domain. (input)alpha
(float
[]
) – The vector \(\alpha\). (output)
- Return:
alpha
(float
[]
) – The vector \(\alpha\).- Groups:
- Task.getpowerdomaininfo¶
getpowerdomaininfo(domidx) -> (n,nleft)
Obtains structural information about a primal or dual power cone domain.
- Parameters:
domidx
(int64
) – Index of the domain. (input)- Return:
n
(int64
) – Dimension of the domain.nleft
(int64
) – Number of variables on the left hand side.
- Groups:
- Task.getprimalobj¶
getprimalobj(whichsol) -> (primalobj)
Computes the primal objective value for the desired solution. Note that if the solution is an infeasibility certificate, then the fixed term in the objective is not included.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
primalobj
(float
) – Objective value corresponding to the primal solution.- Groups:
- Task.getprimalsolutionnorms¶
getprimalsolutionnorms(whichsol) -> (nrmxc,nrmxx,nrmbarx)
Compute norms of the primal solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
nrmxc
(float
) – The norm of the \(x^c\) vector.nrmxx
(float
) – The norm of the \(x\) vector.nrmbarx
(float
) – The norm of the \(\barX\) vector.
- Groups:
- Task.getprobtype¶
getprobtype() -> (probtype)
Obtains the problem type.
- Return:
probtype
(mosek.problemtype
) – The problem type.- Groups:
- Task.getprosta¶
getprosta(whichsol) -> (problemsta)
Obtains the problem status.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
problemsta
(mosek.prosta
) – Problem status.- Groups:
- Task.getpviolacc¶
getpviolacc(whichsol,accidxlist,viol)
getpviolacc(whichsol,accidxlist) -> (viol)
Computes the primal solution violation for a set of affine conic constraints. Let \(x^*\) be the value of the variable \(x\) for the specified solution. For simplicity let us assume that \(x\) is a member of a quadratic cone, then the violation is computed as follows
\[\begin{split}\left\{ \begin{array}{ll} \max(0,\|x_{2:n}\|-x_1) / \sqrt{2}, & x_1 \geq -\|x_{2:n}\|, \\ \|x\|, & \mbox{otherwise.} \end{array} \right.\end{split}\]Both when the solution is a certificate of dual infeasibility or when it is primal feasible the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)accidxlist
(int64
[]
) – An array of indexes of conic constraints. (input)viol
(float
[]
) –viol[k]
is the violation of the solution associated with the affine conic constraint numberaccidxlist[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the solution associated with the affine conic constraint numberaccidxlist[k]
.- Groups:
- Task.getpviolbarvar¶
getpviolbarvar(whichsol,sub,viol)
getpviolbarvar(whichsol,sub) -> (viol)
Computes the primal solution violation for a set of semidefinite variables. Let \((\barX_j)^*\) be the value of the variable \(\barX_j\) for the specified solution. Then the primal violation of the solution associated with variable \(\barX_j\) is given by
\[\max(-\lambda_{\min}(\barX_j),\ 0.0).\]Both when the solution is a certificate of dual infeasibility or when it is primal feasible the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of \(\barX\) variables. (input)viol
(float
[]
) –viol[k]
is how much the solution violates the constraint \(\barX_{\mathtt{sub}[k]} \in \PSD\). (output)
- Return:
viol
(float
[]
) –viol[k]
is how much the solution violates the constraint \(\barX_{\mathtt{sub}[k]} \in \PSD\).- Groups:
- Task.getpviolcon¶
getpviolcon(whichsol,sub,viol)
getpviolcon(whichsol,sub) -> (viol)
Computes the primal solution violation for a set of constraints. The primal violation of the solution associated with the \(i\)-th constraint is given by
\[\max(\tau l_i^c - (x_i^c)^*,\ (x_i^c)^* - \tau u_i^c),\ |\sum_{j=\idxbeg}^{\idxend{\mathtt{numvar}}} a_{ij} x_j^* - x_i^c|)\]where \(\tau=0\) if the solution is a certificate of dual infeasibility and \(\tau=1\) otherwise. Both when the solution is a certificate of dual infeasibility and when it is primal feasible the violation should be small. The above formula applies for the linear case but is appropriately generalized in other cases.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of constraints. (input)viol
(float
[]
) –viol[k]
is the violation associated with the solution for the constraintsub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation associated with the solution for the constraintsub[k]
.- Groups:
- Task.getpviolcones Deprecated¶
getpviolcones(whichsol,sub,viol)
getpviolcones(whichsol,sub) -> (viol)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Computes the primal solution violation for a set of conic constraints. Let \(x^*\) be the value of the variable \(x\) for the specified solution. For simplicity let us assume that \(x\) is a member of a quadratic cone, then the violation is computed as follows
\[\begin{split}\left\{ \begin{array}{ll} \max(0,\|x_{2:n}\|-x_1) / \sqrt{2}, & x_1 \geq -\|x_{2:n}\|, \\ \|x\|, & \mbox{otherwise.} \end{array} \right.\end{split}\]Both when the solution is a certificate of dual infeasibility or when it is primal feasible the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of conic constraints. (input)viol
(float
[]
) –viol[k]
is the violation of the solution associated with the conic constraint numbersub[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the solution associated with the conic constraint numbersub[k]
.- Groups:
- Task.getpvioldjc¶
getpvioldjc(whichsol,djcidxlist,viol)
getpvioldjc(whichsol,djcidxlist) -> (viol)
Computes the primal solution violation for a set of disjunctive constraints. For a single DJC the violation is defined as
\[\mathrm{viol}\left(\bigvee_{i=1}^t \bigwedge_{j=1}^{s_i} T_{i,j}\right) = \min_{i=1,\ldots,t}\left(\max_{j=1,\ldots,s_j}(\mathrm{viol}(T_{i,j}))\right)\]where the violation of each simple term \(T_{i,j}\) is defined as for an ordinary linear constraint.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)djcidxlist
(int64
[]
) – An array of indexes of disjunctive constraints. (input)viol
(float
[]
) –viol[k]
is the violation of the solution associated with the disjunctive constraint numberdjcidxlist[k]
. (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation of the solution associated with the disjunctive constraint numberdjcidxlist[k]
.- Groups:
- Task.getpviolvar¶
getpviolvar(whichsol,sub,viol)
getpviolvar(whichsol,sub) -> (viol)
Computes the primal solution violation associated to a set of variables. Let \(x_j^*\) be the value of \(x_j\) for the specified solution. Then the primal violation of the solution associated with variable \(x_j\) is given by
\[\max( \tau l_j^x - x_j^*,\ x_j^* - \tau u_j^x,\ 0).\]where \(\tau=0\) if the solution is a certificate of dual infeasibility and \(\tau=1\) otherwise. Both when the solution is a certificate of dual infeasibility and when it is primal feasible the violation should be small.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sub
(int32
[]
) – An array of indexes of \(x\) variables. (input)viol
(float
[]
) –viol[k]
is the violation associated with the solution for the variable \(x_\mathtt{sub[k]}\). (output)
- Return:
viol
(float
[]
) –viol[k]
is the violation associated with the solution for the variable \(x_\mathtt{sub[k]}\).- Groups:
- Task.getqconk¶
getqconk(k,qcsubi,qcsubj,qcval) -> (numqcnz)
getqconk(k) -> (numqcnz,qcsubi,qcsubj,qcval)
Obtains all the quadratic terms in a constraint. The quadratic terms are stored sequentially in
qcsubi
,qcsubj
, andqcval
.- Parameters:
k
(int32
) – Which constraint. (input)qcsubi
(int32
[]
) – Row subscripts for quadratic constraint matrix. (output)qcsubj
(int32
[]
) – Column subscripts for quadratic constraint matrix. (output)qcval
(float
[]
) – Quadratic constraint coefficient values. (output)
- Return:
numqcnz
(int64
) – Number of quadratic terms.qcsubi
(int32
[]
) – Row subscripts for quadratic constraint matrix.qcsubj
(int32
[]
) – Column subscripts for quadratic constraint matrix.qcval
(float
[]
) – Quadratic constraint coefficient values.
- Groups:
Inspecting the task, Problem data - quadratic part, Problem data - constraints
- Task.getqobj¶
getqobj(qosubi,qosubj,qoval) -> (numqonz)
getqobj() -> (numqonz,qosubi,qosubj,qoval)
Obtains the quadratic terms in the objective. The required quadratic terms are stored sequentially in
qosubi
,qosubj
, andqoval
.- Parameters:
qosubi
(int32
[]
) – Row subscripts for quadratic objective coefficients. (output)qosubj
(int32
[]
) – Column subscripts for quadratic objective coefficients. (output)qoval
(float
[]
) – Quadratic objective coefficient values. (output)
- Return:
numqonz
(int64
) – Number of non-zero elements in the quadratic objective terms.qosubi
(int32
[]
) – Row subscripts for quadratic objective coefficients.qosubj
(int32
[]
) – Column subscripts for quadratic objective coefficients.qoval
(float
[]
) – Quadratic objective coefficient values.
- Groups:
- Task.getqobjij¶
getqobjij(i,j) -> (qoij)
Obtains one coefficient \(q_{ij}^o\) in the quadratic term of the objective.
- Parameters:
i
(int32
) – Row index of the coefficient. (input)j
(int32
) – Column index of coefficient. (input)
- Return:
qoij
(float
) – The required coefficient.- Groups:
- Task.getreducedcosts¶
getreducedcosts(whichsol,first,last,redcosts)
getreducedcosts(whichsol,first,last) -> (redcosts)
Computes the reduced costs for a slice of variables and returns them in the array
redcosts
i.e.(15.2)¶\[\mathtt{redcosts} = \left[ (s_l^x)_j-(s_u^x)_j, ~j=\mathtt{first},\ldots,\mathtt{last}-1 \right]\]- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – The index of the first variable in the sequence. (input)last
(int32
) – The index of the last variable in the sequence plus 1. (input)redcosts
(float
[]
) – The reduced costs for the required slice of variables. (output)
- Return:
redcosts
(float
[]
) – The reduced costs for the required slice of variables.- Groups:
- Task.getskc¶
getskc(whichsol,skc)
getskc(whichsol) -> (skc)
Obtains the status keys for the constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (output)
- Return:
skc
(mosek.stakey
[]
) – Status keys for the constraints.- Groups:
- Task.getskcslice¶
getskcslice(whichsol,first,last,skc)
getskcslice(whichsol,first,last) -> (skc)
Obtains the status keys for a slice of the constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (output)
- Return:
skc
(mosek.stakey
[]
) – Status keys for the constraints.- Groups:
- Task.getskn¶
getskn(whichsol,skn)
getskn(whichsol) -> (skn)
Obtains the status keys for the conic constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skn
(mosek.stakey
[]
) – Status keys for the conic constraints. (output)
- Return:
skn
(mosek.stakey
[]
) – Status keys for the conic constraints.- Groups:
- Task.getskx¶
getskx(whichsol,skx)
getskx(whichsol) -> (skx)
Obtains the status keys for the scalar variables.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (output)
- Return:
skx
(mosek.stakey
[]
) – Status keys for the variables.- Groups:
- Task.getskxslice¶
getskxslice(whichsol,first,last,skx)
getskxslice(whichsol,first,last) -> (skx)
Obtains the status keys for a slice of the scalar variables.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (output)
- Return:
skx
(mosek.stakey
[]
) – Status keys for the variables.- Groups:
- Task.getslc¶
getslc(whichsol,slc)
getslc(whichsol) -> (slc)
Obtains the \(s_l^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (output)
- Return:
slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints.- Groups:
- Task.getslcslice¶
getslcslice(whichsol,first,last,slc)
getslcslice(whichsol,first,last) -> (slc)
Obtains a slice of the \(s_l^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (output)
- Return:
slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints.- Groups:
- Task.getslx¶
getslx(whichsol,slx)
getslx(whichsol) -> (slx)
Obtains the \(s_l^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (output)
- Return:
slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables.- Groups:
- Task.getslxslice¶
getslxslice(whichsol,first,last,slx)
getslxslice(whichsol,first,last) -> (slx)
Obtains a slice of the \(s_l^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (output)
- Return:
slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables.- Groups:
- Task.getsnx¶
getsnx(whichsol,snx)
getsnx(whichsol) -> (snx)
Obtains the \(s_n^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (output)
- Return:
snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables.- Groups:
- Task.getsnxslice¶
getsnxslice(whichsol,first,last,snx)
getsnxslice(whichsol,first,last) -> (snx)
Obtains a slice of the \(s_n^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (output)
- Return:
snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables.- Groups:
- Task.getsolsta¶
getsolsta(whichsol) -> (solutionsta)
Obtains the solution status.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
solutionsta
(mosek.solsta
) – Solution status.- Groups:
- Task.getsolution¶
getsolution(whichsol, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx) -> (problemsta,solutionsta)
getsolution(whichsol) -> (problemsta, solutionsta, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx)
Obtains the complete solution.
Consider the case of linear programming. The primal problem is given by
\[\begin{split}\begin{array}{lccccl} \mbox{minimize} & & & c^T x+c^f & & \\ \mbox{subject to} & l^c & \leq & A x & \leq & u^c, \\ & l^x & \leq & x & \leq & u^x. \\ \end{array}\end{split}\]and the corresponding dual problem is
\[\begin{split}\begin{array}{lccl} \mbox{maximize} & (l^c)^T s_l^c - (u^c)^T s_u^c & \\ & + (l^x)^T s_l^x - (u^x)^T s_u^x + c^f & \\ \mbox{subject to} & A^T y + s_l^x - s_u^x & = & c, \\ & -y + s_l^c - s_u^c & = & 0, \\ & s_l^c,s_u^c,s_l^x,s_u^x \geq 0. & & \\ \end{array}\end{split}\]A conic optimization problem has the same primal variables as in the linear case. Recall that the dual of a conic optimization problem is given by:
\[\begin{split}\begin{array}{lccccc} \mbox{maximize} & (l^c)^T s_l^c - (u^c)^T s_u^c & & \\ & +(l^x)^T s_l^x - (u^x)^T s_u^x + c^f & & \\ \mbox{subject to} & A^T y + s_l^x - s_u^x + s_n^x & = & c, \\ & -y + s_l^c - s_u^c & = & 0, \\ & s_l^c,s_u^c,s_l^x,s_u^x & \geq & 0, \\ & s_n^x \in \K^* & & \\ \end{array}\end{split}\]The mapping between variables and arguments to the function is as follows:
xx
: Corresponds to variable \(x\) (also denoted \(x^x\)).xc
: Corresponds to \(x^c:=Ax\).y
: Corresponds to variable \(y\).slc
: Corresponds to variable \(s_l^c\).suc
: Corresponds to variable \(s_u^c\).slx
: Corresponds to variable \(s_l^x\).sux
: Corresponds to variable \(s_u^x\).snx
: Corresponds to variable \(s_n^x\).
The meaning of the values returned by this function depend on the solution status returned in the argument
solsta
. The most important possible values ofsolsta
are:solsta.optimal
: An optimal solution satisfying the optimality criteria for continuous problems is returned.solsta.integer_optimal
: An optimal solution satisfying the optimality criteria for integer problems is returned.solsta.prim_feas
: A solution satisfying the feasibility criteria.solsta.prim_infeas_cer
: A primal certificate of infeasibility is returned.solsta.dual_infeas_cer
: A dual certificate of infeasibility is returned.
In order to retrieve the primal and dual values of semidefinite variables see
Task.getbarxj
andTask.getbarsj
.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (output)skx
(mosek.stakey
[]
) – Status keys for the variables. (output)skn
(mosek.stakey
[]
) – Status keys for the conic constraints. (output)xc
(float
[]
) – Primal constraint solution. (output)xx
(float
[]
) – Primal variable solution. (output)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (output)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (output)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (output)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (output)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (output)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (output)
- Return:
problemsta
(mosek.prosta
) – Problem status.solutionsta
(mosek.solsta
) – Solution status.skc
(mosek.stakey
[]
) – Status keys for the constraints.skx
(mosek.stakey
[]
) – Status keys for the variables.skn
(mosek.stakey
[]
) – Status keys for the conic constraints.xc
(float
[]
) – Primal constraint solution.xx
(float
[]
) – Primal variable solution.y
(float
[]
) – Vector of dual variables corresponding to the constraints.slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints.suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints.slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables.sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables.snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables.
- Groups:
- Task.getsolutioninfo¶
getsolutioninfo(whichsol) -> (pobj, pviolcon, pviolvar, pviolbarvar, pviolcone, pviolitg, dobj, dviolcon, dviolvar, dviolbarvar, dviolcone)
Obtains information about a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
pobj
(float
) – The primal objective value as computed byTask.getprimalobj
.pviolcon
(float
) – Maximal primal violation of the solution associated with the \(x^c\) variables where the violations are computed byTask.getpviolcon
.pviolvar
(float
) – Maximal primal violation of the solution for the \(x\) variables where the violations are computed byTask.getpviolvar
.pviolbarvar
(float
) – Maximal primal violation of solution for the \(\barX\) variables where the violations are computed byTask.getpviolbarvar
.pviolcone
(float
) – Maximal primal violation of solution for the conic constraints where the violations are computed byTask.getpviolcones
.pviolitg
(float
) – Maximal violation in the integer constraints. The violation for an integer variable \(x_j\) is given by \(\min(x_j-\lfloor x_j \rfloor,\lceil x_j \rceil - x_j)\). This number is always zero for the interior-point and basic solutions.dobj
(float
) – Dual objective value as computed byTask.getdualobj
.dviolcon
(float
) – Maximal violation of the dual solution associated with the \(x^c\) variable as computed byTask.getdviolcon
.dviolvar
(float
) – Maximal violation of the dual solution associated with the \(x\) variable as computed byTask.getdviolvar
.dviolbarvar
(float
) – Maximal violation of the dual solution associated with the \(\barS\) variable as computed byTask.getdviolbarvar
.dviolcone
(float
) – Maximal violation of the dual solution associated with the dual conic constraints as computed byTask.getdviolcones
.
- Groups:
- Task.getsolutioninfonew¶
getsolutioninfonew(whichsol) -> (pobj, pviolcon, pviolvar, pviolbarvar, pviolcone, pviolacc, pvioldjc, pviolitg, dobj, dviolcon, dviolvar, dviolbarvar, dviolcone, dviolacc)
Obtains information about a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
pobj
(float
) – The primal objective value as computed byTask.getprimalobj
.pviolcon
(float
) – Maximal primal violation of the solution associated with the \(x^c\) variables where the violations are computed byTask.getpviolcon
.pviolvar
(float
) – Maximal primal violation of the solution for the \(x\) variables where the violations are computed byTask.getpviolvar
.pviolbarvar
(float
) – Maximal primal violation of solution for the \(\barX\) variables where the violations are computed byTask.getpviolbarvar
.pviolcone
(float
) – Maximal primal violation of solution for the conic constraints where the violations are computed byTask.getpviolcones
.pviolacc
(float
) – Maximal primal violation of solution for the affine conic constraints where the violations are computed byTask.getpviolacc
.pvioldjc
(float
) – Maximal primal violation of solution for the disjunctive constraints where the violations are computed byTask.getpvioldjc
.pviolitg
(float
) – Maximal violation in the integer constraints. The violation for an integer variable \(x_j\) is given by \(\min(x_j-\lfloor x_j \rfloor,\lceil x_j \rceil - x_j)\). This number is always zero for the interior-point and basic solutions.dobj
(float
) – Dual objective value as computed byTask.getdualobj
.dviolcon
(float
) – Maximal violation of the dual solution associated with the \(x^c\) variable as computed byTask.getdviolcon
.dviolvar
(float
) – Maximal violation of the dual solution associated with the \(x\) variable as computed byTask.getdviolvar
.dviolbarvar
(float
) – Maximal violation of the dual solution associated with the \(\barS\) variable as computed byTask.getdviolbarvar
.dviolcone
(float
) – Maximal violation of the dual solution associated with the dual conic constraints as computed byTask.getdviolcones
.dviolacc
(float
) – Maximal violation of the dual solution associated with the affine conic constraints as computed byTask.getdviolacc
.
- Groups:
- Task.getsolutionnew¶
getsolutionnew(whichsol, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx, doty) -> (problemsta,solutionsta)
getsolutionnew(whichsol) -> (problemsta, solutionsta, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx, doty)
Obtains the complete solution. See
Task.getsolution
for further information.In order to retrieve the primal and dual values of semidefinite variables see
Task.getbarxj
andTask.getbarsj
.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (output)skx
(mosek.stakey
[]
) – Status keys for the variables. (output)skn
(mosek.stakey
[]
) – Status keys for the conic constraints. (output)xc
(float
[]
) – Primal constraint solution. (output)xx
(float
[]
) – Primal variable solution. (output)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (output)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (output)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (output)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (output)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (output)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (output)doty
(float
[]
) – Dual variables corresponding to affine conic constraints. (output)
- Return:
problemsta
(mosek.prosta
) – Problem status.solutionsta
(mosek.solsta
) – Solution status.skc
(mosek.stakey
[]
) – Status keys for the constraints.skx
(mosek.stakey
[]
) – Status keys for the variables.skn
(mosek.stakey
[]
) – Status keys for the conic constraints.xc
(float
[]
) – Primal constraint solution.xx
(float
[]
) – Primal variable solution.y
(float
[]
) – Vector of dual variables corresponding to the constraints.slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints.suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints.slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables.sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables.snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables.doty
(float
[]
) – Dual variables corresponding to affine conic constraints.
- Groups:
- Task.getsolutionslice¶
getsolutionslice(whichsol,solitem,first,last,values)
getsolutionslice(whichsol,solitem,first,last) -> (values)
Obtains a slice of one item from the solution. The format of the solution is exactly as in
Task.getsolution
. The parametersolitem
determines which of the solution vectors should be returned.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)solitem
(mosek.solitem
) – Which part of the solution is required. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)values
(float
[]
) – The values in the required sequence are stored sequentially invalues
. (output)
- Return:
values
(float
[]
) – The values in the required sequence are stored sequentially invalues
.- Groups:
- Task.getsparsesymmat¶
getsparsesymmat(idx,subi,subj,valij)
getsparsesymmat(idx) -> (subi,subj,valij)
Get a single symmetric matrix from the matrix store.
- Parameters:
idx
(int64
) – Index of the matrix to retrieve. (input)subi
(int32
[]
) – Row subscripts of the matrix non-zero elements. (output)subj
(int32
[]
) – Column subscripts of the matrix non-zero elements. (output)valij
(float
[]
) – Coefficients of the matrix non-zero elements. (output)
- Return:
subi
(int32
[]
) – Row subscripts of the matrix non-zero elements.subj
(int32
[]
) – Column subscripts of the matrix non-zero elements.valij
(float
[]
) – Coefficients of the matrix non-zero elements.
- Groups:
- Task.getstrparam¶
getstrparam(param) -> (len,parvalue)
Obtains the value of a string parameter.
- Parameters:
param
(mosek.sparam
) – Which parameter. (input)- Return:
len
(int32
) – The length of the parameter value.parvalue
(str
) – Parameter value.
- Groups:
- Task.getstrparamlen¶
getstrparamlen(param) -> (len)
Obtains the length of a string parameter.
- Parameters:
param
(mosek.sparam
) – Which parameter. (input)- Return:
len
(int32
) – The length of the parameter value.- Groups:
- Task.getsuc¶
getsuc(whichsol,suc)
getsuc(whichsol) -> (suc)
Obtains the \(s_u^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (output)
- Return:
suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints.- Groups:
- Task.getsucslice¶
getsucslice(whichsol,first,last,suc)
getsucslice(whichsol,first,last) -> (suc)
Obtains a slice of the \(s_u^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (output)
- Return:
suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints.- Groups:
- Task.getsux¶
getsux(whichsol,sux)
getsux(whichsol) -> (sux)
Obtains the \(s_u^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (output)
- Return:
sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables.- Groups:
- Task.getsuxslice¶
getsuxslice(whichsol,first,last,sux)
getsuxslice(whichsol,first,last) -> (sux)
Obtains a slice of the \(s_u^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (output)
- Return:
sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables.- Groups:
- Task.getsymmatinfo¶
getsymmatinfo(idx) -> (dim,nz,mattype)
MOSEK maintains a vector denoted by \(E\) of symmetric data matrices. This function makes it possible to obtain important information about a single matrix in \(E\).
- Parameters:
idx
(int64
) – Index of the matrix for which information is requested. (input)- Return:
dim
(int32
) – Returns the dimension of the requested matrix.nz
(int64
) – Returns the number of non-zeros in the requested matrix.mattype
(mosek.symmattype
) – Returns the type of the requested matrix.
- Groups:
- Task.gettaskname¶
gettaskname() -> (taskname)
Obtains the name assigned to the task.
- Return:
taskname
(str
) – Returns the task name.- Groups:
- Task.gettasknamelen¶
gettasknamelen() -> (len)
Obtains the length the task name.
- Return:
len
(int32
) – Returns the length of the task name.- Groups:
- Task.getvarbound¶
getvarbound(i) -> (bk,bl,bu)
Obtains bound information for one variable.
- Parameters:
i
(int32
) – Index of the variable for which the bound information should be obtained. (input)- Return:
bk
(mosek.boundkey
) – Bound keys.bl
(float
) – Values for lower bounds.bu
(float
) – Values for upper bounds.
- Groups:
Problem data - linear part, Inspecting the task, Problem data - bounds, Problem data - variables
- Task.getvarboundslice¶
getvarboundslice(first,last,bk,bl,bu)
getvarboundslice(first,last) -> (bk,bl,bu)
Obtains bounds information for a slice of the variables.
- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bk
(mosek.boundkey
[]
) – Bound keys. (output)bl
(float
[]
) – Values for lower bounds. (output)bu
(float
[]
) – Values for upper bounds. (output)
- Return:
bk
(mosek.boundkey
[]
) – Bound keys.bl
(float
[]
) – Values for lower bounds.bu
(float
[]
) – Values for upper bounds.
- Groups:
Problem data - linear part, Inspecting the task, Problem data - bounds, Problem data - variables
- Task.getvarname¶
getvarname(j) -> (name)
Obtains the name of a variable.
- Parameters:
j
(int32
) – Index of a variable. (input)- Return:
name
(str
) – Returns the required name.- Groups:
Names, Problem data - linear part, Problem data - variables, Inspecting the task
- Task.getvarnameindex¶
getvarnameindex(somename) -> (asgn,index)
Checks whether the name
somename
has been assigned to any variable. If so, the index of the variable is reported.- Parameters:
somename
(str
) – The name which should be checked. (input)- Return:
asgn
(int32
) – Is non-zero if the namesomename
is assigned to a variable.index
(int32
) – If the namesomename
is assigned to a variable, thenindex
is the index of the variable.
- Groups:
Names, Problem data - linear part, Problem data - variables, Inspecting the task
- Task.getvarnamelen¶
getvarnamelen(i) -> (len)
Obtains the length of the name of a variable.
- Parameters:
i
(int32
) – Index of a variable. (input)- Return:
len
(int32
) – Returns the length of the indicated name.- Groups:
Names, Problem data - linear part, Problem data - variables, Inspecting the task
- Task.getvartype¶
getvartype(j) -> (vartype)
Gets the variable type of one variable.
- Parameters:
j
(int32
) – Index of the variable. (input)- Return:
vartype
(mosek.variabletype
) – Variable type of the \(j\)-th variable.- Groups:
- Task.getvartypelist¶
getvartypelist(subj,vartype)
getvartypelist(subj) -> (vartype)
Obtains the variable type of one or more variables. Upon return
vartype[k]
is the variable type of variablesubj[k]
.- Parameters:
subj
(int32
[]
) – A list of variable indexes. (input)vartype
(mosek.variabletype
[]
) – The variables types corresponding to the variables specified bysubj
. (output)
- Return:
vartype
(mosek.variabletype
[]
) – The variables types corresponding to the variables specified bysubj
.- Groups:
- Task.getxc¶
getxc(whichsol,xc)
getxc(whichsol) -> (xc)
Obtains the \(x^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)xc
(float
[]
) – Primal constraint solution. (output)
- Return:
xc
(float
[]
) – Primal constraint solution.- Groups:
- Task.getxcslice¶
getxcslice(whichsol,first,last,xc)
getxcslice(whichsol,first,last) -> (xc)
Obtains a slice of the \(x^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)xc
(float
[]
) – Primal constraint solution. (output)
- Return:
xc
(float
[]
) – Primal constraint solution.- Groups:
- Task.getxx¶
getxx(whichsol,xx)
getxx(whichsol) -> (xx)
Obtains the \(x^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)xx
(float
[]
) – Primal variable solution. (output)
- Return:
xx
(float
[]
) – Primal variable solution.- Groups:
- Task.getxxslice¶
getxxslice(whichsol,first,last,xx)
getxxslice(whichsol,first,last) -> (xx)
Obtains a slice of the \(x^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)xx
(float
[]
) – Primal variable solution. (output)
- Return:
xx
(float
[]
) – Primal variable solution.- Groups:
- Task.gety¶
gety(whichsol,y)
gety(whichsol) -> (y)
Obtains the \(y\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (output)
- Return:
y
(float
[]
) – Vector of dual variables corresponding to the constraints.- Groups:
- Task.getyslice¶
getyslice(whichsol,first,last,y)
getyslice(whichsol,first,last) -> (y)
Obtains a slice of the \(y\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (output)
- Return:
y
(float
[]
) – Vector of dual variables corresponding to the constraints.- Groups:
- Task.infeasibilityreport¶
infeasibilityreport(whichstream,whichsol)
Prints the infeasibility report to an output stream.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)
- Groups:
- Task.initbasissolve¶
initbasissolve(basis)
initbasissolve() -> (basis)
Prepare a task for use with the
Task.solvewithbasis
function.This function should be called
immediately before the first call to
Task.solvewithbasis
, andimmediately before any subsequent call to
Task.solvewithbasis
if the task has been modified.
If the basis is singular i.e. not invertible, then the error
rescode.err_basis_singular
is reported.- Parameters:
basis
(int32
[]
) – The array of basis indexes to use. The array is interpreted as follows: If \(\mathtt{basis}[i] \leq \idxend{numcon}\), then \(x_{\mathtt{basis}[i]}^c\) is in the basis at position \(i\), otherwise \(x_{\mathtt{basis}[i]-\mathtt{numcon}}\) is in the basis at position \(i\). (output)- Return:
basis
(int32
[]
) – The array of basis indexes to use. The array is interpreted as follows: If \(\mathtt{basis}[i] \leq \idxend{numcon}\), then \(x_{\mathtt{basis}[i]}^c\) is in the basis at position \(i\), otherwise \(x_{\mathtt{basis}[i]-\mathtt{numcon}}\) is in the basis at position \(i\).- Groups:
- Task.inputdata¶
inputdata(maxnumcon, maxnumvar, c, cfix, aptrb, aptre, asub, aval, bkc, blc, buc, bkx, blx, bux)
Input the linear part of an optimization problem.
The non-zeros of \(A\) are inputted column-wise in the format described in Section Column or Row Ordered Sparse Matrix.
For an explained code example see Section Linear Optimization and Section Matrix Formats.
- Parameters:
maxnumcon
(int32
) – Number of preallocated constraints in the optimization task. (input)maxnumvar
(int32
) – Number of preallocated variables in the optimization task. (input)c
(float
[]
) – Linear terms of the objective as a dense vector. The length is the number of variables. (input)cfix
(float
) – Fixed term in the objective. (input)aptrb
(int64
[]
) – Row or column start pointers. (input)aptre
(int64
[]
) – Row or column end pointers. (input)asub
(int32
[]
) – Coefficient subscripts. (input)aval
(float
[]
) – Coefficient values. (input)bkc
(mosek.boundkey
[]
) – Bound keys for the constraints. (input)blc
(float
[]
) – Lower bounds for the constraints. (input)buc
(float
[]
) – Upper bounds for the constraints. (input)bkx
(mosek.boundkey
[]
) – Bound keys for the variables. (input)blx
(float
[]
) – Lower bounds for the variables. (input)bux
(float
[]
) – Upper bounds for the variables. (input)
- Groups:
Problem data - linear part, Problem data - bounds, Problem data - constraints
- Task.isdouparname¶
isdouparname(parname) -> (param)
Checks whether
parname
is a valid double parameter name.- Parameters:
parname
(str
) – Parameter name. (input)- Return:
param
(mosek.dparam
) – Returns the parameter corresponding to the name, if one exists.- Groups:
- Task.isintparname¶
isintparname(parname) -> (param)
Checks whether
parname
is a valid integer parameter name.- Parameters:
parname
(str
) – Parameter name. (input)- Return:
param
(mosek.iparam
) – Returns the parameter corresponding to the name, if one exists.- Groups:
- Task.isstrparname¶
isstrparname(parname) -> (param)
Checks whether
parname
is a valid string parameter name.- Parameters:
parname
(str
) – Parameter name. (input)- Return:
param
(mosek.sparam
) – Returns the parameter corresponding to the name, if one exists.- Groups:
- Task.linkfiletostream¶
linkfiletostream(whichstream,filename,append)
Directs all output from a task stream
whichstream
to a filefilename
.- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)filename
(str
) – A valid file name. (input)append
(int32
) – If this argument is 0 the output file will be overwritten, otherwise it will be appended to. (input)
- Groups:
- Task.onesolutionsummary¶
onesolutionsummary(whichstream,whichsol)
Prints a short summary of a specified solution.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)
- Groups:
- Task.optimize¶
optimize() -> (trmcode)
Calls the optimizer. Depending on the problem type and the selected optimizer this will call one of the optimizers in MOSEK. By default the interior point optimizer will be selected for continuous problems. The optimizer may be selected manually by setting the parameter
iparam.optimizer
.- Return:
trmcode
(mosek.rescode
) – Is eitherrescode.ok
or a termination response code.- Groups:
- Task.optimizermt¶
optimizermt(address,accesstoken) -> (trmcode)
Offload the optimization task to an instance of OptServer specified by
addr
, which should be a valid URL, for examplehttp://server:port
orhttps://server:port
. The call will block until a result is available or the connection closes.If the server requires authentication, the authentication token can be passed in the
accesstoken
argument.If the server requires encryption, the keys can be passed using one of the solver parameters
sparam.remote_tls_cert
orsparam.remote_tls_cert_path
.- Parameters:
address
(str
) – Address of the OptServer. (input)accesstoken
(str
) – Access token. (input)
- Return:
trmcode
(mosek.rescode
) – Is eitherrescode.ok
or a termination response code.- Groups:
- Task.optimizersummary¶
optimizersummary(whichstream)
Prints a short summary with optimizer statistics from last optimization.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)- Groups:
- Task.primalrepair¶
primalrepair(wlc,wuc,wlx,wux)
The function repairs a primal infeasible optimization problem by adjusting the bounds on the constraints and variables where the adjustment is computed as the minimal weighted sum of relaxations to the bounds on the constraints and variables. Observe the function only repairs the problem but does not solve it. If an optimal solution is required the problem should be optimized after the repair.
The function is applicable to linear and conic problems possibly with integer variables.
Observe that when computing the minimal weighted relaxation the termination tolerance specified by the parameters of the task is employed. For instance the parameter
iparam.mio_mode
can be used to make MOSEK ignore the integer constraints during the repair which usually leads to a much faster repair. However, the drawback is of course that the repaired problem may not have an integer feasible solution.Note the function modifies the task in place. If this is not desired, then apply the function to a cloned task.
- Parameters:
wlc
(float
[]
) – \((w_l^c)_i\) is the weight associated with relaxing the lower bound on constraint \(i\). If the weight is negative, then the lower bound is not relaxed. Moreover, if the argument isNone
, then all the weights are assumed to be \(1\). (input)wuc
(float
[]
) – \((w_u^c)_i\) is the weight associated with relaxing the upper bound on constraint \(i\). If the weight is negative, then the upper bound is not relaxed. Moreover, if the argument isNone
, then all the weights are assumed to be \(1\). (input)wlx
(float
[]
) – \((w_l^x)_j\) is the weight associated with relaxing the lower bound on variable \(j\). If the weight is negative, then the lower bound is not relaxed. Moreover, if the argument isNone
, then all the weights are assumed to be \(1\). (input)wux
(float
[]
) – \((w_l^x)_i\) is the weight associated with relaxing the upper bound on variable \(j\). If the weight is negative, then the upper bound is not relaxed. Moreover, if the argument isNone
, then all the weights are assumed to be \(1\). (input)
- Groups:
- Task.primalsensitivity¶
primalsensitivity(subi, marki, subj, markj, leftpricei, rightpricei, leftrangei, rightrangei, leftpricej, rightpricej, leftrangej, rightrangej)
primalsensitivity(subi,marki,subj,markj) -> (leftpricei, rightpricei, leftrangei, rightrangei, leftpricej, rightpricej, leftrangej, rightrangej)
Calculates sensitivity information for bounds on variables and constraints. For details on sensitivity analysis, the definitions of shadow price and linearity interval and an example see Section Sensitivity Analysis.
The type of sensitivity analysis to be performed (basis or optimal partition) is controlled by the parameter
iparam.sensitivity_type
.- Parameters:
subi
(int32
[]
) – Indexes of constraints to analyze. (input)marki
(mosek.mark
[]
) – The value ofmarki[i]
indicates for which bound of constraintsubi[i]
sensitivity analysis is performed. Ifmarki[i]
=mark.up
the upper bound of constraintsubi[i]
is analyzed, and ifmarki[i]
=mark.lo
the lower bound is analyzed. Ifsubi[i]
is an equality constraint, eithermark.lo
ormark.up
can be used to select the constraint for sensitivity analysis. (input)subj
(int32
[]
) – Indexes of variables to analyze. (input)markj
(mosek.mark
[]
) – The value ofmarkj[j]
indicates for which bound of variablesubj[j]
sensitivity analysis is performed. Ifmarkj[j]
=mark.up
the upper bound of variablesubj[j]
is analyzed, and ifmarkj[j]
=mark.lo
the lower bound is analyzed. Ifsubj[j]
is a fixed variable, eithermark.lo
ormark.up
can be used to select the bound for sensitivity analysis. (input)leftpricei
(float
[]
) –leftpricei[i]
is the left shadow price for the boundmarki[i]
of constraintsubi[i]
. (output)rightpricei
(float
[]
) –rightpricei[i]
is the right shadow price for the boundmarki[i]
of constraintsubi[i]
. (output)leftrangei
(float
[]
) –leftrangei[i]
is the left range \(\beta_1\) for the boundmarki[i]
of constraintsubi[i]
. (output)rightrangei
(float
[]
) –rightrangei[i]
is the right range \(\beta_2\) for the boundmarki[i]
of constraintsubi[i]
. (output)leftpricej
(float
[]
) –leftpricej[j]
is the left shadow price for the boundmarkj[j]
of variablesubj[j]
. (output)rightpricej
(float
[]
) –rightpricej[j]
is the right shadow price for the boundmarkj[j]
of variablesubj[j]
. (output)leftrangej
(float
[]
) –leftrangej[j]
is the left range \(\beta_1\) for the boundmarkj[j]
of variablesubj[j]
. (output)rightrangej
(float
[]
) –rightrangej[j]
is the right range \(\beta_2\) for the boundmarkj[j]
of variablesubj[j]
. (output)
- Return:
leftpricei
(float
[]
) –leftpricei[i]
is the left shadow price for the boundmarki[i]
of constraintsubi[i]
.rightpricei
(float
[]
) –rightpricei[i]
is the right shadow price for the boundmarki[i]
of constraintsubi[i]
.leftrangei
(float
[]
) –leftrangei[i]
is the left range \(\beta_1\) for the boundmarki[i]
of constraintsubi[i]
.rightrangei
(float
[]
) –rightrangei[i]
is the right range \(\beta_2\) for the boundmarki[i]
of constraintsubi[i]
.leftpricej
(float
[]
) –leftpricej[j]
is the left shadow price for the boundmarkj[j]
of variablesubj[j]
.rightpricej
(float
[]
) –rightpricej[j]
is the right shadow price for the boundmarkj[j]
of variablesubj[j]
.leftrangej
(float
[]
) –leftrangej[j]
is the left range \(\beta_1\) for the boundmarkj[j]
of variablesubj[j]
.rightrangej
(float
[]
) –rightrangej[j]
is the right range \(\beta_2\) for the boundmarkj[j]
of variablesubj[j]
.
- Groups:
- Task.putacc¶
putacc(accidx,domidx,afeidxlist,b)
Puts an affine conic constraint. This method overwrites an existing affine conic constraint number
accidx
with new data specified in the same format as inTask.appendacc
.- Parameters:
accidx
(int64
) – Affine conic constraint index. (input)domidx
(int64
) – Domain index. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.putaccb¶
putaccb(accidx,b)
Updates an existing affine conic constraint number
accidx
by putting a new vector \(b\).- Parameters:
accidx
(int64
) – Affine conic constraint index. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.putaccbj¶
putaccbj(accidx,j,bj)
Sets one value \(b[j]\) in the \(b\) vector for the affine conic constraint number
accidx
.- Parameters:
accidx
(int64
) – Affine conic constraint index. (input)j
(int64
) – The index of an element in b to change. (input)bj
(float
) – The new value of \(b[j]\). (input)
- Groups:
- Task.putaccdoty¶
putaccdoty(whichsol,accidx,doty)
putaccdoty(whichsol,accidx) -> (doty)
Puts the \(\dot{y}\) vector for a solution (the dual values of an affine conic constraint).
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)accidx
(int64
) – The index of the affine conic constraint. (input)doty
(float
[]
) – The dual values for this affine conic constraint. The array should have length equal to the dimension of the constraint. (output)
- Return:
doty
(float
[]
) – The dual values for this affine conic constraint. The array should have length equal to the dimension of the constraint.- Groups:
- Task.putacclist¶
putacclist(accidxs,domidxs,afeidxlist,b)
Puts affine conic constraints. This method overwrites existing affine conic constraints whose numbers are provided in the list
accidxs
with new data which is a concatenation of individual constraint descriptions in the same format as inTask.appendacc
(see alsoTask.appendaccs
).- Parameters:
accidxs
(int64
[]
) – Affine conic constraint indices. (input)domidxs
(int64
[]
) – Domain indices. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)
- Groups:
- Task.putaccname¶
putaccname(accidx,name)
Sets the name of an affine conic constraint.
- Parameters:
accidx
(int64
) – Index of the affine conic constraint. (input)name
(str
) – The name of the affine conic constraint. (input)
- Groups:
- Task.putacol¶
putacol(j,subj,valj)
Change one column of the linear constraint matrix \(A\). Resets all the elements in column \(j\) to zero and then sets
\[a_{\mathtt{subj}[k],\mathtt{j}} = \mathtt{valj}[k], \quad k=\idxbeg,\ldots,\idxend{\mathtt{nzj}}.\]- Parameters:
j
(int32
) – Index of a column in \(A\). (input)subj
(int32
[]
) – Row indexes of non-zero values in column \(j\) of \(A\). (input)valj
(float
[]
) – New non-zero values of column \(j\) in \(A\). (input)
- Groups:
- Task.putacollist¶
putacollist(sub,ptrb,ptre,asub,aval)
Change a set of columns in the linear constraint matrix \(A\) with data in sparse triplet format. The requested columns are set to zero and then updated with:
\[\begin{split}\begin{array}{rl} \mathtt{for} & i=\idxbeg,\ldots,\idxend{\mathtt{num}}\\ & a_{\mathtt{asub}[k],\mathtt{sub}[i]} = \mathtt{aval}[k],\quad k=\mathtt{ptrb}[i],\ldots,\mathtt{ptre}[i]-1. \end{array}\end{split}\]- Parameters:
sub
(int32
[]
) – Indexes of columns that should be replaced, no duplicates. (input)ptrb
(int64
[]
) – Array of pointers to the first element in each column. (input)ptre
(int64
[]
) – Array of pointers to the last element plus one in each column. (input)asub
(int32
[]
) – Row indexes of new elements. (input)aval
(float
[]
) – Coefficient values. (input)
- Groups:
- Task.putacolslice¶
putacolslice(first,last,ptrb,ptre,asub,aval)
Change a slice of columns in the linear constraint matrix \(A\) with data in sparse triplet format. The requested columns are set to zero and then updated with:
\[\begin{split}\begin{array}{rl} \mathtt{for} & i=\mathtt{first},\ldots,\mathtt{last}-1\\ & a_{\mathtt{asub}[k],i} = \mathtt{aval}[k],\quad k=\mathtt{ptrb}[i-\mathtt{first}\idxorg],\ldots,\mathtt{ptre}[i-\mathtt{first}\idxorg]-1. \end{array}\end{split}\]- Parameters:
first
(int32
) – First column in the slice. (input)last
(int32
) – Last column plus one in the slice. (input)ptrb
(int64
[]
) – Array of pointers to the first element in each column. (input)ptre
(int64
[]
) – Array of pointers to the last element plus one in each column. (input)asub
(int32
[]
) – Row indexes of new elements. (input)aval
(float
[]
) – Coefficient values. (input)
- Groups:
- Task.putafebarfblocktriplet¶
putafebarfblocktriplet(afeidx,barvaridx,subk,subl,valkl)
Inputs the \(\barF\) matrix data in block triplet form.
- Parameters:
afeidx
(int64
[]
) – Constraint index. (input)barvaridx
(int32
[]
) – Symmetric matrix variable index. (input)subk
(int32
[]
) – Block row index. (input)subl
(int32
[]
) – Block column index. (input)valkl
(float
[]
) – The numerical value associated with each block triplet. (input)
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.putafebarfentry¶
putafebarfentry(afeidx,barvaridx,termidx,termweight)
This function sets one entry \(\barF_{ij}\) where \(i=\mathrm{afeidx}\) is the row index in the store of affine expressions and \(j=\mathrm{barvaridx}\) is the index of a symmetric variable. That is, the expression
\[\langle \barF_{ij}, \barX_j\rangle\]will be added to the \(i\)-th affine expression.
The matrix \(\barF_{ij}\) is specified as a weighted sum of symmetric matrices from the symmetric matrix storage \(E\), so \(\barF_{ij}\) is a symmetric matrix, precisely:
\[\barF_{\mathrm{afeidx},\mathrm{barvaridx}} = \sum_{k} \mathrm{termweight}[k] \cdot E_{\mathrm{termidx}[k]}.\]By default all elements in \(\barF\) are 0, so only non-zero elements need be added. Setting the same entry again will overwrite the earlier entry.
The symmetric matrices from \(E\) are defined separately using the function
Task.appendsparsesymmat
.- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)barvaridx
(int32
) – Semidefinite variable index. (input)termidx
(int64
[]
) – Indices in \(E\) of the matrices appearing in the weighted sum for the \(\barF\) entry being specified. (input)termweight
(float
[]
) –termweight[k]
is the coefficient of thetermidx[k]
-th element of \(E\) in the weighted sum the \(\barF\) entry being specified. (input)
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.putafebarfentrylist¶
putafebarfentrylist(afeidx, barvaridx, numterm, ptrterm, termidx, termweight)
This function sets a list of entries in \(\barF\). Each entry should be described as in
Task.putafebarfentry
and all those descriptions should be combined (for example concatenated) in the input to this method. That means the \(k\)-th entry set will have row indexafeidx[k]
, symmetric variable indexbarvaridx[k]
and the description of this term consists of indices in \(E\) and weights appearing in positions\[\mathrm{ptrterm}[k],\ldots,\mathrm{ptrterm}[k] + (\mathrm{lenterm}[k] - 1)\]in the corresponding arrays
termidx
andtermweight
. SeeTask.putafebarfentry
for details.- Parameters:
afeidx
(int64
[]
) – Row indexes of \(\barF\). (input)barvaridx
(int32
[]
) – Semidefinite variable indexes. (input)numterm
(int64
[]
) – The number of terms in the weighted sums that form each entry. (input)ptrterm
(int64
[]
) – The pointer to the beginning of the description of each entry. (input)termidx
(int64
[]
) – Concatenated lists of indices in \(E\) of the matrices appearing in the weighted sums for the \(\barF\) being specified. (input)termweight
(float
[]
) – Concatenated lists of weights appearing in the weighted sums forming the \(\barF\) elements being specified. (input)
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.putafebarfrow¶
putafebarfrow(afeidx, barvaridx, numterm, ptrterm, termidx, termweight)
This function inputs one row in \(\barF\). It first clears the row, i.e. sets \(\barF_{\mathrm{afeidx},*}=0\) and then sets the new entries. Each entry should be described as in
Task.putafebarfentry
and all those descriptions should be combined (for example concatenated) in the input to this method. That means the \(k\)-th entry set will have row indexafeidx
, symmetric variable indexbarvaridx[k]
and the description of this term consists of indices in \(E\) and weights appearing in positions\[\mathrm{ptrterm}[k],\ldots,\mathrm{ptrterm}[k] + (\mathrm{numterm}[k] - 1)\]in the corresponding arrays
termidx
andtermweight
. SeeTask.putafebarfentry
for details.- Parameters:
afeidx
(int64
) – Row index of \(\barF\). (input)barvaridx
(int32
[]
) – Semidefinite variable indexes. (input)numterm
(int64
[]
) – The number of terms in the weighted sums that form each entry. (input)ptrterm
(int64
[]
) – The pointer to the beginning of the description of each entry. (input)termidx
(int64
[]
) – Concatenated lists of indices in \(E\) of the matrices appearing in the weighted sums for the \(\barF\) entries in the row. (input)termweight
(float
[]
) – Concatenated lists of weights appearing in the weighted sums forming the \(\barF\) entries in the row. (input)
- Groups:
Problem data - affine expressions, Problem data - semidefinite
- Task.putafefcol¶
putafefcol(varidx,afeidx,val)
Change one column of the matrix \(F\) of affine expressions. Resets all the elements in column
varidx
to zero and then sets\[F_{\mathtt{afeidx}[k],\mathtt{varidx}} = \mathtt{val}[k], \quad k=\idxbeg,\ldots,\idxend{\mathtt{numnz}}.\]- Parameters:
varidx
(int32
) – Index of a column in \(F\). (input)afeidx
(int64
[]
) – Row indexes of non-zero values in the column of \(F\). (input)val
(float
[]
) – New non-zero values in the column of \(F\). (input)
- Groups:
- Task.putafefentry¶
putafefentry(afeidx,varidx,value)
Replaces one entry in the affine expression store \(F\), that is it sets:
\[F_{\mathrm{afeidx}, \mathrm{varidx}} = \mathrm{value}.\]- Parameters:
afeidx
(int64
) – Row index in \(F\). (input)varidx
(int32
) – Column index in \(F\). (input)value
(float
) – Value of \(F_{\mathrm{afeidx},\mathrm{varidx}}\). (input)
- Groups:
- Task.putafefentrylist¶
putafefentrylist(afeidx,varidx,val)
Replaces a number of entries in the affine expression store \(F\), that is it sets:
\[F_{\mathrm{afeidxs}[k], \mathrm{varidx}[k]} = \mathrm{val}[k]\]for all \(k\).
- Parameters:
afeidx
(int64
[]
) – Row indices in \(F\). (input)varidx
(int32
[]
) – Column indices in \(F\). (input)val
(float
[]
) – Values of the entries in \(F\). (input)
- Groups:
- Task.putafefrow¶
putafefrow(afeidx,varidx,val)
Change one row of the matrix \(F\) of affine expressions. Resets all the elements in row
afeidx
to zero and then sets\[F_{\mathtt{afeidx},\mathtt{varidx}[k]} = \mathtt{val}[k], \quad k=\idxbeg,\ldots,\idxend{\mathtt{numnz}}.\]- Parameters:
afeidx
(int64
) – Index of a row in \(F\). (input)varidx
(int32
[]
) – Column indexes of non-zero values in the row of \(F\). (input)val
(float
[]
) – New non-zero values in the row of \(F\). (input)
- Groups:
- Task.putafefrowlist¶
putafefrowlist(afeidx,numnzrow,ptrrow,varidx,val)
Clears and then changes a number of rows of the matrix \(F\) of affine expressions. The \(k\)-th of the rows to be changed has index \(i = \mathrm{afeidx}[k]\), contains \(\mathrm{numnzrow}[k]\) nonzeros and its description as in
Task.putafefrow
starts in position \(\mathrm{ptrrow}[k]\) of the arraysvaridx
andval
. Formally, the row with index \(i\) is cleared and then set as:\[F_{i,\mathrm{varidx}[\mathrm{ptrrow}[k]+j]} = \mathrm{val}[\mathrm{ptrrow}[k] + j], \quad j=0,\ldots,\mathrm{numnzrow}[k]-1.\]- Parameters:
afeidx
(int64
[]
) – Indices of rows in \(F\). (input)numnzrow
(int32
[]
) – Number of non-zeros in each of the modified rows of \(F\). (input)ptrrow
(int64
[]
) – Pointer to the first nonzero in each row of \(F\). (input)varidx
(int32
[]
) – Column indexes of non-zero values. (input)val
(float
[]
) – New non-zero values in the rows of \(F\). (input)
- Groups:
- Task.putafeg¶
putafeg(afeidx,g)
Change one element of the vector \(g\) in affine expressions i.e.
\[g_{\mathtt{afeidx}} = \mathtt{gi}.\]- Parameters:
afeidx
(int64
) – Index of an entry in \(g\). (input)g
(float
) – New value for \(g_{\mathrm{afeidx}}\). (input)
- Groups:
- Task.putafeglist¶
putafeglist(afeidx,g)
Changes a list of elements of the vector \(g\) in affine expressions i.e. for all \(k\) it sets
\[g_{\mathrm{afeidx}[k]} = \mathrm{glist}[k].\]- Parameters:
afeidx
(int64
[]
) – Indices of entries in \(g\). (input)g
(float
[]
) – New values for \(g\). (input)
- Groups:
- Task.putafegslice¶
putafegslice(first,last,slice)
Modifies a slice in the vector \(g\) of constant terms in affine expressions using the principle
\[g_{\mathtt{j}} = \mathtt{slice[j-first\idxorg]}, \quad j=\mathrm{first},..,\mathrm{last}-1\]- Parameters:
first
(int64
) – First index in the sequence. (input)last
(int64
) – Last index plus 1 in the sequence. (input)slice
(float
[]
) – The slice of \(g\) as a dense vector. The length islast-first
. (input)
- Groups:
- Task.putaij¶
putaij(i,j,aij)
Changes a coefficient in the linear coefficient matrix \(A\) using the method
\[a_{i,j} = \mathtt{aij}.\]- Parameters:
i
(int32
) – Constraint (row) index. (input)j
(int32
) – Variable (column) index. (input)aij
(float
) – New coefficient for \(a_{i,j}\). (input)
- Groups:
- Task.putaijlist¶
putaijlist(subi,subj,valij)
Changes one or more coefficients in \(A\) using the method
\[a_{\mathtt{subi[k]},\mathtt{subj[k]}} = \mathtt{valij[k]}, \quad k=\idxbeg,\ldots,\idxend{\mathtt{num}}.\]Duplicates are not allowed.
- Parameters:
subi
(int32
[]
) – Constraint (row) indices. (input)subj
(int32
[]
) – Variable (column) indices. (input)valij
(float
[]
) – New coefficient values for \(a_{i,j}\). (input)
- Groups:
- Task.putarow¶
putarow(i,subi,vali)
Change one row of the linear constraint matrix \(A\). Resets all the elements in row \(i\) to zero and then sets
\[a_{\mathtt{i},\mathtt{subi}[k]} = \mathtt{vali}[k], \quad k=\idxbeg,\ldots,\idxend{\mathtt{nzi}}.\]- Parameters:
i
(int32
) – Index of a row in \(A\). (input)subi
(int32
[]
) – Column indexes of non-zero values in row \(i\) of \(A\). (input)vali
(float
[]
) – New non-zero values of row \(i\) in \(A\). (input)
- Groups:
- Task.putarowlist¶
putarowlist(sub,ptrb,ptre,asub,aval)
Change a set of rows in the linear constraint matrix \(A\) with data in sparse triplet format. The requested rows are set to zero and then updated with:
\[\begin{split}\begin{array}{rl} \mathtt{for} & i=\idxbeg,\ldots,\idxend{\mathtt{num}} \\ & a_{\mathtt{sub}[i],\mathtt{asub}[k]} = \mathtt{aval}[k],\quad k=\mathtt{ptrb}[i],\ldots,\mathtt{ptre}[i]-1. \end{array}\end{split}\]- Parameters:
sub
(int32
[]
) – Indexes of rows that should be replaced, no duplicates. (input)ptrb
(int64
[]
) – Array of pointers to the first element in each row. (input)ptre
(int64
[]
) – Array of pointers to the last element plus one in each row. (input)asub
(int32
[]
) – Column indexes of new elements. (input)aval
(float
[]
) – Coefficient values. (input)
- Groups:
- Task.putarowslice¶
putarowslice(first,last,ptrb,ptre,asub,aval)
Change a slice of rows in the linear constraint matrix \(A\) with data in sparse triplet format. The requested rows are set to zero and then updated with:
\[\begin{split}\begin{array}{rl} \mathtt{for} & i=\mathtt{first},\ldots,\mathtt{last}-1 \\ & a_{i,\mathtt{asub}[k]} = \mathtt{aval}[k],\quad k=\mathtt{ptrb}[i-\mathtt{first}\idxorg],\ldots,\mathtt{ptre}[i-\mathtt{first}\idxorg]-1. \end{array}\end{split}\]- Parameters:
first
(int32
) – First row in the slice. (input)last
(int32
) – Last row plus one in the slice. (input)ptrb
(int64
[]
) – Array of pointers to the first element in each row. (input)ptre
(int64
[]
) – Array of pointers to the last element plus one in each row. (input)asub
(int32
[]
) – Column indexes of new elements. (input)aval
(float
[]
) – Coefficient values. (input)
- Groups:
- Task.putatruncatetol¶
putatruncatetol(tolzero)
Truncates (sets to zero) all elements in \(A\) that satisfy
\[|a_{i,j}| \leq \mathtt{tolzero}.\]- Parameters:
tolzero
(float
) – Truncation tolerance. (input)- Groups:
- Task.putbarablocktriplet¶
putbarablocktriplet(subi,subj,subk,subl,valijkl)
Inputs the \(\barA\) matrix in block triplet form.
- Parameters:
subi
(int32
[]
) – Constraint index. (input)subj
(int32
[]
) – Symmetric matrix variable index. (input)subk
(int32
[]
) – Block row index. (input)subl
(int32
[]
) – Block column index. (input)valijkl
(float
[]
) – The numerical value associated with each block triplet. (input)
- Groups:
- Task.putbaraij¶
putbaraij(i,j,sub,weights)
This function sets one element in the \(\barA\) matrix.
Each element in the \(\barA\) matrix is a weighted sum of symmetric matrices from the symmetric matrix storage \(E\), so \(\barA_{ij}\) is a symmetric matrix. By default all elements in \(\barA\) are 0, so only non-zero elements need be added. Setting the same element again will overwrite the earlier entry.
The symmetric matrices from \(E\) are defined separately using the function
Task.appendsparsesymmat
.- Parameters:
i
(int32
) – Row index of \(\barA\). (input)j
(int32
) – Column index of \(\barA\). (input)sub
(int64
[]
) – Indices in \(E\) of the matrices appearing in the weighted sum for \(\barA_{ij}\). (input)weights
(float
[]
) –weights[k]
is the coefficient of thesub[k]
-th element of \(E\) in the weighted sum forming \(\barA_{ij}\). (input)
- Groups:
- Task.putbaraijlist¶
putbaraijlist(subi, subj, alphaptrb, alphaptre, matidx, weights)
This function sets a list of elements in the \(\barA\) matrix.
Each element in the \(\barA\) matrix is a weighted sum of symmetric matrices from the symmetric matrix storage \(E\), so \(\barA_{ij}\) is a symmetric matrix. By default all elements in \(\barA\) are 0, so only non-zero elements need be added. Setting the same element again will overwrite the earlier entry.
The symmetric matrices from \(E\) are defined separately using the function
Task.appendsparsesymmat
.- Parameters:
subi
(int32
[]
) – Row index of \(\barA\). (input)subj
(int32
[]
) – Column index of \(\barA\). (input)alphaptrb
(int64
[]
) – Start entries for terms in the weighted sum that forms \(\barA_{ij}\). (input)alphaptre
(int64
[]
) – End entries for terms in the weighted sum that forms \(\barA_{ij}\). (input)matidx
(int64
[]
) – Indices in \(E\) of the matrices appearing in the weighted sum for \(\barA_{ij}\). (input)weights
(float
[]
) –weights[k]
is the coefficient of thesub[k]
-th element of \(E\) in the weighted sum forming \(\barA_{ij}\). (input)
- Groups:
- Task.putbararowlist¶
putbararowlist(subi, ptrb, ptre, subj, nummat, matidx, weights)
This function replaces a list of rows in the \(\barA\) matrix.
- Parameters:
subi
(int32
[]
) – Row indexes of \(\barA\). (input)ptrb
(int64
[]
) – Start of rows in \(\barA\). (input)ptre
(int64
[]
) – End of rows in \(\barA\). (input)subj
(int32
[]
) – Column index of \(\barA\). (input)nummat
(int64
[]
) – Number of entries in weighted sum of matrixes. (input)matidx
(int64
[]
) – Matrix indexes for weighted sum of matrixes. (input)weights
(float
[]
) – Weights for weighted sum of matrixes. (input)
- Groups:
- Task.putbarcblocktriplet¶
putbarcblocktriplet(subj,subk,subl,valjkl)
Inputs the \(\barC\) matrix in block triplet form.
- Parameters:
subj
(int32
[]
) – Symmetric matrix variable index. (input)subk
(int32
[]
) – Block row index. (input)subl
(int32
[]
) – Block column index. (input)valjkl
(float
[]
) – The numerical value associated with each block triplet. (input)
- Groups:
- Task.putbarcj¶
putbarcj(j,sub,weights)
This function sets one entry in the \(\barC\) vector.
Each element in the \(\barC\) vector is a weighted sum of symmetric matrices from the symmetric matrix storage \(E\), so \(\barC_{j}\) is a symmetric matrix. By default all elements in \(\barC\) are 0, so only non-zero elements need be added. Setting the same element again will overwrite the earlier entry.
The symmetric matrices from \(E\) are defined separately using the function
Task.appendsparsesymmat
.- Parameters:
j
(int32
) – Index of the element in \(\barC\) that should be changed. (input)sub
(int64
[]
) – Indices in \(E\) of matrices appearing in the weighted sum for \(\barC_j\) (input)weights
(float
[]
) –weights[k]
is the coefficient of thesub[k]
-th element of \(E\) in the weighted sum forming \(\barC_j\). (input)
- Groups:
- Task.putbarsj¶
putbarsj(whichsol,j,barsj)
Sets the dual solution for a semidefinite variable.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)j
(int32
) – Index of the semidefinite variable. (input)barsj
(float
[]
) – Value of \(\barS_j\). Format as inTask.getbarsj
. (input)
- Groups:
- Task.putbarvarname¶
putbarvarname(j,name)
Sets the name of a semidefinite variable.
- Parameters:
j
(int32
) – Index of the variable. (input)name
(str
) – The variable name. (input)
- Groups:
- Task.putbarxj¶
putbarxj(whichsol,j,barxj)
Sets the primal solution for a semidefinite variable.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)j
(int32
) – Index of the semidefinite variable. (input)barxj
(float
[]
) – Value of \(\barX_j\). Format as inTask.getbarxj
. (input)
- Groups:
- Task.putcfix¶
putcfix(cfix)
Replaces the fixed term in the objective by a new one.
- Parameters:
cfix
(float
) – Fixed term in the objective. (input)- Groups:
- Task.putcj¶
putcj(j,cj)
Modifies one coefficient in the linear objective vector \(c\), i.e.
\[c_{\mathtt{j}} = \mathtt{cj}.\]If the absolute value exceeds
dparam.data_tol_c_huge
an error is generated. If the absolute value exceedsdparam.data_tol_cj_large
, a warning is generated, but the coefficient is inputted as specified.- Parameters:
j
(int32
) – Index of the variable for which \(c\) should be changed. (input)cj
(float
) – New value of \(c_j\). (input)
- Groups:
- Task.putclist¶
putclist(subj,val)
Modifies the coefficients in the linear term \(c\) in the objective using the principle
\[c_{\mathtt{subj[t]}} = \mathtt{val[t]}, \quad t=\idxbeg,\ldots,\idxend{\mathtt{num}}.\]If a variable index is specified multiple times in
subj
only the last entry is used. Data checks are performed as inTask.putcj
.- Parameters:
subj
(int32
[]
) – Indices of variables for which the coefficient in \(c\) should be changed. (input)val
(float
[]
) – New numerical values for coefficients in \(c\) that should be modified. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - objective
- Task.putconbound¶
putconbound(i,bkc,blc,buc)
Changes the bounds for one constraint.
If the bound value specified is numerically larger than
dparam.data_tol_bound_inf
it is considered infinite and the bound key is changed accordingly. If a bound value is numerically larger thandparam.data_tol_bound_wrn
, a warning will be displayed, but the bound is inputted as specified.- Parameters:
i
(int32
) – Index of the constraint. (input)bkc
(mosek.boundkey
) – New bound key. (input)blc
(float
) – New lower bound. (input)buc
(float
) – New upper bound. (input)
- Groups:
Problem data - linear part, Problem data - constraints, Problem data - bounds
- Task.putconboundlist¶
putconboundlist(sub,bkc,blc,buc)
Changes the bounds for a list of constraints. If multiple bound changes are specified for a constraint, then only the last change takes effect. Data checks are performed as in
Task.putconbound
.- Parameters:
sub
(int32
[]
) – List of constraint indexes. (input)bkc
(mosek.boundkey
[]
) – Bound keys for the constraints. (input)blc
(float
[]
) – Lower bounds for the constraints. (input)buc
(float
[]
) – Upper bounds for the constraints. (input)
- Groups:
Problem data - linear part, Problem data - constraints, Problem data - bounds
- Task.putconboundlistconst¶
putconboundlistconst(sub,bkc,blc,buc)
Changes the bounds for one or more constraints. Data checks are performed as in
Task.putconbound
.- Parameters:
sub
(int32
[]
) – List of constraint indexes. (input)bkc
(mosek.boundkey
) – New bound key for all constraints in the list. (input)blc
(float
) – New lower bound for all constraints in the list. (input)buc
(float
) – New upper bound for all constraints in the list. (input)
- Groups:
Problem data - linear part, Problem data - constraints, Problem data - bounds
- Task.putconboundslice¶
putconboundslice(first,last,bkc,blc,buc)
Changes the bounds for a slice of the constraints. Data checks are performed as in
Task.putconbound
.- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bkc
(mosek.boundkey
[]
) – Bound keys for the constraints. (input)blc
(float
[]
) – Lower bounds for the constraints. (input)buc
(float
[]
) – Upper bounds for the constraints. (input)
- Groups:
Problem data - linear part, Problem data - constraints, Problem data - bounds
- Task.putconboundsliceconst¶
putconboundsliceconst(first,last,bkc,blc,buc)
Changes the bounds for a slice of the constraints. Data checks are performed as in
Task.putconbound
.- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bkc
(mosek.boundkey
) – New bound key for all constraints in the slice. (input)blc
(float
) – New lower bound for all constraints in the slice. (input)buc
(float
) – New upper bound for all constraints in the slice. (input)
- Groups:
Problem data - linear part, Problem data - constraints, Problem data - bounds
- Task.putcone Deprecated¶
putcone(k,ct,conepar,submem)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
k
(int32
) – Index of the cone. (input)ct
(mosek.conetype
) – Specifies the type of the cone. (input)conepar
(float
) – For the power cone it denotes the exponent alpha. For other cone types it is unused and can be set to 0. (input)submem
(int32
[]
) – Variable subscripts of the members in the cone. (input)
- Groups:
- Task.putconename Deprecated¶
putconename(j,name)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
- Parameters:
j
(int32
) – Index of the cone. (input)name
(str
) – The name of the cone. (input)
- Groups:
- Task.putconname¶
putconname(i,name)
Sets the name of a constraint.
- Parameters:
i
(int32
) – Index of the constraint. (input)name
(str
) – The name of the constraint. (input)
- Groups:
Names, Problem data - constraints, Problem data - linear part
- Task.putconsolutioni¶
putconsolutioni(i,whichsol,sk,x,sl,su)
Sets the primal and dual solution information for a single constraint.
- Parameters:
i
(int32
) – Index of the constraint. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)sk
(mosek.stakey
) – Status key of the constraint. (input)x
(float
) – Primal solution value of the constraint. (input)sl
(float
) – Solution value of the dual variable associated with the lower bound. (input)su
(float
) – Solution value of the dual variable associated with the upper bound. (input)
- Groups:
- Task.putcslice¶
putcslice(first,last,slice)
Modifies a slice in the linear term \(c\) in the objective using the principle
\[c_{\mathtt{j}} = \mathtt{slice[j-first\idxorg]}, \quad j=\mathtt{first},..,\mathtt{last}-1\]Data checks are performed as in
Task.putcj
.- Parameters:
first
(int32
) – First element in the slice of \(c\). (input)last
(int32
) – Last element plus 1 of the slice in \(c\) to be changed. (input)slice
(float
[]
) – New numerical values for coefficients in \(c\) that should be modified. (input)
- Groups:
- Task.putdjc¶
putdjc(djcidx, domidxlist, afeidxlist, b, termsizelist)
Inputs a disjunctive constraint. The constraint has the form
\[T_1\ \mathrm{or}\ T_2\ \mathrm{or}\ \cdots\ \mathrm{or}\ T_{\mathrm{numterms}}\]For each \(i=1,\ldots\mathrm{numterms}\) the \(i\)-th clause (term) \(T_i\) has the form a sequence of affine expressions belongs to a product of domains, where the number of domains is \(\mathrm{termsizelist}[i]\) and the number of affine expressions is equal to the sum of dimensions of all domains appearing in \(T_i\).
All the domains and all the affine expressions appearing in the above description are arranged sequentially in the lists
domidxlist
andafeidxlist
, respectively. In particular, the length ofdomidxlist
must be equal to the sum of elements oftermsizelist
, and the length ofafeidxlist
must be equal to the sum of dimensions of all the domains appearing indomidxlist
.The elements of
domidxlist
are indexes of domains previously defined with one of theappend...domain
functions.The elements of
afeidxlist
are indexes to the store of affine expressions, i.e. the \(k\)-th affine expression appearing in the disjunctive constraint is going to be\[F_{\mathrm{afeidxlist}[k],:}x + g_{\mathrm{afeidxlist}[k]}\]If an optional vector
b
of the same length asafeidxlist
is specified then the \(k\)-th affine expression appearing in the disjunctive constraint will be taken as\[F_{\mathrm{afeidxlist}[k],:}x + g_{\mathrm{afeidxlist}[k]} - b_k\]- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)domidxlist
(int64
[]
) – List of domain indexes. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. (input)termsizelist
(int64
[]
) – List of term sizes. (input)
- Groups:
- Task.putdjcname¶
putdjcname(djcidx,name)
Sets the name of a disjunctive constraint.
- Parameters:
djcidx
(int64
) – Index of the disjunctive constraint. (input)name
(str
) – The name of the disjunctive constraint. (input)
- Groups:
- Task.putdjcslice¶
putdjcslice(idxfirst, idxlast, domidxlist, afeidxlist, b, termsizelist, termsindjc)
Inputs a slice of disjunctive constraints.
The array
termsindjc
should have length \(\mathrm{idxlast}-\mathrm{idxfirst}\) and contain the number of terms in consecutive constraints forming the slice.The rest of the input consists of concatenated descriptions of individual constraints, where each constraint is described as in
Task.putdjc
.- Parameters:
idxfirst
(int64
) – Index of the first disjunctive constraint in the slice. (input)idxlast
(int64
) – Index of the last disjunctive constraint in the slice plus 1. (input)domidxlist
(int64
[]
) – List of domain indexes. (input)afeidxlist
(int64
[]
) – List of affine expression indexes. (input)b
(float
[]
) – The vector of constant terms modifying affine expressions. Optional, can beNone
if not required. (input)termsizelist
(int64
[]
) – List of term sizes. (input)termsindjc
(int64
[]
) – Number of terms in each of the disjunctive constraints in the slice. (input)
- Groups:
- Task.putdomainname¶
putdomainname(domidx,name)
Sets the name of a domain.
- Parameters:
domidx
(int64
) – Index of the domain. (input)name
(str
) – The name of the domain. (input)
- Groups:
- Task.putdouparam¶
putdouparam(param,parvalue)
Sets the value of a double parameter.
- Parameters:
param
(mosek.dparam
) – Which parameter. (input)parvalue
(float
) – Parameter value. (input)
- Groups:
- Task.putintparam¶
putintparam(param,parvalue)
Sets the value of an integer parameter.
- Parameters:
param
(mosek.iparam
) – Which parameter. (input)parvalue
(int32
) – Parameter value. (input)
- Groups:
- Task.putlintparam¶
putlintparam(param,parvalue)
Sets the value of an integer parameter.
- Parameters:
param
(mosek.iparam
) – Which parameter. (input)parvalue
(int64
) – Parameter value. (input)
- Groups:
- Task.putmaxnumacc¶
putmaxnumacc(maxnumacc)
Sets the number of preallocated affine conic constraints in the optimization task. When this number is reached MOSEK will automatically allocate more space. It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
- Parameters:
maxnumacc
(int64
) – Number of preallocated affine conic constraints. (input)- Groups:
Environment and task management, Problem data - affine conic constraints
- Task.putmaxnumafe¶
putmaxnumafe(maxnumafe)
Sets the number of preallocated affine expressions in the optimization task. When this number is reached MOSEK will automatically allocate more space for affine expressions. It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
- Parameters:
maxnumafe
(int64
) – Number of preallocated affine expressions. (input)- Groups:
Environment and task management, Problem data - affine expressions
- Task.putmaxnumanz¶
putmaxnumanz(maxnumanz)
Sets the number of preallocated non-zero entries in \(A\).
MOSEK stores only the non-zero elements in the linear coefficient matrix \(A\) and it cannot predict how much storage is required to store \(A\). Using this function it is possible to specify the number of non-zeros to preallocate for storing \(A\).
If the number of non-zeros in the problem is known, it is a good idea to set
maxnumanz
slightly larger than this number, otherwise a rough estimate can be used. In general, if \(A\) is inputted in many small chunks, setting this value may speed up the data input phase.It is not mandatory to call this function, since MOSEK will reallocate internal structures whenever it is necessary.
The function call has no effect if both
maxnumcon
andmaxnumvar
are zero.- Parameters:
maxnumanz
(int64
) – Number of preallocated non-zeros in \(A\). (input)- Groups:
- Task.putmaxnumbarvar¶
putmaxnumbarvar(maxnumbarvar)
Sets the number of preallocated symmetric matrix variables in the optimization task. When this number of variables is reached MOSEK will automatically allocate more space for variables.
It is not mandatory to call this function. It only gives a hint about the amount of data to preallocate for efficiency reasons.
Please note that
maxnumbarvar
must be larger than the current number of symmetric matrix variables in the task.- Parameters:
maxnumbarvar
(int32
) – Number of preallocated symmetric matrix variables. (input)- Groups:
Environment and task management, Problem data - semidefinite
- Task.putmaxnumcon¶
putmaxnumcon(maxnumcon)
Sets the number of preallocated constraints in the optimization task. When this number of constraints is reached MOSEK will automatically allocate more space for constraints.
It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
Please note that
maxnumcon
must be larger than the current number of constraints in the task.- Parameters:
maxnumcon
(int32
) – Number of preallocated constraints in the optimization task. (input)- Groups:
- Task.putmaxnumcone Deprecated¶
putmaxnumcone(maxnumcone)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Sets the number of preallocated conic constraints in the optimization task. When this number of conic constraints is reached MOSEK will automatically allocate more space for conic constraints.
It is not mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
Please note that
maxnumcon
must be larger than the current number of conic constraints in the task.- Parameters:
maxnumcone
(int32
) – Number of preallocated conic constraints in the optimization task. (input)- Groups:
Environment and task management, Problem data - cones (deprecated)
- Task.putmaxnumdjc¶
putmaxnumdjc(maxnumdjc)
Sets the number of preallocated disjunctive constraints in the optimization task. When this number is reached MOSEK will automatically allocate more space. It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
- Parameters:
maxnumdjc
(int64
) – Number of preallocated disjunctive constraints in the task. (input)- Groups:
Environment and task management, Problem data - disjunctive constraints
- Task.putmaxnumdomain¶
putmaxnumdomain(maxnumdomain)
Sets the number of preallocated domains in the optimization task. When this number is reached MOSEK will automatically allocate more space. It is never mandatory to call this function, since MOSEK will reallocate any internal structures whenever it is required.
- Parameters:
maxnumdomain
(int64
) – Number of preallocated domains. (input)- Groups:
- Task.putmaxnumqnz¶
putmaxnumqnz(maxnumqnz)
Sets the number of preallocated non-zero entries in quadratic terms.
MOSEK stores only the non-zero elements in \(Q\). Therefore, MOSEK cannot predict how much storage is required to store \(Q\). Using this function it is possible to specify the number non-zeros to preallocate for storing \(Q\) (both objective and constraints).
It may be advantageous to reserve more non-zeros for \(Q\) than actually needed since it may improve the internal efficiency of MOSEK, however, it is never worthwhile to specify more than the double of the anticipated number of non-zeros in \(Q\).
It is not mandatory to call this function, since MOSEK will reallocate internal structures whenever it is necessary.
- Parameters:
maxnumqnz
(int64
) – Number of non-zero elements preallocated in quadratic coefficient matrices. (input)- Groups:
Environment and task management, Problem data - quadratic part
- Task.putmaxnumvar¶
putmaxnumvar(maxnumvar)
Sets the number of preallocated variables in the optimization task. When this number of variables is reached MOSEK will automatically allocate more space for variables.
It is not mandatory to call this function. It only gives a hint about the amount of data to preallocate for efficiency reasons.
Please note that
maxnumvar
must be larger than the current number of variables in the task.- Parameters:
maxnumvar
(int32
) – Number of preallocated variables in the optimization task. (input)- Groups:
- Task.putnadouparam¶
putnadouparam(paramname,parvalue)
Sets the value of a named double parameter.
- Parameters:
paramname
(str
) – Name of a parameter. (input)parvalue
(float
) – Parameter value. (input)
- Groups:
- Task.putnaintparam¶
putnaintparam(paramname,parvalue)
Sets the value of a named integer parameter.
- Parameters:
paramname
(str
) – Name of a parameter. (input)parvalue
(int32
) – Parameter value. (input)
- Groups:
- Task.putnastrparam¶
putnastrparam(paramname,parvalue)
Sets the value of a named string parameter.
- Parameters:
paramname
(str
) – Name of a parameter. (input)parvalue
(str
) – Parameter value. (input)
- Groups:
- Task.putobjname¶
putobjname(objname)
Assigns a new name to the objective.
- Parameters:
objname
(str
) – Name of the objective. (input)- Groups:
- Task.putobjsense¶
putobjsense(sense)
Sets the objective sense of the task.
- Parameters:
sense
(mosek.objsense
) – The objective sense of the task. The valuesobjsense.maximize
andobjsense.minimize
mean that the problem is maximized or minimized respectively. (input)- Groups:
- Task.putoptserverhost¶
putoptserverhost(host)
Specify an OptServer URL for remote calls. The URL should contain protocol, host and port in the form
http://server:port
orhttps://server:port
. If the URL is set using this function, all subsequent calls to any MOSEK function that involves synchronous optimization will be sent to the specified OptServer instead of being executed locally. PassingNone
or empty string deactivates this redirection.Has the same effect as setting the parameter
sparam.remote_optserver_host
.- Parameters:
host
(str
) – A URL specifying the optimization server to be used. (input)- Groups:
- Task.putparam¶
putparam(parname,parvalue)
Checks if
parname
is valid parameter name. If it is, the parameter is assigned the value specified byparvalue
.- Parameters:
parname
(str
) – Parameter name. (input)parvalue
(str
) – Parameter value. (input)
- Groups:
- Task.putqcon¶
putqcon(qcsubk,qcsubi,qcsubj,qcval)
Replace all quadratic entries in the constraints. The list of constraints has the form
\[l_k^c \leq \half \sum_{i=\idxbeg}^{\idxend{\mathtt{numvar}}} \sum_{j=\idxbeg}^{\idxend{\mathtt{numvar}}} q_{ij}^k x_i x_j + \sum_{j=\idxbeg}^{\idxend{\mathtt{numvar}}} a_{kj} x_j \leq u_k^c, ~\ k=\idxbeg,\ldots,\idxend{m}.\]This function sets all the quadratic terms to zero and then performs the update:
\[q_{\mathtt{qcsubi[t]},\mathtt{qcsubj[t]}}^{\mathtt{qcsubk[t]}} = q_{\mathtt{\mathtt{qcsubj[t]},qcsubi[t]}}^{\mathtt{qcsubk[t]}} = q_{\mathtt{\mathtt{qcsubj[t]},qcsubi[t]}}^{\mathtt{qcsubk[t]}} + \mathtt{qcval[t]},\]for \(t=\idxbeg,\ldots,\idxend{\mathtt{numqcnz}}\).
Please note that:
For large problems it is essential for the efficiency that the function
Task.putmaxnumqnz
is employed to pre-allocate space.Only the lower triangular parts should be specified because the \(Q\) matrices are symmetric. Specifying entries where \(i < j\) will result in an error.
Only non-zero elements should be specified.
The order in which the non-zero elements are specified is insignificant.
Duplicate elements are added together as shown above. Hence, it is usually not recommended to specify the same entry multiple times.
For a code example see Section Quadratic Optimization
- Parameters:
qcsubk
(int32
[]
) – Constraint subscripts for quadratic coefficients. (input)qcsubi
(int32
[]
) – Row subscripts for quadratic constraint matrix. (input)qcsubj
(int32
[]
) – Column subscripts for quadratic constraint matrix. (input)qcval
(float
[]
) – Quadratic constraint coefficient values. (input)
- Groups:
- Task.putqconk¶
putqconk(k,qcsubi,qcsubj,qcval)
Replaces all the quadratic entries in one constraint. This function performs the same operations as
Task.putqcon
but only with respect to constraint numberk
and it does not modify the other constraints. See the description ofTask.putqcon
for definitions and important remarks.- Parameters:
k
(int32
) – The constraint in which the new \(Q\) elements are inserted. (input)qcsubi
(int32
[]
) – Row subscripts for quadratic constraint matrix. (input)qcsubj
(int32
[]
) – Column subscripts for quadratic constraint matrix. (input)qcval
(float
[]
) – Quadratic constraint coefficient values. (input)
- Groups:
- Task.putqobj¶
putqobj(qosubi,qosubj,qoval)
Replace all quadratic terms in the objective. If the objective has the form
\[\half \sum_{i=\idxbeg}^{\idxend{\mathtt{numvar}}} \sum_{j=\idxbeg}^{\idxend{\mathtt{numvar}}} q_{ij}^o x_i x_j + \sum_{j=\idxbeg}^{\idxend{\mathtt{numvar}}} c_{j} x_j + c^f\]then this function sets all the quadratic terms to zero and then performs the update:
\[q_{\mathtt{qosubi[t]},\mathtt{qosubj[t]}}^{o} = q_{\mathtt{\mathtt{qosubj[t]},qosubi[t]}}^{o} = q_{\mathtt{\mathtt{qosubj[t]},qosubi[t]}}^{o} + \mathtt{qoval[t]},\]for \(t=\idxbeg,\ldots,\idxend{\mathtt{numqonz}}\).
See the description of
Task.putqcon
for important remarks and example.- Parameters:
qosubi
(int32
[]
) – Row subscripts for quadratic objective coefficients. (input)qosubj
(int32
[]
) – Column subscripts for quadratic objective coefficients. (input)qoval
(float
[]
) – Quadratic objective coefficient values. (input)
- Groups:
- Task.putqobjij¶
putqobjij(i,j,qoij)
Replaces one coefficient in the quadratic term in the objective. The function performs the assignment
\[q_{ij}^o = q_{ji}^o = \mathtt{qoij}.\]Only the elements in the lower triangular part are accepted. Setting \(q_{ij}\) with \(j>i\) will cause an error.
Please note that replacing all quadratic elements one by one is more computationally expensive than replacing them all at once. Use
Task.putqobj
instead whenever possible.- Parameters:
i
(int32
) – Row index for the coefficient to be replaced. (input)j
(int32
) – Column index for the coefficient to be replaced. (input)qoij
(float
) – The new value for \(q_{ij}^o\). (input)
- Groups:
- Task.putskc¶
putskc(whichsol,skc)
Sets the status keys for the constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (input)
- Groups:
- Task.putskcslice¶
putskcslice(whichsol,first,last,skc)
Sets the status keys for a slice of the constraints.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (input)
- Groups:
- Task.putskx¶
putskx(whichsol,skx)
Sets the status keys for the scalar variables.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (input)
- Groups:
- Task.putskxslice¶
putskxslice(whichsol,first,last,skx)
Sets the status keys for a slice of the variables.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (input)
- Groups:
- Task.putslc¶
putslc(whichsol,slc)
Sets the \(s_l^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (input)
- Groups:
- Task.putslcslice¶
putslcslice(whichsol,first,last,slc)
Sets a slice of the \(s_l^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (input)
- Groups:
- Task.putslx¶
putslx(whichsol,slx)
Sets the \(s_l^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (input)
- Groups:
- Task.putslxslice¶
putslxslice(whichsol,first,last,slx)
Sets a slice of the \(s_l^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (input)
- Groups:
- Task.putsnx¶
putsnx(whichsol,sux)
Sets the \(s_n^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (input)
- Groups:
- Task.putsnxslice¶
putsnxslice(whichsol,first,last,snx)
Sets a slice of the \(s_n^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (input)
- Groups:
- Task.putsolution¶
putsolution(whichsol, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx)
Inserts a solution into the task.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (input)skn
(mosek.stakey
[]
) – Status keys for the conic constraints. (input)xc
(float
[]
) – Primal constraint solution. (input)xx
(float
[]
) – Primal variable solution. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (input)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (input)
- Groups:
- Task.putsolutionnew¶
putsolutionnew(whichsol, skc, skx, skn, xc, xx, y, slc, suc, slx, sux, snx, doty)
Inserts a solution into the task.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)skc
(mosek.stakey
[]
) – Status keys for the constraints. (input)skx
(mosek.stakey
[]
) – Status keys for the variables. (input)skn
(mosek.stakey
[]
) – Status keys for the conic constraints. (input)xc
(float
[]
) – Primal constraint solution. (input)xx
(float
[]
) – Primal variable solution. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (input)slc
(float
[]
) – Dual variables corresponding to the lower bounds on the constraints. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (input)slx
(float
[]
) – Dual variables corresponding to the lower bounds on the variables. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (input)snx
(float
[]
) – Dual variables corresponding to the conic constraints on the variables. (input)doty
(float
[]
) – Dual variables corresponding to affine conic constraints. (input)
- Groups:
- Task.putsolutionyi¶
putsolutionyi(i,whichsol,y)
Inputs the dual variable of a solution.
- Parameters:
i
(int32
) – Index of the dual variable. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)y
(float
) – Solution value of the dual variable. (input)
- Groups:
- Task.putstrparam¶
putstrparam(param,parvalue)
Sets the value of a string parameter.
- Parameters:
param
(mosek.sparam
) – Which parameter. (input)parvalue
(str
) – Parameter value. (input)
- Groups:
- Task.putsuc¶
putsuc(whichsol,suc)
Sets the \(s_u^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (input)
- Groups:
- Task.putsucslice¶
putsucslice(whichsol,first,last,suc)
Sets a slice of the \(s_u^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)suc
(float
[]
) – Dual variables corresponding to the upper bounds on the constraints. (input)
- Groups:
- Task.putsux¶
putsux(whichsol,sux)
Sets the \(s_u^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (input)
- Groups:
- Task.putsuxslice¶
putsuxslice(whichsol,first,last,sux)
Sets a slice of the \(s_u^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)sux
(float
[]
) – Dual variables corresponding to the upper bounds on the variables. (input)
- Groups:
- Task.puttaskname¶
puttaskname(taskname)
Assigns a new name to the task.
- Parameters:
taskname
(str
) – Name assigned to the task. (input)- Groups:
- Task.putvarbound¶
putvarbound(j,bkx,blx,bux)
Changes the bounds for one variable.
If the bound value specified is numerically larger than
dparam.data_tol_bound_inf
it is considered infinite and the bound key is changed accordingly. If a bound value is numerically larger thandparam.data_tol_bound_wrn
, a warning will be displayed, but the bound is inputted as specified.- Parameters:
j
(int32
) – Index of the variable. (input)bkx
(mosek.boundkey
) – New bound key. (input)blx
(float
) – New lower bound. (input)bux
(float
) – New upper bound. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - bounds
- Task.putvarboundlist¶
putvarboundlist(sub,bkx,blx,bux)
Changes the bounds for one or more variables. If multiple bound changes are specified for a variable, then only the last change takes effect. Data checks are performed as in
Task.putvarbound
.- Parameters:
sub
(int32
[]
) – List of variable indexes. (input)bkx
(mosek.boundkey
[]
) – Bound keys for the variables. (input)blx
(float
[]
) – Lower bounds for the variables. (input)bux
(float
[]
) – Upper bounds for the variables. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - bounds
- Task.putvarboundlistconst¶
putvarboundlistconst(sub,bkx,blx,bux)
Changes the bounds for one or more variables. Data checks are performed as in
Task.putvarbound
.- Parameters:
sub
(int32
[]
) – List of variable indexes. (input)bkx
(mosek.boundkey
) – New bound key for all variables in the list. (input)blx
(float
) – New lower bound for all variables in the list. (input)bux
(float
) – New upper bound for all variables in the list. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - bounds
- Task.putvarboundslice¶
putvarboundslice(first,last,bkx,blx,bux)
Changes the bounds for a slice of the variables. Data checks are performed as in
Task.putvarbound
.- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bkx
(mosek.boundkey
[]
) – Bound keys for the variables. (input)blx
(float
[]
) – Lower bounds for the variables. (input)bux
(float
[]
) – Upper bounds for the variables. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - bounds
- Task.putvarboundsliceconst¶
putvarboundsliceconst(first,last,bkx,blx,bux)
Changes the bounds for a slice of the variables. Data checks are performed as in
Task.putvarbound
.- Parameters:
first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)bkx
(mosek.boundkey
) – New bound key for all variables in the slice. (input)blx
(float
) – New lower bound for all variables in the slice. (input)bux
(float
) – New upper bound for all variables in the slice. (input)
- Groups:
Problem data - linear part, Problem data - variables, Problem data - bounds
- Task.putvarname¶
putvarname(j,name)
Sets the name of a variable.
- Parameters:
j
(int32
) – Index of the variable. (input)name
(str
) – The variable name. (input)
- Groups:
- Task.putvarsolutionj¶
putvarsolutionj(j,whichsol,sk,x,sl,su,sn)
Sets the primal and dual solution information for a single variable.
- Parameters:
j
(int32
) – Index of the variable. (input)whichsol
(mosek.soltype
) – Selects a solution. (input)sk
(mosek.stakey
) – Status key of the variable. (input)x
(float
) – Primal solution value of the variable. (input)sl
(float
) – Solution value of the dual variable associated with the lower bound. (input)su
(float
) – Solution value of the dual variable associated with the upper bound. (input)sn
(float
) – Solution value of the dual variable associated with the conic constraint. (input)
- Groups:
- Task.putvartype¶
putvartype(j,vartype)
Sets the variable type of one variable.
- Parameters:
j
(int32
) – Index of the variable. (input)vartype
(mosek.variabletype
) – The new variable type. (input)
- Groups:
- Task.putvartypelist¶
putvartypelist(subj,vartype)
Sets the variable type for one or more variables. If the same index is specified multiple times in
subj
only the last entry takes effect.- Parameters:
subj
(int32
[]
) – A list of variable indexes for which the variable type should be changed. (input)vartype
(mosek.variabletype
[]
) – A list of variable types that should be assigned to the variables specified bysubj
. (input)
- Groups:
- Task.putxc¶
putxc(whichsol,xc)
putxc(whichsol) -> (xc)
Sets the \(x^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)xc
(float
[]
) – Primal constraint solution. (output)
- Return:
xc
(float
[]
) – Primal constraint solution.- Groups:
- Task.putxcslice¶
putxcslice(whichsol,first,last,xc)
Sets a slice of the \(x^c\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)xc
(float
[]
) – Primal constraint solution. (input)
- Groups:
- Task.putxx¶
putxx(whichsol,xx)
Sets the \(x^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)xx
(float
[]
) – Primal variable solution. (input)
- Groups:
- Task.putxxslice¶
putxxslice(whichsol,first,last,xx)
Sets a slice of the \(x^x\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)xx
(float
[]
) – Primal variable solution. (input)
- Groups:
- Task.puty¶
puty(whichsol,y)
Sets the \(y\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (input)
- Groups:
- Task.putyslice¶
putyslice(whichsol,first,last,y)
Sets a slice of the \(y\) vector for a solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)first
(int32
) – First index in the sequence. (input)last
(int32
) – Last index plus 1 in the sequence. (input)y
(float
[]
) – Vector of dual variables corresponding to the constraints. (input)
- Groups:
- Task.readbsolution¶
readbsolution(filename,compress)
Read a binary dump of the task solution.
- Parameters:
filename
(str
) – A valid file name. (input)compress
(mosek.compresstype
) – Data compression type. (input)
- Groups:
- Task.readdata¶
readdata(filename)
Reads an optimization problem and associated data from a file.
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.readdataformat¶
readdataformat(filename,format,compress)
Reads an optimization problem and associated data from a file.
- Parameters:
filename
(str
) – A valid file name. (input)format
(mosek.dataformat
) – File data format. (input)compress
(mosek.compresstype
) – File compression type. (input)
- Groups:
- Task.readjsonsol¶
readjsonsol(filename)
Reads a solution file in JSON format (JSOL file) and inserts it in the task. Only the section
Task/solutions
is taken into consideration.- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.readjsonstring¶
readjsonstring(data)
Load task data from a JSON string, replacing any data that already exists in the task object. All problem data, parameters and other settings are resorted, but if the string contains solutions, the solution status after loading a file is set to unknown, even if it is optimal or otherwise well-defined.
- Parameters:
data
(str
) – Problem data in text format. (input)- Groups:
- Task.readlpstring¶
readlpstring(data)
Load task data from a string in LP format, replacing any data that already exists in the task object.
- Parameters:
data
(str
) – Problem data in text format. (input)- Groups:
- Task.readopfstring¶
readopfstring(data)
Load task data from a string in OPF format, replacing any data that already exists in the task object.
- Parameters:
data
(str
) – Problem data in text format. (input)- Groups:
- Task.readparamfile¶
readparamfile(filename)
Reads MOSEK parameters from a file. Data is read from the file
filename
if it is a nonempty string. Otherwise data is read from the file specified bysparam.param_read_file_name
.The parameter file must begin with
BEGIN MOSEK
and end withEND MOSEK
; empty lines and lines starting from a%
sign are ignored; each remaining line contains a valid MOSEK parameter name followed by its value (using generic names as in the command-line tool syntax). Example:BEGIN MOSEK % This is a comment. MSK_IPAR_PRESOLVE_USE MSK_OFF MSK_DPAR_INTPNT_TOL_PFEAS 1.0e-9 END MOSEK
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.readptfstring¶
readptfstring(data)
Load task data from a PTF string, replacing any data that already exists in the task object. All problem data, parameters and other settings are resorted, but if the string contains solutions, the solution status after loading a file is set to unknown, even if it is optimal or otherwise well-defined.
- Parameters:
data
(str
) – Problem data in text format. (input)- Groups:
- Task.readsolution¶
readsolution(whichsol,filename)
Reads a solution file and inserts it as a specified solution in the task. Data is read from the file
filename
if it is a nonempty string. Otherwise data is read from one of the files specified bysparam.bas_sol_file_name
,sparam.itr_sol_file_name
orsparam.int_sol_file_name
depending on which solution is chosen.- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)filename
(str
) – A valid file name. (input)
- Groups:
- Task.readsolutionfile¶
readsolutionfile(filename)
Read solution file in format determined by the filename
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.readsummary¶
readsummary(whichstream)
Prints a short summary of last file that was read.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)- Groups:
- Task.readtask¶
readtask(filename)
Load task data from a file, replacing any data that already exists in the task object. All problem data, parameters and other settings are resorted, but if the file contains solutions, the solution status after loading a file is set to unknown, even if it was optimal or otherwise well-defined when the file was dumped.
See section The Task Format for a description of the Task format.
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.removebarvars¶
removebarvars(subset)
The function removes a subset of the symmetric matrices from the optimization task. This implies that the remaining symmetric matrices are renumbered.
- Parameters:
subset
(int32
[]
) – Indexes of symmetric matrices which should be removed. (input)- Groups:
- Task.removecones Deprecated¶
removecones(subset)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Removes a number of conic constraints from the problem. This implies that the remaining conic constraints are renumbered. In general, it is much more efficient to remove a cone with a high index than a low index.
- Parameters:
subset
(int32
[]
) – Indexes of cones which should be removed. (input)- Groups:
- Task.removecons¶
removecons(subset)
The function removes a subset of the constraints from the optimization task. This implies that the remaining constraints are renumbered.
- Parameters:
subset
(int32
[]
) – Indexes of constraints which should be removed. (input)- Groups:
- Task.removevars¶
removevars(subset)
The function removes a subset of the variables from the optimization task. This implies that the remaining variables are renumbered.
- Parameters:
subset
(int32
[]
) – Indexes of variables which should be removed. (input)- Groups:
- Task.resetdouparam¶
resetdouparam(param)
Resets a double parameter to its default value.
- Parameters:
param
(mosek.dparam
) – Which parameter. (input)- Groups:
- Task.resetintparam¶
resetintparam(param)
Resets an integer parameter to its default value.
- Parameters:
param
(mosek.iparam
) – Which parameter. (input)- Groups:
- Task.resetparameters¶
resetparameters()
Resets all the parameters to their default values.
- Groups:
- Task.resetstrparam¶
resetstrparam(param)
Resets a string parameter to its defalt value.
- Parameters:
param
(mosek.sparam
) – Which parameter. (input)- Groups:
- Task.resizetask¶
resizetask(maxnumcon, maxnumvar, maxnumcone, maxnumanz, maxnumqnz)
Sets the amount of preallocated space assigned for each type of data in an optimization task.
It is never mandatory to call this function, since it only gives a hint about the amount of data to preallocate for efficiency reasons.
Please note that the procedure is destructive in the sense that all existing data stored in the task is destroyed.
- Parameters:
maxnumcon
(int32
) – New maximum number of constraints. (input)maxnumvar
(int32
) – New maximum number of variables. (input)maxnumcone
(int32
) – New maximum number of cones. (input)maxnumanz
(int64
) – New maximum number of non-zeros in \(A\). (input)maxnumqnz
(int64
) – New maximum number of non-zeros in all \(Q\) matrices. (input)
- Groups:
- Task.sensitivityreport¶
sensitivityreport(whichstream)
Reads a sensitivity format file from a location given by
sparam.sensitivity_file_name
and writes the result to the streamwhichstream
. Ifsparam.sensitivity_res_file_name
is set to a non-empty string, then the sensitivity report is also written to a file of this name.- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)- Groups:
- Task.set_InfoCallback¶
set_InfoCallback(callback)
Receive callbacks with solver status and information during optimization.
For example:
task.set_InfoCallback(lambda code,dinf,iinf,liinf: print("Called from: {0}".format(code)))
- Parameters:
callback
(callbackfunc
) – The callback function. (input)- Groups:
- Task.set_Progress¶
set_Progress(callback)
Receive callbacks about current status of the solver during optimization.
For example:
task.set_Progress(lambda code: print("Called from: {0}".format(code)))
- Parameters:
callback
(progresscallbackfunc
) – The callback function. (input)- Groups:
- Task.set_Stream¶
set_Stream(whichstream, callback)
Directs all output from a task stream to a callback function.
- Parameters:
whichstream
(streamtype
) – Index of the stream. (input)callback
(streamfunc
) – The callback function. (input)
- Groups:
- Task.solutiondef¶
solutiondef(whichsol) -> (isdef)
Checks whether a solution is defined.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Return:
isdef
(bool
) – Is non-zero if the requested solution is defined.- Groups:
- Task.solutionsummary¶
solutionsummary(whichstream)
Prints a short summary of the current solutions.
- Parameters:
whichstream
(mosek.streamtype
) – Index of the stream. (input)- Groups:
- Task.solvewithbasis¶
solvewithbasis(transp,numnz,sub,val) -> (numnzout)
If a basic solution is available, then exactly \(numcon\) basis variables are defined. These \(numcon\) basis variables are denoted the basis. Associated with the basis is a basis matrix denoted \(B\). This function solves either the linear equation system
(15.3)¶\[B \barX = b\]or the system
(15.4)¶\[B^T \barX = b\]for the unknowns \(\barX\), with \(b\) being a user-defined vector. In order to make sense of the solution \(\barX\) it is important to know the ordering of the variables in the basis because the ordering specifies how \(B\) is constructed. When calling
Task.initbasissolve
an ordering of the basis variables is obtained, which can be used to deduce how MOSEK has constructed \(B\). Indeed if the \(k\)-th basis variable is variable \(x_j\) it implies that\[B_{i,k} = A_{i,j}, ~i=\idxbeg,\ldots,\idxend{\mathtt{numcon}}.\]Otherwise if the \(k\)-th basis variable is variable \(x_j^c\) it implies that
\[\begin{split}B_{i,k} = \left\{ \begin{array}{ll} -1, & i = j, \\ 0 , & i \neq j. \\ \end{array} \right.\end{split}\]The function
Task.initbasissolve
must be called before a call to this function. Please note that this function exploits the sparsity in the vector \(b\) to speed up the computations.- Parameters:
transp
(bool
) – If this argument is zero, then (15.3) is solved, if non-zero then (15.4) is solved. (input)numnz
(int32
) – The number of non-zeros in \(b\). (input)sub
(int32
[]
) – As input it contains the positions of non-zeros in \(b\). As output it contains the positions of the non-zeros in \(\barX\). It must have room for \(numcon\) elements. (input/output)val
(float
[]
) – As input it is the vector \(b\) as a dense vector (although the positions of non-zeros are specified insub
it is required that \(\mathtt{val}[i] = 0\) when \(b[i] = 0\)). As outputval
is the vector \(\barX\) as a dense vector. It must have length \(numcon\). (input/output)
- Return:
numnzout
(int32
) – The number of non-zeros in \(\barX\).- Groups:
- Task.strtoconetype Deprecated¶
strtoconetype(str) -> (conetype)
NOTE: This interface to conic optimization is deprecated and will be removed in a future major release. Conic problems should be specified using the affine conic constraints interface (ACC), see Sec. 6.2 (From Linear to Conic Optimization) for details.
Obtains cone type code corresponding to a cone type string.
- Parameters:
str
(str
) – String corresponding to the cone type codeconetype
. (input)- Return:
conetype
(mosek.conetype
) – The cone type corresponding to the stringstr
.- Groups:
- Task.strtosk¶
strtosk(str) -> (sk)
Obtains the status key corresponding to an abbreviation string.
- Parameters:
str
(str
) – A status key abbreviation string. (input)- Return:
sk
(mosek.stakey
) – Status key corresponding to the string.- Groups:
- Task.toconic Deprecated¶
toconic()
This function tries to reformulate a given Quadratically Constrained Quadratic Optimization problem (QCQO) as a Conic Quadratic Optimization problem (CQO). The first step of the reformulation is to convert the quadratic term of the objective function, if any, into a constraint. Then the following steps are repeated for each quadratic constraint:
a conic constraint is added along with a suitable number of auxiliary variables and constraints;
the original quadratic constraint is not removed, but all its coefficients are zeroed out.
Note that the reformulation preserves all the original variables.
The conversion is performed in-place, i.e. the task passed as argument is modified on exit. That also means that if the reformulation fails, i.e. the given QCQP is not representable as a CQO, then the task has an undefined state. In some cases, users may want to clone the task to ensure a clean copy is preserved.
- Groups:
- Task.updatesolutioninfo¶
updatesolutioninfo(whichsol)
Update the information items related to the solution.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)- Groups:
- Task.writebsolution¶
writebsolution(filename,compress)
Write a binary dump of the task solution.
- Parameters:
filename
(str
) – A valid file name. (input)compress
(mosek.compresstype
) – Data compression type. (input)
- Groups:
- Task.writedata¶
writedata(filename)
Writes problem data associated with the optimization task to a file in one of the supported formats. See Section Supported File Formats for the complete list.
The data file format is determined by the file name extension. To write in compressed format append the extension
.gz
. E.g to write a gzip compressed MPS file use the extensionmps.gz
.Please note that MPS, LP and OPF files require all variables to have unique names. If a task contains no names, it is possible to write the file with automatically generated anonymous names by setting the
iparam.write_generic_names
parameter toonoffkey.on
.Data is written to the file
filename
if it is a nonempty string. Otherwise data is written to the file specified bysparam.data_file_name
.- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.writedatastream¶
writedatastream(format, compress, stream)
Writes problem data associated with the optimization task to a stream in one of the supported formats.
The stream should have a
write
method accepting a byte-like object, typically an instance ofio.BytesIO
will be suitable. Examples:task.writedatastream(dataformat.ptf, compresstype.none, sys.stdout.buffer) task.writedatastream(dataformat.task, compresstype.none, open("outfile.task", "wb"))
- Parameters:
format
(mosek.dataformat
) – Data format. (input)compress
(mosek.compresstype
) – Selects compression type. (input)stream
(iostream
) – The output stream. (input)
- Groups:
- Task.writejsonsol¶
writejsonsol(filename)
Saves the current solutions and solver information items in a JSON file. If the file name has the extensions .gz or .zst, then the file is gzip or Zstd compressed respectively.
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.writeparamfile¶
writeparamfile(filename)
Writes all the parameters to a parameter file.
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.writesolution¶
writesolution(whichsol,filename)
Saves the current basic, interior-point, or integer solution to a file.
- Parameters:
whichsol
(mosek.soltype
) – Selects a solution. (input)filename
(str
) – A valid file name. (input)
- Groups:
- Task.writesolutionfile¶
writesolutionfile(filename)
Write solution file in format determined by the filename
- Parameters:
filename
(str
) – A valid file name. (input)- Groups:
- Task.writetask¶
writetask(filename)
Write a binary dump of the task data. This format saves all problem data, coefficients and parameter settings. See section The Task Format for a description of the Task format.
- Parameters:
filename
(str
) – A valid file name. (input)- Groups: