Constrained and risk-sensitive variants
Five planners here change what the search optimizes, not how it searches. Two keep an expected-cost budget; three replace the mean in the value backup with a tail measure.
Cost-constrained (dual ascent). CPFT_DPW and CPOMCPOW are
PFT-DPW and POMCPOW under a Lagrangian: the search maximizes
reward minus lambda times cost. After every simulation, dual ascent moves
lambda by lambda_step times the greedy root action’s estimated cost
minus cost_budget, clipped at zero, so lambda grows while the cost is
over budget and shrinks toward zero while it is under.
The search machinery is untouched; only the value being backed up changes. The
cost comes from the environment, which must subclass
ConstrainedEnvironment and implement
constraint_cost(state, action, next_state).
Risk-sensitive (iterated CVaR). ICVaR_PFT_DPW, ICVaR_POMCPOW and
ICVaRSparseSampling back up the Conditional Value at Risk of the child
values instead of their mean, at every node. The result is a policy judged on
the worst alpha fraction of outcomes, so it avoids branches whose tail is
bad even when their mean is high. alpha = 1 recovers the risk-neutral
planner. These planners need no extra cost from the environment: the cost they
minimize is the negative reward.
Notes
Constrained planners: Jamgochian, A., Corso, A., & Kochenderfer, M. J. (2023). Online Planning for Constrained POMDPs with Continuous Spaces through Dual Ascent. ICAPS 33, 198-202. https://doi.org/10.1609/icaps.v33i1.27195
CVaR planners: Pariente, Y., & Indelman, V. (2026). Online Risk-Averse Planning in POMDPs Using Iterated CVaR Value Function. arXiv:2601.20554. https://arxiv.org/abs/2601.20554
CPFT_DPWandCPOMCPOWare not in the policy registry — import them directly.ICVaR_PFT_DPWandICVaR_POMCPOWtakemin_immediate_costandmax_immediate_cost: the bounds the tail estimate is normalized against.ICVaR_POMCPOWrequires them;ICVaR_PFT_DPWdefaults them to0and1, so set them to your environment’s cost range.
Can I use?
Discrete |
Continuous |
|
|---|---|---|
State |
✔️ |
✔️ |
Action |
✔️ |
✔️ |
Observation |
✔️ |
✔️ |
Also supports |
|
|---|---|
Cost constraints |
✔️ |
GPU |
❌ |
ICVaRSparseSampling is the exception: it takes discrete actions only and
does no widening.
Example
The example adds a cost to Light-Dark: every step longer than 0.5 costs 1.
CPFT_DPW then plans to keep the expected cost at or below cost_budget.
import numpy as np
from POMDPPlanners.core.belief import get_initial_belief
from POMDPPlanners.core.environment import ConstrainedEnvironment
from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
ContinuousLightDarkPOMDP,
)
from POMDPPlanners.planners.mcts_planners.constrained_pft_dpw import CPFT_DPW
from POMDPPlanners.utils.action_samplers import UnitCircleActionSampler
class LightDarkWithStepCost(ContinuousLightDarkPOMDP, ConstrainedEnvironment):
"""Light-Dark with a cost of 1 for every step longer than 0.5."""
def constraint_cost(self, state, action, next_state):
return np.array([float(np.linalg.norm(action) > 0.5)])
np.random.seed(0)
env = LightDarkWithStepCost(discount_factor=0.95)
planner = CPFT_DPW(
environment=env,
discount_factor=0.95,
depth=5,
name="example_cpft_dpw",
action_sampler=UnitCircleActionSampler(max_action_magnitude=1.0),
cost_budget=0.5,
lambda_init=0.0,
lambda_step=0.1,
k_a=1.0,
alpha_a=0.5,
k_o=1.0,
alpha_o=0.5,
exploration_constant=1.0,
time_out_in_seconds=2.0,
)
belief = get_initial_belief(env, n_particles=50)
actions, run_data = planner.action(belief)
Parameters
- class POMDPPlanners.planners.mcts_planners.constrained_pft_dpw.CPFT_DPW(environment, discount_factor, depth, name, action_sampler, cost_budget, lambda_init=0.0, lambda_step=0.1, return_minimal_cost=True, k_a=1.0, alpha_a=0.5, k_o=1.0, alpha_o=0.5, exploration_constant=1.0, time_out_in_seconds=None, n_simulations=None, min_visit_count_per_action=1, reserve_capacity=0, log_path=None, debug=False, use_queue_logger=False)[source]
Bases:
ConstrainedMCTSMixin,PFT_DPWConstrained PFT-DPW with vector-valued dual ascent.
The Lagrangian / dual-ascent layer lives on
ConstrainedMCTSMixin; this class supplies only the PFT-DPW-specificSIMULATE(Algorithm 2 in the paper) via_simulate_path_with_cost()and its belief-cost helpers, alongside its constructor and a_reset_per_action_stateoverride that also clears the per-belief-child cost cache.Args mirror
PFT_DPWplus:environment: AConstrainedEnvironment— constraint cost is read viaenvironment.constraint_cost(s, a, s'). Passing a plainEnvironmentraisesTypeError.cost_budget: Discounted-cost budget. Scalar or 1-D array of lengthK. SeeConstrainedMCTSMixin._validate_and_pack_constraint_params().lambda_init: Initial Lagrange multiplier per constraint dimension. Defaults to0.0.lambda_step: Dual-ascent step size (> 0). Defaults to0.1.return_minimal_cost: Enable the minimal-cost propagation trick from Jamgochian et al. (2023, Section 4 “Cost backpropagation”). Defaults toTrue.
- Raises:
TypeError – If
environmentis not aConstrainedEnvironment.ValueError – See
ConstrainedMCTSMixinvalidation rules.
- Parameters:
environment (Environment)
discount_factor (float)
depth (int)
name (str)
action_sampler (ActionSampler)
cost_budget (ndarray)
lambda_init (ndarray)
lambda_step (float)
return_minimal_cost (bool)
k_a (float)
alpha_a (float)
k_o (float)
alpha_o (float)
exploration_constant (float)
time_out_in_seconds (int | None)
n_simulations (int | None)
min_visit_count_per_action (int)
reserve_capacity (int)
log_path (Path | None)
debug (bool)
use_queue_logger (bool)
Notes
Per-belief-child cost is recorded at expansion time and reused on existing-child re-sampling (matches the per-belief-child
(b', r, c)triple semantics of Algorithm 2 line 7 in the paper, generalised to vectorc).Leaf expansion uses a cost-aware random rollout that accumulates
Σ γ^t · constraint_cost(s_t, a_t, s_{t+1}).
- class POMDPPlanners.planners.mcts_planners.constrained_pomcpow.CPOMCPOW(environment, discount_factor, depth, exploration_constant, k_o, k_a, alpha_o, alpha_a, name, action_sampler, cost_budget, lambda_init=0.0, lambda_step=0.1, return_minimal_cost=True, time_out_in_seconds=None, n_simulations=None, min_visit_count_per_action=1, reserve_capacity=0, log_path=None, debug=False, use_queue_logger=False)[source]
Bases:
ConstrainedMCTSMixin,POMCPOWConstrained POMCPOW with vector-valued dual ascent.
The Lagrangian / dual-ascent layer lives on
ConstrainedMCTSMixin; this class supplies only the POMCPOW-specificSIMULATE(Algorithm 1 in the paper) via_simulate_state_path_with_cost(), alongside its constructor.Args mirror
POMCPOWplus:environment: AConstrainedEnvironment— constraint cost is read viaenvironment.constraint_cost(s, a, s'). Passing a plainEnvironmentraisesTypeError.cost_budget: Discounted-cost budget. Scalar or 1-D array of lengthK. SeeConstrainedMCTSMixin._validate_and_pack_constraint_params().lambda_init: Initial Lagrange multiplier per constraint dimension. Defaults to0.0.lambda_step: Dual-ascent step size (> 0). Defaults to0.1.return_minimal_cost: Enable the minimal-cost propagation trick from Jamgochian et al. (2023, Section 4 “Cost backpropagation”). Defaults toTrue.
- Raises:
TypeError – If
environmentis not aConstrainedEnvironment.ValueError – See
ConstrainedMCTSMixinvalidation rules.
- Parameters:
environment (Environment)
discount_factor (float)
depth (int)
exploration_constant (float)
k_o (float)
k_a (float)
alpha_o (float)
alpha_a (float)
name (str)
action_sampler (ActionSampler)
cost_budget (ndarray)
lambda_init (ndarray)
lambda_step (float)
return_minimal_cost (bool)
time_out_in_seconds (int | None)
n_simulations (int | None)
min_visit_count_per_action (int)
reserve_capacity (int)
log_path (Path | None)
debug (bool)
use_queue_logger (bool)
Notes
Leaf expansion uses a cost-aware random rollout that accumulates
Σ γ^t · constraint_cost(s_t, a_t, s_{t+1})along the trajectory, so multi-step hazards are reflected in QC backups.
- class POMDPPlanners.planners.mcts_planners.icvar_pft_dpw.ICVaR_PFT_DPW(environment, name, depth, action_sampler, discount_factor=0.95, time_out_in_seconds=None, n_simulations=None, alpha=0.1, delta=0.1, belief_child_num=5, min_immediate_cost=0.0, max_immediate_cost=1.0, min_visit_count_per_action=1, exploration_constant=1.0, k_a=1.0, alpha_a=0.5, k_o=1.0, alpha_o=0.5, visit_count_penalty=0.0, reserve_capacity=0)[source]
Bases:
ArenaPathSimulationPolicyCostSettingICVaR PFT-DPW operating on the arena
Tree+ integer node IDs.See module docstring for algorithm details and reference.
- Parameters:
environment (Environment)
name (str)
depth (int)
action_sampler (ActionSampler)
discount_factor (float)
time_out_in_seconds (int | None)
n_simulations (int | None)
alpha (float)
delta (float)
belief_child_num (int)
min_immediate_cost (float)
max_immediate_cost (float)
min_visit_count_per_action (int)
exploration_constant (float)
k_a (float)
alpha_a (float)
k_o (float)
alpha_o (float)
visit_count_penalty (float)
reserve_capacity (int)
- classmethod get_space_info()[source]
Get space type requirements for this policy class.
This class method specifies what types of action and observation spaces this policy implementation can handle, enabling compatibility checking with environments.
- Return type:
- Returns:
PolicySpaceInfo specifying required action and observation space types
Note
Subclasses must implement this method to declare their space compatibility. This is used for validation when pairing policies with environments.
- class POMDPPlanners.planners.mcts_planners.icvar_pomcpow.ICVaR_POMCPOW(environment, discount_factor, depth, exploration_constant, k_o, k_a, alpha_o, alpha_a, min_immediate_cost, max_immediate_cost, min_visit_count_per_action, delta, name, action_sampler, time_out_in_seconds=None, n_simulations=None, alpha=0.05, min_samples_per_node=10, reserve_capacity=0, log_path=None, debug=False, visit_count_penalty=0.0)[source]
Bases:
ArenaPathSimulationPolicyCostSettingICVaR POMCPOW operating on the arena
Tree+ integer node IDs.See module docstring for algorithm details and reference.
- Parameters:
environment (Environment)
discount_factor (float)
depth (int)
exploration_constant (float)
k_o (float)
k_a (float)
alpha_o (float)
alpha_a (float)
min_immediate_cost (float)
max_immediate_cost (float)
min_visit_count_per_action (int)
delta (float)
name (str)
action_sampler (ActionSampler)
time_out_in_seconds (int | None)
n_simulations (int | None)
alpha (float)
min_samples_per_node (int)
reserve_capacity (int)
log_path (Path | None)
debug (bool)
visit_count_penalty (float)
- classmethod get_space_info()[source]
Get space type requirements for this policy class.
This class method specifies what types of action and observation spaces this policy implementation can handle, enabling compatibility checking with environments.
- Return type:
- Returns:
PolicySpaceInfo specifying required action and observation space types
Note
Subclasses must implement this method to declare their space compatibility. This is used for validation when pairing policies with environments.
- class POMDPPlanners.planners.sparse_sampling_planners.icvar_sparse_sampling.ICVaRSparseSampling(environment, branching_factor, depth, alpha, name='ICVaRSparseSampling')[source]
Bases:
SparseSamplingDiscreteActionsPlannerRisk-sensitive sparse sampling planner using CVaR for value backups.
This planner extends the standard sparse sampling algorithm by replacing the expected value (mean) in Q-value computation with the Conditional Value at Risk (CVaR). CVaR focuses on the worst-alpha fraction of outcomes, making the planner risk-sensitive.
- The standard Q-value update uses:
Q = immediate_cost + gamma * mean(child_v_values)
- The ICVaR variant replaces this with:
Q = immediate_cost + gamma * CVaR_alpha(child_v_values)
- Parameters:
environment (DiscreteActionsEnvironment)
branching_factor (int)
depth (int)
alpha (float)
name (str)
- alpha
CVaR confidence level (0 < alpha <= 1). Lower alpha means more risk-sensitive (focuses on worse outcomes). alpha=1.0 recovers the standard expected value.
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 risk-sensitive planner >>> tiger = TigerPOMDP(discount_factor=0.95) >>> planner = ICVaRSparseSampling( ... environment=tiger, ... branching_factor=2, ... depth=2, ... alpha=0.3, ... name="ICVaRPlanner" ... ) >>> >>> # Basic planner interface usage >>> planner.name 'ICVaRPlanner' >>> planner.alpha 0.3 >>> >>> # 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 = ICVaRSparseSampling.get_space_info() >>> space_info.action_space.name 'DISCRETE'
- classmethod get_space_info()[source]
Get space type requirements for this policy class.
This class method specifies what types of action and observation spaces this policy implementation can handle, enabling compatibility checking with environments.
- Return type:
- Returns:
PolicySpaceInfo specifying required action and observation space types
Note
Subclasses must implement this method to declare their space compatibility. This is used for validation when pairing policies with environments.