TSP: Tour selbst bauen
About this app
Dreißig Punkte in einem rechteckigen Gebiet, ein Startpunkt: Verbinde die Punkte Kante für Kante zu einer möglichst kurzen Rundreise. Jeder Punkt bekommt genau zwei Kanten, Kanten lassen sich wieder löschen und umbauen. Die Länge läuft mit, Kreuzungen und geschlossene Teilkreise werden markiert. Immer dasselbe Gebiet zum Vergleichen, auf Wunsch neue Punkte.
What it is about
The travelling salesman problem (TSP) asks for the shortest tour that visits each place exactly once and returns to the start. Seen as a graph, every point of a tour has exactly two edges, and all edges form a single cycle. Several separate cycles also satisfy the degree condition but are not a tour; that is exactly why the optimisation model needs subtour elimination constraints. With 30 points there are 29!/2, roughly 4.4 · 10³⁰ different tours, so trying them all is out of the question.
What the app shows
A rectangular area in 3 : 2 format with a km scale and 30 points, one marked as the start. The standard area is always the same, so results can be compared within a group; new points can be drawn on request. The length of your own tour updates live. Crossings are marked at their intersection, closed sub-cycles are highlighted, and a complete tour is confirmed with its length.
Try it yourself
Tap two points one after the other or drag from point to point to set an edge; tapping an edge removes it again. First try nearest neighbour from the start and watch the long final edges. Then remove every marked crossing by reconnecting the two edges crosswise: the tour gets shorter every time. Compare your lengths on the standard area.
Frequently asked questions
- Why is an optimal tour in the plane free of crossings?
- If two edges AB and CD cross, they can be replaced by AC and BD, traversing the piece in between in reverse. By the triangle inequality the two new edges together are shorter than the two crossing ones. A tour with a crossing can therefore always be shortened and cannot be optimal.
- What is a subtour in the TSP?
- A subtour is a closed cycle that visits only some of the points. It arises when every point has two edges but the edges form several separate cycles. In the integer model, subtour elimination constraints exclude such solutions: every proper subset of the points must be connected to the rest.
- Is nearest neighbour a good strategy?
- It gives a tour quickly, but usually not an optimal one. The first steps look short, towards the end scattered points are left over and the final edges become long. On random points the nearest neighbour tour is typically about a quarter longer than the optimum.
- Can I rebuild my tour in the app?
- Yes. Every edge can be deleted again by tapping it, and Undo takes back the last step. Each point has at most two edges; the app rejects a third one with a hint.
Subject: Operations research
More from Operations research
- Big M: Nebenbedingungen an- und ausschalten
- Dijkstra's algorithm
- Ganzzahlig ist anders: LP gegen IP
- Konvexe Mengen, Hülle und Ecken
- Linear problems made visual
- Nebenbedingungen verschärfen (Tightening)
- Simplex in space
- Simplex algorithm
A VisuApp by heyprof: interactive, free in your browser, no sign-up. What is a VisuApp? · All apps