Module variation
Expand description
The pure NSGA-II variation operators, in the transform-layer unit hypercube.
The arithmetic core of Nsga2, kept free of any sampler or
study state so every operator can be pinned by an exact golden computed by
hand from the published formulas.
Everything works on the unit representation of a configuration — one
coordinate in [0, 1] per declared parameter — so a single implementation
covers every Distribution kind; mapping back
to the declared support is
Distribution::from_unit’s job,
done once when the child is finally assigned.
§A categorical is not an interval, and this module says so
Simulated binary crossover and polynomial mutation are real-parameter
operators: they assume that the numbers between two parents are meaningful
intermediates. That is true for a Float
and (after rounding) for an Int — the
unit coordinate of a log-scaled or stepped numeric is still a position on a
monotone axis. It is false for a
Cat or a
Bool: “halfway between adam and
rmsprop” is not a thing, and blending their unit coordinates would invent
an ordering that the study never declared.
So the two kinds get different operators, and the split is
GeneKind-driven rather than hidden:
| Gene | Crossover | Mutation |
|---|---|---|
Numeric | SBX, η_c | polynomial, η_m |
Categorical | uniform: take one parent’s value whole | uniform re-choice over the support |
§The RNG stream is a function of the dimension alone
Both operators draw a fixed number of f64s per dimension, whatever the
rates are and whichever branch a coin takes:
crossover draws exactly one per dimension, mutate exactly two (a rate
coin and a magnitude, even when the coin does not fire). That costs a few
wasted draws and buys the property a resumed study rests on — the stream
position after an operator depends only on d. Short-circuiting either loop
would make the sequence depend on the coins, which is precisely the defect
crossover_bin documents having
been fixed.
Enums§
- Gene
Kind - Which family of operators a declared parameter belongs to.
Functions§
- binary_
tournament - NSGA-II’s binary tournament on the crowded-comparison operator.
- crossover
- Breeds one child from two parents, gene by gene.
- mutate
- Mutates a child in place, gene by gene, at per-gene probability
rate. - polynomial_
delta - The perturbation of polynomial mutation (Deb & Goyal 1996).
- random_
unit_ vector - A fresh uniform-random unit vector in
[0, 1]^d— the initial population’s generator, drawing exactly onef64per dimension. - sbx_
child - One child coordinate of simulated binary crossover (Deb & Agrawal 1995).