flatland.core.effects_generator module#
- class flatland.core.effects_generator.EffectsGenerator(on_episode_start: Callable[[EnvType], EnvType] | None = None, on_episode_step_start: Callable[[EnvType], EnvType] | None = None, on_episode_step_end: Callable[[EnvType], EnvType] | None = None)[source]#
Bases:
Generic[EnvType]Hook for external events modifying the env (state) before observations and rewards are computed.
See flatland-association/flatland-workshop-2024
- classmethod from_state(state_dict: Dict[str, Any]) EffectsGenerator[source]#
- property fullname#
- on_episode_start(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the end of reset before computing observations and infos.
In the future, will receive immutable state instead of full env.
Naming similar to https://docs.ray.io/en/latest/rllib/package_ref/doc/ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_start.html#ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_start, but modifying.
Parameters#
env args kwargs
Returns#
- on_episode_step_end(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the end of step before computing observations and infos.
In the future, will receive immutable state instead of full env.
Naming similar to https://docs.ray.io/en/latest/rllib/package_ref/doc/ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_step.html#ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_step, but modifying.
Parameters#
env: Ra args kwargs
Returns#
- on_episode_step_start(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the beginning of step before evaluating the agent’s actions.
In the future, will receive immutable state instead of full env.
No naming similar to RLlib equivalent, see https://docs.ray.io/en/latest/rllib/rllib-callback.html
Parameters#
env args kwargs
Returns#
- class flatland.core.effects_generator.MultiEffectsGeneratorWrapped(*effects_generators: EffectsGenerator[EnvType])[source]#
Bases:
EffectsGenerator[EnvType]- on_episode_start(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the end of reset before computing observations and infos.
In the future, will receive immutable state instead of full env.
Naming similar to https://docs.ray.io/en/latest/rllib/package_ref/doc/ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_start.html#ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_start, but modifying.
Parameters#
env args kwargs
Returns#
- on_episode_step_end(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the end of step before computing observations and infos.
In the future, will receive immutable state instead of full env.
Naming similar to https://docs.ray.io/en/latest/rllib/package_ref/doc/ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_step.html#ray.rllib.callbacks.callbacks.RLlibCallback.on_episode_step, but modifying.
Parameters#
env: Ra args kwargs
Returns#
- on_episode_step_start(env: EnvType, *args, **kwargs) EnvType[source]#
Called by env at the beginning of step before evaluating the agent’s actions.
In the future, will receive immutable state instead of full env.
No naming similar to RLlib equivalent, see https://docs.ray.io/en/latest/rllib/rllib-callback.html
Parameters#
env args kwargs
Returns#
- flatland.core.effects_generator.find_all_effects_generators(effects_generator: EffectsGenerator[EnvType], cls: Type[T]) List[T][source]#
Recursively collect all instances of cls within a (possibly MultiEffectsGeneratorWrapped-composed) effects generator.
- flatland.core.effects_generator.find_effects_generator(effects_generator: EffectsGenerator[EnvType], cls: Type[T]) T | None[source]#
Recursively search a (possibly MultiEffectsGeneratorWrapped-composed) effects generator for an instance of cls.
- flatland.core.effects_generator.make_multi_effects_generator(*effects_generators: EffectsGenerator[EnvType]) EffectsGenerator[EnvType][source]#
Compose effects generators into a single flat MultiEffectsGeneratorWrapped - any argument that is itself a MultiEffectsGeneratorWrapped (however deeply nested) is unwrapped first, so nesting never accumulates regardless of the shape of what’s passed in.