MultiViewModel

MultiViewModel is an abstract base class that decouples the observation function (what each sensor measures) from the network simulation. Users subclass it to define per-sensor observations.

class netrl.MultiViewModel(observer_ids, obs_shapes, obs_dtypes)[source]

Bases: object

Parameters:
__init__(observer_ids, obs_shapes, obs_dtypes)[source]
Parameters:
observe(env=None, state=None)[source]

Class to implement the observations of each node

Parameters:

env (Env)

Usage pattern

import numpy as np
from netrl import MultiViewModel

class MySensors(MultiViewModel):
    def observe(self, env, state):
        """Return one observation array per observer_id."""
        return {
            self.observer_ids[0]: state[:2].astype(np.float32),
            self.observer_ids[1]: np.random.randn(8).astype(np.float32),
        }

model = MySensors(
    observer_ids=["lidar", "camera"],
    obs_shapes  =[(2,), (8,)],
    obs_dtypes  =[np.float32, np.float32],
)

The model.spaces dictionary holds the per-observer Box spaces (single-step shapes, without the buffer dimension):

model.spaces["lidar"]   # Box(shape=(2,), dtype=float32)
model.spaces["camera"]  # Box(shape=(8,), dtype=float32)

Note

MultiViewNetworkedEnv wraps each observer’s space with the buffer dimension to produce Box(shape=(buffer_size, *obs_shape)).