Ga naar inhoud

1. A* Search Method

The A* search algorithm was introduced in 1968 by Peter Hart, Nils Nilsson, and Bertram Raphael at Stanford Research Institute 1. It stands as one of the most influential algorithms in artificial intelligence, combining the completeness of uninformed search with the efficiency of heuristic guidance. A* is the foundation for a vast family of pathfinding methods used in robotics, navigation, game AI, and combinatorial optimisation.

1.1 The Core Idea

A* is a best-first search algorithm that operates on a graph \(G = (V, E)\) starting from a node \(s\) and expanding nodes in an order determined by an evaluation function. It does not explicitly "search for the minimum-cost path" in the sense of enumerating and comparing all paths. Instead, it follows a principled expansion strategy: at each step it selects from an open list the node \(n\) that minimises:

\[ \begin{equation} f(n) = g(n) + h(n) \label{eq:astar_eval} \end{equation} \]

Here \(g(n)\) is the exact cost of the cheapest path found so far from the start node \(s\) to node \(n\), and \(h(n)\) is a heuristic function estimating the cost of the cheapest path from \(n\) to the goal. The function \(f(n)\) therefore estimates the total cost of a solution that passes through \(n\). This interplay between known cost and estimated future cost is what distinguishes A* from pure breadth-first or depth-first expansion, and equally from greedy best-first search, which considers only \(h(n)\) and may follow misleading short-term shortcuts.

The key theoretical result, and the central contribution of Hart, et.al. in 1968 paper 1, is that under a specific condition on the heuristic (admissibility, defined below), the first path the algorithm finds to the goal is provably optimal. Optimality is therefore a consequence of the algorithm's behaviour, not an explicit objective encoded in its mechanics.

1.2 Admissibility and Optimality

A heuristic \(h(n)\) is called admissible if it never overestimates the true cost \(h^*(n)\) to the goal:

\[ \begin{equation} h(n) \leq h^*(n) \quad \forall\, n \in V \label{eq:admissibility} \end{equation} \]

When the heuristic is admissible, A is guaranteed to find an optimal solution the first time it expands the goal node. This result was proved formally in the original paper by Hart, Nilsson, and Raphael 1 and is the central theoretical guarantee that made A so attractive to the AI community. A stronger property, consistency (also called monotonicity), requires that for every edge \((n, n')\) with cost \(c(n, n')\):

\[ \begin{equation} h(n) \leq c(n, n') + h(n') \label{eq:consistency} \end{equation} \]

A consistent heuristic is always admissible, and when consistency holds the \(f\)-values along any path are non-decreasing, which allows A* to avoid re-expanding nodes it has already closed—making the algorithm more efficient in practice. Russell and Norvig provide a thorough treatment of both conditions and their consequences 2.

1.3 The Algorithm

A maintains two sets. The open list (typically a min-priority queue ordered by \(f\)) holds nodes that have been generated but not yet expanded. The closed list* (or visited set) holds nodes that have already been expanded.

The algorithm begins by placing \(s\) in the open list with \(g(s) = 0\). At each iteration it extracts the node \(n\) with the smallest \(f(n)\). If \(n\) is the goal, the path is reconstructed by tracing back through parent pointers and the procedure terminates. Otherwise \(n\) is moved to the closed list and each of its successors \(n'\) is evaluated. If \(n'\) has not been seen before, or if the path through \(n\) offers a lower \(g\)-value than any previously recorded path, \(n'\) is inserted or updated in the open list with:

\[ \begin{equation} g(n') = g(n) + c(n, n'), \qquad f(n') = g(n') + h(n') \label{eq:astar_update} \end{equation} \]

The algorithm is both complete (it will always find a solution if one exists on a finite graph) and, under admissibility, optimally efficient: no algorithm with the same heuristic information can expand fewer nodes while guaranteeing optimality 3.

1.4 Heuristic Design

The practical performance of A depends critically on the quality of \(h(n)\). A heuristic that is well-informed—meaning \(h(n)\) is close to \(h^*(n)\)—leads to far fewer node expansions than a weak or uninformative one. A classic example is the Manhattan distance* heuristic used in grid-based pathfinding, which counts the minimum number of horizontal and vertical steps between two cells and is admissible whenever diagonal moves are forbidden. For the Euclidean plane, the straight-line distance to the goal is a natural admissible heuristic.

Judea Pearl thoroughly analyses the relationship between heuristic accuracy and search efficiency in his monograph on heuristic search 3, showing that the expected number of node expansions grows polynomially with problem size when a tight heuristic is available, compared to exponential growth with an uninformative one. In practice, designing a good heuristic often requires deep domain knowledge, and there is no universal recipe for obtaining one.

1.5 Variants and Extensions

Several important variants of A address its limitations. IDA* (Iterative Deepening A), introduced by Korf, eliminates the open list by performing iterative deepening with the \(f\)-cost as the threshold, drastically reducing memory requirements while preserving optimality. SMA* (Simplified Memory-Bounded A) discards the least promising frontier nodes whenever memory is exhausted, retaining enough information to regenerate them if needed. Weighted A** relaxes the optimality requirement by using:

\[ \begin{equation} f(n) = g(n) + w \cdot h(n), \quad w > 1 \label{eq:weighted_astar} \end{equation} \]

trading solution quality (the returned path costs at most \(w \cdot f^*\)) for substantially faster search. These extensions, along with their formal analyses, are discussed in detail by Russell and Norvig 2.

1.6 Complexity

In the worst case, A expands all nodes \(n\) with \(f(n) < f^*\), where \(f^*\) is the optimal solution cost. The time complexity is therefore exponential in the depth of the solution, identical to that of uninformed search in the worst case. However, with a near-perfect heuristic the number of expanded nodes approaches the length of the optimal path itself, making A effectively polynomial in practice. The space complexity is \(O(b^d)\), where \(b\) is the branching factor and \(d\) is the depth of the shallowest optimal solution, since all generated nodes must be retained in memory.

1.7 Applications and Relevance

Since its introduction, A has become the reference algorithm for single-source shortest-path problems in AI. It underlies route-planning systems in mapping services such as GPS navigation, robotic motion planning where a robot must move around obstacles, video game pathfinding where hundreds of agents may search simultaneously, and natural language parsing where the search space is a lattice of partial analyses. Nilsson 4 provided early context for A's role within the broader landscape of problem-solving methods in AI, helping establish it as a go-to technique for graph search.

1.8 Limitations and Challenges

Despite its strengths, A faces meaningful challenges in practice. Its memory requirements can become prohibitive in large state spaces, since all frontier nodes must be stored simultaneously in the open list. Designing an effective admissible heuristic is non-trivial and highly domain-dependent; a poor heuristic degrades performance toward that of Dijkstra's algorithm or worse. A is also sensitive to the representation of the problem: the same search problem formulated with a finer or differently structured state space may require orders of magnitude more computation. Finally, in dynamic environments where edge costs change while the algorithm runs, A must be restarted or replaced with incremental variants such as D or D* Lite, which update the search tree efficiently as new information arrives.

1.9 Interactive Demonstration

The animation below runs A step by step on a small grid. Each cell in the open list shows its current \(f\), \(g\), and \(h\) values. The Manhattan distance is used as the heuristic. Use Step to advance one expansion at a time, or Play* to run automatically.

The numbers along the top and left edges are the column and row indices of each cell. The start node S sits at (row 1, col 1) and the goal G at (row 8, col 12). Because no moves have been made yet, \(g(s)=0\), so the initial \(f\)-value is driven entirely by the heuristic:

\[h(s) = |1-8| + |1-12| = 7 + 11 = 18\]

This is the Manhattan distance — the minimum number of horizontal and vertical steps needed to reach the goal on an obstacle-free grid.


  1. Peter E. Hart, Nils J. Nilsson, and Bertram Raphael. A formal basis for the heuristic determination of minimum cost paths. IEEE Transactions on Systems Science and Cybernetics, 4(2):100–107, 1968. doi:10.1109/TSSC.1968.300136. ↩↩↩

  2. Stuart Russell and Peter Norvig. Artificial Intelligence: A Modern Approach. Pearson, 4th edition, 2020. ISBN 978-0-13-461099-3. ↩↩

  3. Judea Pearl. Heuristics: Intelligent Search Strategies for Computer Problem Solving. Addison-Wesley, 1984. ISBN 978-0-201-05594-0. ↩↩

  4. Nils J. Nilsson. Problem-Solving Methods in Artificial Intelligence. McGraw-Hill, 1971. ↩