Skip to main content

math_audio_optimisation/
mutant_best2.rs

1use ndarray::{Array1, Array2};
2use rand::Rng;
3
4use crate::distinct_indices::distinct_indices;
5
6pub(crate) fn mutant_best2<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, 4, pop.nrows(), rng);
14    let r0 = idxs[0];
15    let r1 = idxs[1];
16    let r2 = idxs[2];
17    let r3 = idxs[3];
18    &pop.row(best_idx).to_owned()
19        + &((pop.row(r0).to_owned() + pop.row(r1).to_owned()
20            - pop.row(r2).to_owned()
21            - pop.row(r3).to_owned())
22            * f)
23}