test(hyperband,moead,knea,ibea,ipop_cma_es,mopso): pin helper functions
Phase 1 tests: - hyperband: compare / better feasibility-first + direction branches. - moead: tchebycheff (max weighted deviation from ideal) and weight_distance (Euclidean) pins. - knea: perpendicular_distance to the simplex hyperplane, zero-on-plane, and the too-few-extremes degenerate fallback. - ibea: compute_fitness empty/dominating/symmetric-tradeoff cases and binary_tournament fitness preference. - ipop_cma_es: better feasibility-first + direction + equal-not-better. - mopso: population/front sizing and determinism cross-check.
This commit is contained in:
@@ -442,4 +442,35 @@ mod tests {
|
||||
);
|
||||
let _ = opt.run(&MultiObj);
|
||||
}
|
||||
|
||||
// ---- 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);
|
||||
assert_eq!(compare(&infeasible, &feasible, Direction::Minimize), std::cmp::Ordering::Greater);
|
||||
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);
|
||||
// two infeasible: smaller violation is "Less" (better).
|
||||
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_compare_equals_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));
|
||||
// equal → not strictly better.
|
||||
let eq = Evaluation::new(vec![1.0]);
|
||||
assert!(!better(&lo, &eq, Direction::Minimize));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user