beamSearch
beamSearch<
TState>(initialState,traits,beamWidth,maxDepth):TState|undefined
Defined in: optimize/beam-search.ts:38
Performs a beam search over a state space.
Starting from initialState, each step expands every live state, then keeps
only the top beamWidth candidates by score. The search stops on the first
goal state in the beam, when no successors are produced, or at maxDepth.
Time complexity: O(maxDepth · beamWidth · b log(beamWidth · b)) for a
branching factor b — the sort at each step dominates.
Type Parameters
Section titled “Type Parameters”TState
Section titled “TState”TState extends DefinedValue
Parameters
Section titled “Parameters”initialState
Section titled “initialState”TState
Seed state for the search.
traits
Section titled “traits”BeamSearchTraits<TState>
How to expand, score and test a state.
beamWidth
Section titled “beamWidth”number
Maximum number of states kept after each expansion step.
maxDepth
Section titled “maxDepth”number
Maximum number of expansion steps before the search stops.
Returns
Section titled “Returns”TState | undefined
The highest-scoring surviving state, or undefined if no states
survive.