【问题标题】:If the A* search with the Euclidean Distance heuristic allowed diagonal moves, would it still be optimal?如果使用欧几里得距离启发式的 A* 搜索允许对角线移动,它仍然是最优的吗?
【发布时间】:2019-07-28 10:27:05
【问题描述】:

因此,如果我在一个 10x10 的迷宫中进行 A* 搜索,其中包含 10 个障碍物,并且我允许在其中进行对角线移动,它仍然是最优的吗?

我的回答是它仍然是最优的,这是因为欧几里得距离已经计算了两点之间的直线距离,所以无论如何它都会对角地越过搜索空间,所以我认为它不会有所作为,或者甚至可以使它变得更好?不知道我的想法是否正确。

【问题讨论】:

    标签: search artificial-intelligence a-star heuristics best-first-search


    【解决方案1】:

    这取决于对角线移动的成本。

    考虑统一成本的情况:对角线移动的成本与非对角线移动的成本相同 (Chebyshev distance)。

    在这种情况下,绿点和红点之间的距离是6。一般来说:

    def chebyshev_distance(node):
        dx = abs(node.x - goal.x)
        dy = abs(node.y - goal.y)
        return max(dx, dy)
    

    而欧几里得距离启发式:

    def heuristic(node):
        dx = abs(node.x - goal.x)
        dy = abs(node.y - goal.y)
        return sqrt(dx * dx + dy * dy)
    

    给出heuristic ≅ 6.71 并高估了路径的成本,导致不可接受的启发式算法(可能找不到最佳路径)。

    一般:

    ma​​x(|dx|,|dy|) = |Max| = sqrt(Max2) ≤ sqrt(Max2 + min2) = sqrt(dx2 + dy2)

    【讨论】:

      猜你喜欢
      • 2018-08-23
      • 2019-11-05
      • 2021-10-01
      • 1970-01-01
      • 2013-03-02
      • 2011-07-19
      • 2016-11-05
      相关资源
      最近更新 更多