Backend for constraint type implementations.
- class picos.constraints.constraint.ConicConstraint(typeTerm, customString=None, printSize=False)[source]¶
Base class for constraints with an immediate conic representation.
- abstract property conic_membership_form¶
The constraint in conic membership form.
For a conic constraint this is the pair where is an affine expression and a basic cone supported by PICOS.
- property conic_standard_form[source]¶
The constraint in conic standard form.
For a conic constraint this is the triple where is a linear expression, is a constant, and a basic cone supported by PICOS.
- class picos.constraints.constraint.Constraint(typeTerm, customString=None, printSize=False)[source]¶
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)[source]¶
Perform basic initialization for
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
- classmethod make_type(*args, **kwargs)[source]¶
Create a detailed constraint type from subtype parameters.
Make the constraint concern a different set of mutables.
- EQ = '='¶
- GE = '>'¶
- LE = '<'¶
- property dual¶
Value of the constraint’s Lagrange dual variable.
- property expressions¶
Yield expressions stored with the constraint.
- property id¶
The unique ID of the constraint, assigned at creation.
The ID is kept when the constraint is copied via
replace_mutables, so that the copy can be identified with the original despite pointing to different expressions and mutable objects.
- property size¶
Langrange dual variable shape.
The dimensionality of the constraint, more precisely the dimensionality of its Lagrange dual variable, as a pair.
- property slack¶
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.
- property subtype¶
- property type¶
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.
- class picos.constraints.constraint.ConstraintConversion[source]¶
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
- abstract classmethod convert(constraint, options)[source]¶
Convert a given constraint.
Returns a temporary problem instance that contains auxilary constraints and variables replacing the given constraint.
- classmethod dual(auxVarPrimals, auxConDuals, options)[source]¶
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.
- abstract classmethod predict(subtype, options)[source]¶
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.
- class picos.constraints.constraint.ConstraintType(theClass, subtype)[source]¶
Container for a pair of constraint class type and constraint subtype.