picos.expressions.variables¶
Implements all mathematical variable types and their base class.
Classes
- class picos.expressions.variables.BaseVariable(name, vectorization, lower=None, upper=None)[source]¶
Bases:
Mutable
Primary base class for all variable types.
Variables need to inherit this class with priority (first class listed) and
ComplexAffineExpression
orAffineExpression
without priority.- __init__(name, vectorization, lower=None, upper=None)[source]¶
Perform basic initialization for
BaseVariable
instances.- Parameters
name (str) – Name of the variable. A leading “__” denotes a private variable and is replaced by a sequence containing the variable’s unique ID.
vectorization (BaseVectorization) – Vectorization format used to store the value.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- classmethod make_var_type(*args, **kwargs)[source]¶
Create a detailed variable type from subtype parameters.
See also
var_type
.
- property bound_dicts[source]¶
Variable bounds as a pair of mappings from index to scalar bound.
The indices and bound values are with respect to the internal representation of the variable, whose value can be accessed with
internal_value
.Upper and lower bounds set to
float("inf")
andfloat("-inf")
on variable creation, respectively, are not included.
- property num_bounds¶
Number of scalar bounds associated with the variable.
- property var_type¶
The detailed variable type.
This intentionally does not override
Expression.type
so that the variable still behaves as the affine expression that it represents when prediction constraint outcomes.
- class picos.expressions.variables.BinaryVariable(name, shape=(1, 1))[source]¶
Bases:
BaseVariable
,AffineExpression
A
-valued variable.
- class picos.expressions.variables.ComplexVariable(name, shape=(1, 1))[source]¶
Bases:
BaseVariable
,ComplexAffineExpression
A complex-valued variable.
Passed to solvers as a real variable vector with
entries.
- class picos.expressions.variables.HermitianVariable(name, shape)[source]¶
Bases:
BaseVariable
,ComplexAffineExpression
A hermitian matrix variable.
Stored internally and passed to solvers as the horizontal concatenation of a real symmetric vectorization with
entries and a real skew-symmetric vectorization with
entries, resulting in a real vector with only
entries total.
- class picos.expressions.variables.IntegerVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
An integer-valued variable.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create an
IntegerVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
shape (int or tuple or list) – The shape of a vector or matrix variable.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.LowerTriangularVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
A lower triangular matrix variable.
Stored internally and passed to solvers as a lower triangular vectorization with only
entries.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create a
LowerTriangularVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.RealVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
A real-valued variable.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create a
RealVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
shape (int or tuple or list) – The shape of a vector or matrix variable.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.SkewSymmetricVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
A skew-symmetric matrix variable.
Stored internally and passed to solvers as a skew-symmetric vectorization with only
entries.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create a
SkewSymmetricVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.SymmetricVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
A symmetric matrix variable.
Stored internally and passed to solvers as a symmetric vectorization with only
entries.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create a
SymmetricVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.UpperTriangularVariable(name, shape=(1, 1), lower=None, upper=None)[source]¶
Bases:
BaseVariable
,AffineExpression
An upper triangular matrix variable.
Stored internally and passed to solvers as an upper triangular vectorization with only
entries.
- __init__(name, shape=(1, 1), lower=None, upper=None)[source]¶
Create a
UpperTriangularVariable
.- Parameters
name (str) – The variable’s name, used for both string description and identification.
lower – Constant lower bound on the variable. May contain
float("-inf")
to denote unbounded elements.upper – Constant upper bound on the variable. May contain
float("inf")
to denote unbounded elements.
- class picos.expressions.variables.VariableType(theClass, subtype)[source]¶
Bases:
DetailedType
The detailed type of a variable for predicting reformulation outcomes.
Objects
- picos.expressions.variables.CONTINUOUS_VARTYPES¶
Built-in immutable sequence.
If no argument is given, the constructor returns an empty tuple. If iterable is specified the tuple is initialized from iterable’s items.
If the argument is a tuple, the return value is the same object.
- Default value
(<class 'picos.expressions.variables.RealVariable'>, <class 'picos.expressions.variables.ComplexVariable'>, <class 'picos.expressions.variables.SymmetricVariable'>, <class 'picos.expressions.variables.SkewSymmetricVariable'>, <class...