地图提供商(如谷歌或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),尽管它有点偏僻。
编辑:这两个例子似乎都不起作用了,但在最初的帖子发布时都起作用了。
作为一个在地图公司工作了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.
通过沿着这些路线进行修改,您甚至可以在非常合理的时间范围内完成跨国家路由。
这个问题在过去几年中一直是一个活跃的研究领域。主要思想是对图进行一次预处理,以加快所有后续查询的速度。有了这些附加信息,行程可以很快计算出来。尽管如此,Dijkstra算法仍然是所有优化的基础。
Arachnid描述了双向搜索和基于层次信息的边缘修剪的用法。这些加速技术工作得很好,但最新的算法在任何方面都优于这些技术。使用目前的算法,在大陆公路网上计算最短路径的时间可大大少于1毫秒。快速实现未修改的Dijkstra算法大约需要10秒。
工程快速路线规划算法概述了该领域的研究进展。有关进一步信息,请参阅那篇论文的参考文献。
已知最快的算法不使用数据中关于道路层次状态的信息,即它是高速公路还是本地道路。相反,他们在预处理步骤中计算自己的层次结构,优化以加快路线规划。这种预计算可以用来精简搜索:在Dijkstra算法中,远离起点和目的地的缓慢道路不需要考虑。好处是非常好的性能和结果的正确性保证。
第一个优化的路线规划算法只处理静态道路网络,这意味着图中的边缘具有固定的成本值。这在实践中是不正确的,因为我们想要考虑交通堵塞或车辆相关限制等动态信息。最新的算法也可以处理这些问题,但仍有问题需要解决,研究还在继续。
如果您需要最短路径距离来计算TSP的解,那么您可能对包含源和目的地之间所有距离的矩阵感兴趣。为此,您可以考虑使用高速公路层次结构计算多对多最短路径。请注意,在过去的两年里,这已经通过更新的方法得到了改进。