Function binary_tournament
pub fn binary_tournament(
rank: &[usize],
crowding: &[f64],
rng: &mut ChaCha8Rng,
) -> Option<usize>Expand description
NSGA-II’s binary tournament on the crowded-comparison operator.
Two candidates are drawn uniformly (with replacement, as in the reference) and the crowded-better one wins: a lower non-domination rank beats a higher one, and within the same rank a larger crowding distance beats a smaller one — quality first, diversity as the tie-break.
A complete tie goes to the second draw. The crowded-comparison operator
is asked “is the first candidate better”, and a tie answers no, so the
second wins. This is not a corner case: crowding distance is ∞ at every
front boundary and a front of one or two is all boundary, so equal-rank
equal-distance pairs are routine. Either convention is a pure function of the
RNG stream (which is what the operator’s determinism actually rests on) and
NSGA-II’s definition leaves the tie arbitrary; this one is the code’s, it is
pinned by a test, and it is stated here so a reader can rely on it.
Draws exactly two random_range(0..n) values. Returns None for an empty
population (there is nobody to select), rather than panicking on an empty
range.
This is deliberately stronger than Optuna’s NSGA-II parent selection, which
compares by dominance alone and leaves crowding distance as a TODO: without
the diversity tie-break the tournament has no preference at all inside the
first front, which is where a converged run spends most of its time.