14.2.12 Class Domain¶
- mosek.fusion.Domain¶
The
Domain
class defines a set of static method for creating various variable and constraint domains. ADomain
object specifies a subset of \(\real^n\), which can be used to define the feasible domain of variables and expressions.For further details on the use of these, see
Model.variable
andModel.constraint
.- Static members
Domain.axis – Set the dimension along which the cones are created.
Domain.binary – Creates a domain of binary variables.
Domain.equalsTo (==) – Defines the domain consisting of a fixed point.
Domain.greaterThan (>=) – Defines the domain specified by a lower bound in each dimension.
Domain.inDExpCone – Defines the dual exponential cone.
Domain.inDGeoMeanCone – Defines the domain of dual geometric mean cones.
Domain.inDPowerCone – Defines the dual power cone.
Domain.inPExpCone – Defines the primal exponential cone.
Domain.inPGeoMeanCone – Defines the domain of primal geometric mean cones.
Domain.inPPowerCone – Defines the primal power cone.
Domain.inPSDCone – Creates a domain of Positive Semidefinite matrices.
Domain.inQCone – Defines the domain of quadratic cones.
Domain.inRange – Creates a domain specified by a range in each dimension.
Domain.inRotatedQCone – Defines the domain of rotated quadratic cones.
Domain.inSVecPSDCone – Creates a domain of vectorized Positive Semidefinite matrices.
Domain.integral – Creates a domain of integral variables.
Domain.isTrilPSD – Creates a domain of Positive Semidefinite matrices.
Domain.lessThan (<=) – Defines the domain specified by an upper bound in each dimension.
Domain.sparse – Use a sparse representation.
Domain.symmetric – Impose symmetry on a given linear domain.
Domain.unbounded – Creates a domain in which variables are unbounded.
- Domain.axis¶
Domain.axis(ConeDomain c, int a) -> ConeDomain
Set the dimension along which the cones are created. If this conic domain is used for a variable or expression of dimension \(d\), then the conic constraint will be applicable to all vectors obtained by fixing the coordinates other than \(a\)-th and moving along the \(a\)-th coordinate. If \(d=2\) this can be used to define the conditions “every row of the matrix is in a cone” and “every column of a matrix is in a cone”.
The default is the last dimension \(a=d-1\).
- Parameters
c
(ConeDomain
) – A conic domain.a
(int
) – The axis.
- Return
- Domain.binary¶
Domain.binary(int n) -> RangeDomain Domain.binary(int m, int n) -> RangeDomain Domain.binary(int[] dims) -> RangeDomain Domain.binary() -> RangeDomain
Create a domain of binary variables. A binary domain can only be used when creating variables, but is not allowed in a constraint. Another way of restricting variables to be integers is the method
Variable.makeInteger
.- Parameters
n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.
- Return
- Domain.equalsTo (==)¶
Domain.equalsTo(float b) -> LinearDomain Domain.equalsTo(float b, int n) -> LinearDomain Domain.equalsTo(float b, int m, int n) -> LinearDomain Domain.equalsTo(float b, int[] dims) -> LinearDomain Domain.equalsTo(float[] a1) -> LinearDomain Domain.equalsTo(float[][] a2) -> LinearDomain Domain.equalsTo(float[] a1, int[] dims) -> LinearDomain Domain.equalsTo(Matrix mx) -> LinearDomain
Defines the domain consisting of a fixed point.
The standard Python operator
==
can also be used for this purpose. See Sec. 14.1.3 (Pythonic extensions) for details.- Parameters
b
(float
) – A single value. This is scalable: it means that each element in the variable or constraint is fixed to \(b\).n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(float
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(float
[][]) – A two-dimensional array of bounds. The shape must match the variable or constraint with which it is used.mx
(Matrix
) – A matrix of bound values. The shape must match the variable or constraint with which it is used.
- Return
- Domain.greaterThan (>=)¶
Domain.greaterThan(float b) -> LinearDomain Domain.greaterThan(float b, int n) -> LinearDomain Domain.greaterThan(float b, int m, int n) -> LinearDomain Domain.greaterThan(float b, int[] dims) -> LinearDomain Domain.greaterThan(float[] a1) -> LinearDomain Domain.greaterThan(float[][] a2) -> LinearDomain Domain.greaterThan(float[] a1, int[] dims) -> LinearDomain Domain.greaterThan(Matrix mx) -> LinearDomain
Defines the domain specified by a lower bound in each dimension.
The standard Python operator
>=
can also be used for this purpose. See Sec. 14.1.3 (Pythonic extensions) for details.- Parameters
b
(float
) – A single value. This is scalable: it means that each element in the variable or constraint is greater than or equal to \(b\).n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(float
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(float
[][]) – A two-dimensional array of bounds. The shape must match the variable or constraint with which it is used.mx
(Matrix
) – A matrix of bound values. The shape must match the variable or constraint with which it is used.
- Return
- Domain.inDExpCone¶
Domain.inDExpCone() -> ConeDomain Domain.inDExpCone(int m) -> ConeDomain Domain.inDExpCone(int[] dims) -> ConeDomain
Defines the domain of dual exponential cones:
\[\left\{ x\in \real^3 ~:~ x_1 \geq -x_3 e^{-1} e^{x_2/x_3},\ x_1> 0,\ x_3< 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to an exponential cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inDGeoMeanCone¶
Domain.inDGeoMeanCone() -> ConeDomain Domain.inDGeoMeanCone(int n) -> ConeDomain Domain.inDGeoMeanCone(int m, int n) -> ConeDomain Domain.inDGeoMeanCone(int[] dims) -> ConeDomain
Defines the domain of dual geometric mean cones:
\[\left\{ x\in \real^n ~:~ (n-1) \left(\prod_{i=1}^{n-1} x_i\right)^{1/(n-1)} \geq |x_n|,\ x_1,\ldots,x_{n-1}\geq 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to a cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
n
(int
) – The size of each cone; at least 2.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inDPowerCone¶
Domain.inDPowerCone(float alpha) -> ConeDomain Domain.inDPowerCone(float alpha, int m) -> ConeDomain Domain.inDPowerCone(float alpha, int[] dims) -> ConeDomain Domain.inDPowerCone(float[] alphas) -> ConeDomain Domain.inDPowerCone(float[] alphas, int m) -> ConeDomain Domain.inDPowerCone(float[] alphas, int[] dims) -> ConeDomain
Defines the domain of dual power cones. For a single double argument
alpha
it defines the set\[\left\{ x\in \real^n ~:~ \left(\frac{x_1}{\alpha}\right)^\alpha \left(\frac{x_2}{1-\alpha}\right)^{1-\alpha} \geq \sqrt{\sum_{i=3}^n x_i^2},\ x_1,x_2\geq 0 \right\}.\]For an array
alphas
of length \(n_l\), consisting of weights for the cone, it defines the set\[\left\{ x\in\real^n~:~ \prod_{i=1}^{n_l}\left(\frac{x_i}{\beta_i}\right)^{\beta_i} \geq \sqrt{x_{n_l+1}^2+\cdots+x_n^2},\ x_1,\ldots,x_{n_l}\geq 0 \right\}.\]where \(\beta_i\) are the weights normalized to add up to \(1\), ie. \(\beta_i=\alpha_i/(\sum_j \alpha_j)\) for \(i=1,\ldots,n_l\).
The conic domain scales as follows. If a variable or expression constrained to a power cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
alpha
(float
) – The exponent of the power cone. Must be between 0 and 1.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.alphas
(float
[]) – The weights of the power cone. Must be positive.
- Return
- Domain.inPExpCone¶
Domain.inPExpCone() -> ConeDomain Domain.inPExpCone(int m) -> ConeDomain Domain.inPExpCone(int[] dims) -> ConeDomain
Defines the domain of primal exponential cones:
\[\left\{ x\in \real^3 ~:~ x_1 \geq x_2 e^{x_3/x_2},\ x_1,x_2> 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to an exponential cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inPGeoMeanCone¶
Domain.inPGeoMeanCone() -> ConeDomain Domain.inPGeoMeanCone(int n) -> ConeDomain Domain.inPGeoMeanCone(int m, int n) -> ConeDomain Domain.inPGeoMeanCone(int[] dims) -> ConeDomain
Defines the domain of primal geometric mean cones:
\[\left\{ x\in \real^n ~:~ \left(\prod_{i=1}^{n-1} x_i\right)^{1/(n-1)} \geq |x_n|,\ x_1\ldots,x_{n-1}\geq 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to a cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
n
(int
) – The size of each cone; at least 2.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inPPowerCone¶
Domain.inPPowerCone(float alpha) -> ConeDomain Domain.inPPowerCone(float alpha, int m) -> ConeDomain Domain.inPPowerCone(float alpha, int[] dims) -> ConeDomain Domain.inPPowerCone(float[] alphas) -> ConeDomain Domain.inPPowerCone(float[] alphas, int m) -> ConeDomain Domain.inPPowerCone(float[] alphas, int[] dims) -> ConeDomain
Defines the domain of primal power cones. For a single double argument
alpha
it defines the set\[\left\{ x\in \real^n ~:~ x_1^\alpha x_2^{1-\alpha} \geq \sqrt{\sum_{i=3}^n x_i^2},\ x_1,x_2\geq 0 \right\}.\]For an array
alphas
of length \(n_l\), consisting of weights for the cone, it defines the set\[\left\{ x\in\real^n~:~ \prod_{i=1}^{n_l}x_i^{\beta_i} \geq \sqrt{x_{n_l+1}^2+\cdots+x_n^2},\ x_1,\ldots,x_{n_l}\geq 0 \right\}.\]where \(\beta_i\) are the weights normalized to add up to \(1\), ie. \(\beta_i=\alpha_i/(\sum_j \alpha_j)\) for \(i=1,\ldots,n_l\).
The conic domain scales as follows. If a variable or expression constrained to a power cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
alpha
(float
) – The exponent of the power cone. Must be between 0 and 1.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.alphas
(float
[]) – The weights of the power cone. Must be positive.
- Return
- Domain.inPSDCone¶
Domain.inPSDCone() -> PSDDomain Domain.inPSDCone(int n) -> PSDDomain Domain.inPSDCone(int n, int m) -> PSDDomain
When used to create a new variable in
Model.variable
it defines a domain of symmetric positive semidefinite matrices, that is\[\PSD^n = \left\{ X \in \real^{n\times n} ~:~ X=X^T,\ y^TXy\geq 0,\ \mbox{for all}\ y \right\}.\]The shape of the result is \(n\times n\). If \(m\) was given the domain is a product of \(m\) such cones, that is of shape \(m\times n\times n\).
When used to impose a constraint in
Model.constraint
it defines a domain\[\left\{ X \in \real^{n\times n} ~:~ \half (X + X^T) \in \PSD^n \right\}.\]i.e. a positive semidefinite matrix without the symmetry assumption.
- Parameters
n
(int
) – Dimension of the PSD matrix.m
(int
) – Number of matrices (default 1).
- Return
- Domain.inQCone¶
Domain.inQCone() -> ConeDomain Domain.inQCone(int n) -> ConeDomain Domain.inQCone(int m, int n) -> ConeDomain Domain.inQCone(int[] dims) -> ConeDomain
Defines the domain of quadratic cones:
\[\left\{ x\in \real^n ~:~ x_1^2 \geq \sum_{i=2}^n x_i^2,~ x_1 \geq 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to a quadratic cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
n
(int
) – The size of each cone; at least 2.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inRange¶
Domain.inRange(float lb, float ub) -> RangeDomain Domain.inRange(float lb, float[] uba) -> RangeDomain Domain.inRange(float[] lba, float ub) -> RangeDomain Domain.inRange(float[] lba, float[] uba) -> RangeDomain Domain.inRange(float lb, float ub, int[] dims) -> RangeDomain Domain.inRange(float lb, float[] uba, int[] dims) -> RangeDomain Domain.inRange(float[] lba, float ub, int[] dims) -> RangeDomain Domain.inRange(float[] lba, float[] uba, int[] dims) -> RangeDomain Domain.inRange(float[][] lba, float[][] uba) -> RangeDomain Domain.inRange(Matrix lbm, Matrix ubm) -> RangeDomain
Creates a domain specified by a range in each dimension.
- Parameters
lb
(float
) – The lower bound as a common scalar value.ub
(float
) – The upper bound as a common scalar value.uba
(float
[]) – The upper bounds as an array.uba
(float
[][]) – The upper bounds as an array.lba
(float
[]) – The lower bounds as an array.lba
(float
[][]) – The lower bounds as an array.dims
(int
[]) – A list of dimension sizes.
- Return
- Domain.inRotatedQCone¶
Domain.inRotatedQCone() -> ConeDomain Domain.inRotatedQCone(int n) -> ConeDomain Domain.inRotatedQCone(int m, int n) -> ConeDomain Domain.inRotatedQCone(int[] dims) -> ConeDomain
Defines the domain of rotated quadratic cones:
\[\left\{ x\in\real^n ~:~ 2x_1 x_2 \geq \sum_{i=3}^n x_i^2,~ x_1,x_2 \geq 0 \right\}\]The conic domain scales as follows. If a variable or expression constrained to a quadratic cone is not a single vector but a \(d\)-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first \(d-1\) coordinates and moving along the last coordinate. If \(d=2\) it means that each row of a matrix must belong to a cone. See also
Domain.axis
.If \(m\) was given the domain is a product of \(m\) such cones.
- Parameters
n
(int
) – The size of each cone; at least 3.m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return
- Domain.inSVecPSDCone¶
Domain.inSVecPSDCone() -> ConeDomain Domain.inSVecPSDCone(int n) -> ConeDomain Domain.inSVecPSDCone(int d1, int d2) -> ConeDomain Domain.inSVecPSDCone(int[] dims) -> ConeDomain
Creates a domain of vectorized Positive Semidefinite matrices:
\[\{(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.
- Parameters
n
(int
) – Length of the vectorization - this must be of the form \(d*(d+1)/2\) for some positive integer \(d\).d1
(int
) – Size of first dimension of the domain.d2
(int
) – Size of second dimension of the domain.dims
(int
[]) – Shape of the domain.
- Return
- Domain.integral¶
Domain.integral(ConeDomain c) -> ConeDomain Domain.integral(LinearDomain ld) -> LinearDomain Domain.integral(RangeDomain rd) -> RangeDomain
Modify a given domain restricting its elements to be integral. An integral domain can only be used when creating variables, but is not allowed in a constraint. Another way of restricting variables to be integers is the method
Variable.makeInteger
.- Parameters
c
(ConeDomain
) – A conic domain.ld
(LinearDomain
) – A linear domain.rd
(RangeDomain
) – A ranged domain.
- Return
- Domain.isTrilPSD¶
Domain.isTrilPSD() -> PSDDomain Domain.isTrilPSD(int n) -> PSDDomain Domain.isTrilPSD(int n, int m) -> PSDDomain
Creates an object representing a cone of the form
\[\left\{ X \in \real^{n\times n} ~:~ \mbox{tril}(X) \in \PSD^n \right\}.\]i.e. the lower triangular part of \(X\) defines the symmetric matrix that is positive semidefinite. The shape of the result is \(n\times n\). If \(m\) was given the domain is a product of \(m\) such cones, that is of shape \(m\times n\times n\).
- Parameters
n
(int
) – Dimension of the PSD matrix.m
(int
) – Number of matrices (default 1).
- Return
- Domain.lessThan (<=)¶
Domain.lessThan(float b) -> LinearDomain Domain.lessThan(float b, int n) -> LinearDomain Domain.lessThan(float b, int m, int n) -> LinearDomain Domain.lessThan(float b, int[] dims) -> LinearDomain Domain.lessThan(float[] a1) -> LinearDomain Domain.lessThan(float[][] a2) -> LinearDomain Domain.lessThan(float[] a1, int[] dims) -> LinearDomain Domain.lessThan(Matrix mx) -> LinearDomain
Defines the domain specified by an upper bound in each dimension.
The standard Python operator
<=
can also be used for this purpose. See Sec. 14.1.3 (Pythonic extensions) for details.- Parameters
b
(float
) – A single value. This is scalable: it means that each element in the variable or constraint is less than or equal to \(b\).n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(float
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(float
[][]) – A two-dimensional array of bounds. The shape must match the variable or constraint with which it is used.mx
(Matrix
) – A matrix of bound values. The shape must match the variable or constraint with which it is used.
- Return
- Domain.sparse¶
Domain.sparse(LinearDomain ld, int[] sparsity) -> LinearDomain Domain.sparse(LinearDomain ld, int[][] sparsity) -> LinearDomain Domain.sparse(RangeDomain rd, int[] sparsity) -> RangeDomain Domain.sparse(RangeDomain rd, int[][] sparsity) -> RangeDomain
Given a linear domain, this method explicitly suggest to Fusion that a sparse representation is helpful.
- Parameters
ld
(LinearDomain
) – The linear sparse domain.sparsity
(int
[]) – Sparsity pattern.sparsity
(int
[][]) – Sparsity pattern.rd
(RangeDomain
) – The ranged sparse domain.
- Return
- Domain.symmetric¶
Domain.symmetric(LinearDomain ld) -> SymmetricLinearDomain Domain.symmetric(RangeDomain rd) -> SymmetricRangeDomain
Given a linear domain \(D\) whose shape is that of square matrices, this method returns a domain consisting of symmetric matrices in \(D\).
- Parameters
ld
(LinearDomain
) – The linear domain to be symmetrized.rd
(RangeDomain
) – The ranged domain to be symmetrized.
- Return
- Domain.unbounded¶
Domain.unbounded() -> LinearDomain Domain.unbounded(int n) -> LinearDomain Domain.unbounded(int m, int n) -> LinearDomain Domain.unbounded(int[] dims) -> LinearDomain
Creates a domain in which variables are unbounded.
- Parameters
n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.
- Return