理论上看你写的是正确的。 然而,您运行 A* 的图有一个非常重要的属性,它应该是有效的,以便您知道算法会产生最佳解决方案:您使用的启发式函数应该是乐观的,即永远不要高估到目标的实际距离。如果我理解正确的话,你有几个目标节点 C 和 D,问题是 A 的启发值并不乐观,实际上它高估了(从 A 到目标节点 C 的路径只有 1,小于 h (A) = 3)。这就是为什么你实际上没有得到最佳解决方案。
Theoretically looking at what you have written it is correct. However, there is one very important property of graphs you run A* on that should be valid so that you know the algorithm produces optimal solution: The heuristic function you use should be optimistic, i.e. never overestimate the real distance to the goal. If I get it correctly you have couple of goal nodes C and D and the problem is that the heuristic value of A is not optimistic, actually it overestimates (the path from A to the goal node C is only 1, which is less than h(A) = 3). This is why you actually do not get optimal solution.
发布评论
评论(1)
理论上看你写的是正确的。
然而,您运行 A* 的图有一个非常重要的属性,它应该是有效的,以便您知道算法会产生最佳解决方案:您使用的启发式函数应该是乐观的,即永远不要高估到目标的实际距离。如果我理解正确的话,你有几个目标节点 C 和 D,问题是 A 的启发值并不乐观,实际上它高估了(从 A 到目标节点 C 的路径只有 1,小于 h (A) = 3)。这就是为什么你实际上没有得到最佳解决方案。
Theoretically looking at what you have written it is correct.
However, there is one very important property of graphs you run A* on that should be valid so that you know the algorithm produces optimal solution: The heuristic function you use should be optimistic, i.e. never overestimate the real distance to the goal. If I get it correctly you have couple of goal nodes C and D and the problem is that the heuristic value of A is not optimistic, actually it overestimates (the path from A to the goal node C is only 1, which is less than h(A) = 3). This is why you actually do not get optimal solution.