Selection Operators
The pycellga.selection package provides various selection operators that determine how individuals are chosen from the population to act as parents in genetic algorithms. Selection operators play a key role in balancing exploration and exploitation during the optimization process, directly impacting convergence and diversity.
Tournament Selection
Implements a tournament selection method, where a subset of individuals competes, and the best-performing individual is selected as a parent. This method is useful in maintaining diversity and is effective in multimodal optimization landscapes.
- class TournamentSelection(pop_list: List[Individual] = [], c: int = 0, K: int = 2)[source]
Bases:
SelectionOperator
TournamentSelection performs a tournament selection on a population of individuals to select parent individuals for crossover.
- Parameters:
pop_list (list of Individual) – The population of individuals to select from.
c (int) – The index of the individual to start selection from.
K (int) – The number of individuals to be chosen at random from neighbors.
- __init__(pop_list: List[Individual] = [], c: int = 0, K: int = 2)[source]
Initialize the TournamentSelection object.
- Parameters:
pop_list (list of Individual) – The population of individuals to select from.
c (int) – The index of the individual to start selection from.
K (int) – The number of individuals to be chosen at random from neighbors.
- get_parents() List[Individual] [source]
Perform the tournament selection to get parent individuals.
- Returns:
A list containing the selected parent individuals.
- Return type:
list of Individual
Roulette Wheel Selection
Implements a roulette wheel selection mechanism where each individual’s chance of being selected is proportional to its fitness. This method is widely used for its simplicity and is effective in problems where fitness proportionate selection is beneficial.
- class RouletteWheelSelection(pop_list: List[Individual] = [], c: int = 0)[source]
Bases:
SelectionOperator
RouletteWheelSelection performs a roulette wheel selection on a population of individuals to select parent individuals for crossover.
- Parameters:
pop_list (list of Individual) – The population of individuals to select from.
c (int) – The index of the individual to start selection from.
- __init__(pop_list: List[Individual] = [], c: int = 0)[source]
Initialize the RouletteWheelSelection object.
- Parameters:
pop_list (list of Individual) – The population of individuals to select from.
c (int) – The index of the individual to start selection from.
- get_parents() List[Individual] [source]
Perform the roulette wheel selection to get parent individuals.
- Returns:
A list containing the selected parent individuals.
- Return type:
list of Individual