Selection
Selection
- class gaggle.operators.selection.selection.Selection(ga_args: GAArgs = None)[source]
Bases:
object
The parent class for any Selection Operator. It gives functions to select the protected (elitism) set and to select the parents for crossover.
- select_all(manager: PopulationManager, mates_per_crossover: int, children_per_crossover: int) PopulationManager [source]
Calls both the protoected and parent selection fucntions
- abstract select_parents(manager: PopulationManager, mates_per_crossover: int, children_per_crossover: int) PopulationManager [source]
Should select both the parents and the mating tuples
- select_protected(manager: PopulationManager) PopulationManager [source]
By default, the select protected is elitism, to turn off elitism, set elitism to 0. in ga_args.
Selection_factory
- class gaggle.operators.selection.selection_factory.SelectionFactory[source]
Bases:
object
Factory that generates pre-existing available selection operators. SelectionFactory.selections stores said selection operators as a dictionary with their name as the key and the uninitialized selection object as the value.
- classmethod from_ga_args(ga_args: GAArgs = None) Selection [source]
Initializes the requested selection from the dictionary of available selections.
This is done by using the attribute ga_args.selection as the lookup key to SelectionFactory.selections.
- Parameters:
ga_args – GAArgs object for the current run
- Returns:
An initialized selection class object.
- selections = {'probabilistic_tournament': <class 'gaggle.operators.selection.base_selections.probabilistic_tournament_selection.ProbabilisticTournamentSelection'>, 'relative_weighted': <class 'gaggle.operators.selection.base_selections.relative_weighted_selection.RelativeWeightedSelection'>, 'simple_tournament': <class 'gaggle.operators.selection.base_selections.simple_tournament_selection.SimpleTournamentSelection'>, 'truncation': <class 'gaggle.operators.selection.base_selections.truncation_selection.TruncationSelection'>, 'weighted': <class 'gaggle.operators.selection.base_selections.weighted_selection.WeightedSelection'>}
- classmethod update(key, selection)[source]
Add a new selection operator to the dictionary of selections that can be created.
It is added to SelectionFactory.selections
- Parameters:
key – selection name that will be used as the dictionary lookup key
selection – selection class object, it needs to not be already initialized