Planning & Search in Rust
Esc

Loading…

↑↓ move ↵ open Esc close
Colour theme
All algorithms

Weighted A*

Also known as WA*

search heuristic-search

Weighted A* is A* that trusts its heuristic more. It expands the open state with the lowest g + w · h, where the weight w is at least 1. A larger w pushes the search toward the goal, so it usually expands far fewer states. The price is quality: with an admissible heuristic (one that never overestimates), the path costs at most w times the optimum (bounded-suboptimal). With w = 1 it is plain A*. The heuristic-search crate takes w as a fraction p/q and orders by q · g + p · h, so integer costs stay exact.

See it run

1/26

The start state is the only open state.

Weighted A* on a small example.Open states are expanded by f = g + w·h with w = 3, trading optimality for speed. openclosedexpandingpathwallcostly cell

Pseudocode

algorithm Weighted-A*(s₀, goal, h, w)input: start state s₀, goal test goal, admissible heuristic h, weight w ≥ 1output: a path that costs at most w times the optimum, or failureg[s₀] ← 0OPEN ← {s₀}                                  ▷ ordered by f = g + w · hwhile OPEN ≠ ∅ dos ← extract-min(OPEN)if goal(s) thenreturn path-to(s)for each (s′, c) in successors(s) doif g[s] + c < g[s′] then                 ▷ g of an unseen state is ∞g[s′] ← g[s] + cparent[s′] ← sinsert-or-update(OPEN, s′, g[s′] + w · h(s′))   ▷ w = p/q sorts as q · g + p · hreturn failure

In the crates

Lineage

Comes from

generalizes A*

Led to

ARA* builds on it

MHA* builds on it

Papers

  1. Heuristic search viewed as path finding in a graph Ira Pohl · 1970· Artificial Intelligence introduces doi 10.1016/0004-3702(70)90007-X