SMA* — Simplified Memory-Bounded A*

GATE Relevance: Low

Prerequisites

  • A* Search — f(n) = g(n) + h(n) and open/closed lists
  • RBFS — recursive best-first approach and backed-up f-values
  • IDA* — iterative deepening with f-cost cutoff

🎯 Learning Objectives

  • Understand SMA* as a memory-bounded variant of A*
  • Explain the “drop worst leaf, back up f-value” mechanism
  • Write and trace SMA* pseudocode
  • Compare SMA* with RBFS and IDA*
  • Identify when SMA* is the best choice

1. Core Idea

A* is optimal and complete, but its exponential memory requirement makes it impractical for large state spaces. SMA* (Simplified Memory-Bounded A*) addresses this by using all available memory to conduct a best-first search. When memory is full and a new node needs to be added, SMA* drops the worst leaf node (the one with the highest f-value) and backs up its f-value to its parent, preserving information about the forgotten subtree.

Key Principle

SMA* behaves exactly like A* when enough memory is available. When memory runs out, it gracefully degrades by forgetting the least promising nodes while remembering how promising they were.

The algorithm was introduced by Stuart Russell (1992) as a simplification of the earlier MA* algorithm. The key innovation is that SMA* maintains a single data structure (the search queue) and uses a simple drop-and-backup strategy rather than the more complex bookkeeping of MA*.

1.1 Why Not Just Use RBFS or IDA*?

Both RBFS and IDA* use only O(bd) memory, which is minimal but wasteful when more memory is available. If a machine has, say, 8 GB of RAM, RBFS and IDA* will only use a tiny fraction of it, discarding information they could profitably retain. SMA* fills this gap: it uses whatever memory you give it, trading off between A*’s memory-hungry optimality and RBFS’s memory thriftiness.

2. How SMA* Works

SMA* maintains a priority queue (open list) of nodes, sorted by f-value. The algorithm proceeds as follows:

  1. Expand the best node (lowest f-value) from the queue.
  2. Generate one successor at a time. For each successor:
    • Compute f(successor) = max(f(parent), g(successor) + h(successor)). The max ensures f-values are non-decreasing along any path (monotonicity).
    • If the successor is already in memory with a higher f-value, update it.
  3. If memory is full and we need to insert a new node:
    • Find the worst leaf node — the leaf with the highest f-value. Break ties by choosing the shallowest such node (to preserve deeper nodes that took more work to reach).
    • Back up this node’s f-value to its parent. The parent records: “my forgotten child had f = X.”
    • Remove the worst leaf from memory.
    • Insert the new successor in its place.
  4. If a node’s best forgotten child becomes more promising than current alternatives, SMA* will regenerate it later (since the parent stores the backed-up f-value).

⚠ Important Detail

When computing f(successor), SMA* uses max(f(parent), g(s)+h(s)) rather than simply g(s)+h(s). This guarantees that f-values never decrease along a path, which is essential for the algorithm’s correctness. With a consistent heuristic this max is always equal to g(s)+h(s), but with merely admissible heuristics the parent’s f-value may be higher.

3. Pseudocode

function SMA-STAR(problem, max_nodes):
    // max_nodes = maximum number of nodes that fit in memory
    root = MAKE-NODE(problem.initial_state)
    root.f = max(g(root) + h(root), 0)  // = h(root)
    queue = priority queue ordered by f, depth (deeper preferred for ties)
    INSERT(queue, root)

    loop:
        if queue is EMPTY:
            return FAILURE

        node = BEST(queue)           // lowest-f node (deepest if tie)

        if GOAL-TEST(node.state):
            return SOLUTION(node)

        // Generate the next unexpanded successor of node
        successor = NEXT-SUCCESSOR(node)
        successor.f = max(node.f, g(successor) + h(successor))

        if ALL successors of node have been generated:
            // node is now fully expanded; update its f-value
            node.f = min(f-values of node's successors in memory)

        if memory is FULL (|queue| == max_nodes):
            // Drop the worst leaf (highest f, shallowest if tied)
            worst = WORST-LEAF(queue)
            // Back up f-value to parent
            worst.parent.forgotten_f = min(worst.parent.forgotten_f, worst.f)
            REMOVE(queue, worst)

        INSERT(queue, successor)

    return FAILURE   // unreachable if solvable within memory

📝 Implementation Notes

  • Each node tracks which successors have been generated (an index or set).
  • Each node may store a forgotten_f value representing the best f-value among forgotten children.
  • When all on-path children are exhausted and forgotten_f is promising, the node may regenerate its forgotten children.
  • Tie-breaking: among nodes with equal f, prefer the deeper node (closer to a goal). Among worst leaves with equal f, prefer the shallowest (cheapest to regenerate).

4. Properties of SMA*

PropertySMA*
Complete?Yes, if any reachable solution fits in memory (i.e., the depth of the shallowest solution ≤ max_nodes)
Optimal?Yes, if the optimal solution is reachable within the memory limit. Otherwise returns the best solution reachable in memory.
TimeDepends on memory. With ample memory: same as A*. With tight memory: may regenerate nodes many times (pathological thrashing).
SpaceO(max_nodes) — uses exactly the memory you give it
Heuristic requirementAdmissible (for optimality); consistent preferred

4.1 Completeness Condition

SMA* is complete if the shallowest goal node is reachable within the memory budget. Formally, if d is the depth of the shallowest optimal solution, then SMA* needs memory for at least d + 1 nodes (the solution path itself plus one working node). If the available memory is less than this, no memory-bounded algorithm can find the solution.

4.2 The Thrashing Problem

When memory is very tight, SMA* may repeatedly generate and forget the same nodes. Consider a search tree where many paths have similar f-values: SMA* drops a node, then the backed-up f-value at the parent makes the parent promising again, so SMA* regenerates the same child. This cycle can repeat indefinitely, making SMA* very slow despite being correct.

Thrashing Scenario

Imagine memory for 3 nodes. The search tree has root S with children A (f=5), B (f=5), and A has children C (f=6), D (f=6).

  1. Memory: {S, A, B}. Expand A → need space for C.
  2. Drop B (worst leaf, f=5, but A is being expanded so B is worst). Memory: {S, A, C}.
  3. S.forgotten_f = 5 (backed up from B). C has f=6 > 5.
  4. Regenerate B (f=5 is promising). Drop C. Memory: {S, A, B}. A.forgotten_f = 6.
  5. The cycle can repeat until SMA* resolves the tie.

SMA* eventually breaks out by raising backed-up values, but it can take many cycles.

5. Worked Example — SMA* Trace

Example: SMA* with Memory = 4 Nodes
Graph (directed, edge costs shown):
  S → A (cost 2), S → B (cost 3)
  A → C (cost 2), A → D (cost 3)
  B → G (cost 2)
  C → G (cost 3)

Heuristics: h(S)=4, h(A)=3, h(B)=2, h(C)=2, h(D)=5, h(G)=0
Memory limit: 4 nodes

Step 1: Insert S. f(S) = 0+4 = 4. Queue: {S(f=4)}.

Step 2: Expand S → generate A. f(A) = max(4, 2+3) = 5. Queue: {S(f=4), A(f=5)}.

Step 3: Generate B (next successor of S). f(B) = max(4, 3+2) = 5. S fully expanded → S.f = min(5,5) = 5. Queue: {A(f=5), B(f=5), S(f=5)}.

Step 4: Best node = A (f=5, deeper than S). Expand A → generate C. f(C) = max(5, 4+2) = 6. Memory: 4 nodes {S, A, B, C} — exactly at limit. Queue: {B(f=5), S(f=5), A(f=5), C(f=6)}.

Step 5: Best = B (f=5, deeper). Expand B → need memory for G. Memory is full! Drop worst leaf = C (f=6, shallowest worst). Back up: A.forgotten_f = 6. Remove C. Insert G(via B): f(G) = max(5, 5+0) = 5. Queue: {G(f=5), B(f=5), A(f=6), S(f=5)}.

Step 6: Best = G (f=5). GOAL-TEST(G) = true. Solution: S → B → G, cost = 5. ✔

Note how SMA* found the optimal solution using only 4 node slots. A* would have needed space for all nodes. SMA* dropped C (which led to a longer path) and used the freed memory for the goal node via B.

6. SMA* vs RBFS vs IDA*

PropertyIDA*RBFSSMA*
SpaceO(bd) — linearO(bd) — linearUser-specified (up to A*)
Uses extra memory?No — wastes available RAMNo — wastes available RAMYes — fills whatever you give it
Node regenerationHigh (entire iterations repeated)Moderate (subtrees repeated)Low if memory is ample; can thrash if tight
Real-valued costsPoor (too many unique cutoffs)GoodGood
ImplementationSimpleModerateComplex
Optimal?Yes (admissible h)Yes (admissible h)Yes (if solution fits in memory)
Best when…Integer costs, many duplicates OKMemory scarce, real-valued costsMemory available but not unlimited

7. When to Use SMA*

  • Use SMA* when you have a known memory budget and want the best possible search within that budget.
  • Use RBFS when memory is extremely limited and you want simplicity.
  • Use IDA* when step costs are uniform or integer-valued and the problem has many duplicate f-values (so few iterations are needed).
  • Use A* when you have enough memory for the entire search (SMA* degrades to A* in this case anyway).

Rule of Thumb

SMA* is most beneficial when memory is limited but not severely limited. If memory is so tight that the solution path barely fits, SMA* will thrash excessively and RBFS may be more practical despite using less memory. If memory is abundant, A* is simpler and equally fast.

Summary

  • SMA* is a memory-bounded version of A* that uses all available memory.
  • When memory is full, it drops the worst leaf (highest f, shallowest) and backs up its f-value to the parent.
  • Complete if the shallowest solution fits in memory; optimal under the same condition.
  • Gracefully degrades: with max memory it becomes A*, with minimal memory it resembles RBFS.
  • Main weakness: can thrash (repeatedly forget and regenerate nodes) when memory is tight relative to the search space.
  • Preferred over RBFS/IDA* when extra memory is available and should be exploited.

References

  • Russell, S. (1992). “Efficient memory-bounded search methods.” ECAI-92.
  • Russell & Norvig, Artificial Intelligence: A Modern Approach, 4th Ed. — Section 3.5.4.