friendlysam.opt.Constraint¶
-
class
friendlysam.opt.
Constraint
(expr, desc=None, origin=None)¶ An equality or inequality constraint.
This class is used to wrap a constraint expression and (optionally) add some metadata.
Parameters: - expr (
Relation
instance) – An equality or inequality. - desc (str, optional) – A text describing the constraint.
- origin (anything, optional) – Some object describing where the constraint comes from.
Examples
>>> x = Variable('x') >>> c = Constraint(x + 1 <= 2 * x, desc='Some text') >>> print(c) <Constraint: Some text> >>> c.origin = 'randomly created' >>> print(c) <Constraint [randomly created]: Some text> >>> print(c.expr) x + 1 <= 2 * x
- expr (
Constraint.desc |
A description of the constraint, for debugging. |
Constraint.long_description |
A long, human-readable string representation of the constraint. |
Constraint.origin |
The origin of the description. |
Constraint.variables |
Read only property, shorthand for .expr.variables |