POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs package

class POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.SafetyAntVelocityVectorizedUpdater(obs_dist, dt, mass, damping, max_force, force_scales)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Safety Ant Velocity POMDP.

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

The transition is stochastic because force direction is uniformly random, so batch_transition samples N independent force directions for N particles. Observations follow a diagonal Gaussian constructed from the environment’s position and velocity noise parameters.

Parameters:
obs_dist

Observation noise distribution (4-D diagonal Gaussian).

dt

Integration time step.

mass

Agent mass.

damping

Damping coefficient opposing velocity.

max_force

Maximum force magnitude.

force_scales

Force scaling factors for each discrete action.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.safety_ant_velocity_pomdp import (
...     SafeAntVelocityPOMDP,
... )
>>> env = SafeAntVelocityPOMDP(discount_factor=0.99)
>>> updater = SafetyAntVelocityVectorizedUpdater.from_environment(env)
>>> particles = np.column_stack([
...     np.random.uniform(-1, 1, (50, 2)),
...     np.zeros((50, 2)),
... ])
>>> action = 2
>>> next_p = updater.batch_transition(particles, action)
>>> next_p.shape
(50, 4)
>>> obs = np.array([0.0, 0.0, 0.0, 0.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 SafeAntVelocityPOMDP instance.

Parameters:

env (SafeAntVelocityPOMDP) – Environment to extract parameters from.

Return type:

SafetyAntVelocityVectorizedUpdater

Returns:

A new SafetyAntVelocityVectorizedUpdater instance.

POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.create_safety_ant_velocity_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200)[source]

Create a ready-to-use belief for the Safety Ant Velocity POMDP.

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

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

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

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

Submodules

POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.safety_ant_velocity_belief_factory module

Belief factory for the Safety Ant Velocity POMDP.

Functions:
create_safety_ant_velocity_belief: Factory producing a configured belief

for SafeAntVelocityPOMDP.

POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.safety_ant_velocity_belief_factory.create_safety_ant_velocity_belief(env, belief_type=BeliefType.VECTORIZED_PARTICLE, n_particles=200)[source]

Create a ready-to-use belief for the Safety Ant Velocity POMDP.

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

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

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

Return type:

Belief

Returns:

A configured Belief object.

Raises:

ValueError – If belief_type is not supported.

POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.safety_ant_velocity_vectorized_updater module

Vectorized particle belief updater for the Safety Ant Velocity POMDP.

This module implements a concrete VectorizedParticleBeliefUpdater that performs batched state transitions and observation log-likelihood evaluations for the Safety Ant Velocity environment, replacing per-particle Python loops with NumPy array operations.

Classes:
SafetyAntVelocityVectorizedUpdater: Batched updater for the

Safety Ant Velocity POMDP.

class POMDPPlanners.environments.safety_ant_velocity_pomdp.safety_ant_velocity_pomdp_beliefs.safety_ant_velocity_vectorized_updater.SafetyAntVelocityVectorizedUpdater(obs_dist, dt, mass, damping, max_force, force_scales)[source]

Bases: VectorizedParticleBeliefUpdater

Vectorized particle belief updater for the Safety Ant Velocity POMDP.

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

The transition is stochastic because force direction is uniformly random, so batch_transition samples N independent force directions for N particles. Observations follow a diagonal Gaussian constructed from the environment’s position and velocity noise parameters.

Parameters:
obs_dist

Observation noise distribution (4-D diagonal Gaussian).

dt

Integration time step.

mass

Agent mass.

damping

Damping coefficient opposing velocity.

max_force

Maximum force magnitude.

force_scales

Force scaling factors for each discrete action.

Example

>>> import numpy as np
>>> np.random.seed(42)
>>> from POMDPPlanners.environments.safety_ant_velocity_pomdp import (
...     SafeAntVelocityPOMDP,
... )
>>> env = SafeAntVelocityPOMDP(discount_factor=0.99)
>>> updater = SafetyAntVelocityVectorizedUpdater.from_environment(env)
>>> particles = np.column_stack([
...     np.random.uniform(-1, 1, (50, 2)),
...     np.zeros((50, 2)),
... ])
>>> action = 2
>>> next_p = updater.batch_transition(particles, action)
>>> next_p.shape
(50, 4)
>>> obs = np.array([0.0, 0.0, 0.0, 0.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 SafeAntVelocityPOMDP instance.

Parameters:

env (SafeAntVelocityPOMDP) – Environment to extract parameters from.

Return type:

SafetyAntVelocityVectorizedUpdater

Returns:

A new SafetyAntVelocityVectorizedUpdater instance.