如何使用Google Maps / 地理定位 / 路线查找解决旅行推销员问题?
我不需要最佳解决方案,误差在5%以内即可。
例如,我有20个要访问的英国地点,顺序任意。这可能需要扩展到数百个位置。
在能够查找距离(但不想查找数百个距离)的情况下,可以使用什么样的算法?
如何使用Google Maps / 地理定位 / 路线查找解决旅行推销员问题?
我不需要最佳解决方案,误差在5%以内即可。
例如,我有20个要访问的英国地点,顺序任意。这可能需要扩展到数百个位置。
在能够查找距离(但不想查找数百个距离)的情况下,可以使用什么样的算法?
这是一个使用JS实现的TSP项目 http://code.google.com/p/google-maps-tsp-solver/
你可以在这里看到实时演示 http://gebweb.net/optimap/
谷歌确实在其路线规划API中有一个参数,可以将路线优化为旅行推销员问题:
根据文档(关键部分为&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 ]
如果只需要一次性的使用,建议使用@Kunukn推荐的OptiMap。
如果你正在寻找欧几里得TSP的多项式逼近,有几种算法被提出。可以在这里看一下。