Constraint implementation¶
Low-level constraint violation helpers. For user-defined constrained problems, use the public problem-definition workflow instead.
Internal implementation API
These deep modules are not stable public imports. Documentation does not create a compatibility guarantee. See the stability policy.
Public problem definition · Constraints guide
ConstraintInfo
dataclass
¶
compute_constraint_info(G, eps=0.0)
¶
Compute aggregate constraint violation and feasibility mask.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
G
|
NDArray[float64] | None
|
Constraint values where |
required |
eps
|
float
|
Feasibility tolerance. Constraints |
``0.0``
|
Utility helpers for constraint handling.
compute_violation(G, *, n=None, eps=0.0)
¶
Sum per solution of each constraint's excess over eps; assumes G shape (N, n_constraints), g<=0 satisfied.
When G is None (unconstrained), n must be provided so the output
length is explicit.
eps is the feasibility tolerance of :func:is_feasible: the violation is
sum(max(g - eps, 0)), so a solution has zero violation exactly when it is
feasible with the same eps (default 0.0).
is_feasible(G, *, n=None, eps=0.0)
¶
Boolean feasibility mask; assumes G shape (N, n_constraints).
When G is None (unconstrained), n must be provided so the output
length is explicit.
eps is a feasibility tolerance: constraints with g(x) <= eps are
treated as satisfied (default 0.0).