地图提供商(如谷歌或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),尽管它有点偏僻。

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


当前回答

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

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

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

其他回答

事实上,我已经做过很多次了,尝试了几种不同的方法。根据地图的大小(地理位置),您可能会考虑使用haversine函数作为启发式方法。

我的最佳解决方案是使用带有直线距离的A*作为启发式函数。但接下来你需要地图上每个点(交集或顶点)的某种坐标。您还可以为启发式函数尝试不同的权重,即。

f(n) = k*h(n) + g(n)

k是一个大于0的常数。

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.

只是解决三角形不等式的违反,希望他们优化的额外因素是常识。你不一定想要最短或最快的路线,因为这可能会导致混乱和破坏。如果你想让自己的路线更适合卡车行驶,并且能够应对每个卫星导航跟踪司机都沿着这些路线行驶的情况,那么你很快就可以放弃三角形不等式[1]。

如果Y是X和Z之间的一条狭窄的住宅街道,那么您可能只想在用户明确要求X-Y-Z时使用通过Y的快捷方式。如果他们要求X-Z,他们应该坚持走主干道,即使它有点远,需要更长的时间。这类似于Braess悖论——如果每个人都试图选择最短、最快的路线,那么随之而来的拥堵意味着这条路线不再是任何人最快的路线。从这里开始,我们将从图论转向博弈论。

事实上,当你允许单向道路并失去对称性要求时,任何产生的距离将是数学意义上的距离函数的希望都将破灭。失去三角不等式也只是在伤口上撒盐。

就静态道路网络的查询时间而言,目前最先进的技术是Abraham等人提出的Hub标签算法http://link.springer.com/chapter/10.1007/978-3-642-20662-7_20。最近,微软技术报告http://research.microsoft.com/pubs/207102/MSR-TR-2014-4.pdf发布了一份关于该领域的全面而出色的调查报告。

简短的说法是……

Hub标签算法为静态道路网络提供了最快的查询,但需要大量ram来运行(18 GiB)。

传输节点路由稍慢,不过它只需要大约2 GiB的内存,并且有更快的预处理时间。

收缩层次结构在快速预处理时间、低空间需求(0.4 GiB)和快速查询时间之间提供了一个很好的平衡。

没有一种算法是完全占主导地位的……

彼得·桑德斯的谷歌科技演讲可能会让你感兴趣

https://www.youtube.com/watch?v=-0ErpE8tQbw

还有Andrew Goldberg的演讲

https://www.youtube.com/watch?v=WPrkc78XLhw

压缩层次结构的开源实现可从KIT的Peter Sanders研究小组网站获得。http://algo2.iti.kit.edu/english/routeplanning.php

还有一篇微软写的关于CRP算法用法的博客文章…http://blogs.bing.com/maps/2012/01/05/bing-maps-new-routing-engine/

全对最短路径算法将计算图中所有顶点之间的最短路径。这将允许预先计算路径,而不需要每次寻找源和目的地之间的最短路径时都计算路径。Floyd-Warshall算法是一种全对最短路径算法。