Memory-Bounded Search
Prerequisites
- A* Search — f(n) = g(n)+h(n), memory problem
- Admissibility & Consistency
🎯 Learning Objectives
- Understand why A* runs out of memory
- Describe SMA* and Beam Search
- Analyze the tradeoff between optimality and memory usage
1. The Memory Problem
A* stores every generated node in the frontier (open list) and explored set (closed list). For problems like the 15-puzzle, the search tree has roughly 1013 nodes. Even at 100 bytes per node, this requires about 1 petabyte of memory. A* simply cannot solve many real-world problems within available memory.
Memory-bounded search algorithms address this by limiting memory usage, trading time (or optimality) for space.
2. SMA* (Simplified Memory-Bounded A*)
SMA* works like A*, but when memory is full, it drops the worst leaf node (the one with the highest f-value) from the frontier. Before dropping, it backs up the f-value of the forgotten node to its parent, so the parent “remembers” the best f-value of its forgotten subtree.
How It Works
- Expand the best leaf (lowest f) as normal.
- If memory is full, identify the worst leaf (highest f).
- Store the forgotten node’s f-value in its parent node.
- Remove the worst leaf to free memory for the new child.
- If SMA* needs to revisit the forgotten subtree later, it re-expands the parent, now with the backed-up f-value reflecting the best known cost.
Properties
- Complete: If any solution is reachable within the memory limit
- Optimal: If the optimal solution fits in memory
- Space: Uses exactly the available memory budget
- Time: Can be much worse than A* due to re-expansion of forgotten nodes
If memory is very tight, SMA* may repeatedly generate and forget the same nodes, leading to thrashing — spending most of its time regenerating forgotten subtrees instead of making progress.
3. Beam Search
Beam search limits the size of the frontier to a fixed number W (the beam width). At each level, it keeps only the W best nodes (lowest f-values) and discards the rest.
Properties
- Space: O(W × b) — drastically reduced
- Complete: No — the optimal solution may be pruned away
- Optimal: No — for the same reason
- Practical use: Very popular in NLP (machine translation, speech recognition) where finding a “good enough” solution quickly is more important than guaranteed optimality
With W=1, beam search becomes hill climbing (greedy local search). With W=∞, it becomes standard best-first search.
4. Tradeoff Summary
| Algorithm | Memory | Optimal? | Complete? | Notes |
|---|---|---|---|---|
| A* | Exponential | Yes | Yes | Best quality, worst memory |
| IDA* | O(bd) | Yes | Yes | Good for integer costs (see next page) |
| RBFS | O(bd) | Yes | Yes | Linear space, more overhead |
| SMA* | User-set limit | If fits | If fits | Flexible but may thrash |
| Beam | O(Wb) | No | No | Fast, practical, not guaranteed |
5. Worked Examples
Tree: S→A(f=3), S→B(f=5), A→C(f=4), A→D(f=6), C→G(f=5)
Memory limit: 4 nodes
Step 1: Insert S (1 node). Expand S → {A:3, B:5}. Memory: {S, A, B} (3 nodes).
Step 2: Expand A (f=3) → {C:4, D:6}. Memory would be {S, A, B, C, D} (5 nodes) → exceeds limit!
Drop worst leaf: D (f=6). Back up f=6 to A's memory. Memory: {S, A, B, C} (4 nodes). A now records “forgotten child had f=6.”
Step 3: Expand C (f=4) → {G:5}. Memory would be 5 nodes. Drop worst leaf: B (f=5). Back up to S. Memory: {S, A, C, G} (4 nodes).
Step 4: Expand G (f=5) → Goal! Path: S→A→C→G.
Level 0: S (f=10)
Level 1: A(f=6), B(f=8), C(f=12)
Level 2 from A: D(f=5), E(f=9)
Level 2 from B: F(f=4), G(goal, f=7)
W=2: At Level 1, keep best 2: {A:6, B:8}. Discard C:12.
At Level 2: From A → {D:5, E:9}; from B → {F:4, G:7}. All candidates: {D:5, E:9, F:4, G:7}. Keep best 2: {F:4, D:5}. G is discarded!
Continue expanding F and D — they may or may not lead to the goal. The optimal path through G was lost because beam search discarded it.
With W=3: We’d keep {F:4, D:5, G:7} at Level 2, and G would be found as the goal. Wider beam = better chance of finding the optimal solution, at the cost of more memory.
Summary
- A*’s main limitation is exponential memory usage.
- SMA* drops the worst node when memory is full, backing up its f-value.
- Beam search keeps only W nodes per level — fast but incomplete and non-optimal.
- IDA* and RBFS (covered next) achieve linear space with optimality guarantees.
References
- Russell & Norvig, AIMA 4th Ed. — Section 3.5.3–3.5.5