liveBook · Manning

Beam search

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

An informed search technique that retains only a limited number of the most promising partial solutions at each step.

Beam search is an informed, non-exhaustive search technique that expands promising nodes while retaining only a fixed number of states. Its beam width w controls how many candidates survive at each level, reducing memory compared with breadth-first search but allowing promising routes to be discarded. section 4.1 section 4.3.2

At each iteration, beam search:

  • Generates neighboring states for every route in the current beam. section 4.3.2
  • Combines those children with the current candidates, ranks them using a heuristic or cost, and keeps the best w states. section 4.3.2
  • Repeats until the beam stops changing or reaches a goal, optionally using a beam threshold to avoid expensive sorting. section 4.3.2
  • Trades completeness and possible optimality for lower memory use; wider beams explore more alternatives but require more computation. section 4.3.2 section 4.4.2

Routing from S to G

On a small weighted graph, a beam width of w = 2 keeps two states after each expansion and can produce the route S-A-C-E-G. A larger beam or more generated children increases the chance of finding a near-optimal route, while smaller settings improve processing time. section 4.3.2 section 4.4.2

Algorithm 4.3 The beam search algorithm
Inputs: A source node, a destination node, and beam width w
Output: A route from source to destination
  
Initialize Seen ← nil
Initialize beam ← random w routes from source to destination
Add beam to seen
Initialize pool ← children of routes in the beam with consideration of seen + beam
Initialize last_beam ← nil
While beam is not last_beam do
   Update last_beam ← beam
   Update beam ← the best w routes from pool
   If last_beam == beam then break
   Add beam to seen
   Update pool ← children of routes in the beam + beam
  
Return optimal route in beam

Use the pseudocode to trace initialization, child generation, candidate selection, duplicate tracking, and termination. section 4.3.2

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Explains state retention, expansion, ranking, complexity, thresholds, and failure modes, stopping short of optimality guarantees.
Examples
Demonstrates S-to-G routing with w = 2 and larger routing experiments using k = 10 and n = 20.
What it assumes
Assumes graph-search concepts such as nodes, neighbors, routes, costs, heuristics, and breadth-first search.
What you can do after
Apply it via Python graph code by tuning beam width, generated children, costs, and route-expansion parameters.
How it connects
Contrasts with hill climbing and breadth-first search and relates to A* through informed node selection.

Also explained in

Compare how 5 books explain beam search →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.