gxm.wrappers.Rollout#
- class Rollout(env)#
Bases:
WrapperWrapper that adds a rollout method to the environment.
- __init__(env)#
Methods
__init__(env)get_wrapper(wrapper_type)Retrieve the first wrapper of a specific type from the environment.
has_wrapper(wrapper_type)Check if the environment or any of its wrappers is of a specific type.
init(key)Initialize the environment and return the initial state.
reset(key, env_state)Reset the environment to its initial state.
rollout(key, env_state, pi, num_steps)step(key, env_state, action)Perform a step in the environment given an action.
Attributes
unwrapunwrappedRetrieve the base environment by unwrapping all wrappers.
envidThe unique identifier of the environment.
action_spaceThe action space of the environment.
observation_spaceThe observation space of the environment.
- init(key)#
Initialize the environment and return the initial state.
- Parameters:
key (
Array) – A JAX random key for any stochastic initialization.- Return type:
tuple[EnvironmentState,Timestep]- Returns:
A tuple containing the initial environment state and the initial timestep.
- reset(key, env_state)#
Reset the environment to its initial state.
- Parameters:
key (
Array) – A JAX random key for any stochasticity in the environment.env_state (
EnvironmentState) – The current state of the environment.
- Return type:
tuple[EnvironmentState,Timestep]- Returns:
A tuple containing the reset environment state and the initial timestep.
- rollout(key, env_state, pi, num_steps)#
- Return type:
tuple[EnvironmentState,Trajectory]
- step(key, env_state, action)#
Perform a step in the environment given an action.
- Parameters:
key (
Array) – A JAX random key for any stochasticity in the environment.env_state (
EnvironmentState) – The current state of the environment.action (
Array) – The action to take in the environment.
- Return type:
tuple[EnvironmentState,Timestep]- Returns:
A tuple containing the new environment state and the resulting timestep.