velora.gym¶
Documentation
Dedicated Gymnasium [] utility methods to simplify working with the Gymnasium API.
EnvResult
dataclass
¶
Container for environment search results.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name
|
str
|
the name of the environment |
required |
type
|
str
|
the environment type, either |
required |
Source code in velora/gym/search.py
Python | |
---|---|
8 9 10 11 12 13 14 15 16 17 18 19 |
|
EnvSearch
¶
A utility class for searching for Gymnasium environments.
Source code in velora/gym/search.py
Python | |
---|---|
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
continuous()
classmethod
¶
Get all available continuous Gymnasium environments.
Returns:
Name | Type | Description |
---|---|---|
names |
List[EnvResult]
|
a list of available continuous environments. |
Source code in velora/gym/search.py
Python | |
---|---|
146 147 148 149 150 151 152 153 154 155 156 157 158 |
|
discrete()
classmethod
¶
Get all available discrete Gymnasium environments.
Returns:
Name | Type | Description |
---|---|---|
names |
List[EnvResult]
|
a list of available discrete environments. |
Source code in velora/gym/search.py
Python | |
---|---|
132 133 134 135 136 137 138 139 140 141 142 143 144 |
|
find(query)
classmethod
¶
Find a Gymnasium environment that contains query
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query
|
str
|
partial or complete name of an environment
(e.g., |
required |
Returns:
Name | Type | Description |
---|---|---|
result |
List[EnvResult]
|
a list of environment results matching the query. |
Source code in velora/gym/search.py
Python | |
---|---|
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
|
SearchHelper
¶
A helper class containing methods for creating the EnvSearch
cache.
Source code in velora/gym/search.py
Python | |
---|---|
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
get_env_type(env_name)
staticmethod
¶
Determines if an environment has a discrete or continuous action space.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env_name
|
str
|
name of the environment |
required |
Returns:
Name | Type | Description |
---|---|---|
env_type |
str | None
|
one of three values - |
Literal['discrete', 'continuous'] | None
|
|
|
Literal['discrete', 'continuous'] | None
|
|
|
Literal['discrete', 'continuous'] | None
|
|
Source code in velora/gym/search.py
Python | |
---|---|
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
|
get_latest_env_names()
staticmethod
¶
Builds a list of the latest Gymnasium environment names.
Returns:
Name | Type | Description |
---|---|---|
names |
List[str]
|
a list of names for all latest env versions. |
Source code in velora/gym/search.py
Python | |
---|---|
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
add_core_env_wrappers(env, device)
¶
Wraps a Gymnasium environment with the following (in order) if not already applied:
- RecordEpisodeStatistics - for easily retrieving episode statistics.
- NumpyToTorch - for turning environment feedback into
PyTorch
tensors.
Used in all pre-built algorithms.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env
|
gym.Env
|
the Gymnasium environment |
required |
device
|
torch.device
|
the PyTorch device to perform computations on |
required |
Returns:
Name | Type | Description |
---|---|---|
env |
gym.Env
|
an updated Gymnasium environment |
Source code in velora/gym/wrap.py
Python | |
---|---|
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
|
wrap_gym_env(env, wrappers)
¶
Creates a new Gymnasium environment with one or more gymnasium.Wrappers applied.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
env
|
gymnasium.Env | str
|
a name of a Gymnasium environment or the environment itself to wrap |
required |
wrappers
|
List[gym.Wrapper | gym.vector.VectorWrapper | functools.partial]
|
a list of wrapper classes or partially applied wrapper functions |
required |
Examples:
A Gymnasium environment with normalization and reward clipping:
Python | |
---|---|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Returns:
Name | Type | Description |
---|---|---|
env |
gymnasium.Env
|
The wrapped environment |
Source code in velora/gym/wrap.py
Python | |
---|---|
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
|