Backend for constraint type implementations.
Constraint(typeTerm, customString=None, printSize=False)¶
Abstract base class for optimization constraints.
need to implement at least the abstract methods
need to implement
_get_size, unless duals are not supported, and
are supposed to call
Constraint.__init__from within their own implementation of
__init__(typeTerm, customString=None, printSize=False)¶
Perform basic initialization for
Return an algebraic string representation of the constraint.
Formerly this would remove the constraint from the single problem it is assigned to, if any.
Deprecated since version 2.0: Both variables and constraints have been decoupled from problems: Both may safely appear in multiple problems but at the same time they do not know which problems they were added to. To remove a constraint from a problem, you have to call its
Whether the left side is posed greater or equal than the right.
Whether the constraints states an equality.
Whether the left side is posed smaller or equal than the right.
Whether the constraints states an inequality.
Return the regular string representation.
Create a detailed constraint type from subtype parameters.
Make the constraint concern a different set of variables.
Value of the constraint’s Lagrange dual variable.
Yield expressions stored with the constraint.
The unique ID of the constraint, assigned at creation.
The ID is kept when the constraint is copied via
replace_variables, so that the copy can be identified with the original despite pointing to different expressions and variable objects.
Langrange dual variable shape.
The dimensionality of the constraint, more precisely the dimensionality of its Lagrange dual variable, as a pair.
Value of a slack variable or of the negative constraint violation.
A negative value whose absolute value corresponds to the amount of violation, if the constraint is violated, or a non-negative value that corresponds to the value of a slack variable, otherwise.
Detailed type of the constraint.
The detailed type of the constraint, which is suffcient to predict the outcome (detailed types and quantities of auxilary variables and constraints) of any constraint conversion.
All variables referenced by the constraint.
Recipe for conversion from one constraint to a set of other constraints.
Implementations of this class are defined within the class body of a Constraint implementation to tell PICOS’ reformulation framework how that constraint can be reformulated into a number of other constraints and auxiliary variables.
Implementation class names must end in
Conversion, and in particular may be called just
Conversion. If for instance
AffineConversion, then the reformulation will be coined
AbsoluteValueToAffineReformulation. If the conversions was just named
Conversion, the result would be a class named
Convert a given constraint.
Returns a temporary problem instance that contains auxilary constraints and variables replacing the given constraint.
dual(auxVarPrimals, auxConDuals, options)¶
Convert back the dual value of a constraint that was converted.
Given a mapping of auxilary variable names (as named in
convert) to primals and a list of auxilary constraint duals (in the order as the constraints were added in
convert), returns a dual value for the converted constraint.
NotImplementedError – When dual format not decided upon or not known. This will be caught by the reformulation’s backward method.
Predict the outcome of a constraint conversion.
Records to be added to a problem footprint when an instance of the parent constraint with the given subtype is converted according to this conversion.
- abstract classmethod