The Traveling Salesman Problem (TSP) is a classic computer science challenge: What path do you choose when visiting a set of destinations so as to minimize the distance traveled? It’s a problem for which there aren’t any easy shortcuts or a quick formula, and hence it’s become something of a cause célèbre among mathematicians and programmers for measuring the efficiency of algorithms and the processing speed of grid computers.
One of the most impressive recent TSP calculations minimized the distance traveled between Swedish towns — all 24,978 of them(!). I was hoping to overlay the map of the shortest route onto Google Earth, but the projection isn’t right. The raw data is available, so I might well turn it into a KML file sometime.
In the meantime, though, I wanted to make my own TSP solver for KML files of placemarks.
Instructions: Collect up to nine placemarks in a folder. (Hint, you can also right-click on city icons and save them as placemarks.) Right-click on the folder and Save it locally as a KML file (NOT as a KMZ file). Use the TSP Solver to upload the file and wait around 10 seconds. You’ll get a KML file back that contains the shortest route between those placemarks. Guaranteed:-)
Unfortunately, This being a PHP script running on a server, nine placemarks is all that the algorithm can manage in a reasonable time. Ten placemarks would take 10 times longer. The current algorithm isn’t very efficient, in any case, and I’ll be playing with better solutions in the coming weeks, but I just wanted to get a base system working now. Any speed suggestions are most welcome, or else feel free to roll your own, better TSP solver.
Excellent.
Heh. I love FME. It took me something like 15 minutes and 8 transformers to figure out how to convert the TSP data into KML:
Bork Bork Bork
Jason
That’s awesome Jason, thanks.
I get the error:
Fatal error: Call to a member function on a non-object in /home/ogle/public_html/tsp/index.php on line 40
kmz file is here:
http://www.cs.drexel.edu/~cera/tmp/TSP.kmz
Any help is appreciated.
That’s a KMZ file, Chris.
Wow, works great. Thank you Stefan.
Curious!
Only a comment: The permutation heuristic, isnt very great idea. You must use another more efficient heuristic or solve by MILP solver.
More info on: http://personales.upv.es/arodrigu/rutas/
Thanks. very fast solution. I am assuming that it caluculates “as the crow flies” versus actual surface roads. Is that assumption correct? Even if so, it’s still impressive work.
Thank you.(감사합니다)
but exception occured!
recommend : add in 71st line
if ($placemark_count= 2″;
exit();
}
if not, infinite loop
이것을 읽는 한국인이 있으면 반갑겠네요. 소스코드는 실행해 봤는데, 잘 됩니다.
http://lispro06.woweb.net/dw/earth/tsp.php