← Back to Stochastic Hill Climbing docs

teeline · algorithms/stochastic_hill

Stochastic Hill Climbing

Each step draws a random 2-opt candidate — a random segment reversal. The candidate is accepted only if it beats the best tour found so far; otherwise it is rejected and the tour stays. When the search goes stale (too many rejections in a row), it restarts from a fresh random tour — the best tour survives. Random restarts are what rescue the search from mediocre local optima.

21034567
tour edge best tour (ghost) candidate (remove) candidate (add) removed new edge
Click Step to draw a random 2-opt candidate
epoch
0
restarts
0
best cost
1129
current cost
1129
accept rate
step
0
cities: 8random 2-opt · accept only if < best · random restart