Performs binary tournament selection with multiple comparators.
This selection operator uses a list of comparators in sequence to determine the winner between two randomly selected solutions. The first comparator that can determine a winner is used. If all comparators result in a tie, a random solution is chosen.
comparator_list: List of comparators to use in sequence.
Performs binary tournament selection between two random solutions.
This selection operator randomly selects two solutions from the population and returns the better one according to the provided comparator. If the comparator returns 0 (tie), a random solution is chosen.
comparator: Comparator used to compare solutions (default: DominanceComparator)
Bases: Selection[List[S], List[S]]
Performs selection for differential evolution algorithms.
This selection operator is specifically designed for differential evolution algorithms. It selects three distinct solutions from the population, with an optional index to exclude (typically the current solution’s index to avoid self-selection).
This is useful to avoid selecting the same solution as the base vector.
Select three distinct solutions for differential evolution.
front: List of solutions to select from.
A list containing three distinct solutions from the front.
ValueError: If front is None, empty, or has fewer than 4 solutions.
Performs random selection of multiple solutions from a population.
This selection operator randomly selects a specified number of distinct solutions from the population with uniform probability. The selection is done without replacement, meaning each solution can be selected at most once.
Must be a positive integer.
Performs random selection of a solution from a population.
This selection operator randomly selects a single solution from the provided population with uniform probability. It’s a simple selection method that doesn’t consider solution quality.
Bases: Selection[List[S], List[S]]
Performs selection based on non-dominated ranking and crowding distance.
This selection operator first ranks the solutions using non-dominated sorting and then applies crowding distance to maintain diversity within each rank. It’s commonly used in NSGA-II and other multi-objective evolutionary algorithms.
max_population_size: Maximum number of solutions to select. dominance_comparator: Comparator used for non-dominated sorting.
Defaults to DominanceComparator().
Select solutions using non-dominated ranking and crowding distance.
front: List of solutions to select from.
A list of selected solutions, with size up to max_population_size.
ValueError: If front is None, empty, or max_population_size is invalid.
Bases: Selection[List[S], List[S]]
Performs selection based on non-dominated ranking and hypervolume contribution.
This selection operator first ranks the solutions using non-dominated sorting and then applies hypervolume contribution to maintain diversity within each rank. It’s commonly used in multi-objective evolutionary algorithms that aim to maximize the hypervolume indicator.
max_population_size: Maximum number of solutions to select. reference_point: Reference point used for hypervolume calculation.
Should be dominated by all solutions.
Defaults to DominanceComparator().
Compute hypervolume-based fitness values for a population.
This method computes the hypervolume contribution of each solution in the population and stores it in the solution’s attributes as ‘fitness’.
population: List of solutions to evaluate. reference_point: Reference point for hypervolume calculation. k: Number of points to consider for hypervolume approximation.
If negative, uses the entire population size.
The input population with updated fitness values in their attributes.
Select solutions using non-dominated ranking and hypervolume contribution.
This method first performs non-dominated sorting of the input front. It then fills the new population with solutions from the best ranks, using hypervolume contribution to select solutions when a rank needs to be split.
front: List of solutions to select from.
A list of selected solutions, with size equal to max_population_size.
ValueError: If front is None or empty.
Get the name of the selection operator.
A string representing the name of the selection operator.
Recursively compute hypervolume contributions.
This is a helper method for hypervolume calculation. It’s an implementation of the Hype algorithm for hypervolume approximation.
l: Number of points. A: List of objective vectors. actDim: Current dimension being processed. bounds: Reference point coordinates. pvec: Indices of points in A. alpha: Weighting factors for hypervolume contribution. k: Number of points to consider.
List of hypervolume contributions for each point.
Performs roulette wheel selection.
This selection operator selects solutions based on their fitness values using a roulette wheel mechanism. It can handle both single and multi-objective optimization by using the first objective value for selection. For multi-objective optimization, consider using a proper fitness assignment strategy first.
Note: This implementation assumes all objective values are non-negative. If negative values are present, a proper normalization should be applied first.
alias of TypeVar(‘S’, bound=Solution)