src.plangym.vectorization.ray#
Implement a plangym.VectorizedEnv that uses ray when calling step_batch.
Classes#
Module Contents#
- class src.plangym.vectorization.ray.RemoteEnv(env_callable)[source]#
Bases:
plangym.core.PlanEnvRemote ray Actor interface for a plangym.PlanEnv.
- _env_callable#
- env = None#
- property unwrapped#
- Completely unwrap this Environment.
- Returns
plangym.Environment: The base non-wrapped plangym.Environment instance
- property name: str#
Return the name of the environment.
- Return type:
str
- step(action, state=None, dt=1, return_state=None)[source]#
Take a simulation step and make the environment evolve.
- Parameters:
action – Chosen action applied to the environment.
state – Set the environment to the given state before stepping it. If state is None the behaviour of this function will be the same as in OpenAI gym.
dt (int) – Consecutive number of times to apply an action.
return_state (bool | None) – Whether to return the state in the returned tuple. If None, step will return the state if state was passed as a parameter.
- Returns:
if states is None returns (observs, rewards, ends, infos) else returns(new_states, observs, rewards, ends, infos)
- Return type:
tuple
- step_batch(actions, states=None, dt=1, return_state=None)[source]#
Take a step on a batch of states and actions.
- Parameters:
actions ([numpy.ndarray, list]) – Chosen actions applied to the environment.
states – Set the environment to the given states before stepping it. If state is None the behaviour of this function will be the same as in OpenAI gym.
dt (int) – Consecutive number of times that the action will be applied.
return_state (bool | None) – Whether to return the state in the returned tuple. If None, step will return the state if state was passed as a parameter.
- Returns:
if states is None returns (observs, rewards, ends, infos) else returns(new_states, observs, rewards, ends, infos)
- Return type:
tuple
- reset(return_state=True)[source]#
Restart the environment.
- Parameters:
return_state (bool)
- Return type:
[numpy.ndarray, tuple]
- class src.plangym.vectorization.ray.RayEnv(env_class, name, frameskip=1, autoreset=True, delay_setup=False, n_workers=8, **kwargs)[source]#
Bases:
plangym.vectorization.env.VectorizedEnvUse ray for taking steps in parallel when calling step_batch.
- Parameters:
name (str)
frameskip (int)
autoreset (bool)
delay_setup (bool)
n_workers (int)
- _workers = None#
- property workers: list[RemoteEnv]#
Remote actors exposing copies of the environment.
- Return type:
list[RemoteEnv]
- setup()[source]#
Run environment initialization and create the subprocesses for stepping in parallel.
- make_transitions(actions, states=None, dt=1, return_state=None)[source]#
Implement the logic for stepping the environment in parallel.
- Parameters:
dt ([numpy.ndarray, int])
return_state (bool | None)