Admissibility and consistency

Author

Clayton Cafiero

Published

2026-06-01

Admissibility and why it matters

A heuristic is said to be admissible if it never overestimates the true cost to reach the goal. In other words, for any node x, the heuristic estimate h(x) must always be less than or equal to the actual minimal cost from x to the goal. That is,

h(x) \leq h^{*}(x)

where h(x) is the heuristic—the estimated cost to goal—and h^{*}(x) is the true cost of x to the goal.

This property is crucial because it guarantees optimality.

Optimality refers to finding the best solution according to some criteria. This speaks more to the quality of the solution if one is found. To say an algorithm is optimal means that it will always find the best or a best solution if one exists, e.g., finding a minimal cost path, finding the maximum reward, etc. An optimal algorithm finds a best possible solution according to some metric—one that cannot be improved within the given constraints. Note: To say an algorithm is optimal is not necessarily saying it is the best of all possible algorithms with respect to some problem instance or class of problems.

In the case of path finding in a graph, given some start node and goal node, we’d say that an algorithm is complete if it will always find some path between the start node and the goal node, if one exists (for many problems this is sufficient). Completeness is guaranteed by finite branching and positive edge costs.

If our algorithm guarantees that it will always find a shortest path, we’d call that optimal with respect to the desired property of finding a shortest path.

  • An algorithm can be complete without being optimal.
  • Sometimes we sacrifice optimality for faster execution.
  • In some cases, finding an optimal solution is computationally infeasible (TSP, for example).

Admissibility guarantees optimality

\astar relies on the f(x) = g(x) + h(x) score to decide which node to explore next. If h(x) overestimates the cost (i.e., it is not admissible), \astar might incorrectly determine that a path through node x is more expensive than it actually is, causing the algorithm to skip or delay exploring it. This could result in \astar choosing a longer path that looks less expensive based on the inflated, inadmissible heuristic, leading to a suboptimal solution. Put another way, if the heuristic overestimates, \astar may not expand nodes that lie on the shortest path, effectively ignoring better solutions.

With an admissible heuristic, \astar is guaranteed to find an optimal solution. This happens because as the algorithm progresses it accumulates the true cost g(x), ensuring that the correct path is eventually found. Because paths are prioritized based on f score, which includes the heuristic, unpromising paths are effectively, and safely, pruned.

When a heuristic is admissible, it provides a safe lower bound on the remaining cost. This ensures that \astar will always explore the most promising nodes first, but without prematurely discarding potentially optimal solutions. Over time, as \astar explores, it refines its knowledge of the true cost and can backtrack to the correct path if needed.

Do we need to know all the actual distances in some graph to show that a heuristic is admissible?

Generally, no. Even though admissibility requires that

h(x) \leq h^{*}(x)

in all cases, if we choose an appropriate heuristic, we can prove its admissibility. In many cases, proofs of admissibility are straightforward. In other cases, proof may require considerable work.

An example of an admissible heuristic for which proof of admissibility is easy is straight-line (Euclidan) distance between two points on a map. The roads between two points may twist and turn, sometimes adding considerable distance to a journey. However, in no case can a road be any shorter than the straight-line distance between two points. There’s no teleportation. There are no negative edge weights. Therefore, there’s no shorter route between A and B than the straight-line distance between them. Thus, in this scenario, straight-line distance is admissible, because

h(x) \leq h^{*}(x)

always holds. We may not know the actual driving distance between A and B (the actual cost), but it cannot possibly be less than the straight-line distance (the heuristic).

How can we compute the heuristic if we don’t know the actual cost between two nodes?

That’s just it: we don’t need to know! If we were to erase all the roads on a map but leave the towns and cities we could compute the heuristic (straight-line distance) between any two points using their map coordinates: latitude and longitude. From these, on the assumption we can ignore the curvature of the earth for a map of a small region, we convert change in longitude to a distance in one dimension (say, x), and convert change in latitude to another (y). Pythagoras takes care of the rest.

Proofs of admissibility

It is often possible to prove admissibility without knowing the true cost between any specific pair of nodes. The following are two examples.

Euclidean distance in \mathbb{R}^3

Consider a drone navigating through three-dimensional space cluttered with obstacles—buildings, trees, terrain, restricted airspace. Possible positions are nodes in a graph; edges connect positions between which the drone can travel without obstruction, with edge cost equal to the actual distance flown along that segment. Because obstacles force detours, the actual path cost from any node to the goal may be far greater than the straight-line distance between them and we cannot know the actual cost without exploring the graph. A good heuristic is the straight-line distance from a node x to the goal g in \mathbb{R}^3:

h(x) = \|x - g\|_2 = \sqrt{(x_1 - g_1)^2 + (x_2 - g_2)^2 + (x_3 - g_3)^2}

(Recall that double vertical bars are used to denote the length of a vector: \| \mathbf{v} \|.)

Claim: h is admissible.

Proof: Let x = p_0, p_1, \ldots, p_k = g be any path from x to the goal, with total cost

\text{cost}(P) = \sum_{i=0}^{k-1} c(p_i, p_{i+1}) = \sum_{i=0}^{k-1} \|p_{i+1} - p_i\|_2

By the triangle inequality applied repeatedly we have

\|p_0 - p_k\|_2 \leq \|p_0 - p_1\|_2 + \|p_1 - p_k\|_2 \leq \cdots \leq \sum_{i=0}^{k-1} \|p_{i+1} - p_i\|_2

The left-hand side is h(x) and the right-hand side is the actual cost of the path. Since this holds for every path from x to g, it holds for the optimal path in particular:

h(x) \leq h^*(x) \quad \square

Misplaced tiles (8-puzzle)

In the 8-puzzle, states are configurations of a 3 \times 3 grid with eight numbered tiles and one blank square. Each move slides one tile into the adjacent blank; every move has cost one. Define:

h(s) = \text{number of tiles not in their goal position in state } s \text{ (blank not counted)}

Claim: h is admissible.

Proof: Let s be any state and let m = h(s) be the number of misplaced tiles. Each move displaces exactly one tile by exactly one cell, so each move can correct at most one misplacement. Therefore at least m moves are required to reach the goal from s:

h^*(s) \geq m = h(s)

Thus h(s) \leq h^*(s) for all states s. \quad \square

Note: For this problem, while counting misplaced tiles is an admissible heuristic, the sum of Manhattan distance of all tiles from their goal positions gives us a better estimate which is also admissible. A proof of admissibility of this heuristic is left as an exercise for the reader.


Consistency and why it matters

Another very desirable property of a heuristic is consistency. A heuristic is consistent if the following hold:

h(x) \leq c(x, n) + h(n), \quad \forall x,\ \forall n \in \text{neighbors}(x) \\ h(\text{goal}) = 0

where h(x) is the estimated cost of reaching the goal from x, h(n) is the estimated cost of reaching the goal from n, a neighbor of x, and c(x, n) is the actual cost of reaching neighbor n from x. This means that the estimated cost from the current node to the goal cannot be greater than the actual cost of reaching any neighbor plus the remaining estimated cost to the goal.

This is, essentially, the triangle inequality, and a heuristic is consistent if it obeys the triangle inequality. Because this also means that cost along any path to the goal is monotonically non-decreasing, some authors call this property monotonicity.

Consistency provides stronger guarantees than does admissibility.

First, if a heuristic is consistent, it is necessarily admissible, though the converse is not always true. This means that we have guarantees of optimality and completeness (with positive edge costs). However, with consistency we have an additional guarantee: if a node has been dequeued and expanded, we never need to requeue or re-expand a node. Once a node has been expanded by the algorithm, the optimal path to that node has already been found.

What can go wrong if a heuristic is not consistent?

If a heuristic is not consistent, it is possible for a node that has already been expanded to be added back to the queue.

When a node x is expanded for the first time, \astar calculates its cost g(x), removes it from the open set, and adds it to the closed set. \astar then expands the node’s neighbors and updates their costs based on this path. Later in the search, if a new path to the node x is discovered that has a lower cost than the previously calculated g(x), then \astar will update g(x) to reflect the newly-discovered lower-cost path. This can occur if the heuristic is not consistent. In such an event, if a lower-cost path to x is found, \astar will reinsert x into the queue (open set) so that it can be processed again, this time using the updated, lower cost.

This happens with inconsistent heuristics because inconsistent heuristics violate the triangle inequality, meaning that a lower-cost path to a node may be found after it has already been expanded. If the heuristic is consistent, this situation cannot occur.

Comparison

Property Admissible (only) Consistent (implies admissible)
Guarantees optimal solution? YES YES
Guarantees completeness? YES (with positive costs) YES (with positive costs)
Requires node re-expansions? MAYBE NO
Strength of guarantees weaker stronger


Monotonicity

Example

Notice that in both scenarios the heuristic (at least as far as is shown) is admissible.

Also: Let’s say there was a lower-cost path to w (not shown). The problem with an inconsistent heuristic is that it might lead us to first discover w along the path x \to y \to z \to w, when a lower-cost path exists elsewhere in the graph. In order to be assured we’ve found the lowest-cost path to w in such a case, we’d need to enqueue and dequeue w more than once!

Test your comprehension

Problem

(Solution below.)

Consistency implies admissibility (proof)

We wish to show that if a heuristic h is consistent and h(N_0) = 0 (goal) then h(N) \leq h^{*}(N) for every node N. That is, consistency implies admissibility.

Let N_k \rightarrow N_{k-1} \rightarrow \ldots \rightarrow N_1 \rightarrow N_0 be an optimal path from N_k to goal N_0.

Define:

h^{*}(N_k) = \sum\limits_{i=1}^k c(N_i, N_{i-1})

Base case:

h(N_0) = 0, and h^{*}(N_0) = 0, so h(N_0) \leq h^{*}(N_0)

Inductive hyp.

Assume for some node N_i, that h(N_i) \leq h*(N_i)

Prove for predecessor

Inductive step

Consistency gives us

h(N_{i+1}) \leq c(N_{i+1}, N_i) + h(N_i)

By I.H. h(N_i) \leq h^{*}(N_i)

Substitute (not by equivalence but by bounding upward)

h(N_{i+1}) \leq c(N_{i+1}) + h^{*}(N_i)

(since h(N_i) \leq h^{*}(N_i) we know c(N_{i+1}, N_i) + h(N_i) \leq c(N_{i+1}, N_i) + h^{*}(N_i))

By definition of true cost

h^{*}(N_{i+1}) \leq c(N_{i+1}, N_i) + h^{*}(N_i)

Therefore

h(N_{i+1}) \leq h^{*}(N_i) as desired. \square


Solution to comprehension check

Solution


Copyright © 2023–2026 Clayton Cafiero

No generative AI was used in producing drafts of this material. This was written the old-fashioned way. AI was used to rewrite existing pseudocode in LaTeX to produce standalone *.tex files for rendering, and for revisions toward satisfying WCAG 2.1 AA-level accessibility standards as required by UVM policy. It may also have been used to proofread selected human-written prose. Claude 2.1.150 with model Sonnet 4.6. Revisions, if any, were performed by the author. AI was not used in generating any code whatsoever. All code samples and starter code are by the author only.