使用 Google 地图解决旅行商问题的实用方法是什么?

发布于 2024-12-09 06:35:48 字数 167 浏览 2 评论 0原文

使用 Google 地图/地理定位/路线查找来解决旅行商问题的实用解决方案是什么?

我不需要最好的解决方案,5%以内就可以了。

例如,我在英国有 20 个地点可供参观,顺序不限。这可能需要扩展到数百个位置。

鉴于我可以查找距离(但不想查找数百个距离),我可以使用哪种算法?

What is a practical solution to the Travelling Salesman problem, using Google Maps / geolocation / route finding?

I don't need the best solution, within 5% would be fine.

For example, I have 20 locations in the UK to visit, in any order. This may need to scale to hundreds of locations.

What sort of algorithm can I use, given that I can lookup distances (but don't want to lookup hundreds of distances)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

鸠书 2024-12-16 06:35:48

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/

我不咬妳我踢妳 2024-12-16 06:35:48

Google 的路线 API 上确实有一个参数,可以优化旅行推销员问题的路线:

来自文档(关键部分是&waypoints=optimize:true|...):

以下示例计算从阿德莱德出发的公路旅行路线,
南澳大利亚到南澳大利亚的每个主要葡萄酒产区都使用
路线优化。

http://maps.googleapis.com/maps/api/directions/json?origin=阿德莱德,SA
  &目的地=南澳大利亚州阿德莱德
  &waypoints=optimize:true|南澳州巴罗莎+谷|南澳州克莱尔|南澳州康纳瓦拉|南澳州迈凯轮+谷
  &传感器=假

检查计算出的路线将表明该路线是
使用以下航点顺序计算:

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

对于一次性使用 @Kunukn 推荐的 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

眼眸印温柔 2024-12-16 06:35:48

您可以使用长纬度来粗略估计位置之间的距离,然后进行一些查找以查找彼此附近的位置。

一个更简单的替代方法是将地图分成 3 x 3 部分。仅查找相邻路段位置的路线。

但这些技术并不是 100% 准确。

即使您查找所有路径,最终的查找次数也不会超过 190 次。

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.

痞味浪人 2024-12-16 06:35:48

如果您正在寻找欧几里得 TSP 的多项式近似,已经建议了几种算法。请查看此处

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文