Sparse sampling
The forward-search baseline of Kearns, Mansour and Ng (2002). Sparse sampling
builds a full lookahead tree of fixed depth: at every node it expands every
action, samples
branching_factor outcomes per action, and solves the tree by dynamic
programming from the leaves up. Nothing is adaptive — the tree’s shape is a
function of branching_factor and depth alone, and the same tree is built
no matter what the values turn out to be.
That is why it is useful as a comparison point: it has no exploration heuristic to tune, so a planner that beats it is beating the search, not the tuning.
Notes
Original paper: Kearns, M., Mansour, Y., & Ng, A. Y. (2002). A Sparse Sampling Algorithm for Near-Optimal Planning in Large Markov Decision Processes. Machine Learning 49, 193-208. https://link.springer.com/article/10.1023/A:1017932429737
Cost grows as
(|A| * branching_factor) ** depth. Small depths only.The CVaR variant is in Constrained and risk-sensitive variants.
Can I use?
Discrete |
Continuous |
|
|---|---|---|
State |
✔️ |
✔️ |
Action |
✔️ |
❌ |
Observation |
✔️ |
✔️ |
Also supports |
|
|---|---|
Cost constraints |
❌ |
GPU |
❌ |
Example
import numpy as np
from POMDPPlanners.core.belief import get_initial_belief
from POMDPPlanners.environments.tiger_pomdp import TigerPOMDP
from POMDPPlanners.planners.sparse_sampling_planners.sparse_sampling import (
SparseSamplingDiscreteActionsPlanner,
)
np.random.seed(42)
tiger = TigerPOMDP(discount_factor=0.95)
planner = SparseSamplingDiscreteActionsPlanner(
environment=tiger,
branching_factor=2,
depth=2,
name="ExamplePlanner",
)
belief = get_initial_belief(tiger, n_particles=10)
actions, run_data = planner.action(belief)
Parameters
- class POMDPPlanners.planners.sparse_sampling_planners.sparse_sampling.SparseSamplingDiscreteActionsPlanner(environment, branching_factor, depth, name='SparseSamplingDiscreteActionsPlanner')[source]
Bases:
BaseSparseSamplingDiscreteActionsPlannerStandard implementation of sparse sampling for POMDP planning.
This concrete implementation of sparse sampling uses standard value updates: - Q-values for actions are computed as immediate cost plus discounted future value - V-values for beliefs are computed as the minimum Q-value over actions (cost formulation) - Leaf nodes use only immediate cost estimates
The algorithm provides theoretical guarantees: with probability 1-δ, the computed policy is ε-optimal, where ε decreases with increasing depth and branching factor.
Example
>>> import numpy as np >>> from POMDPPlanners.environments.tiger_pomdp import TigerPOMDP >>> from POMDPPlanners.core.belief import get_initial_belief >>> np.random.seed(42) # For reproducible results >>> >>> # Create environment and planner >>> tiger = TigerPOMDP(discount_factor=0.95) >>> planner = SparseSamplingDiscreteActionsPlanner( ... environment=tiger, ... branching_factor=2, ... depth=2, ... name="ExamplePlanner" ... ) >>> >>> # Basic planner interface usage >>> planner.name 'ExamplePlanner' >>> >>> # Action selection from belief >>> initial_belief = get_initial_belief(tiger, n_particles=10) >>> actions, run_data = planner.action(initial_belief) >>> >>> # Planner space information >>> space_info = SparseSamplingDiscreteActionsPlanner.get_space_info() >>> space_info.action_space.name 'DISCRETE'
- Parameters:
environment (DiscreteActionsEnvironment)
branching_factor (int)
depth (int)
name (str)