Dummy Vectorized Environments

Lightweight wrappers that expose a single environment through a VectorEnv-like API, adding a leading batch dimension of size 1.

class agilerl.vector.dummy_vec_env.DummyVecEnv(env: Env)

Wraps a single gymnasium.Env with a VectorEnv-like API.

Observations returned by reset() and step() always carry a leading batch dimension of size 1, and actions are expected to have the same leading dimension (which is stripped before forwarding to the underlying environment).

Episodes auto-reset following the gymnasium >= 1.0 next-step convention (matching gymnasium.vector.SyncVectorEnv): the step after a termination/truncation resets the environment and returns the reset observation with zero reward and both done flags False.

Parameters:

env (gymnasium.Env) – The environment to wrap.

close() None

Close the wrapped environment.

render() Any

Render the environment.

Returns:

Render output from the wrapped environment.

Return type:

Any

reset(*, seed: int | None = None, options: dict[str, Any] | None = None) tuple[ndarray, dict[str, Any]]

Reset the environment and return batched observation.

Parameters:
  • seed (int | None) – Random seed for the reset.

  • options (dict[str, Any] | None) – Additional options for the reset.

Returns:

A tuple of (obs, info) with a leading batch dim on obs.

Return type:

tuple[np.ndarray, dict[str, Any]]

step(action: ndarray) tuple[ndarray, ndarray, ndarray, ndarray, dict[str, Any]]

Take a step in the environment.

If the previous step ended the episode, the environment is reset instead (next-step autoreset) and the reset observation is returned with zero reward and False done flags.

Parameters:

action (np.ndarray) – Batched action array (shape (1, ...)).

Returns:

A tuple of (obs, reward, terminated, truncated, info) with leading batch dimensions.

Return type:

tuple[np.ndarray, np.ndarray, np.ndarray, np.ndarray, dict]