IDA* — Iterative Deepening A*
Prerequisites
- A* Search — f(n)=g(n)+h(n)
- Memory-Bounded Search — Why we need linear-space alternatives
🎯 Learning Objectives
- Understand IDA* as iterative deepening with f-cost cutoff
- Write IDA* pseudocode
- Analyze space O(bd) and time complexity
- Trace IDA* on a small example
1. Core Idea
IDA* applies the iterative deepening strategy to A*. Instead of using depth as the cutoff (as in IDDFS), IDA* uses the f-cost as the cutoff. Each iteration performs a depth-first search, but prunes any node whose f(n) exceeds the current cutoff. The cutoff starts at f(start) = h(start) and increases to the smallest f-value that exceeded the previous cutoff.
2. Pseudocode
function IDA-STAR(problem):
root = problem.initial_state
cutoff = h(root)
loop:
result, next_cutoff = DFS-CONTOUR(root, 0, cutoff)
if result == FOUND:
return solution
if next_cutoff == ∞:
return FAILURE
cutoff = next_cutoff
function DFS-CONTOUR(node, g, cutoff):
f = g + h(node)
if f > cutoff:
return NOT_FOUND, f // return f as candidate for next cutoff
if GOAL-TEST(node):
return FOUND, f
next_cutoff = ∞
for each action in ACTIONS(node):
child = RESULT(node, action)
result, new_f = DFS-CONTOUR(child, g + COST(action), cutoff)
if result == FOUND:
return FOUND, new_f
next_cutoff = min(next_cutoff, new_f)
return NOT_FOUND, next_cutoff
3. Properties
| Property | IDA* |
|---|---|
| Complete? | Yes (with admissible h and finite branching factor) |
| Optimal? | Yes (with admissible/consistent h) |
| Space | O(bd) — linear! (depth-first, stores only current path) |
| Time | Depends on number of distinct f-values. For integer costs: O(bd). For real-valued costs: potentially many iterations. |
IDA* is most effective when edge costs are small integers (like unit costs), because the number of distinct f-values is small, meaning few iterations are needed. For real-valued costs (e.g., Euclidean distances), many distinct f-values may exist, causing many iterations with only 1–2 new nodes explored each time.
4. Worked Examples
Tree (unit costs): S → A, S → B; A → C, A → D; B → E; C → G
h: h(S)=3, h(A)=2, h(B)=4, h(C)=1, h(D)=3, h(E)=2, h(G)=0
Iteration 1: cutoff = f(S) = 0+3 = 3
- Expand S: f(S)=3 ≤ 3 ✔
- DFS child A: f(A)=1+2=3 ≤ 3 ✔. Expand A.
- DFS child C: f(C)=2+1=3 ≤ 3 ✔. Expand C.
- DFS child G: f(G)=3+0=3 ≤ 3 ✔. Goal found!
Path: S→A→C→G, cost = 3. Found in first iteration!
Tree (unit costs): S→A, S→B; A→G(cost 2), B→G(cost 1)
h: h(S)=2, h(A)=1, h(B)=2, h(G)=0
Iteration 1: cutoff = f(S) = 0+2 = 2
- S: f=2 ✔. Expand.
- A: f=1+1=2 ✔. Expand.
- G (via A): f=1+2+0=3 > 2. Prune. Return f=3.
- B: f=1+2=3 > 2. Prune. Return f=3.
Next cutoff = min(3, 3) = 3.
Iteration 2: cutoff = 3
- S: f=2 ✔. Expand.
- A: f=2 ✔. Expand.
- G (via A): f=3 ≤ 3 ✔. Goal via S→A→G, cost=3.
But wait — Let’s also check B in this iteration: B: f=3 ≤ 3. Expand. G (via B): f=1+1+0=2 ≤ 3 ✔. Cost=2.
IDA* uses DFS order, so it explores A’s subtree first. It finds G via A (cost 3) first. But DFS-CONTOUR returns FOUND immediately upon finding the goal, so it returns cost 3. The cheaper path via B (cost 2) is missed because IDA* explores siblings left-to-right in DFS order and returns the first goal found at the current cutoff threshold.
Actually, this depends on whether IDA* continues after finding a goal at the current cutoff. Standard IDA* returns the first goal within the cutoff and is guaranteed optimal because any goal at a lower cutoff would have been found in a previous iteration. Here, G via B has f=2 < cutoff 3, so it should have been found in iteration 1. Let me re-check: f(B)=1+2=3 > 2 in iteration 1, so B itself was pruned. In iteration 2, f(B)=3 ✔, and G via B has f=2 ✔, cost=2. DFS explores A first (left child), finds G via A at cost 3. But it should also explore B. In standard IDA*, the DFS continues to find the minimum-cost goal. The correct optimal result is S→B→G with cost 2.
Summary
- IDA* = Iterative deepening with f-cost cutoff instead of depth cutoff.
- Space: O(bd) — same as DFS. Much better than A*.
- Optimal and complete with admissible heuristic.
- Best for problems with integer/unit step costs (few unique f-values).
- Standard algorithm for solving the 15-puzzle and similar problems.
References
- Korf, R. (1985). “Depth-first iterative-deepening: An optimal admissible tree search.”
- Russell & Norvig, AIMA 4th Ed. — Section 3.5.3