math_audio_optimisation/
mutant_current_to_best1.rs1use ndarray::{Array1, Array2, Zip};
2use rand::Rng;
3
4use crate::distinct_indices::distinct_indices;
5
6pub(crate) fn mutant_current_to_best1<R: Rng + ?Sized>(
7 i: usize,
8 pop: &Array2<f64>,
9 best_idx: usize,
10 f: f64,
11 rng: &mut R,
12) -> Array1<f64> {
13 let idxs = distinct_indices(i, 2, pop.nrows(), rng);
14 let r0 = idxs[0];
15 let r1 = idxs[1];
16
17 Zip::from(pop.row(i))
18 .and(pop.row(best_idx))
19 .and(pop.row(r0))
20 .and(pop.row(r1))
21 .map_collect(|&curr, &best, &x0, &x1| curr + f * (best - curr + x0 - x1))
22}