Local beam search is an optimization of the best-first search algorithm that uses limited memory while maintaining the ability to explore multiple promising paths simultaneously. Unlike breadth-first search (which can be memory-intensive) or greedy search (which can get stuck in local optima), local beam search keeps track of k states at each step - hence the name "beam" search with beam width k.
Algorithm Description
The local beam search algorithm works as follows:
Start with k randomly generated states
Generate all successors of these k states
Select the k best successors from the combined pool of successors
Repeat steps 2-3 until a goal state is found or termination criteria are met
This approach allows the algorithm to explore multiple paths concurrently, providing better chances of finding an optimal solution than greedy approaches while being more memory-efficient than exhaustive searches.
Mathematical Example
Let's consider a graph search problem with heuristic values (where lower values are better):
We have a start node A with a goal to reach node Z. The beam width k = 2.
code
Step 1: Initialize beam with start state
Beam = {A(10)}
Step 2: Generate successors of A
Successors of A = {B(8), C(7), D(12)}
Step 3: Select best k=2 successors
Beam = {C(7), B(8)}
Step 4: Generate successors of all states in beam
Successors of C = {E(6), F(9)}
Successors of B = {G(5), H(7)}
Combined = {G(5), E(6), H(7), F(9)}
Step 5: Select best k=2 successors
Beam = {G(5), E(6)}
Step 6: Generate successors
Successors of G = {I(4), J(8)}
Successors of E = {K(3), L(7)}
Combined = {K(3), I(4), L(7), J(8)}
Step 7: Select best k=2 successors
Beam = {K(3), I(4)}
Step 8: Generate successors
Successors of K = {M(2), N(5)}
Successors of I = {O(3), P(6)}
Combined = {M(2), O(3), N(5), P(6)}
Step 9: Select best k=2 successors
Beam = {M(2), O(3)}
Step 10: Generate successors
Successors of M = {Z(0), Q(4)}
Successors of O = {R(2), S(5)}
Combined = {Z(0), R(2), Q(4), S(5)}
Step 11: Goal state Z found!
Final path: A → C → E → K → M → Z
Advantages and Limitations
Advantages:
Memory efficient (stores only k states at each step)
Can escape local optima better than greedy search
Generally faster than exhaustive search algorithms
Limitations:
Not guaranteed to find the optimal solution
Performance depends heavily on beam width k
May fail to find any solution if k is too small
Applications
Local beam search is particularly useful in:
Natural language processing (parsing, machine translation)
Planning and scheduling problems
Image recognition
Any search problem with large branching factors where exhaustive search is impractical
When implementing local beam search, selecting an appropriate beam width is crucial - too small and you risk missing solutions, too large and you lose the efficiency benefits.