Heuristic Function Design and Admissibility / Consistency — Beginner-Friendly Notes
1. What Is a Heuristic
= estimate of cheapest true cost from to goal . Good heuristics make A* fast; bad ones make it slow or non-optimal.
2. Admissibility — Never Overestimate
Admissible iff for every node : (optimistic, never thinks it is farther than reality).
- Example: straight-line distance ≤ actual road distance → admissible.
- 8-puzzle: misplaced tiles () and Manhattan distance () are admissible; if you count diagonal moves as 1, it would be inadmissible if it overestimates.
If is admissible, A is optimal* (tree search) — standard exam theorem.
3. Consistency (Monotonicity) — Stronger Condition
Consistent iff for every edge with cost : (triangle inequality), and .
- Means never decreases along a path — 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
dominates if for all , and both admissible → is better (expands fewer nodes, still optimal).
- Example: Manhattan dominates misplaced-tiles for 8-puzzle → always prefer .
- Best is itself (perfect), but computing it is as hard as solving the problem.
5. How to Design Heuristics (3 tricks)
- Relax the problem: allow illegal moves, cost of relaxed problem ≤ real cost → admissible. (e.g., allow tiles to move anywhere → misplacedtiles).
- Use pattern database: precompute exact costs for subproblems.
- Learn it: train a model to predict .
6. Common Exam Traps
- Admissible does not mean "good" — is admissible (then A* = UCS) but not informative.
- Inconsistent but admissible 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 (ensuring A* optimality) and consistent if (ensuring monotonic and graph-search optimal efficiency); dominant heuristics among admissible ones should be preferred.
8. Quick Self-Check
- Is admissible?
- Does consistent imply admissible? Does admissible imply consistent?
- Which dominates for 8-puzzle: , when truth is 5?