Problem Solving by Search (9hrs) · Introduction to AI

Heuristic function design and admissibility/consistency

Watch lectures

Heuristic Function Design and Admissibility / Consistency — Beginner-Friendly Notes

1. What Is a Heuristic

h(n)h(n) = estimate of cheapest true cost from nn to goal h∗(n)h*(n). Good heuristics make A* fast; bad ones make it slow or non-optimal.

2. Admissibility — Never Overestimate

Admissible iff for every node nn: h(n)≤h∗(n)h(n) \leq h*(n) (optimistic, never thinks it is farther than reality).

  • Example: straight-line distance ≤ actual road distance → admissible.
  • 8-puzzle: misplaced tiles (h1h1) and Manhattan distance (h2h2) are admissible; if you count diagonal moves as 1, it would be inadmissible if it overestimates.

If hh is admissible, A is optimal* (tree search) — standard exam theorem.

3. Consistency (Monotonicity) — Stronger Condition

Consistent iff for every edge n→n′n \rightarrow n' with cost c(n,n′)c(n,n'): h(n)≤c(n,n′)+h(n′)h(n) \leq c(n,n') + h(n') (triangle inequality), and h(goal)=0h(goal)=0.

  • Means f(n)=g(n)+h(n)f(n)=g(n)+h(n) never decreases along a path — ff is monotonic.
  • Consistent ⇒ Admissible (but not vice versa).
  • With consistency, A* graph search is optimal and never needs to re-open closed nodes.

Beginner mnemonic: Admissible = optimistic. Consistent = optimistic and smooth.

4. Dominance — Which Heuristic to Pick

h2h2 dominates h1h1 if for all nn, h2(n)≥h1(n)h2(n) \geq h1(n) and both admissible → h2h2 is better (expands fewer nodes, still optimal).

  • Example: Manhattan h2h2 dominates misplaced-tiles h1h1 for 8-puzzle → always prefer h2h2.
  • Best hh is h∗(n)h*(n) itself (perfect), but computing it is as hard as solving the problem.

5. How to Design Heuristics (3 tricks)

  1. Relax the problem: allow illegal moves, cost of relaxed problem ≤ real cost → admissible. (e.g., allow tiles to move anywhere → misplacedtiles).
  2. Use pattern database: precompute exact costs for subproblems.
  3. Learn it: train a model to predict h∗(n)h*(n).

6. Common Exam Traps

  • Admissible does not mean "good" — h(n)=0h(n)=0 is admissible (then A* = UCS) but not informative.
  • Inconsistent but admissible hh can still be optimal with tree search, but graph search may need to re-expand nodes.

7. One-Line Summary

A heuristic is admissible if it never overestimates h∗(n)h*(n) (ensuring A* optimality) and consistent if h(n)≤c(n,n′)+h(n′)h(n) \leq c(n,n')+h(n') (ensuring monotonic ff and graph-search optimal efficiency); dominant heuristics among admissible ones should be preferred.

8. Quick Self-Check

  1. Is h(n)=h∗(n)+2h(n)=h*(n)+2 admissible?
  2. Does consistent imply admissible? Does admissible imply consistent?
  3. Which dominates for 8-puzzle: h1=2h1=2, h2=4h2=4 when truth is 5?
Student FinanceWeb Platform

Pocketly — Personal Finance for Students

Keep your hostel and college expenses under control. Track accounts, log spending in seconds, and stay within your monthly budget.

← All Introduction to AI modules