Skip to main content

crossover

Function crossover 

pub fn crossover(
    a: &[f64],
    b: &[f64],
    kinds: &[GeneKind],
    eta: f64,
    swapping_prob: f64,
    rng: &mut ChaCha8Rng,
) -> Vec<f64>
Expand description

Breeds one child from two parents, gene by gene.

Numeric genes get SBX; categorical genes get uniform crossover — the child takes parent b’s value with probability swapping_prob and parent a’s otherwise, whole, never blended.

Draws exactly one f64 per dimension, in gene order (see the module documentation). A gene beyond either parent’s length keeps whatever a had (or 0.5 if a is short too) rather than panicking: the two are the same length by construction, but this is a library path.