designspace.ConstraintEval#
- class designspace.ConstraintEval(constraint: Constraint, instance_path: str | None, applicable: bool, satisfied: bool | None, margin: float | None)#
Bases:
objectOne constraint evaluated against one configuration.
Read violated rather than satisfied unless you mean to handle polarity yourself: a forbid names a bad state, so satisfying it is the unhealthy outcome.
- constraint#
The constraint evaluated. For a per-element constraint inside a .repeat(), the template rather than a per-instance copy.
- Type:
- instance_path#
Which element this evaluation is for, when the constraint lives inside a lift; None otherwise.
- Type:
str | None
- applicable#
Whether the constraint could be decided at all. False when a parameter it reads is inactive, in which case it neither holds nor fails, since an inapplicable constraint is never violated.
- Type:
- satisfied#
Whether the stored predicate held. None when the outcome is unknown, which is also when applicable is False.
- Type:
bool | None
- margin#
How far the configuration sits from the constraint boundary, signed so that a positive value means the stored predicate holds. None for a predicate with no numeric distance, such as a Boolean composition or an opaque ds.value(…, returns=bool).
- Type:
float | None
- property violated: bool#
Whether this evaluation counts against feasibility (for a hard forbid/require) or is flagged as a violation (for a soft encourage/discourage). It is polarity-correct across all four kinds. An inapplicable (Kleene-Unknown) eval is never violated (rule 4); otherwise the stored predicate is violated when
satisfieddiffers from the constraint’s desired polarity. This is the public, display-ready reading the reference sampler andvalidateuse internally (eval.is_violated); seeConstraint.feasible_when_satisfied.