Computer Science
TSP Local Search Simulator
2026-03-22
TSP LOCAL SEARCH
Simulated Annealing
Iteration
0
Current Cost
627
Best Cost
627
Temperature
100.000
Parameters
CITIES
TEMP (T₀)
COOLING
COOLING SCHEDULE
T = T × rate. 가장 일반적. 일정한 비율로 감쇠합니다.
Current
cost=
627
Best Found
cost=
627
0 → 1 → 2 → 3 → 4 → 5 → 6 → 7 → 8 → 9 → 0
Transform Function
랜덤한 두 위치 사이 구간을 뒤집습니다. 교차하는 경로를 풀어주는 데 효과적입니다.
transform(route, distances) → route
// 2-opt: 랜덤 구간을 뒤집어 교차 제거
const n = route.length;
const newRoute = [...route];
let i = Math.floor(Math.random() * n);
let j = Math.floor(Math.random() * n);
while (j === i) j = Math.floor(Math.random() * n);
let lo = Math.min(i, j);
let hi = Math.max(i, j);
while (lo < hi) {
[newRoute[lo], newRoute[hi]] = [newRoute[hi], newRoute[lo]];
lo++;
hi--;
}
return newRoute;