What is a practical solution to the Travelling Salesman prblem, using Google Maps?

|▌冷眼眸甩不掉的悲伤 提交于 2019-11-30 14:11:19

I you are looking for a polynomial approximation for the Euclidean TSP, several algorithms have been suggested. Have a look here.

There is this TSP project implemented in JS http://code.google.com/p/google-maps-tsp-solver/

You can see live demo here http://gebweb.net/optimap/

Google does have a parameter on their directions API which will optimize the route as a travelling salesman problem:

From the documentation (the key part is &waypoints=optimize:true|...):

The following example calculates a road trip route from Adelaide, South Australia to each of South Australia's main wine regions using route optimization.

http://maps.googleapis.com/maps/api/directions/json?origin=Adelaide,SA
  &destination=Adelaide,SA
  &waypoints=optimize:true|Barossa+Valley,SA|Clare,SA|Connawarra,SA|McLaren+Vale,SA
  &sensor=false

Inspection of the calculated route will indicate that the route is calculated using the following waypoint order:

"waypoint_order": [ 1, 0, 2, 3 ]

For a one-off it's probably easier to use OptiMap as recommended by @Kunukn

you can use long lat to estimated roughly how far apart the locations are, then make a few lookups for those that are nearby each other.

a simpler alternative is to separate your map into 3 x 3 sections. Only look up routes for locations in adjacent sections.

these techniques aren't 100% accurate though.

And even if you look up all the paths, you should end up with no more than 190 lookups.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!