env#
Source code: tianshou/highlevel/env.py
- class ContinuousEnvironments(env: Env, train_envs: BaseVectorEnv, test_envs: BaseVectorEnv)[source]#
Represents (vectorized) continuous environments.
- static from_factory(factory_fn: Callable[[], Env], venv_type: VectorEnvType, num_training_envs: int, num_test_envs: int) ContinuousEnvironments[source]#
Creates an instance from a factory function that creates a single instance.
- Parameters:
factory_fn – the factory for a single environment instance
venv_type – the vector environment type to use for parallelization
num_training_envs – the number of training environments to create
num_test_envs – the number of test environments to create
- Returns:
the instance
- class DiscreteEnvironments(env: Env, train_envs: BaseVectorEnv, test_envs: BaseVectorEnv)[source]#
Represents (vectorized) discrete environments.
- static from_factory(factory_fn: Callable[[], Env], venv_type: VectorEnvType, num_training_envs: int, num_test_envs: int) DiscreteEnvironments[source]#
Creates an instance from a factory function that creates a single instance.
- Parameters:
factory_fn – the factory for a single environment instance
venv_type – the vector environment type to use for parallelization
num_training_envs – the number of training environments to create
num_test_envs – the number of test environments to create
- Returns:
the instance
- class EnvFactory[source]#
- abstract create_envs(num_training_envs: int, num_test_envs: int) Environments[source]#
- class EnvType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
Enumeration of environment types.
- CONTINUOUS = 'continuous'#
- DISCRETE = 'discrete'#
- class Environments(env: Env, train_envs: BaseVectorEnv, test_envs: BaseVectorEnv)[source]#
Represents (vectorized) environments.
- static from_factory_and_type(factory_fn: Callable[[], Env], env_type: EnvType, venv_type: VectorEnvType, num_training_envs: int, num_test_envs: int) Environments[source]#
Creates a suitable subtype instance from a factory function that creates a single instance and the type of environment (continuous/discrete).
- Parameters:
factory_fn – the factory for a single environment instance
env_type – the type of environments created by factory_fn
venv_type – the vector environment type to use for parallelization
num_training_envs – the number of training environments to create
num_test_envs – the number of test environments to create
- Returns:
the instance
- set_persistence(*p: Persistence) None[source]#
Associates the given persistence handlers which may persist and restore environment-specific information.
- Parameters:
p – persistence handlers
- class VectorEnvType(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)[source]#
- DUMMY = 'dummy'#
Vectorized environment without parallelization; environments are processed sequentially
- RAY = 'ray'#
Parallelization based on the ray library
- SUBPROC = 'subproc'#
Parallelization based on subprocess
- SUBPROC_SHARED_MEM = 'shmem'#
Parallelization based on subprocess with shared memory
- create_venv(factories: list[collections.abc.Callable[[], gymnasium.core.Env]]) BaseVectorEnv[source]#