AffineConstraint

class picos.constraints.AffineConstraint(lhs, relation, rhs, customString=None)

Bases: picos.constraints.Constraint

An equality or inequality between two affine expressions.

Attributes Summary

EQ
GE
LE
dual
ge0 The expression posed to be greater or equal than zero in case of an inequality, otherwise the right hand side minus the left hand side.
greater The greater-or-equal side expression in case of an inequality, otherwise the right hand side.
le0 The expression posed to be less or equal than zero in case of an inequality, otherwise the left hand side minus the right hand side.
size
slack
smaller The smaller-or-equal side expression in case of an inequality, otherwise the left hand side.

Methods Summary

bounded_linear_form() Separates the constraint into a linear function on the left hand side and a constant bound on the right hand side.
constring()
copy_with_new_vars(newVars[, newCons])
delete() Deletes the constraint from the problem it is assigned to.
expressions()
is_complex()
is_decreasing() Whether the constraint states exactly that the left hand side is greater or equal than the right hand side.
is_equality() Whether the constraints states the equality between the left hand side and the right hand side.
is_increasing() Whether the constraint states exactly that the left hand side is smaller or equal than the right hand side.
is_inequality() Whether the constraints states an inequality between the left hand side and the right hand side.
is_meta()
is_real()
keyconstring()
sparse_Ab_rows(varOffsetMap[, indexFunction]) A sparse list representation of the constraint, given a mapping of PICOS variables to column offsets (or alternatively given an index function).

Attributes Documentation

EQ = '='
GE = '>'
LE = '<'
dual
ge0

The expression posed to be greater or equal than zero in case of an inequality, otherwise the right hand side minus the left hand side.

greater

The greater-or-equal side expression in case of an inequality, otherwise the right hand side.

le0

The expression posed to be less or equal than zero in case of an inequality, otherwise the left hand side minus the right hand side.

size
slack
smaller

The smaller-or-equal side expression in case of an inequality, otherwise the left hand side.

Methods Documentation

bounded_linear_form()

Separates the constraint into a linear function on the left hand side and a constant bound on the right hand side.

Returns:A pair (linear, bound) where linear is a pure linear expression and bound is a constant expression.
constring()
copy_with_new_vars(newVars, newCons=None)
delete()

Deletes the constraint from the problem it is assigned to.

expressions()
is_complex()
is_decreasing()

Whether the constraint states exactly that the left hand side is greater or equal than the right hand side.

is_equality()

Whether the constraints states the equality between the left hand side and the right hand side.

is_increasing()

Whether the constraint states exactly that the left hand side is smaller or equal than the right hand side.

is_inequality()

Whether the constraints states an inequality between the left hand side and the right hand side.

is_meta()
is_real()
keyconstring()
sparse_Ab_rows(varOffsetMap, indexFunction=None)

A sparse list representation of the constraint, given a mapping of PICOS variables to column offsets (or alternatively given an index function).

The constraint is brought into a bounded linear form A • b, where • is one of ≤, ≥, or =, depending on the constraint relation, and the rows returned correspond to the matrix [A|b].

Parameters:
  • varOffsetMap (dict) – Maps variables or variable start indices to column offsets.
  • indexFunction – Instead of adding the local variable index to the value returned by varOffsetMap, use the return value of this function, that takes as argument the variable and its local index, as the “column index”, which need not be an integer. When this parameter is passed, the parameter varOffsetMap is ignored.
Returns:

A list of triples (J, V, c) where J contains column indices (representing scalar variables), V contains coefficients for each column index and c is a constant term. Each entry of the list represents a row in a constraint matrix.