← Back to Or-opt docs

teeline · algorithms/or_opt

Or-opt Local Search

Or-opt relocates segments of 1–3 consecutive cities to a better position elsewhere in the tour — a cut-and-paste move, unlike 2-opt's edge reversal. Each pass scans every segment size (Or-1, Or-2, Or-3) and every insertion point, applying the single best-improving relocation (reversed insertions are also tried for Or-2/Or-3). Repeats until no relocation improves the tour.

0123485967
tour edge segment (relocating) cut edge paste edge insertion gap improving gap (scan)
Click Step to scan for the best Or-1/2/3 relocation
pass
0
moves
0
best cost
1039
distance
1039
last Δ
step
0
cities: 10Or-1/2/3 relocation · best-improvement · runs to local optimum