FixedPenaltyPreparation#
- class FixedPenaltyPreparation#
Selection for the fixed-weight penalty Preparation phase.
Let \(F(x)\) be the active objective and \(g_i(x)\) the body of each active regular constraint. With normalized nonnegative penalty magnitudes \(w_i\), the keyed operation replaces the active objective by
\[ F(x) + \sum_i w_i g_i(x)^2 \]for minimization, and by \(F(x) - \sum_i w_i g_i(x)^2\) for maximization. The uniform operation uses one \(w\) for every active regular constraint. For an inequality \(g_i(x) \leq 0\), this squares \(g_i(x)\) itself; it is not the one-sided penalty \(\max(0, g_i(x))^2\).
On success, every active regular constraint moves to
removed_constraints, while existing removed constraints are preserved. When at least one active regular constraint is converted, the entry output semantics are preserved inoutput_objectivefor solution and sample evaluation (retaining an existing output objective, or capturing the active pair), but active-formulation optimality is no longer transported. Active Indicator, OneHot, or SOS1 constraints are not penalty-converted and cause an error before mutation. Validation, objective construction, and regular constraint lifecycle changes are atomic: any error leaves the instance unchanged. When a penalty is applied to active constraints, OMMX validates the weight domain but cannot decide whether a weight is large enough for an application’s penalty rule; that choice belongs to the caller.- __eq__(other: object, /) bool#
- penalty_method_with_fixed_weights(*, weights: Mapping[int, float], atol: Optional[float] = None) FixedPenaltyPreparation#
Select the keyed fixed-weight penalty owner operation.
The keys of
weightsmust be exactly the active regular constraint IDs. Each value is the corresponding \(w_i\) in the class formula.atolis used by the owner operation to accept a penalty magnitude down to-atoland normalize a tolerated negative value to zero. Every weight must be finite. Removed constraints recordreason="ommx.Instance.penalty_method_with_fixed_weights"with no reason parameters.
- uniform_penalty_method_with_fixed_weight(*, weight: float, atol: Optional[float] = None) FixedPenaltyPreparation#
Select the uniform fixed-weight penalty owner operation.
weightis the common \(w\) in the class formula for every active regular constraint. In particular, this replaces \(F(x)\) by \(F(x) + w \sum_i g_i(x)^2\) for minimization and by \(F(x) - w \sum_i g_i(x)^2\) for maximization, after normalizing \(w\).atolis used by the owner operation to accept a penalty magnitude down to-atoland normalize a tolerated negative value to zero. When at least one active regular constraint is converted, the weight must be finite. With no active constraint of any family, the owner operation is an identity and does not inspect the weight. Removed constraints recordreason="ommx.Instance.uniform_penalty_method_with_fixed_weight"with no reason parameters.