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 , 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.unbounded – Creates a domain in which variables are unbounded.
- Domain.axis¶
ConeDomain::t Domain::axis(ConeDomain::t c, int a)
Set the dimension along which the cones are created. If this conic domain is used for a variable or expression of dimension
, then the conic constraint will be applicable to all vectors obtained by fixing the coordinates other than -th and moving along the -th coordinate. If 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
.- Parameters:
c
(ConeDomain
) – A conic domain.a
(int
) – The axis.
- Return:
- Domain.binary¶
RangeDomain::t Domain::binary(int n) RangeDomain::t Domain::binary(int m, int n) RangeDomain::t Domain::binary(shared_ptr<ndarray<int,1>> dims) RangeDomain::t Domain::binary()
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¶
LinearDomain::t Domain::equalsTo(double b) LinearDomain::t Domain::equalsTo(double b, int n) LinearDomain::t Domain::equalsTo(double b, int m, int n) LinearDomain::t Domain::equalsTo(double b, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::equalsTo(shared_ptr<ndarray<double,1>> a1) LinearDomain::t Domain::equalsTo(shared_ptr<ndarray<double,2>> a2) LinearDomain::t Domain::equalsTo(shared_ptr<ndarray<double,1>> a1, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::equalsTo(Matrix::t mx)
Defines the domain consisting of a fixed point.
- Parameters:
b
(double
) – A single value. This is scalable: it means that each element in the variable or constraint is fixed to .n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(double
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(double
[][]) – 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¶
LinearDomain::t Domain::greaterThan(double b) LinearDomain::t Domain::greaterThan(double b, int n) LinearDomain::t Domain::greaterThan(double b, int m, int n) LinearDomain::t Domain::greaterThan(double b, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::greaterThan(shared_ptr<ndarray<double,1>> a1) LinearDomain::t Domain::greaterThan(shared_ptr<ndarray<double,2>> a2) LinearDomain::t Domain::greaterThan(shared_ptr<ndarray<double,1>> a1, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::greaterThan(Matrix::t mx)
Defines the domain specified by a lower bound in each dimension.
- Parameters:
b
(double
) – A single value. This is scalable: it means that each element in the variable or constraint is greater than or equal to .n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(double
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(double
[][]) – 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¶
ConeDomain::t Domain::inDExpCone() ConeDomain::t Domain::inDExpCone(int m) ConeDomain::t Domain::inDExpCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of dual exponential cones:
The conic domain scales as follows. If a variable or expression constrained to an exponential cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of such cones.- Parameters:
m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return:
- Domain.inDGeoMeanCone¶
ConeDomain::t Domain::inDGeoMeanCone() ConeDomain::t Domain::inDGeoMeanCone(int n) ConeDomain::t Domain::inDGeoMeanCone(int m, int n) ConeDomain::t Domain::inDGeoMeanCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of dual geometric mean cones:
The conic domain scales as follows. If a variable or expression constrained to a cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of 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¶
ConeDomain::t Domain::inDPowerCone(double alpha) ConeDomain::t Domain::inDPowerCone(double alpha, int m) ConeDomain::t Domain::inDPowerCone(double alpha, shared_ptr<ndarray<int,1>> dims) ConeDomain::t Domain::inDPowerCone(shared_ptr<ndarray<double,1>> alphas) ConeDomain::t Domain::inDPowerCone(shared_ptr<ndarray<double,1>> alphas, int m) ConeDomain::t Domain::inDPowerCone(shared_ptr<ndarray<double,1>> alphas, shared_ptr<ndarray<int,1>> dims)
Defines the domain of dual power cones. For a single double argument
alpha
it defines the setFor an array
alphas
of length , consisting of weights for the cone, it defines the setwhere
are the weights normalized to add up to , ie. for .The conic domain scales as follows. If a variable or expression constrained to a power cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of such cones.- Parameters:
alpha
(double
) – 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
(double
[]) – The weights of the power cone. Must be positive.
- Return:
- Domain.inPExpCone¶
ConeDomain::t Domain::inPExpCone() ConeDomain::t Domain::inPExpCone(int m) ConeDomain::t Domain::inPExpCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of primal exponential cones:
The conic domain scales as follows. If a variable or expression constrained to an exponential cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of such cones.- Parameters:
m
(int
) – The number of cones (default 1).dims
(int
[]) – Shape of the domain.
- Return:
- Domain.inPGeoMeanCone¶
ConeDomain::t Domain::inPGeoMeanCone() ConeDomain::t Domain::inPGeoMeanCone(int n) ConeDomain::t Domain::inPGeoMeanCone(int m, int n) ConeDomain::t Domain::inPGeoMeanCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of primal geometric mean cones:
The conic domain scales as follows. If a variable or expression constrained to a cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of 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¶
ConeDomain::t Domain::inPPowerCone(double alpha) ConeDomain::t Domain::inPPowerCone(double alpha, int m) ConeDomain::t Domain::inPPowerCone(double alpha, shared_ptr<ndarray<int,1>> dims) ConeDomain::t Domain::inPPowerCone(shared_ptr<ndarray<double,1>> alphas) ConeDomain::t Domain::inPPowerCone(shared_ptr<ndarray<double,1>> alphas, int m) ConeDomain::t Domain::inPPowerCone(shared_ptr<ndarray<double,1>> alphas, shared_ptr<ndarray<int,1>> dims)
Defines the domain of primal power cones. For a single double argument
alpha
it defines the setFor an array
alphas
of length , consisting of weights for the cone, it defines the setwhere
are the weights normalized to add up to , ie. for .The conic domain scales as follows. If a variable or expression constrained to a power cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of such cones.- Parameters:
alpha
(double
) – 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
(double
[]) – The weights of the power cone. Must be positive.
- Return:
- Domain.inPSDCone¶
PSDDomain::t Domain::inPSDCone() PSDDomain::t Domain::inPSDCone(int n) PSDDomain::t Domain::inPSDCone(int n, int m)
When used to create a new variable in
Model.variable
it defines a domain of symmetric positive semidefinite matrices, that isThe shape of the result is
. If was given the domain is a product of such cones, that is of shape .When used to impose a constraint in
Model.constraint
it defines a domaini.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¶
ConeDomain::t Domain::inQCone() ConeDomain::t Domain::inQCone(int n) ConeDomain::t Domain::inQCone(int m, int n) ConeDomain::t Domain::inQCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of quadratic cones:
The conic domain scales as follows. If a variable or expression constrained to a quadratic cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of 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¶
RangeDomain::t Domain::inRange(double lb, double ub) RangeDomain::t Domain::inRange(double lb, shared_ptr<ndarray<double,1>> uba) RangeDomain::t Domain::inRange(shared_ptr<ndarray<double,1>> lba, double ub) RangeDomain::t Domain::inRange(shared_ptr<ndarray<double,1>> lba, shared_ptr<ndarray<double,1>> uba) RangeDomain::t Domain::inRange(double lb, double ub, shared_ptr<ndarray<int,1>> dims) RangeDomain::t Domain::inRange(double lb, shared_ptr<ndarray<double,1>> uba, shared_ptr<ndarray<int,1>> dims) RangeDomain::t Domain::inRange(shared_ptr<ndarray<double,1>> lba, double ub, shared_ptr<ndarray<int,1>> dims) RangeDomain::t Domain::inRange(shared_ptr<ndarray<double,1>> lba, shared_ptr<ndarray<double,1>> uba, shared_ptr<ndarray<int,1>> dims) RangeDomain::t Domain::inRange(shared_ptr<ndarray<double,2>> lba, shared_ptr<ndarray<double,2>> uba) RangeDomain::t Domain::inRange(Matrix::t lbm, Matrix::t ubm)
Creates a domain specified by a range in each dimension.
- Parameters:
lb
(double
) – The lower bound as a common scalar value.ub
(double
) – The upper bound as a common scalar value.uba
(double
[]) – The upper bounds as an array.uba
(double
[][]) – The upper bounds as an array.lba
(double
[]) – The lower bounds as an array.lba
(double
[][]) – The lower bounds as an array.dims
(int
[]) – A list of dimension sizes.
- Return:
- Domain.inRotatedQCone¶
ConeDomain::t Domain::inRotatedQCone() ConeDomain::t Domain::inRotatedQCone(int n) ConeDomain::t Domain::inRotatedQCone(int m, int n) ConeDomain::t Domain::inRotatedQCone(shared_ptr<ndarray<int,1>> dims)
Defines the domain of rotated quadratic cones:
The conic domain scales as follows. If a variable or expression constrained to a quadratic cone is not a single vector but a
-dimensional variable then the conic domain is applicable to all vectors obtained by fixing the first coordinates and moving along the last coordinate. If it means that each row of a matrix must belong to a cone. See alsoDomain.axis
.If
was given the domain is a product of 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¶
ConeDomain::t Domain::inSVecPSDCone() ConeDomain::t Domain::inSVecPSDCone(int n) ConeDomain::t Domain::inSVecPSDCone(int d1, int d2) ConeDomain::t Domain::inSVecPSDCone(shared_ptr<ndarray<int,1>> dims)
Creates a domain of vectorized Positive Semidefinite matrices:
where
and
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 for some positive integer .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¶
ConeDomain::t Domain::integral(ConeDomain::t c) LinearDomain::t Domain::integral(LinearDomain::t ld) RangeDomain::t Domain::integral(RangeDomain::t rd)
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¶
PSDDomain::t Domain::isTrilPSD() PSDDomain::t Domain::isTrilPSD(int n) PSDDomain::t Domain::isTrilPSD(int n, int m)
Creates an object representing a cone of the form
i.e. the lower triangular part of
defines the symmetric matrix that is positive semidefinite. The shape of the result is . If was given the domain is a product of such cones, that is of shape .- Parameters:
n
(int
) – Dimension of the PSD matrix.m
(int
) – Number of matrices (default 1).
- Return:
- Domain.lessThan¶
LinearDomain::t Domain::lessThan(double b) LinearDomain::t Domain::lessThan(double b, int n) LinearDomain::t Domain::lessThan(double b, int m, int n) LinearDomain::t Domain::lessThan(double b, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::lessThan(shared_ptr<ndarray<double,1>> a1) LinearDomain::t Domain::lessThan(shared_ptr<ndarray<double,2>> a2) LinearDomain::t Domain::lessThan(shared_ptr<ndarray<double,1>> a1, shared_ptr<ndarray<int,1>> dims) LinearDomain::t Domain::lessThan(Matrix::t mx)
Defines the domain specified by an upper bound in each dimension.
- Parameters:
b
(double
) – A single value. This is scalable: it means that each element in the variable or constraint is less than or equal to .n
(int
) – Dimension size.m
(int
) – Dimension size.dims
(int
[]) – A list of dimension sizes.a1
(double
[]) – A one-dimensional array of bounds. The shape must match the variable or constraint with which it is used.a2
(double
[][]) – 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¶
LinearDomain::t Domain::sparse(LinearDomain::t ld, shared_ptr<ndarray<int,1>> sparsity) LinearDomain::t Domain::sparse(LinearDomain::t ld, shared_ptr<ndarray<int,2>> sparsity) RangeDomain::t Domain::sparse(RangeDomain::t rd, shared_ptr<ndarray<int,1>> sparsity) RangeDomain::t Domain::sparse(RangeDomain::t rd, shared_ptr<ndarray<int,2>> sparsity)
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.unbounded¶
LinearDomain::t Domain::unbounded() LinearDomain::t Domain::unbounded(int n) LinearDomain::t Domain::unbounded(int m, int n) LinearDomain::t Domain::unbounded(shared_ptr<ndarray<int,1>> dims)
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: