Memory-Bounded Search

GATE Relevance: Medium

Prerequisites

🎯 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*

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

  1. Expand the best leaf (lowest f) as normal.
  2. If memory is full, identify the worst leaf (highest f).
  3. Store the forgotten node’s f-value in its parent node.
  4. Remove the worst leaf to free memory for the new child.
  5. 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
⚠ Thrashing

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.

4. Tradeoff Summary

AlgorithmMemoryOptimal?Complete?Notes
A*ExponentialYesYesBest quality, worst memory
IDA*O(bd)YesYesGood for integer costs (see next page)
RBFSO(bd)YesYesLinear space, more overhead
SMA*User-set limitIf fitsIf fitsFlexible but may thrash
BeamO(Wb)NoNoFast, practical, not guaranteed

5. Worked Examples

Example 1: SMA* with Memory Limit of 4 Nodes
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.

Example 2: Beam Search with W=2
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