๐Ÿ“ Monotone Condition & Pruning in A*

465 words
2 min read
Python Week 1: the first filter for runtime behavior
Visual companion
Python
Type and operator map

Python Week 1: the first filter for runtime behavior

View
Revision summary

What this note is really saying

Short form

# ๐Ÿ“ Monotone Condition & Pruning in A* ## 1. ๐ŸŽฏ Learning Objectives - State and prove the monotone (consistency) condition - Explain why consistency ensures A* never re-opens nodes - Describe pruning strategies: OPEN pruning, CLOSED pruning (frontier search) ## 2.

๐Ÿ“ Monotone Condition & Pruning in A*

1. ๐ŸŽฏ Learning Objectives

  • State and prove the monotone (consistency) condition
  • Explain why consistency ensures A* never re-opens nodes
  • Describe pruning strategies: OPEN pruning, CLOSED pruning (frontier search)

2. ๐Ÿ“– Core Content

3.1 Monotone (Consistency) Condition

Definition: A heuristic hh is consistent (or monotone) if for all nodes m and n where n is a successor of m:
h(m)โˆ’h(n)โ‰คk(m,n)h(m) - h(n) \leq k(m, n)
Where k(m,n)k(m, n) is the cost from m to n. This is essentially the triangle inequality: the heuristic drop between adjacent nodes cannot exceed the actual cost between them.

3.2 Why Consistency Matters

If hh is consistent:
  • A* never has to re-open nodes (first expansion is optimal)
  • The ff values along any path are non-decreasing
  • A* behaves like BFS with optimal cost contours Proof of non-decreasing f: Let n be a successor of m. Then:
f(n)=g(n)+h(n)=g(m)+k(m,n)+h(n)f(n) = g(n) + h(n) = g(m) + k(m,n) + h(n) f(m)=g(m)+h(m)f(m) = g(m) + h(m) f(n)โˆ’f(m)=k(m,n)+h(n)โˆ’h(m)f(n) - f(m) = k(m,n) + h(n) - h(m)
By consistency: h(m)โˆ’h(n)โ‰คk(m,n)h(m) - h(n) \leq k(m,n) โ†’ k(m,n)+h(n)โˆ’h(m)โ‰ฅ0k(m,n) + h(n) - h(m) \geq 0 Thus f(n)โ‰ฅf(m)f(n) \geq f(m) โ€” f values never decrease!

3.3 Relationship: Consistency โ†’ Admissibility

If hh is consistent, then hh is admissible. Proof: Apply consistency along the optimal path from N to goal:
h(N)โˆ’h(G)โ‰คk(N,G)h(N) - h(G) \leq k(N, G)
Since h(G)=0h(G) = 0 and k(N,G)=hโˆ—(N)k(N,G) = h^*(N):
h(N)โ‰คhโˆ—(N)h(N) \leq h^*(N)

3.4 Pruning in A*

Pruning CLOSED (Frontier Search):
  • Don't store all CLOSED nodes โ€” only keep a "relay layer" between search frontier and start
  • Used when state space is too large for full CLOSED set Pruning OPEN:
  • If two nodes have the same state, keep only the one with lower ff
  • This is already handled by A*'s g-value check

3.5 Sequence Alignment (Needleman-Wunsch)

A* can be applied to sequence alignment (bioinformatics). The Needleman-Wunsch algorithm aligns sequences by dynamic programming, which is related to A* search in the alignment state space.

4. ๐Ÿ“ Practice Questions

Q1: If h violates the consistency condition, what happens in A?*
Answer: A* may need to re-open CLOSED nodes when a better path is found. This increases computation but does not affect correctness (A* still finds optimal solution if h is admissible). Q2: Prove that Manhattan distance is consistent for the 8-puzzle.
Answer: Moving a tile one step changes its Manhattan distance by at most 1 (it gets one step closer or farther). The actual move cost is 1. So h(m)-h(n) โ‰ค 1 = k(m,n). Thus Manhattan is consistent. Join Discord PreviousWeighted A* & IDA*NextSMGS & Beam Stack
Document outline

Keep your place and jump directly to a heading.

Table of contents

No note selected

Open a chapter to see its outline, backlinks, and sources here.