POMDPPlanners.planners.vectorized_planners package
GPU-vectorized online POMDP planners.
This package hosts planners whose whole search is expressed as batched tensor
operations over the flat-tensor belief tree in
POMDPPlanners.core.tree.vectorized_belief_tree. Unlike the Monte Carlo
Tree Search planners in POMDPPlanners.planners.mcts_planners, these run
tens of thousands of parallel simulations per planning step with no Python
per-simulation loop and no host/device synchronization.
Currently provided:
VOPPPlanner– the Vectorized Online POMDP Planner (VOPP / PORPP).
- class POMDPPlanners.planners.vectorized_planners.VOPPEpisodeRunner(planner, model, *, num_belief_particles=1000, max_steps=50, world_transition=None, world_observation=None)[source]
Bases:
objectRuns closed-loop POMDP episodes with a
VOPPPlanner.The runner owns the interaction loop but no planning policy of its own: the planner decides actions, the vectorized model supplies the dynamics and the belief filter, and an optional pair of world hooks overrides the ground-truth transition / observation when a real simulator is the world.
- Parameters:
planner (VOPPPlanner)
model (VectorizedGenerativeModel)
num_belief_particles (int)
max_steps (int)
world_transition (Callable[[Tensor, Tensor], Tensor] | None)
world_observation (Callable[[Tensor, Tensor], Tensor] | None)
- num_belief_particles
Size of the particle belief carried between steps.
- max_steps
Maximum number of actions per episode.
Example
>>> import torch >>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import ( ... ContinuousLightDarkPOMDP, ... ) >>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_vectorized_model import ( ... ContinuousLightDarkVectorizedModel, ... ) >>> from POMDPPlanners.planners.vectorized_planners import ( ... VOPPEpisodeRunner, ... VOPPPlanner, ... ) >>> _ = torch.manual_seed(0) >>> env = ContinuousLightDarkPOMDP(discount_factor=0.95, is_obstacle_hit_terminal=False) >>> model = ContinuousLightDarkVectorizedModel(env, device=torch.device("cpu")) >>> planner = VOPPPlanner( ... model, num_actions=model.num_actions, num_particles=128, ... max_depth=6, num_planning_iterations=8, ... ) >>> runner = VOPPEpisodeRunner(planner, model, num_belief_particles=256, max_steps=20) >>> initial = torch.tensor([[0.0, 5.0]]) >>> result = runner.run_episode(initial) >>> result.num_steps >= 1 True
- run_episode(initial_state, initial_particles=None)[source]
Run one closed-loop episode and return its recorded trajectory.
- Parameters:
initial_state (
Tensor) –[1, ds](or[ds]) ground-truth start state.initial_particles (
Optional[Tensor]) – Optional[num_particles, ds]initial belief; defaults to the start state replicated across the particle set.
- Return type:
- Returns:
A
VOPPEpisodeResultholding the states, beliefs, actions, rewards, planning times, and root visit counts of the episode.- Raises:
ValueError – If
initial_statedoes not describe a single state.
- class POMDPPlanners.planners.vectorized_planners.VOPPPlanner(model, num_actions, *, temperature=2.0, num_particles=1000, max_depth=10, discount_factor=0.95, num_planning_iterations=100, value_heuristic=None, belief_capacity=1024, action_capacity=1024, value_dtype=torch.float32)[source]
Bases:
objectFully vectorized online POMDP planner (VOPP / PORPP).
The planner owns a
VectorizedBeliefTreeand repeatedly expands and backs it up entirely with batched tensor operations. A single call toplan()samples particles from the supplied root belief, runs the configured number of forward-search / preference-backup iterations, and returns the greedy root action.- Parameters:
- device
Device every tensor lives on (taken from the model).
- num_actions
Size of the fixed representative action set.
Example
See the module-level docstring for a runnable example.
- plan(root_particles)[source]
Plan from a particle-set root belief and return the greedy action.
The tree is cleared, then
num_planning_iterationsforward-search / preference-backup passes refine the root action preferences. The action with the highest root preference is returned.- Parameters:
root_particles (
Tensor) –[num_root_particles, ds]states representing the current belief; iterations resamplenum_particlesof them with replacement.- Return type:
- Returns:
The index of the greedy root action in
[0, num_actions).- Raises:
ValueError – If
root_particlesis not a 2-D tensor on the planner’s device.
- property tree: VectorizedBeliefTree
The belief tree built by the most recent
plan()call.
- tree_metrics()[source]
Root-tree analysis metrics for the most recent
plan()call.Returns the same
TreeMetricsset the MCTS planners report (root action visit min / max / entropy, number of root actions, root visit count, max depth, leaf flag), making VOPP directly comparable to them.- Return type:
- Returns:
A list of
PolicyInfoVariabledescribing the current tree.
Subpackages
- POMDPPlanners.planners.vectorized_planners.vopp package
VOPPEpisodeRunnerVOPPPlanner- Submodules
- POMDPPlanners.planners.vectorized_planners.vopp.vopp module
- POMDPPlanners.planners.vectorized_planners.vopp.vopp_episode_runner module
VOPPEpisodeResultVOPPEpisodeResult.statesVOPPEpisodeResult.beliefsVOPPEpisodeResult.action_indicesVOPPEpisodeResult.rewardsVOPPEpisodeResult.plan_timesVOPPEpisodeResult.root_visit_countsVOPPEpisodeResult.reached_goalVOPPEpisodeResult.num_stepsVOPPEpisodeResult.action_indicesVOPPEpisodeResult.beliefsVOPPEpisodeResult.num_stepsVOPPEpisodeResult.plan_timesVOPPEpisodeResult.reached_goalVOPPEpisodeResult.rewardsVOPPEpisodeResult.root_visit_countsVOPPEpisodeResult.statesVOPPEpisodeResult.total_plan_timeVOPPEpisodeResult.total_root_visits
VOPPEpisodeRunner