Skip to main content

mutation_rand1

Function mutation_rand1 

pub fn mutation_rand1(r1: &[f64], r2: &[f64], r3: &[f64], f: f64) -> Vec<f64>
Expand description

The rand/1 mutation: x_r1 + F·(x_r2 − x_r3), coordinate by coordinate.

The three donors must be distinct members of the population (the caller draws them with sample_distinct); f is the scale factor F (around 0.5). The result may leave [0, 1] — a BoundaryFix repairs it afterwards.

Never panics: the three slices are the same length by construction (they come from one fixed-dimension population), and the implementation zips rather than indexes, so a mismatched call would yield the shortest common prefix instead of aborting.