test(nelder_mead,nsga2,nsga3,one_plus_one_es,particle_swarm): pin selection/geometry helpers
Phase 1 tests: - nelder_mead: compare / better feasibility-first + direction. - nsga2: binary_tournament prefers lower rank, then higher crowding distance at equal rank (statistical majority over 200 seeds). - nsga3: solve_intercepts on axis-aligned extremes / singular / empty; associate picks the closest reference direction with correct perpendicular distance. - one_plus_one_es: worse_than across feasibility + direction + equal. - particle_swarm: best_index min/max/tie/single-element.
This commit is contained in:
@@ -551,4 +551,32 @@ mod tests {
|
||||
);
|
||||
let _ = opt.run(&SchafferN1);
|
||||
}
|
||||
|
||||
// ---- Mutation-test pinned helpers --------------------------------------
|
||||
|
||||
use crate::core::objective::Direction;
|
||||
|
||||
#[test]
|
||||
fn compare_feasibility_first_and_direction() {
|
||||
let feasible = Evaluation::new(vec![10.0]);
|
||||
let infeasible = Evaluation::constrained(vec![0.0], 1.0);
|
||||
assert_eq!(compare(&feasible, &infeasible, Direction::Minimize), std::cmp::Ordering::Less);
|
||||
let lo = Evaluation::new(vec![1.0]);
|
||||
let hi = Evaluation::new(vec![2.0]);
|
||||
assert_eq!(compare(&lo, &hi, Direction::Minimize), std::cmp::Ordering::Less);
|
||||
assert_eq!(compare(&lo, &hi, Direction::Maximize), std::cmp::Ordering::Greater);
|
||||
let v_lo = Evaluation::constrained(vec![0.0], 0.2);
|
||||
let v_hi = Evaluation::constrained(vec![0.0], 0.8);
|
||||
assert_eq!(compare(&v_lo, &v_hi, Direction::Minimize), std::cmp::Ordering::Less);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn better_is_strict_less() {
|
||||
let lo = Evaluation::new(vec![1.0]);
|
||||
let hi = Evaluation::new(vec![2.0]);
|
||||
assert!(better(&lo, &hi, Direction::Minimize));
|
||||
assert!(!better(&hi, &lo, Direction::Minimize));
|
||||
let eq = Evaluation::new(vec![1.0]);
|
||||
assert!(!better(&lo, &eq, Direction::Minimize));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user