Consistent heuristic


In the study of path-finding problems in artificial intelligence, a heuristic function is said to be consistent, or monotone, if its estimate is always less than or equal to the estimated distance from any neighbouring vertex to the goal, plus the cost of reaching that neighbour.
Formally, for every node N and each successor P of N, the estimated cost of reaching the goal from N is no greater than the step cost of getting to P plus the estimated cost of reaching the goal from P. That is:
where
A consistent heuristic is also admissible, i.e. it never overestimates the cost of reaching the goal. This is proved by induction on, the length of the best path from node to goal. By assumption,, where denotes the cost of the shortest path from n to the goal. Therefore,
making it admissible.

Consequences of monotonicity

Consistent heuristics are called monotone because the estimated final cost of a partial solution, is monotonically non-decreasing along the best path to the goal, where is the cost of the best path from start node to. It's necessary and sufficient for a heuristic to obey the triangle inequality in order to be consistent.
In the A* search algorithm, using a consistent heuristic means that once a node is expanded, the cost by which it was reached is the lowest possible, under the same conditions that Dijkstra's algorithm requires in solving the shortest path problem. In fact, if the search graph is given cost for a consistent, then A* is equivalent to best-first search on that graph using Dijkstra's algorithm. In the unusual event that an admissible heuristic is not consistent, a node will need repeated expansion every time a new best cost is achieved for it.
If the given heuristic is admissible but not consistent, one can artificially force the heuristic values along a path to be monotonically non-decreasing
by using
as the heuristic value for instead of, where is the node immediately preceding on the path and. This idea is due to László Mérō
and is now known as pathmax.
Contrary to common belief, pathmax does not turn an admissible heuristic into a consistent heuristic. For example, if A* uses pathmax and a heuristic that is admissible but not consistent, it is not guaranteed to have an optimal path to a node when it is first expanded.