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(**kwargs: Any) None

Close the wrapped environment.

render() tuple[RenderFrame, ...] | None

Render the environment.

Returns:

Render output from the wrapped environment.

Return type:

tuple[gymnasium.core.RenderFrame, …] | None

reset(*, seed: int | None = None, options: dict[str, Any] | None = None) tuple[ndarray[tuple[int, ...], dtype[_ScalarType_co]], 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[npt.NDArray, dict[str, Any]]

step(actions: ndarray[tuple[int, ...], dtype[_ScalarType_co]]) tuple[ndarray[tuple[int, ...], dtype[_ScalarType_co]], ndarray[tuple[int, ...], dtype[_ScalarType_co]], ndarray[tuple[int, ...], dtype[_ScalarType_co]], ndarray[tuple[int, ...], dtype[_ScalarType_co]], 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:

actions (npt.NDArray) – Batched action array (shape (1, ...)).

Returns:

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

Return type:

tuple[npt.NDArray, npt.NDArray, npt.NDArray, npt.NDArray, dict[str, Any]]