POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs package

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.ContinuousLightDarkDistanceBasedVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: ContinuousLightDarkVectorizedUpdater

Vectorized updater for the DISTANCE_BASED observation model.

Unlike ContinuousLightDarkNoObsInDarkVectorizedUpdater, this model assigns probability 0 (-inf in log space) to array observations when the particle is beyond beacon_radius from all beacons, matching the non-vectorized ContinuousLightDarkDistanceBasedObservationModel behaviour.

Inherits transition logic from ContinuousLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP, ObservationModelType,
... )
>>> env = ContinuousLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.DISTANCE_BASED,
... )
>>> updater = ContinuousLightDarkDistanceBasedVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> ll = updater.batch_observation_log_likelihood(next_p, action, "None")
>>> ll.shape
(50,)
Parameters:
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.ContinuousLightDarkNoObsInDarkVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: ContinuousLightDarkVectorizedUpdater

Vectorized updater for the NORMAL_NOISE_NO_OBS_IN_DARK observation model.

Particles far from all beacons receive "None" observations (log-likelihood 0 for "None", -inf for any array observation). Particles near a beacon use the near-beacon Gaussian distribution.

Inherits transition logic and all precomputation from ContinuousLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP, ObservationModelType,
... )
>>> env = ContinuousLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.NORMAL_NOISE_NO_OBS_IN_DARK,
... )
>>> updater = ContinuousLightDarkNoObsInDarkVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> ll = updater.batch_observation_log_likelihood(next_p, action, "None")
>>> ll.shape
(50,)
Parameters:
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.ContinuousLightDarkVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Continuous Light-Dark POMDP.

Performs all-particle transitions and observation log-likelihood evaluations using vectorized NumPy operations, replacing per-particle Python loops with batched array operations.

Parameters:
state_transition_dist

Noise distribution for state transitions.

obs_dist_near_beacon

Observation distribution when near a beacon.

obs_dist_far_from_beacon

Observation distribution when far from beacons.

beacons

Beacon positions as a (2, n_beacons) array.

beacon_radius

Distance threshold for beacon proximity.

grid_size

Grid boundary for the environment.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP,
... )
>>> env = ContinuousLightDarkPOMDP(discount_factor=0.95)
>>> updater = ContinuousLightDarkVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> next_p.shape
(50, 2)
>>> obs = np.array([5.0, 5.0])
>>> ll = updater.batch_observation_log_likelihood(next_p, action, obs)
>>> ll.shape
(50,)
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (ndarray) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

batch_transition(particles, action)[source]

Transition all particles in a single batched operation.

Parameters:
  • particles (ndarray) – Current particle states of shape (N, d).

  • action (ndarray) – Action vector.

Return type:

ndarray

Returns:

Next-state particles of shape (N, d).

property config_id: str

Return a deterministic identifier for this updater configuration.

classmethod from_environment(env)[source]

Construct an updater from a ContinuousLightDarkPOMDP instance.

Parameters:

env (ContinuousLightDarkPOMDP) – Environment to extract distribution parameters from.

Return type:

ContinuousLightDarkVectorizedUpdater

Returns:

A new ContinuousLightDarkVectorizedUpdater instance.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.DiscreteLightDarkDistanceBasedVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: DiscreteLightDarkVectorizedUpdater

Vectorized updater for the DISTANCE_BASED discrete observation model.

Error probability scales linearly per particle based on distance to the nearest beacon. Particles beyond beacon_radius receive "None" observations.

The scaling formula is:

error_factor = 0.0001 + 0.9999 * (distance / beacon_radius)

Inherits transition logic from DiscreteLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP, ObservationModelType,
... )
>>> env = DiscreteLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.DISTANCE_BASED,
... )
>>> updater = DiscreteLightDarkDistanceBasedVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", "None")
>>> ll.shape
(2,)
Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.DiscreteLightDarkNoObsInDarkVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: DiscreteLightDarkVectorizedUpdater

Vectorized updater for the NO_OBS_IN_DARK discrete observation model.

Particles far from all beacons receive "None" observations (log-likelihood 0 for "None", -inf for any array observation). Particles near a beacon use the near-beacon discrete distribution.

Inherits transition logic and precomputation from DiscreteLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP, ObservationModelType,
... )
>>> env = DiscreteLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.NO_OBS_IN_DARK,
... )
>>> updater = DiscreteLightDarkNoObsInDarkVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", "None")
>>> ll.shape
(2,)
Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.DiscreteLightDarkVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Discrete Light-Dark POMDP.

Performs all-particle transitions and observation log-likelihood evaluations using vectorized NumPy operations. The transition is stochastic: the intended action executes with probability 1 - transition_error_prob and a uniformly random other action executes otherwise.

Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

transition_error_prob

Probability of executing a random action.

observation_error_prob

Base observation error probability.

beacons

Beacon positions as a (2, n_beacons) array.

beacon_radius

Distance threshold for beacon proximity.

grid_size

Grid boundary for the environment.

actions

List of action names.

action_to_vector

Mapping from action names to direction vectors.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP,
... )
>>> env = DiscreteLightDarkPOMDP(discount_factor=0.95)
>>> updater = DiscreteLightDarkVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3], [7, 7]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> next_p.shape
(3, 2)
>>> obs = np.array([6, 5])
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", obs)
>>> ll.shape
(3,)
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

batch_transition(particles, action)[source]

Transition all particles in a single batched operation.

Parameters:
  • particles (ndarray) – Current particle states of shape (N, d).

  • action (ndarray) – Action vector.

Return type:

ndarray

Returns:

Next-state particles of shape (N, d).

property config_id: str

Return a deterministic identifier for this updater configuration.

classmethod from_environment(env)[source]

Construct an updater from a DiscreteLightDarkPOMDP instance.

Parameters:

env (DiscreteLightDarkPOMDP) – Environment to extract parameters from.

Return type:

DiscreteLightDarkVectorizedUpdater

Returns:

A new updater instance of the called class.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.GaussianBeliefUpdaterType(*values)[source]

Bases: Enum

Selector for the Gaussian belief updater variant.

LINEAR_KALMAN

Standard Kalman filter (exact for the linear dynamics).

EKF

Extended Kalman filter (linearised; equivalent to LKF here).

UKF

Unscented Kalman filter (sigma-point propagation).

EKF = 'ekf'
LINEAR_KALMAN = 'linear_kalman'
UKF = 'ukf'
POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.create_continuous_light_dark_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200, **kwargs)[source]

Create a ready-to-use belief for the Continuous Light-Dark POMDP.

For BeliefType.GAUSSIAN, the following keyword arguments are forwarded to create_continuous_light_dark_gaussian_belief():

  • updater_type (GaussianBeliefUpdaterType): defaults to GaussianBeliefUpdaterType.UKF.

  • initial_covariance (np.ndarray): defaults to np.eye(2) * 5.0.

  • use_near_beacon_noise (bool): defaults to False.

Parameters:
  • env (ContinuousLightDarkPOMDP) – ContinuousLightDarkPOMDP environment instance.

  • belief_type (BeliefType) – Desired belief representation. Defaults to BeliefType.VECTORIZED_PARTICLE.

  • n_particles (int) – Number of particles (ignored for GAUSSIAN). Defaults to 200.

  • **kwargs (Any) – Extra arguments forwarded to the Gaussian factory.

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.create_continuous_light_dark_gaussian_belief(env, updater_type, initial_covariance, use_near_beacon_noise=False)[source]

Create a GaussianBelief configured for a ContinuousLightDarkPOMDP.

The Continuous Light-Dark POMDP has linear-Gaussian dynamics:

x_{t+1} = x_t + u_t + w,  w ~ N(0, Q)
z_t     = x_{t+1} + v,    v ~ N(0, R)

so A = I, B = I, H = I with Q and R taken from the environment.

Parameters:
  • env (ContinuousLightDarkPOMDP) – ContinuousLightDarkPOMDP instance.

  • updater_type (GaussianBeliefUpdaterType) – Which Gaussian updater to use.

  • initial_covariance (ndarray) – Initial belief covariance of shape (2, 2).

  • use_near_beacon_noise (bool) – If True use the near-beacon observation covariance (env.observation_cov_matrix * 0.5); otherwise use the full covariance. Defaults to False.

Return type:

GaussianBelief

Returns:

A GaussianBelief with the selected updater.

Example

>>> import numpy as np
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP,
... )
>>> env = ContinuousLightDarkPOMDP(discount_factor=0.95)
>>> belief = create_continuous_light_dark_gaussian_belief(
...     env=env,
...     updater_type=GaussianBeliefUpdaterType.LINEAR_KALMAN,
...     initial_covariance=np.eye(2) * 5.0,
... )
>>> belief.mean.shape
(2,)
POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.create_discrete_light_dark_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200, **kwargs)[source]

Create a ready-to-use belief for the Discrete Light-Dark POMDP.

Parameters:
  • env (DiscreteLightDarkPOMDP) – DiscreteLightDarkPOMDP environment instance.

  • belief_type (BeliefType) – Desired belief representation. Defaults to BeliefType.VECTORIZED_PARTICLE.

  • n_particles (int) – Number of particles. Defaults to 200.

  • **kwargs (Any) – Reserved for future use; kept for interface compatibility.

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

Submodules

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_belief_factory module

Belief factory for the Continuous Light-Dark POMDP.

Functions:
create_continuous_light_dark_belief: Factory producing a configured belief

for ContinuousLightDarkPOMDP.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_belief_factory.create_continuous_light_dark_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200, **kwargs)[source]

Create a ready-to-use belief for the Continuous Light-Dark POMDP.

For BeliefType.GAUSSIAN, the following keyword arguments are forwarded to create_continuous_light_dark_gaussian_belief():

  • updater_type (GaussianBeliefUpdaterType): defaults to GaussianBeliefUpdaterType.UKF.

  • initial_covariance (np.ndarray): defaults to np.eye(2) * 5.0.

  • use_near_beacon_noise (bool): defaults to False.

Parameters:
  • env (ContinuousLightDarkPOMDP) – ContinuousLightDarkPOMDP environment instance.

  • belief_type (BeliefType) – Desired belief representation. Defaults to BeliefType.VECTORIZED_PARTICLE.

  • n_particles (int) – Number of particles (ignored for GAUSSIAN). Defaults to 200.

  • **kwargs (Any) – Extra arguments forwarded to the Gaussian factory.

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_gaussian_beliefs module

Factory for pre-configured Gaussian beliefs for the Continuous Light-Dark POMDP.

This module provides a single factory function that creates a GaussianBelief instance pre-configured for the ContinuousLightDarkPOMDP environment, with an enum-based selector for the updater type (Linear Kalman, EKF, or UKF).

Classes:

GaussianBeliefUpdaterType: Enum selecting the Gaussian updater variant.

Functions:

create_continuous_light_dark_gaussian_belief: Factory producing a configured GaussianBelief.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_gaussian_beliefs.GaussianBeliefUpdaterType(*values)[source]

Bases: Enum

Selector for the Gaussian belief updater variant.

LINEAR_KALMAN

Standard Kalman filter (exact for the linear dynamics).

EKF

Extended Kalman filter (linearised; equivalent to LKF here).

UKF

Unscented Kalman filter (sigma-point propagation).

EKF = 'ekf'
LINEAR_KALMAN = 'linear_kalman'
UKF = 'ukf'
POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_gaussian_beliefs.create_continuous_light_dark_gaussian_belief(env, updater_type, initial_covariance, use_near_beacon_noise=False)[source]

Create a GaussianBelief configured for a ContinuousLightDarkPOMDP.

The Continuous Light-Dark POMDP has linear-Gaussian dynamics:

x_{t+1} = x_t + u_t + w,  w ~ N(0, Q)
z_t     = x_{t+1} + v,    v ~ N(0, R)

so A = I, B = I, H = I with Q and R taken from the environment.

Parameters:
  • env (ContinuousLightDarkPOMDP) – ContinuousLightDarkPOMDP instance.

  • updater_type (GaussianBeliefUpdaterType) – Which Gaussian updater to use.

  • initial_covariance (ndarray) – Initial belief covariance of shape (2, 2).

  • use_near_beacon_noise (bool) – If True use the near-beacon observation covariance (env.observation_cov_matrix * 0.5); otherwise use the full covariance. Defaults to False.

Return type:

GaussianBelief

Returns:

A GaussianBelief with the selected updater.

Example

>>> import numpy as np
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP,
... )
>>> env = ContinuousLightDarkPOMDP(discount_factor=0.95)
>>> belief = create_continuous_light_dark_gaussian_belief(
...     env=env,
...     updater_type=GaussianBeliefUpdaterType.LINEAR_KALMAN,
...     initial_covariance=np.eye(2) * 5.0,
... )
>>> belief.mean.shape
(2,)

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_vectorized_updater module

Vectorized particle belief updaters for the Continuous Light-Dark POMDP.

This module implements concrete VectorizedParticleBeliefUpdater subclasses that perform batched state transitions and observation log-likelihood evaluations for the Continuous Light-Dark environment, replacing per-particle Python loops with NumPy array operations.

Because the state dimension is always 2, all linear-algebra operations (Cholesky sampling, Mahalanobis distance, beacon distance) are expanded into closed-form scalar arithmetic at init time, avoiding per-call solve_triangular / np.linalg.norm dispatch overhead.

Three updaters correspond to the three ObservationModelType variants:

Classes:
ContinuousLightDarkVectorizedUpdater: NORMAL_NOISE — always

returns Gaussian log-likelihoods with binary near/far noise.

ContinuousLightDarkNoObsInDarkVectorizedUpdater:

NORMAL_NOISE_NO_OBS_IN_DARK — handles "None" observations when far from beacons.

ContinuousLightDarkDistanceBasedVectorizedUpdater:

DISTANCE_BASED — handles "None" observations when beyond beacon radius.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_vectorized_updater.ContinuousLightDarkDistanceBasedVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: ContinuousLightDarkVectorizedUpdater

Vectorized updater for the DISTANCE_BASED observation model.

Unlike ContinuousLightDarkNoObsInDarkVectorizedUpdater, this model assigns probability 0 (-inf in log space) to array observations when the particle is beyond beacon_radius from all beacons, matching the non-vectorized ContinuousLightDarkDistanceBasedObservationModel behaviour.

Inherits transition logic from ContinuousLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP, ObservationModelType,
... )
>>> env = ContinuousLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.DISTANCE_BASED,
... )
>>> updater = ContinuousLightDarkDistanceBasedVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> ll = updater.batch_observation_log_likelihood(next_p, action, "None")
>>> ll.shape
(50,)
Parameters:
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_vectorized_updater.ContinuousLightDarkNoObsInDarkVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: ContinuousLightDarkVectorizedUpdater

Vectorized updater for the NORMAL_NOISE_NO_OBS_IN_DARK observation model.

Particles far from all beacons receive "None" observations (log-likelihood 0 for "None", -inf for any array observation). Particles near a beacon use the near-beacon Gaussian distribution.

Inherits transition logic and all precomputation from ContinuousLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP, ObservationModelType,
... )
>>> env = ContinuousLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.NORMAL_NOISE_NO_OBS_IN_DARK,
... )
>>> updater = ContinuousLightDarkNoObsInDarkVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> ll = updater.batch_observation_log_likelihood(next_p, action, "None")
>>> ll.shape
(50,)
Parameters:
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.continuous_light_dark_vectorized_updater.ContinuousLightDarkVectorizedUpdater(state_transition_dist, obs_dist_near_beacon, obs_dist_far_from_beacon, beacons, beacon_radius, grid_size, action_to_vector=None)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Continuous Light-Dark POMDP.

Performs all-particle transitions and observation log-likelihood evaluations using vectorized NumPy operations, replacing per-particle Python loops with batched array operations.

Parameters:
state_transition_dist

Noise distribution for state transitions.

obs_dist_near_beacon

Observation distribution when near a beacon.

obs_dist_far_from_beacon

Observation distribution when far from beacons.

beacons

Beacon positions as a (2, n_beacons) array.

beacon_radius

Distance threshold for beacon proximity.

grid_size

Grid boundary for the environment.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.continuous_light_dark_pomdp import (
...     ContinuousLightDarkPOMDP,
... )
>>> env = ContinuousLightDarkPOMDP(discount_factor=0.95)
>>> updater = ContinuousLightDarkVectorizedUpdater.from_environment(env)
>>> particles = np.random.rand(50, 2) * 10
>>> action = np.array([1.0, 0.0])
>>> next_p = updater.batch_transition(particles, action)
>>> next_p.shape
(50, 2)
>>> obs = np.array([5.0, 5.0])
>>> ll = updater.batch_observation_log_likelihood(next_p, action, obs)
>>> ll.shape
(50,)
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (ndarray) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

batch_transition(particles, action)[source]

Transition all particles in a single batched operation.

Parameters:
  • particles (ndarray) – Current particle states of shape (N, d).

  • action (ndarray) – Action vector.

Return type:

ndarray

Returns:

Next-state particles of shape (N, d).

property config_id: str

Return a deterministic identifier for this updater configuration.

classmethod from_environment(env)[source]

Construct an updater from a ContinuousLightDarkPOMDP instance.

Parameters:

env (ContinuousLightDarkPOMDP) – Environment to extract distribution parameters from.

Return type:

ContinuousLightDarkVectorizedUpdater

Returns:

A new ContinuousLightDarkVectorizedUpdater instance.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_belief_factory module

Belief factory for the Discrete Light-Dark POMDP.

Functions:
create_discrete_light_dark_belief: Factory producing a configured belief

for DiscreteLightDarkPOMDP.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_belief_factory.create_discrete_light_dark_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200, **kwargs)[source]

Create a ready-to-use belief for the Discrete Light-Dark POMDP.

Parameters:
  • env (DiscreteLightDarkPOMDP) – DiscreteLightDarkPOMDP environment instance.

  • belief_type (BeliefType) – Desired belief representation. Defaults to BeliefType.VECTORIZED_PARTICLE.

  • n_particles (int) – Number of particles. Defaults to 200.

  • **kwargs (Any) – Reserved for future use; kept for interface compatibility.

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_vectorized_updater module

Vectorized particle belief updaters for the Discrete Light-Dark POMDP.

This module implements concrete VectorizedParticleBeliefUpdater subclasses that perform batched state transitions and observation log-likelihood evaluations for the Discrete Light-Dark environment, replacing per-particle Python loops with NumPy array operations.

Three updaters correspond to the three ObservationModelType variants:

Classes:
DiscreteLightDarkVectorizedUpdater: NORMAL — discrete

observations with binary near/far error factor.

DiscreteLightDarkNoObsInDarkVectorizedUpdater:

NO_OBS_IN_DARK — returns "None" when far from beacons.

DiscreteLightDarkDistanceBasedVectorizedUpdater:

DISTANCE_BASED — per-particle linear error scaling by distance to nearest beacon.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_vectorized_updater.DiscreteLightDarkDistanceBasedVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: DiscreteLightDarkVectorizedUpdater

Vectorized updater for the DISTANCE_BASED discrete observation model.

Error probability scales linearly per particle based on distance to the nearest beacon. Particles beyond beacon_radius receive "None" observations.

The scaling formula is:

error_factor = 0.0001 + 0.9999 * (distance / beacon_radius)

Inherits transition logic from DiscreteLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP, ObservationModelType,
... )
>>> env = DiscreteLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.DISTANCE_BASED,
... )
>>> updater = DiscreteLightDarkDistanceBasedVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", "None")
>>> ll.shape
(2,)
Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_vectorized_updater.DiscreteLightDarkNoObsInDarkVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: DiscreteLightDarkVectorizedUpdater

Vectorized updater for the NO_OBS_IN_DARK discrete observation model.

Particles far from all beacons receive "None" observations (log-likelihood 0 for "None", -inf for any array observation). Particles near a beacon use the near-beacon discrete distribution.

Inherits transition logic and precomputation from DiscreteLightDarkVectorizedUpdater.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP, ObservationModelType,
... )
>>> env = DiscreteLightDarkPOMDP(
...     discount_factor=0.95,
...     observation_model_type=ObservationModelType.NO_OBS_IN_DARK,
... )
>>> updater = DiscreteLightDarkNoObsInDarkVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", "None")
>>> ll.shape
(2,)
Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

property config_id: str

Return a deterministic identifier for this updater configuration.

class POMDPPlanners.environments.light_dark_pomdp.light_dark_pomdp_beliefs.discrete_light_dark_vectorized_updater.DiscreteLightDarkVectorizedUpdater(transition_error_prob, observation_error_prob, beacons, beacon_radius, grid_size, actions, action_to_vector)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Discrete Light-Dark POMDP.

Performs all-particle transitions and observation log-likelihood evaluations using vectorized NumPy operations. The transition is stochastic: the intended action executes with probability 1 - transition_error_prob and a uniformly random other action executes otherwise.

Parameters:
  • transition_error_prob (float)

  • observation_error_prob (float)

  • beacons (np.ndarray)

  • beacon_radius (float)

  • grid_size (int)

  • actions (List[str])

  • action_to_vector (Dict[str, np.ndarray])

transition_error_prob

Probability of executing a random action.

observation_error_prob

Base observation error probability.

beacons

Beacon positions as a (2, n_beacons) array.

beacon_radius

Distance threshold for beacon proximity.

grid_size

Grid boundary for the environment.

actions

List of action names.

action_to_vector

Mapping from action names to direction vectors.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.light_dark_pomdp.discrete_light_dark_pomdp import (
...     DiscreteLightDarkPOMDP,
... )
>>> env = DiscreteLightDarkPOMDP(discount_factor=0.95)
>>> updater = DiscreteLightDarkVectorizedUpdater.from_environment(env)
>>> particles = np.array([[5, 5], [3, 3], [7, 7]], dtype=float)
>>> next_p = updater.batch_transition(particles, "right")
>>> next_p.shape
(3, 2)
>>> obs = np.array([6, 5])
>>> ll = updater.batch_observation_log_likelihood(next_p, "right", obs)
>>> ll.shape
(3,)
batch_observation_log_likelihood(next_particles, action, observation)[source]

Compute observation log-likelihoods for all particles at once.

Parameters:
  • next_particles (ndarray) – Transitioned particle states of shape (N, d).

  • action (ndarray) – Action vector.

  • observation (Union[ndarray, str]) – Observed value.

Return type:

ndarray

Returns:

Log-likelihoods of shape (N,).

batch_transition(particles, action)[source]

Transition all particles in a single batched operation.

Parameters:
  • particles (ndarray) – Current particle states of shape (N, d).

  • action (ndarray) – Action vector.

Return type:

ndarray

Returns:

Next-state particles of shape (N, d).

property config_id: str

Return a deterministic identifier for this updater configuration.

classmethod from_environment(env)[source]

Construct an updater from a DiscreteLightDarkPOMDP instance.

Parameters:

env (DiscreteLightDarkPOMDP) – Environment to extract parameters from.

Return type:

DiscreteLightDarkVectorizedUpdater

Returns:

A new updater instance of the called class.