mtenv.envs.shared.wrappers package¶
Submodules¶
mtenv.envs.shared.wrappers.multienv module¶
Wrapper to (lazily) construct a multitask environment from a list of constructors (list of functions to construct the environments).
-
class
mtenv.envs.shared.wrappers.multienv.
MultiEnvWrapper
(funcs_to_make_envs: List[Callable[], gym.core.Env]], initial_task_state: int)[source]¶ Bases:
mtenv.core.MTEnv
Wrapper to (lazily) construct a multitask environment from a list of constructors (list of functions to construct the environments).
The wrapper enables activating/slecting any environment (from the list of environments that can be created) and that environment is treated as the current task. The environments are created lazily.
Note that this wrapper is experimental and may change in the future.
- Parameters
funcs_to_make_envs (List[EnvBuilderType]) – list of constructor functions to make the environments.
initial_task_state (TaskStateType) – intial task/environment to select.
-
assert_env_seed_is_set
() → None[source]¶ The seed is set during the call to the constructor of self.env
-
assert_task_seed_is_set
() → None[source]¶ Check that seed (for the task) is set.
sample_task_state function should invoke this function before sampling a new task state (for reproducibility).
-
get_task_state
() → int[source]¶ Return all the information needed to execute the current task again.
This function is useful when we want to set the environment to a previous task.
- Returns
For more information on task_state, refer Task State.
- Return type
TaskStateType
-
reset
() → Dict[str, Union[numpy.ndarray, str, int, float]][source]¶ Reset the environment to some initial state and return the observation in the new state.
The subclasses, extending this class, should ensure that the environment seed is set (by calling seed(int)) before invoking this method (for reproducibility). It can be done by invoking self.assert_env_seed_is_set().
- Returns
For more information on multitask observation returned by the environment, refer MultiTask Observation.
- Return type
ObsType
-
reset_task_state
() → None[source]¶ Sample a new task_state and set the environment to that task_state.
For more information on task_state, refer Task State.
-
sample_task_state
() → int[source]¶ Sample a task_state.
task_state contains all the information that the environment needs to switch to any other task.
The subclasses, extending this class, should ensure that the task seed is set (by calling seed(int)) before invoking this method (for reproducibility). It can be done by invoking self.assert_task_seed_is_set().
- Returns
For more information on task_state, refer Task State.
- Return type
TaskStateType
-
seed
(seed: Optional[int] = None) → List[int][source]¶ Set the seed for the environment’s random number generator.
Invoke seed_task to set the seed for the task’s random number generator.
- Parameters
seed (Optional[int], optional) – Defaults to None.
- Returns
Returns the list of seeds used in the environment’s random number generator. The first value in the list should be the seed that should be passed to this method for reproducibility.
- Return type
List[int]
-
set_task_state
(task_state: int) → None[source]¶ Reset the environment to a particular task.
task_state contains all the information that the environment needs to switch to any other task.
- Parameters
task_state (TaskStateType) – For more information on task_state, refer Task State.
-
step
(action: Union[str, int, float, numpy.ndarray]) → Tuple[Dict[str, Union[numpy.ndarray, str, int, float]], float, bool, Dict[str, Any]][source]¶ Execute the action in the environment.
- Parameters
action (ActionType) –
- Returns
Tuple of multitask observation, reward, done, and info. For more information on multitask observation returned by the environment, refer MultiTask Observation.
- Return type
StepReturnType