In computer science, specifically in algorithms related to pathfinding, a heuristic function is said to be admissible if it never overestimates the cost of reaching the goal, i.e. the cost it estimates to reach the goal is not higher than the lowest possible cost from the current point in the path.[1]

## Search algorithms

An admissible heuristic is used to estimate the cost of reaching the goal state in an informed search algorithm. In order for a heuristic to be admissible to the search problem, the estimated cost must always be lower than or equal to the actual cost of reaching the goal state. The search algorithm uses the admissible heuristic to find an estimated optimal path to the goal state from the current node. For example, in A* search the evaluation function (where ${\displaystyle n}$ is the current node) is:

${\displaystyle f(n)=g(n)+h(n)}$

where

${\displaystyle f(n)}$ = the evaluation function.
${\displaystyle g(n)}$ = the cost from the start node to the current node
${\displaystyle h(n)}$ = estimated cost from current node to goal.

${\displaystyle h(n)}$ is calculated using the heuristic function. With a non-admissible heuristic, the A* algorithm could overlook the optimal solution to a search problem due to an overestimation in ${\displaystyle f(n)}$.

## Formulation

${\displaystyle n}$ is a node
${\displaystyle h}$ is a heuristic
${\displaystyle h(n)}$ is cost indicated by ${\displaystyle h}$ to reach a goal from ${\displaystyle n}$
${\displaystyle h^{*}(n)}$ is the optimal cost to reach a goal from ${\displaystyle n}$
${\displaystyle h(n)}$ is admissible if, ${\displaystyle \forall n}$
${\displaystyle h(n)\leq h^{*}(n)}$

## Construction

An admissible heuristic can be derived from a relaxed version of the problem, or by information from pattern databases that store exact solutions to subproblems of the problem, or by using inductive learning methods.

## Examples

Two different examples of admissible heuristics apply to the fifteen puzzle problem:

The Hamming distance is the total number of misplaced tiles. It is clear that this heuristic is admissible since the total number of moves to order the tiles correctly is at least the number of misplaced tiles (each tile not in place must be moved at least once). The cost (number of moves) to the goal (an ordered puzzle) is at least the Hamming distance of the puzzle.

The Manhattan distance of a puzzle is defined as:

${\displaystyle h(n)=\sum _{\text{all tiles}}{\mathit {distance}}({\text{tile, correct position}})}$

Consider the puzzle below in which the player wishes to move each tile such that the numbers are ordered. The Manhattan distance is an admissible heuristic in this case because every tile will have to be moved at least the number of spots in between itself and its correct position.[2]

 43 61 30 81 72 123 93 144 153 132 14 54 24 101 111

The subscripts show the Manhattan distance for each tile. The total Manhattan distance for the shown puzzle is:

${\displaystyle h(n)=3+1+0+1+2+3+3+4+3+2+4+4+4+1+1=36}$

## Optimality Guarantee

If an admissible heuristic is adapted in an algorithm (for example in A* search algorithm), then this algorithm would eventually find an optimal solution to the goal. A well-known and easy-to-understand example is breadth-first search. In the case of BFS, the heuristic evaluation function ${\displaystyle h(n)}$ equals to ${\displaystyle 0}$ for each node ${\displaystyle n}$, which is obviously less than the actual cost (thus underestimated). This heuristic would cause the BFS algorithm to search literally all the possible paths and eventually find the optimal solution (i.e., the shortest path to the goal).

As an example[3] of why admissibility can guarantee optimality, let's say we have costs as follows:(the cost above/below a node is the heuristic, the cost at an edge is the actual cost)

 0     10   0   100   0
START ----  O  ----- GOAL
|                   |
0|                   |100
|                   |
O ------- O  ------ O
100   1    100   1   100


So clearly we'd start off visiting the top middle node, since the expected total cost, i.e. ${\displaystyle f(n)}$, is ${\displaystyle 10+0=10}$. Then the goal would be a candidate, with ${\displaystyle f(n)}$ equal to ${\displaystyle 10+100+0=110}$. Then we'd clearly pick the bottom nodes one after the other, followed by the updated goal, since they all have ${\displaystyle f(n)}$ lower than the ${\displaystyle f(n)}$ of the current goal, i.e. their ${\displaystyle f(n)}$ is ${\displaystyle 100,101,102,102}$. So even though the goal was a candidate, we couldn't pick it because there were still better paths out there. This way, an admissible heuristic can ensure optimality.

However, note that although an admissible heuristic can guarantee final optimality, it's not necessarily efficient.

## Notes

While all consistent heuristics are admissible, not all admissible heuristics are consistent.

For tree search problems, if an admissible heuristic is used, the A* search algorithm will never return a suboptimal goal node.

## References

1. ^ Russell, S.J.; Norvig, P. (2002). Artificial Intelligence: A Modern Approach. Prentice Hall. ISBN 0-13-790395-2.
2. ^ Korf, Richard E. (2000), "Recent progress in the design and analysis of admissible heuristic functions" (PDF), Recent Progress in the Design and Analysis of Admissible Heuristic Functions, SARA 2000. Abstraction, reformulation, and approximation: 4th international symposium, Texas, USA. LNCS 1864, 1864, Springer, pp. 45–55, doi:10.1007/3-540-44914-0_3, ISBN 978-3-540-67839-7, retrieved 2010-04-26
3. ^ "Why do admissable heuristics guarantee optimality?". algorithm. Stack Overflow. Retrieved 2018-12-11.