Function total_violation
pub fn total_violation<I>(constraints: I) -> f64Expand description
The scalar total constraint violation: the sum of the positive parts.
This f64 can be +∞ if a finite positive sum overflows, as well as for a
NaN or +∞ input. To rank constraint vectors while preserving the order
between finite sums that overflow, use
compare_violations.
constrained_dominates uses the
same positive-sum ordering: the solution closer to the feasible region wins,
which drives an infeasible population toward feasibility.
Satisfied constraints contribute nothing (they are not rewarded — a
solution deep inside the feasible region does not get to out-rank one merely
inside it on that basis). A NaN value yields +∞: a constraint that could
not be evaluated is treated as maximally violated, so it cannot slip through
as “contributes zero” the way a naive if v > 0.0 sum would let it.
use atune_core::pareto::total_violation;
assert_eq!(total_violation(&[-5.0, 0.0]), 0.0);
assert_eq!(total_violation(&[2.0, -1.0, 0.5]), 2.5);
assert_eq!(total_violation(&[f64::NAN, -1.0]), f64::INFINITY);