Boost Graph Library 中的最佳优先搜索

发布于 2024-10-08 15:48:25 字数 225 浏览 4 评论 0原文

我开始使用 boost 图形库。我需要一个最佳优先的搜索,我可以使用 astar_search 实现零成本。 (如果我错了,请纠正我。)

但是,我想知道是否还有另一种可能性这样做?如果不考虑成本,算法的效率应该会稍微高一些。

编辑:抱歉描述不清楚。我实际上正在实施潜在的现场搜索,因此我没有与边缘相关的任何成本/权重,而是需要进行最速下降搜索(这可以克服局部最小值)。

感谢您的任何提示!

I am starting to work with boost graph library. I need a best-first search, which I could implement using astar_search by having zero costs. (Please correct me if I'm wrong.)

However, I wonder if there is another possibility of doing this? If the costs are not considered, the algorithm should be slightly more efficient.

EDIT: Sorry for the unclear description. I am actually implementing a potential field search, so I don't have any costs/weights associated with the edges but rather need to do a steepest-descent-search (which can overcome local minima).

Thanks for any hints!

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

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

发布评论

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

评论(3

仅一夜美梦 2024-10-15 15:48:25

你绝对可以使用 A* 来解决这个问题;你需要h(x)为0,而不是g(x)。 A* 基于 F 对节点进行评级,F 定义为

F(n) = g(n) + h(n).

TotalCost = PathCost + Heuristic.

g(n) = 路径成本,从初始状态到当前状态的距离

h(n) = 启发式,从当前状态到最终状态的成本估计。

来自维基百科

Dijkstra 算法,作为另一个算法
最佳优先搜索的示例
算法,可以看作是一种特殊的
A* 的情况,其中所有 x 的 h(x) = 0。

You could definitely use A* to tackle this; you'd need h(x) to be 0 though, not g(x). A* rates nodes based on F which is defined by

F(n) = g(n) + h(n).

TotalCost = PathCost + Heuristic.

g(n) = Path cost, the distance from the initial to the current state

h(n) = Heuristic, the estimation of cost from current state to end state.

From Wikipedia:

Dijkstra's algorithm, as another
example of a best-first search
algorithm, can be viewed as a special
case of A* where h(x) = 0 for all x.

为你鎻心 2024-10-15 15:48:25

如果您熟悉 C++,我建议尝试 YAGSBPL

If you are comfortable with C++, I would suggest trying out YAGSBPL.

自控 2024-10-15 15:48:25

正如 Aphex 的答案所建议的,您可能想要使用 Dijkstra 的算法;设置边权重的一种方法是将 w(u, v) 设置为 pottial(v) - Potential(u),假设该值是非负的。 Dijkstra 算法假设边权重为正,因此距离会随着远离源节点而增加。如果您正在寻找最小的势,请翻转减法的两侧;如果你的潜力既上升又下降,你可能需要使用贝尔曼福特之类的东西,这不是最好的第一。

As suggested by Aphex's answer, you might want to use Dijkstra's algorithm; one way to set the edge weights is to set w(u, v) to potential(v) - potential(u), assuming that is nonnegative. Dijkstra's algorithm assumes that edge weights are positive and so that distances increase as you move away from the source node. If you are searching for the smallest potential, flip the sides of the subtraction; if you have potentials that go both up and down you might need to use something like Bellman-Ford which is not best-first.

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