fix(tsp): reverse properly in reverse subsequence perturbatio
1 files changed, 8 insertions(+), 6 deletions(-) M codes/tsp_hw01/src/tsp.rs
M codes/tsp_hw01/src/tsp.rs => codes/tsp_hw01/src/tsp.rs +8 -6
@@ 295,13 295,15 @@ where let start = first.min(second); let end = first.max(second); // Only to half of the interval to swap let end = (end + start) / 2; for (i, j) in (start..=end).zip(end..=start) { chromosome.permutation.swap_rows(i, j); // Reverse the subsequence between start and end (inclusive) let mut left = start; let mut right = end; while left < right { chromosome.permutation.swap_rows(left, right); left += 1; right -= 1; } } }