A* 算法示例 - 它是否正确

发布于 2024-12-23 05:08:57 字数 1459 浏览 3 评论 0原文

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

倾城月光淡如水﹏ 2024-12-30 05:08:57

理论上看你写的是正确的。
然而,您运行 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文