Tournament Selection

Tournament selection is used to select the agents from a population which will make up the next generation of agents. If elitism is used, the best agent from a population is automatically preserved and becomes a member of the next generation. Then, for each tournament, k individuals are randomly chosen, and the agent with the best evaluation fitness is preserved. This is repeated until the population for the next generation is full.

The class TournamentSelection defines the functions required for tournament selection. TournamentSelection.select() returns the best agent, and the new generation of agents.

from agilerl.hpo.tournament import TournamentSelection

tournament = TournamentSelection(
  tournament_size=2, # Tournament selection size
  elitism=True,      # Elitism in tournament selection
  population_size=6, # Population size
  eval_loop=1)       # Evaluate using last N fitness scores

Parameters

class agilerl.hpo.tournament.TournamentSelection(tournament_size: int, elitism: bool, population_size: int, eval_loop: int)

The tournament selection class. Calling TournamentSelection.select() on a population of agents will return a cloned population containing the best performing agent as well as the new generation of agents based on their fitness scores.

Parameters:
  • tournament_size (int) – Tournament selection size

  • elitism (bool) – Elitism in tournament selection

  • population_size (int) – Number of agents in population

  • eval_loop (int) – Number of most recent fitness scores to use in evaluation

select(population: list[EvolvableAlgorithm]) tuple[EvolvableAlgorithm, list[EvolvableAlgorithm]]

Select the best agent and new population of agents following tournament selection.

Parameters:

population (PopulationType) – Population of agents

Returns:

Elite agent and new population

Return type:

tuple[EvolvableAlgorithm, PopulationType]