Skip to main content

Module constraint

Module constraint 

Expand description

Typed constraints: the sign convention, the arithmetic, and where a trial’s constraint values live.

§The recording mechanism

A constraint value is typed state on the trial, not an extra objective column and not a new Storage operation — the trait is frozen, and the design’s answer to “somewhere to put structured side-data” is a versioned StateBlob in a Scope — “no system_attrs junk drawer”. Concretely:

A study that never records a constraint writes no constraint state at all, so nothing about its storage bytes changes.

§A multi-seed fan is aggregated conservatively

Under a SeedProtocol fan one trial is k evaluations, so it records k constraint vectors. They collapse into the trial’s one vector through worst_constraints — the componentwise maximum, i.e. the worst violation any replicate saw — because “this configuration is feasible” has to mean feasible on every seed. The per-replicate vectors are kept alongside on ReplicateResult::constraints, exactly as the per-seed objective values are, so aggregation loses nothing.

§The sign convention

≤ 0 is satisfied, > 0 is violated (Optuna’s convention, so a study ported from there keeps its constraint functions). The magnitude matters: it is what ranks two infeasible solutions against each other (total_violation).

Structs§

TrialConstraints
The constraint values a trial recorded.

Constants§

CONSTRAINT_BLOB_KIND
The kind tag of a trial’s constraint-value state blob.
CONSTRAINT_BLOB_VERSION
The schema version of the CONSTRAINT_BLOB_KIND payload (TrialConstraints).

Functions§

constraint_scope
The Scope a trial’s constraint values are stored under.
is_feasible
Whether every constraint value is satisfied — the feasibility test.
total_violation
The total constraint violation: the sum of the positive parts.
worst_constraints
The conservative aggregate of several evaluations’ constraint vectors: the componentwise worst (maximum) value.