What is a 2-opt swap in the context of TSP?
A 2-opt swap is a local search heuristic for the Traveling Salesman Problem. It involves removing two edges from the current tour and reconnecting the resulting paths in a different way to form a new tour. If the new tour is shorter, it replaces the old one.
Conditions
- Applied to a valid TSP tour.
- Involves exactly two edge removals and reconnections.
Reasoning, step by step
- Identify two edges in the current tour.
- Remove the two edges.
- Reconnect the four endpoints in a different configuration to form a new valid tour.
- Compare the length of the new tour to the old one.
- If the new tour is shorter, accept it as the new current solution.
Example
The video shows a 2-Opt swap being applied to a self-crossing greedy route, successfully eliminating the intersection and reducing the total distance from 8969 km to 8570 km.
Common misconceptions
- Believing that a 2-opt swap can only fix self-intersections.
- Assuming that a 2-opt swap always improves the tour length.
Watch the explanation
2:08 – 2:18Watch this moment ↗
Explore next
Answers are generated from source material and independently checked. Consult the original video or creator if something is unclear.