selection
Functions for selecting individuals from populations in EA algorithms.
Package Contents
Functions
|
Select multiple distinct individuals from a population using the provided selection function. |
|
Return individuals based on their respective frontier values and their domination order. |
|
Get indices of the top n genotypes sorted by their fitness. |
|
Perform tournament selection and return the index of the best individual. |
- multiple_unique(selection_size: int, population: list[TIndividual], fitnesses: list[TFitness], selection_function: Callable[[list[TIndividual], list[TFitness]], int]) numpy.typing.NDArray[numpy.float_]
Select multiple distinct individuals from a population using the provided selection function.
- Parameters:
selection_size – Amount of of individuals to select.
population – List of individuals to select from.
fitnesses – Fitnesses of the population.
selection_function – Function that select a single individual from a population. ([TIndividual], [TFitness]) -> index.
- Returns:
Indices of the selected individuals.
- pareto_frontier(frontier_values: list[list[TValues]], frontier_order: list[bool], to_take: int) list[int]
Return individuals based on their respective frontier values and their domination order.
For mor information on the pareto frontier check: https://en.wikipedia.org/wiki/Pareto_front.
- Parameters:
frontier_values – Lists of values that are used for the frontier. The order of the list represents the importance of a value in descending order. These values need to be numeric.
frontier_order – List of orders for the values used in frontier selection. True = ascending, False = descending.
to_take – The amount of individuals to return from the frontier.
- Returns:
The index of the individuals that were selected. Returned in descending order, wrt. frontier values and domination order (Best is first).
- topn(n: int, genotypes: list[Genotype], fitnesses: list[Fitness]) list[int]
Get indices of the top n genotypes sorted by their fitness.
- Parameters:
n – The number of genotypes to select.
genotypes – The genotypes. Ignored, but argument kept for function signature compatibility with other selection functions/
fitnesses – Fitnesses of the genotypes.
- Returns:
Indices of the selected genotypes.
- tournament(rng: numpy.random.Generator, fitnesses: list[Fitness], k: int) int
Perform tournament selection and return the index of the best individual.
- Parameters:
rng – Random number generator.
fitnesses – List of finesses of individuals that joint the tournamente.
k – Amount of individuals to participate in tournament.
- Returns:
The index of te individual that won the tournament.