constraint_set
Container for categorized symbolic constraints.
This module provides a dataclass to hold all symbolic constraint types in a structured way before they are lowered to JAX/CVXPy.
ConstraintSet
dataclass
¶
Container for categorized symbolic constraints.
This dataclass holds all symbolic constraint types in a structured way, providing type safety and a clear API for accessing constraint categories. This is a pre-lowering container - after lowering, constraints live in LoweredJaxConstraints and LoweredCvxpyConstraints.
The constraint set supports two lifecycle stages:
- Before preprocessing: Raw constraints live in
unsorted - After preprocessing:
unsortedis empty, constraints are categorized
Use is_categorized to check which stage the constraint set is in.
Attributes:
| Name | Type | Description |
|---|---|---|
unsorted |
List[Union[Constraint, CTCS]]
|
Raw constraints before categorization. Empty after preprocessing. |
ctcs |
List[CTCS]
|
CTCS (continuous-time) constraints. |
nodal |
List[NodalConstraint]
|
Non-convex nodal constraints (will be lowered to JAX). |
nodal_convex |
List[NodalConstraint]
|
Convex nodal constraints (will be lowered to CVXPy). |
cross_node |
List[CrossNodeConstraint]
|
Non-convex cross-node constraints (will be lowered to JAX). |
cross_node_convex |
List[CrossNodeConstraint]
|
Convex cross-node constraints (will be lowered to CVXPy). |
Example
Before preprocessing (raw constraints)::
constraints = ConstraintSet(unsorted=[c1, c2, c3])
assert not constraints.is_categorized
After preprocessing (categorized)::
# preprocess_symbolic_problem drains unsorted -> fills categories
assert constraints.is_categorized
for c in constraints.nodal:
# Process non-convex nodal constraints
pass
Source code in openscvx/symbolic/constraint_set.py
is_categorized: bool
property
¶
True if all constraints have been sorted into categories.
After preprocessing, unsorted should be empty and all constraints
should be in their appropriate category lists.