grid#

gym_socks.utils.grid.grid_size_from_ranges(xi)[source]#

Returns the size of a grid sample based on ranges.

Parameters

xi (list) – List of ranges.

Returns

The product of the lengths of the ranges.

Return type

int

gym_socks.utils.grid.grid_size_from_space(sample_space, resolution)[source]#

Returns the size of a grid sample based on sample space and resolution.

Parameters
  • sample_space (gym.spaces.box.Box) – The sample space.

  • resolution (int) – The gid resolution, specified either as an integer for all dimensions or as a list of integers, one per dimension.

Returns

The product of the lengths of the ranges.

Return type

int

gym_socks.utils.grid.make_grid_from_ranges(xi)[source]#

Create a grid of points from a list of ranges.

Parameters

xi (list) – List of ranges.

Returns

Grid of points (the product of all points in ranges).

Return type

list

Example

>>> import numpy as np
>>> from gym_socks.utils.grid import make_grid_from_ranges
>>> grid = make_grid_from_ranges([np.linspace(-1, 1, 5), np.linspace(-1, 1, 5)])
gym_socks.utils.grid.make_grid_from_space(sample_space, resolution)[source]#

Create a grid from a bounded sample space.

Parameters
  • sample_space (gym.spaces.box.Box) – Bounded sample space.

  • resolution (int) – The gid resolution, specified either as an integer for all dimensions or as a list of integers, one per dimension.

Returns

Grid of points (the product of all points in ranges).

Return type

list

Example

>>> from gym.spaces import Box
>>> import numpy as np
>>> from gym_socks.utils.grid import make_grid_from_space
>>> sample_space = Box(low=-1, high=1, shape=(2,), dtype=np.float32)
>>> grid = make_grid_from_space(sample_space, [3, 2])