Map elites selection
This file is part of the TPOT library.
The current version of TPOT was developed at Cedars-Sinai by: - Pedro Henrique Ribeiro (https://github.com/perib, https://www.linkedin.com/in/pedro-ribeiro/) - Anil Saini (anil.saini@cshs.org) - Jose Hernandez (jgh9094@gmail.com) - Jay Moran (jay.moran@cshs.org) - Nicholas Matsumoto (nicholas.matsumoto@cshs.org) - Hyunjun Choi (hyunjun.choi@cshs.org) - Miguel E. Hernandez (miguel.e.hernandez@cshs.org) - Jason Moore (moorejh28@gmail.com)
The original version of TPOT was primarily developed at the University of Pennsylvania by: - Randal S. Olson (rso@randalolson.com) - Weixuan Fu (weixuanf@upenn.edu) - Daniel Angell (dpa34@drexel.edu) - Jason Moore (moorejh28@gmail.com) - and many more generous open-source contributors
TPOT is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
TPOT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with TPOT. If not, see http://www.gnu.org/licenses/.
create_nd_matrix(matrix, grid_steps=None, bins=None)
¶
Create an n-dimensional matrix with the highest score for each cell
Parameters:
Name | Type | Description | Default |
---|---|---|---|
matrix |
ndarray
|
The score matrix, where the first column is the score and the rest are the features for the map-elites algorithm. |
required |
grid_steps |
int
|
The number of steps to use for each feature to automatically create the bin thresholds. The default is None. |
None
|
bins |
list
|
A list of lists containing the bin edges for each feature (other than the score). The default is None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
An n-dimensional matrix with the highest score for each cell and the index of the individual with that score. The value in the cell is a dictionary with the keys "score" and "idx" containing the score and index of the individual respectively. |
Source code in tpot2/selectors/map_elites_selection.py
get_bins(arr, k)
¶
Get equally spaced bin thresholds between the min and max values for the array of scores.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr |
ndarray
|
The list of values to calculate the bins for. |
required |
k |
int
|
The number of bins to create. |
required |
Returns:
Type | Description |
---|---|
list
|
A list of bin thresholds calculated to be k equally spaced bins between the min and max of the array. |
Source code in tpot2/selectors/map_elites_selection.py
get_bins_quantiles(arr, k=None, q=None)
¶
Takes a matrix and returns the bin thresholds based on quantiles.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
arr |
ndarray
|
The matrix to calculate the bins for. |
required |
k |
int
|
The number of bins to create. This parameter creates k equally spaced quantiles. For example, k=3 will create quantiles at array([0.25, 0.5 , 0.75]). |
None
|
q |
ndarray
|
Custom quantiles to use for the bins. This parameter creates bins based on the quantiles of the data. The default is None. |
None
|
Source code in tpot2/selectors/map_elites_selection.py
manhattan(a, b)
¶
Calculate the Manhattan distance between two points.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
a |
ndarray
|
The first point. |
required |
b |
ndarray
|
The second point. |
required |
Returns:
Type | Description |
---|---|
float
|
The Manhattan distance between the two points. |
Source code in tpot2/selectors/map_elites_selection.py
map_elites_parent_selector(scores, k, n_parents=1, rng=None, manhattan_distance=2, grid_steps=10, bins=None)
¶
A parent selection algorithm for the map-elites algorithm. First creates a grid of the best individuals per cell and then selects parents based on the Manhattan distance between the cells of the best individuals.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
ndarray
|
The score matrix, where the first column is the score and the rest are the features for the map-elites algorithm. |
required |
k |
int
|
The number of individuals to select. |
required |
n_parents |
int
|
The number of parents to select per individual. The default is 1. |
1
|
rng |
(int, Generator)
|
The random number generator. The default is None. |
None
|
manhattan_distance |
int
|
The maximum Manhattan distance between parents. The default is 2. If no parents are found within this distance, the distance is increased by 1 until at least one other parent is found. |
2
|
grid_steps |
int
|
The number of steps to use for each feature to automatically create the bin thresholds. The default is None. |
10
|
bins |
list
|
A list of lists containing the bin edges for each feature (other than the score). The default is None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
An array of indexes of the parents selected for each individual |
Source code in tpot2/selectors/map_elites_selection.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 |
|
map_elites_survival_selector(scores, k=None, rng=None, grid_steps=10, bins=None)
¶
Takes a matrix of scores and returns the indexes of the individuals that are in the best cells of the map-elites grid. Can either take a grid_steps parameter to automatically create the bins or a bins parameter to specify the bins manually.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
scores |
ndarray
|
The score matrix, where the first column is the score and the rest are the features for the map-elites algorithm. |
required |
k |
int
|
The number of individuals to select. The default is None. |
None
|
rng |
(int, Generator)
|
The random number generator. The default is None. |
None
|
grid_steps |
int
|
The number of steps to use for each feature to automatically create the bin thresholds. The default is None. |
10
|
bins |
list
|
A list of lists containing the bin edges for each feature (other than the score). The default is None. |
None
|
Returns:
Type | Description |
---|---|
ndarray
|
An array of indexes of the individuals in the best cells of the map-elites grid (without repeats). |