style: rustfmt the Phase 1 test additions
The per-file Phase 1 test commits were written without running rustfmt as I went; this pass formats the new test code (long assert_eq! lines wrapped, etc.). Formatting-only — no behavioural change.
This commit is contained in:
@@ -317,9 +317,15 @@ mod tests {
|
||||
#[test]
|
||||
fn infeasible_candidate_with_smaller_violation_evicts_larger() {
|
||||
let mut a = ParetoArchive::<u32>::new(space_min2());
|
||||
a.insert(Candidate::new(1u32, Evaluation::constrained(vec![0.0, 0.0], 1.0)));
|
||||
a.insert(Candidate::new(
|
||||
1u32,
|
||||
Evaluation::constrained(vec![0.0, 0.0], 1.0),
|
||||
));
|
||||
// Smaller violation → dominates the existing infeasible member.
|
||||
a.insert(Candidate::new(2u32, Evaluation::constrained(vec![9.0, 9.0], 0.5)));
|
||||
a.insert(Candidate::new(
|
||||
2u32,
|
||||
Evaluation::constrained(vec![9.0, 9.0], 0.5),
|
||||
));
|
||||
assert_eq!(a.members().len(), 1);
|
||||
assert_eq!(a.members()[0].decision, 2);
|
||||
}
|
||||
|
||||
+10
-2
@@ -169,7 +169,11 @@ mod tests {
|
||||
fn interior_point_distance_is_pinned() {
|
||||
let s = space_min2();
|
||||
// Front along the line f1 + f2 = 4: (0,4), (2,2), (4,0).
|
||||
let pop = [cand(vec![0.0, 4.0]), cand(vec![2.0, 2.0]), cand(vec![4.0, 0.0])];
|
||||
let pop = [
|
||||
cand(vec![0.0, 4.0]),
|
||||
cand(vec![2.0, 2.0]),
|
||||
cand(vec![4.0, 0.0]),
|
||||
];
|
||||
let d = crowding_distance(&pop, &[0, 1, 2], &s);
|
||||
// Boundary points are infinite; the middle point gets
|
||||
// (4-0)/4 + (4-0)/4 = 2.0 (objective 0 span 4, objective 1 span 4).
|
||||
@@ -184,7 +188,11 @@ mod tests {
|
||||
fn asymmetric_interior_distance_is_pinned() {
|
||||
let s = space_min2();
|
||||
// (0,10), (1,2), (10,0): objective-0 span = 10, objective-1 span = 10.
|
||||
let pop = [cand(vec![0.0, 10.0]), cand(vec![1.0, 2.0]), cand(vec![10.0, 0.0])];
|
||||
let pop = [
|
||||
cand(vec![0.0, 10.0]),
|
||||
cand(vec![1.0, 2.0]),
|
||||
cand(vec![10.0, 0.0]),
|
||||
];
|
||||
let d = crowding_distance(&pop, &[0, 1, 2], &s);
|
||||
// middle point: obj0 (10-0)/10 = 1.0; obj1 (10-0)/10 = 1.0 → 2.0.
|
||||
assert!((d[1] - 2.0).abs() < 1e-12, "got {}", d[1]);
|
||||
|
||||
Reference in New Issue
Block a user