Tiles¶
Rectangular Tiles¶
-
class
Tiles
(x_range, n_tiles, state_components=None)[source]¶ Bases:
object
Class implementing rectangular tiling. For each point in the state space, this class can be used to compute the index of the corresponding tile.
-
__init__
(x_range, n_tiles, state_components=None)[source]¶ Constructor.
Parameters: - x_range (list) – list of two-elements lists specifying the range of each state variable;
- n_tiles (list) – list of the number of tiles to be used for each dimension.
- state_components (list, None) – list of the dimensions of the input
to be considered by the tiling. The number of elements must
match the number of elements in
x_range
andn_tiles
.
-
static
generate
(n_tilings, n_tiles, low, high, uniform=False)[source]¶ Factory method to build
n_tilings
tilings ofn_tiles
tiles with a range betweenlow
andhigh
for each dimension.Parameters: - n_tilings (int) – number of tilings, or -1 to compute the number automatically;
- n_tiles (list) – number of tiles for each tilings for each dimension;
- low (np.ndarray) – lowest value for each dimension;
- high (np.ndarray) – highest value for each dimension.
- uniform (bool, False) – if True the displacement for each tiling will be w/n_tilings, where w is the tile width. Otherwise, the displacement will be k*w/n_tilings, where k=2i+1, where i is the dimension index.
Returns: The list of the generated tiles.
-
Voronoi Tiles¶
-
class
VoronoiTiles
(prototypes)[source]¶ Bases:
object
Class implementing voronoi tiling. For each point in the state space, this class can be used to compute the index of the corresponding tile.
-
__init__
(prototypes)[source]¶ Constructor.
Parameters: prototypes (list) – list of prototypes to compute the partition.
-
static
generate
(n_tilings, n_prototypes, low=None, high=None, mu=None, sigma=None)[source]¶ Factory method to build
n_tilings
tilings ofn_prototypes
. Prototypes are generated randomly sampled. If low and high are provided, prototypes are sampled uniformly between low and high, otherwise mu and sigma must be specified and prototypes are sampled from the corresponding Gaussian.Parameters: - n_tilings (int) – number of tilings, or -1 to compute the number automatically;
- n_prototypes (list) – number of prototypes for each tiling;
- low (np.ndarray, None) – lowest value for each dimension, needed for uniform sampling;
- high (np.ndarray, None) – highest value for each dimension, needed for uniform sampling.
- mu (np.ndarray, None) – mean value for each dimension, needed for Gaussian sampling.
- sigma (np.ndarray, None) – variance along each dimension, needed for Gaussian sampling.
Returns: The list of the generated tiles.
-