picos.constraints.constraint¶
Backend for constraint type implementations.
Classes

class
picos.constraints.constraint.
ConicConstraint
(typeTerm, customString=None, printSize=False)[source]¶ Bases:
picos.constraints.constraint.Constraint
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.

abstract property

class
picos.constraints.constraint.
Constraint
(typeTerm, customString=None, printSize=False)[source]¶ Bases:
abc.ABC
Abstract base class for optimization constraints.
Implementations
need to implement at least the abstract methods
_str
,_expression_names
, and_get_slack
,need to implement
_get_size
, unless duals are not supported, andare supposed to call
Constraint.__init__
from within their own implementation of__init__
.

__init__
(typeTerm, customString=None, printSize=False)[source]¶ Perform basic initialization for
Constraint
instances.

delete
()[source]¶ Raise a
NotImplementedError
.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
remove_constraint
method.

classmethod
make_type
(*args, **kwargs)[source]¶ Create a detailed constraint type from subtype parameters.

replace_mutables
(new_mutables)[source]¶ Make the constraint concern a different set of mutables.
See
replace_mutables
for more.

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 nonnegative 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]¶ Bases:
abc.ABC
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 justConversion
. If for instanceAbsoluteValueConstraint
definesAffineConversion
, then the reformulation will be coinedAbsoluteValueToAffineReformulation
. If the conversions was just namedConversion
, the result would be a class namedAbsoluteValueReformulation
.
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 inconvert
), returns a dual value for the converted constraint. Raises
NotImplementedError – When dual format not decided upon or not known. This will be caught by the reformulation’s backward method.

abstract classmethod

class
picos.constraints.constraint.
ConstraintType
(theClass, subtype)[source]¶ Bases:
picos.containers.DetailedType
Container for a pair of constraint class type and constraint subtype.