gxm.spaces#
Spaces for defining action and observation spaces.
- class Box(low, high, shape)#
Bases:
SpaceA bounded box in \(\mathbb{R}^n\).
- contains(x)#
Check whether specific object is within space.
- Parameters:
x (
Any) β Object to be checked.- Return type:
Array- Returns:
Whether the object is within the space.
-
high:
Array# Upper bound of the box.
-
low:
Array# Lower bound of the box.
- property n: int#
- sample(key, shape=())#
Sample uniformly from the box.
- Parameters:
key (
Array) β JAX random key.shape (
Tuple[int,...]) β Shape of the sample to be drawn.
- Return type:
Any- Returns:
Sample drawn from the box.
-
shape:
Tuple[int,...]# Shape of the box.
- class Discrete(n)#
Bases:
SpaceA discrete space consiting of \(\{0, 1, ..., n-1\}\).
- contains(x)#
Check whether specific object is within space.
- Parameters:
x (
Any) β The object to be checked.- Return type:
Array- Returns:
Whether the object is contained in the space.
- property n: int#
- sample(key, shape=())#
Sample random action uniformly from \(\{0, 1, ..., n-1\}\).
- Parameters:
key (
Array) β A JAX random key used for sampling.shape (
Tuple[int,...]) β The shape of the returned sample.
- Return type:
Array- Returns:
The sampled value.
- class Space#
Bases:
objectAbstract base class for action and observation spaces.
- contains(x)#
- Return type:
Any
- property n: int#
- sample(key, shape=())#
- Return type:
Any
- class Tree(spaces)#
Bases:
SpaceSpace composed of multiple subspaces in a tree structure.
- contains(x)#
Check whether dimensions of object are within subspace.
- Parameters:
x (
Array) β Object to be checked.- Return type:
bool- Returns:
True if object is within all subspaces, False otherwise.
- property n: int#
- sample(key, shape=())#
Sample random action from all subspaces, retaining the original structure.
- Parameters:
key (
Array) β JAX random key.shape (
Tuple[int,...]) β Shape of the sample to be drawn from each subspace.
- Return type:
Any- Returns:
A tree-structured object with samples from each subspace.