test(tlbo,umda,simulated_annealing,tabu_search,tpe,snes,rvea,spea2): pin comparison and geometry helpers
Phase 1 tests for eight more algorithms — the feasibility-first comparison helpers (better / better_than / compare_so / worse_than), plus algorithm-specific pure functions: - tlbo: best_index min/max/tie. - tpe: oriented_target sign-flip + penalty; split_good_bad partition and clamp-to-at-least-one-each. - snes: nes_utilities sum-to-zero + descending + positive-best. - rvea: unit_normalize (3-4-5 → 0.6/0.8), zero-vector passthrough; closest_reference smallest-angle; smallest_neighbor_angle = π/2 for orthogonal refs. - spea2: euclidean distance basics; binary_tournament prefers lower fitness.
This commit is contained in:
@@ -421,4 +421,24 @@ mod tests {
|
||||
rb.best.unwrap().evaluation.objectives,
|
||||
);
|
||||
}
|
||||
|
||||
// ---- Mutation-test pinned helpers --------------------------------------
|
||||
|
||||
#[test]
|
||||
fn better_than_feasibility_first_and_direction() {
|
||||
use crate::core::objective::Direction;
|
||||
let feasible = Evaluation::new(vec![100.0]);
|
||||
let infeasible = Evaluation::constrained(vec![0.0], 1.0);
|
||||
assert!(better_than(&feasible, &infeasible, Direction::Minimize));
|
||||
assert!(!better_than(&infeasible, &feasible, Direction::Minimize));
|
||||
let lo = Evaluation::new(vec![1.0]);
|
||||
let hi = Evaluation::new(vec![2.0]);
|
||||
assert!(better_than(&lo, &hi, Direction::Minimize));
|
||||
assert!(better_than(&hi, &lo, Direction::Maximize));
|
||||
let eq = Evaluation::new(vec![1.0]);
|
||||
assert!(!better_than(&lo, &eq, Direction::Minimize));
|
||||
let v_lo = Evaluation::constrained(vec![0.0], 0.2);
|
||||
let v_hi = Evaluation::constrained(vec![0.0], 0.8);
|
||||
assert!(better_than(&v_lo, &v_hi, Direction::Minimize));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user