Flattening

This module implements a block transformation for flattening observation space of the environment.

class gym_jiminy.common.wrappers.flatten.FlattenObservation(env, dtype=None)[source]

Bases: BaseTransformObservation[ndarray[Any, dtype[float64]], Obs, Act], Generic[Obs, Act]

Flatten the observation space of a pipeline environment. It will appear as a simple one-dimension vector.

Note

Following the general (but unusual) convention in Gym-Jiminy, the batching dimensions appears last when aggregating homogeneous data to vectorize computations. This design choice is motivated by efficiency for the default memory layout of Numpy, i.e. row-major (C-style order). Because of this, flattening a multi-dimensional array while pack together components rather than batched element. This is undesirable because values while be spread apart the whole vector after flattening when adding new batch element, which makes it very difficult to compare flattened vectors at first glance. It is also more challenging and computationally expensive to perform operations directly on the flattened vector representation such as mirroring. To get around this issue, all multi-dimensional arrays are transposed before flattening, which is sementically equivalent to data.ravel(order=’F’).

Warning

All leaves of the observation space must have type gym.spaces.Box.

Parameters:
transform_observation()[source]

Update in-place pre-allocated transformed observation buffer with the flattened observation of the wrapped environment.

Return type:

None

class gym_jiminy.common.wrappers.flatten.FlattenAction(env, dtype=None)[source]

Bases: BaseTransformAction[ndarray[Any, dtype[float64]], Obs, Act], Generic[Obs, Act]

Flatten the action space of a pipeline environment. It will appear as a simple one-dimension vector.

Note

Fortran-Style order is used when flattening multi-dimensional arrays. See FlattenObservation documentation for details.

Warning

All leaves of the action space must have type gym.spaces.Box.

Parameters:
transform_action(action)[source]

Update in-place the pre-allocated action buffer of the wrapped environment with the un-flattened action.

Parameters:

action (ndarray[Any, dtype[float64]])

Return type:

None