地图提供商(如谷歌或Yahoo!地图)指示方向?

I mean, they probably have real-world data in some form, certainly including distances but also perhaps things like driving speeds, presence of sidewalks, train schedules, etc. But suppose the data were in a simpler format, say a very large directed graph with edge weights reflecting distances. I want to be able to quickly compute directions from one arbitrary point to another. Sometimes these points will be close together (within one city) while sometimes they will be far apart (cross-country).

Graph algorithms like Dijkstra's algorithm will not work because the graph is enormous. Luckily, heuristic algorithms like A* will probably work. However, our data is very structured, and perhaps some kind of tiered approach might work? (For example, store precomputed directions between certain "key" points far apart, as well as some local directions. Then directions for two far-away points will involve local directions to a key points, global directions to another key point, and then local directions again.)

实践中实际使用的算法是什么?

PS:这个问题的动机是发现在线地图方向的怪癖。与三角形不等式相反,有时谷歌Maps认为X-Z比使用中间点(如X-Y-Z)花费的时间更长,距离更远。但也许他们的行走方向也会优化另一个参数?

pp。这是对三角不等式的另一个违反,这表明(对我来说)他们使用了某种分层方法:X-Z vs X-Y-Z。前者似乎使用了著名的塞瓦斯托波尔大道(Boulevard de Sebastopol),尽管它有点偏僻。

编辑:这两个例子似乎都不起作用了,但在最初的帖子发布时都起作用了。


当前回答

这纯粹是我的猜测,但我认为他们可能会使用覆盖有向图的影响图数据结构,以缩小搜索域。这将允许搜索算法在所需行程较长时将路径导向主要路线。

鉴于这是一个谷歌应用程序,我们也可以合理地假设,许多神奇的功能都是通过大量缓存完成的。如果缓存前5%最常见的谷歌地图路由请求,我不会感到惊讶(20%?50%?)的请求需要通过简单的查询来回答。

其他回答

我有点惊讶这里没有提到Floyd Warshall的算法。这个算法很像Dijkstra算法。它还有一个很好的特性,那就是它允许你计算,只要你想继续允许更多的中间顶点。因此,它自然会很快找到使用州际公路或高速公路的路线。

我知道OP里的地图是怎么回事了:

用指定的中间点来观察路线:由于那条路不直,这条路线略微向后走。

如果他们的算法不会回溯,它就看不到更短的路线。

我以前没有在谷歌或微软或雅虎地图工作过,所以我不能告诉你他们是如何工作的。

然而,我确实为一家能源公司设计了一个定制的供应链优化系统,其中包括为他们的卡车车队提供调度和路由应用程序。然而,我们对路线的标准远比建筑、交通减速或车道封闭的地方更具体。

我们采用了一种称为ACO(蚁群优化)的技术来调度和路线卡车。该技术是一种人工智能技术,应用于旅行推销员问题来解决路由问题。ACO的技巧是基于路由的已知事实构建错误计算,以便图求解模型知道何时退出(当错误足够小时)。

你可以谷歌ACO或TSP找到更多关于这个技术。然而,我没有使用过任何开源AI工具,所以不能推荐一个(尽管我听说SWARM非常全面)。

作为一个在地图公司工作了18个月的人,其中包括研究路由算法……是的,Dijkstra的方法确实有效,只是做了一些修改:

Instead of doing Dijkstra's once from source to dest, you start at each end, and expand both sides until they meet in the middle. This eliminates roughly half the work (2*pi*(r/2)^2 vs pi*r^2). To avoid exploring the back-alleys of every city between your source and destination, you can have several layers of map data: A 'highways' layer that contains only highways, a 'secondary' layer that contains only secondary streets, and so forth. Then, you explore only smaller sections of the more detailed layers, expanding as necessary. Obviously this description leaves out a lot of detail, but you get the idea.

通过沿着这些路线进行修改,您甚至可以在非常合理的时间范围内完成跨国家路由。

Probably similar to the answer on pre-computed routes between major locations and layered maps, but my understanding is that in games, to speed up A*, you have a map that is very coarse for macro navigation, and a fine-grained map for navigation to the boundary of macro directions. So you have 2 small paths to calculate, and hence your search space is much much smaller than simply doing a single path to the destination. And if you're in the business of doing this a lot, you'd have a lot of that data pre-computed so at least part of the search is a search for pre-computed data, rather than a search for a path.