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.
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 failureIn the crates
heuristic-searchA* ordered by g + w * h with a rational weight, trading solution quality for speed within factor w.
Lineage
Papers
- Heuristic search viewed as path finding in a graph Ira Pohl · 1970· Artificial Intelligence