mtenv.envs.tabular_mdp package

Submodules

mtenv.envs.tabular_mdp.setup module

mtenv.envs.tabular_mdp.tmdp module

class mtenv.envs.tabular_mdp.tmdp.TMDP(n_states, n_actions)[source]

Bases: mtenv.core.MTEnv

Defines a Tabuular MDP where task_state is the reward matrix,transition matrix

reward_matrix is n_states*n_actions and gies the probability of having a reward = +1 when choosing action a in state s (matrix[s,a]) transition_matrix is n_states*n_actions*n_states and gives the probability of moving to state s’ when choosing action a in state s (matrix[s,a,s’])

Parameters

MTEnv ([type]) – [description]

Main class for multitask RL Environments.

This abstract class extends the OpenAI Gym environment and adds support for return the task-specific information from the environment. The observation returned from the single task environments is encoded as env_obs (environment observation) while the task specific observation is encoded as the task_obs (task observation). The observation returned by mtenv is a dictionary of env_obs and task_obs. Since this class extends the OpenAI gym, the mtenv API looks similar to the gym API.

import mtenv
env = mtenv.make('xxx')
env.reset()

Any multitask RL environment class should extend/implement this class.

Parameters
  • action_space (Space) –

  • env_observation_space (Space) –

  • task_observation_space (Space) –

get_task_obs()[source]

Get the current value of task observation.

Environment returns task observation everytime we call step or reset. This function is useful when the user wants to access the task observation without acting in (or resetting) the environment.

Returns

Return type

TaskObsType

get_task_state()[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()[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

sample_task_state()[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(env_seed)[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]

seed_task(task_seed)[source]

Set the seed for the task’s random number generator.

Invoke seed to set the seed for the environment’s random number generator.

Parameters

seed (Optional[int], optional) – Defaults to None.

Returns

Returns the list of seeds used in the task’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)[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)[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

class mtenv.envs.tabular_mdp.tmdp.UniformTMDP(n_states, n_actions)[source]

Bases: mtenv.envs.tabular_mdp.tmdp.TMDP

Main class for multitask RL Environments.

This abstract class extends the OpenAI Gym environment and adds support for return the task-specific information from the environment. The observation returned from the single task environments is encoded as env_obs (environment observation) while the task specific observation is encoded as the task_obs (task observation). The observation returned by mtenv is a dictionary of env_obs and task_obs. Since this class extends the OpenAI gym, the mtenv API looks similar to the gym API.

import mtenv
env = mtenv.make('xxx')
env.reset()

Any multitask RL environment class should extend/implement this class.

Parameters
  • action_space (Space) –

  • env_observation_space (Space) –

  • task_observation_space (Space) –

sample_task_state()[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

Module contents