diff --git a/examples/compare.rs b/examples/compare.rs index f735138..cfe9001 100644 --- a/examples/compare.rs +++ b/examples/compare.rs @@ -79,6 +79,7 @@ impl Problem for Dtlz2 { let mut f = vec![0.0_f64; m]; for i in 0..m { let mut prod = scale; + #[allow(clippy::needless_range_loop)] // Body indexes `x[j]`. for j in 0..(m - i - 1) { prod *= (x[j] * std::f64::consts::FRAC_PI_2).cos(); } diff --git a/src/algorithms/nsga3.rs b/src/algorithms/nsga3.rs index 3c66bc3..04f7695 100644 --- a/src/algorithms/nsga3.rs +++ b/src/algorithms/nsga3.rs @@ -119,7 +119,7 @@ where // --- Combine + survival selection --- let mut combined: Vec> = Vec::with_capacity(2 * n); - combined.extend(population.into_iter()); + combined.extend(population); combined.extend(offspring); population = environmental_selection(&combined, &objectives, &reference_points, n, &mut rng); } @@ -325,6 +325,7 @@ fn solve_intercepts(oriented: &[Vec], extremes: &[usize]) -> Option> = extremes.iter().map(|&i| oriented[i].clone()).collect(); let mut b: Vec = vec![1.0; m]; // Forward elimination with partial pivoting. + #[allow(clippy::needless_range_loop)] // Body indexes both `a` and `b` by row. for k in 0..m { let mut pivot = k; for i in (k + 1)..m { @@ -339,6 +340,7 @@ fn solve_intercepts(oriented: &[Vec], extremes: &[usize]) -> Option], extremes: &[usize]) -> Option = x .into_iter() - .map(|v| if v.abs() < 1e-12 { return f64::NAN } else { 1.0 / v }) + .map(|v| if v.abs() < 1e-12 { f64::NAN } else { 1.0 / v }) .collect(); if intercepts.iter().any(|v| !v.is_finite() || *v <= 0.0) { return None; diff --git a/src/algorithms/spea2.rs b/src/algorithms/spea2.rs index c4bcdf1..88c451e 100644 --- a/src/algorithms/spea2.rs +++ b/src/algorithms/spea2.rs @@ -87,8 +87,8 @@ where // --- Combine pool, compute fitness --- let mut pool: Vec> = Vec::with_capacity(population.len() + archive.len()); - pool.extend(population.drain(..)); - pool.extend(archive.drain(..)); + pool.append(&mut population); + pool.append(&mut archive); let fitness = compute_fitness(&pool, &objectives); // --- Build the next archive ---