kb/data/en.wikipedia.org/wiki/Consistent_heuristic-0.md

7.9 KiB
Raw Blame History

title chunk source category tags date_saved instance
Consistent heuristic 1/2 https://en.wikipedia.org/wiki/Consistent_heuristic reference science, encyclopedia 2026-05-05T09:57:25.369916+00:00 kb-cron

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:

    h
    (
    N
    )
    ≤
    c
    (
    N
    ,
    P
    )
    +
    h
    (
    P
    )
  

{\displaystyle h(N)\leq c(N,P)+h(P)}

and

    h
    (
    G
    )
    =
    0.
    
  

{\displaystyle h(G)=0.\,}

where

h is the consistent heuristic function N is any node in the graph P is any descendant of N G is any goal node c(N,P) is the cost of reaching node P from N Informally, every node i will give an estimate that, accounting for the cost to reach the next node, is always lesser than or equal to the estimate at node i+1. A consistent heuristic is also admissible, i.e. it never overestimates the cost of reaching the goal (the converse, however, is not always true). Assuming non negative edges, this can be easily proved by induction. Let

    h
    (
    
      N
      
        0
      
    
    )
    =
    0
  

{\displaystyle h(N_{0})=0}

be the estimated cost for the goal node. This implies that the base condition is trivially true as 0 ≤ 0. Since the heuristic is consistent,

    h
    (
    
      N
      
        i
        +
        1
      
    
    )
    ≤
    c
    (
    
      N
      
        i
        +
        1
      
    
    ,
    
      N
      
        i
      
    
    )
    +
    h
    (
    
      N
      
        i
      
    
    )
    ≤
    c
    (
    
      N
      
        i
        +
        1
      
    
    ,
    
      N
      
        i
      
    
    )
    +
    c
    (
    
      N
      
        i
      
    
    ,
    
      N
      
        i
        
        1
      
    
    )
    +
    .
    .
    .
    +
    c
    (
    
      N
      
        1
      
    
    ,
    
      N
      
        0
      
    
    )
    +
    h
    (
    
      N
      
        0
      
    
    )
  

{\displaystyle h(N_{i+1})\leq c(N_{i+1},N_{i})+h(N_{i})\leq c(N_{i+1},N_{i})+c(N_{i},N_{i-1})+...+c(N_{1},N_{0})+h(N_{0})}

by expansion of each term. The given terms are equal to the true cost,

      ∑
      
        i
        =
        1
      
      
        n
      
    
    c
    (
    
      N
      
        i
      
    
    ,
    
      N
      
        i
        
        1
      
    
    )
  

{\displaystyle \sum _{i=1}^{n}c(N_{i},N_{i-1})}

, so any consistent heuristic is also admissible since it is upperbounded by the true cost. The converse is clearly not true as we can always construct a heuristic that is always below the true cost but is nevertheless inconsistent by, for instance, increasing the heuristic estimate from the farthest node as we get closer and, when the estimate

    h
    (
    
      N
      
        i
      
    
    )
  

{\displaystyle h(N_{i})}

becomes at most the true cost

      h
      
        
      
    
    (
    
      N
      
        i
      
    
    )
  

{\displaystyle h^{*}(N_{i})}

, we make

    h
    (
    
      N
      
        i
        
        1
      
    
    )
    =
    h
    (
    
      N
      
        i
      
    
    )
    
    c
    (
    
      N
      
        i
      
    
    ,
    
      N
      
        i
        
        1
      
    
    )
  

{\displaystyle h(N_{i-1})=h(N_{i})-c(N_{i},N_{i-1})}

.

== Consequences of monotonicity ==

Consistent heuristics are called monotone because the estimated final cost of a partial solution,

    f
    (
    
      N
      
        j
      
    
    )
    =
    g
    (
    
      N
      
        j
      
    
    )
    +
    h
    (
    
      N
      
        j
      
    
    )
  

{\displaystyle f(N_{j})=g(N_{j})+h(N_{j})}

is monotonically non-decreasing along any path, where

    g
    (
    
      N
      
        j
      
    
    )
    =
    
      ∑
      
        i
        =
        2
      
      
        j
      
    
    c
    (
    
      N
      
        i
        
        1
      
    
    ,
    
      N
      
        i
      
    
    )
  

{\displaystyle g(N_{j})=\sum _{i=2}^{j}c(N_{i-1},N_{i})}

is the cost of the best path from start node

      N
      
        1
      
    
  

{\displaystyle N_{1}}

to

      N
      
        j
      
    
  

{\displaystyle N_{j}}

. It's necessary and sufficient for a heuristic to obey the triangle inequality in order to be consistent. The justification for

    f
    (
    N
    )
  

{\displaystyle f(N)}

to be monotonically non-decreasing under a consistent heuristic is as follows: Suppose

    P
  

{\displaystyle P}

is a successor of

    N
  

{\displaystyle N}

, then

    g
    (
    P
    )
    =
    g
    (
    N
    )
    +
    c
    (
    N
    ,
    a
    ,
    P
    )
  

{\displaystyle g(P)=g(N)+c(N,a,P)}

for some action

    a
  

{\displaystyle a}

from

    N
  

{\displaystyle N}

to

    P
  

{\displaystyle P}

. Then we have that

    f
    (
    P
    )
    =
    g
    (
    P
    )
    +
    h
    (
    P
    )
    =
    g
    (
    N
    )
    +
    c
    (
    N
    ,
    a
    ,
    P
    )
    +
    h
    (
    P
    )
    ≥
    g
    (
    N
    )
    +
    h
    (
    N
    )
    =
    f
    (
    N
    )
  

{\displaystyle f(P)=g(P)+h(P)=g(N)+c(N,a,P)+h(P)\geq g(N)+h(N)=f(N)}