简体   繁体   English

找到A *算法的启发式有哪些好方法?

[英]What are some good methods to finding a heuristic for the A* algorithm?

You have a map of square tiles where you can move in any of the 8 directions. 你有一个方形瓷砖地图,你可以在8个方向中的任何一个方向移动。 Given that you have function called cost(tile1, tile2) which tells you the cost of moving from one adjacent tile to another, how do you find a heuristic function h(y, goal) that is both admissible and consistent? 假设你有一个名为cost(tile1, tile2)函数cost(tile1, tile2)它告诉你从一个相邻的tile转移到另一个tile的成本,你如何找到一个可接受且一致的启发式函数h(y,goal)? Can a method for finding the heuristic be generalized given this setting, or would it be vary differently depending on the cost function? 在给定此设置的情况下,是否可以推广用于查找启发式的方法,还是根据cost函数的不同会有不同的变化?

Amit's tutorial is one of the best I've seen on A* (Amit's page) . Amit的教程是我在A * (Amit的页面)上看到过的最好的教程之一。 You should find some very useful hint about heuristics on this page . 您应该在此页面上找到一些关于启发式的非常有用的提示。

Here is the quote about your problem : 以下是关于您的问题的引用:

On a square grid that allows 8 directions of movement, use Diagonal distance (L∞). 在允许8个运动方向的方格上,使用对角线距离(L∞)。

It depends on the cost function. 这取决于成本函数。

There are a couple of common heuristics, such as Euclidean distance (the absolute distance between two tiles on a 2d plane) and Manhattan distance (the sum of the absolute x and y deltas). 有几种常见的启发式方法,例如欧几里德距离 (2d平面上两个瓦片之间的绝对距离)和曼哈顿距离 (绝对x和y三角洲的总和)。 But these assume that the actual cost is never less than a certain amount. 但是这些假设实际成本从不低于一定数量。 Manhattan distance is ruled out if your agent can efficiently move diagonally (ie the cost of moving to a diagonal is less than 2). 如果您的代理人可以有效地沿对角线移动(即移动到对角线的成本小于2),则排除曼哈顿距离。 Euclidean distance is ruled out if the cost of moving to a neighbouring tile is less than the absolute distance of that move (eg maybe if the adjacent tile was "downhill" from this one). 如果移动到相邻区块的成本小于该移动的绝对距离(例如,如果相邻区块是从该区域“下坡”),则排除欧几里德距离。

Edit 编辑

Regardless of your cost function, you always have an admissable and consistent heuristic in h(t1, t2) = -∞ . 无论您的成本函数如何,您总是在h(t1, t2) = -∞具有可接受且一致的启发式算法。 It's just not a good one. 这不是一个好人。

Yes, the heuristic is dependent on the cost function, in a couple of ways. 是的,启发式方法取决于成本函数,有两种方式。 First, it must be in the same units. 首先,它必须是相同的单位。 Second, you can't have a lower-cost path through actual nodes than the cost of the heuristic. 其次,您不能通过实际节点获得比启发式成本更低的成本路径。

In the real world, used for things like navigation on a road network, your heuristic might be "the time a car would take on a direct path at 1.5x the speed limit." 在现实世界中,用于道路网络导航之类的东西,你的启发式可能是“汽车在1.5倍速度限制下直接行驶的时间”。 The cost for each road segment would use the actual speed limit, which will give a higher cost. 每个路段的成本将使用实际的速度限制,这将提供更高的成本。

So, what is your cost function between tiles? 那么,瓷砖之间的成本函数是多少? Is it based on physical properties, or defined outside of your graph? 它是基于物理属性还是在图表之外定义的?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM