geneticengine.algorithms.gp.operators.selection

Classes

TournamentSelection

TournamentSelection represents a tournament selection algorithm, where

LexicaseSelection

Implements Lexicase Selection

WeightedLexicaseSelection

Lexicase selection with accuracy-biased objective ordering.

PriorityLexicaseSelection

Priority Lexicase:

InformedDownsamplingSelection

Selects individuals using only test cases with highest variance.

Module Contents

class geneticengine.algorithms.gp.operators.selection.TournamentSelection(tournament_size, with_replacement=False)

Bases: geneticengine.algorithms.gp.structure.GeneticStep

TournamentSelection represents a tournament selection algorithm, where tournament_size individuals are selected at random, and only the best passes to the next generation.

Parameters:
  • tournament_size (int) – number of individuals from the population that will be randomly selected

  • with_replacement (bool) – whether the selected individuals can appear again in another tournament (default: False)

tournament_size
with_replacement = False
iterate(problem, evaluator, representation, random, population, target_size, generation)
Parameters:
Return type:

Iterator[geneticengine.solutions.individual.PhenotypicIndividual]

class geneticengine.algorithms.gp.operators.selection.LexicaseSelection(epsilon=False)

Bases: geneticengine.algorithms.gp.structure.GeneticStep

Implements Lexicase Selection (http://williamlacava.com/research/lexicase/).

Parameters:

epsilon (bool) – if True, espilon-lexicase is performed. We use the method given by equation 5 in https://dl.acm.org/doi/pdf/10.1145/2908812.2908898.

epsilon = False
iterate(problem, evaluator, representation, random, population, target_size, generation)
Parameters:
Return type:

Iterator[geneticengine.solutions.individual.PhenotypicIndividual]

class geneticengine.algorithms.gp.operators.selection.WeightedLexicaseSelection(epsilon=True, objective_weights=None)

Bases: LexicaseSelection

Lexicase selection with accuracy-biased objective ordering. Uses weighted random permutation: - Objectives [0,1,2] (accuracy splits): weight 4.0 each - Objectives [3,4] (costs): weight 1.0 each

Parameters:
objective_weights = None
_weighted_case_order(random, n_cases)
Parameters:
Return type:

list[int]

iterate(problem, evaluator, representation, random, population, target_size, generation)
Parameters:
Return type:

Iterator[geneticengine.solutions.individual.PhenotypicIndividual]

class geneticengine.algorithms.gp.operators.selection.PriorityLexicaseSelection(epsilon=True, objective_priorities=None)

Bases: LexicaseSelection

Priority Lexicase: - Lower integer means higher priority - Objectives in the same priority level are shuffled. Example: objective_priorities=[1, 1, 2, 3] -> [0/1 shuffled], then 2, then 3.

Parameters:
objective_priorities = None
_priority_case_order(random, n_cases)
Parameters:
Return type:

list[int]

iterate(problem, evaluator, representation, random, population, target_size, generation)
Parameters:
Return type:

Iterator[geneticengine.solutions.individual.PhenotypicIndividual]

class geneticengine.algorithms.gp.operators.selection.InformedDownsamplingSelection(max_sample_size=10, percent=0.1)

Bases: geneticengine.algorithms.gp.structure.GeneticStep

Selects individuals using only test cases with highest variance. Faster than standard Lexicase by reducing test case evaluations.

Parameters:
  • max_sample_size (int)

  • percent (float)

max_sample_size = 10
percent = 0.1
iterate(problem, evaluator, representation, random, population, target_size, generation)
Parameters:
Return type:

Iterator[geneticengine.solutions.individual.PhenotypicIndividual]