saealib.TournamentSelection

class saealib.TournamentSelection(tournament_size)[source]

Bases: ParentSelection

Tournament selection operator.

Parameters:

tournament_size (int)

Methods

__init__

select

Execute tournament selection.

Method Details

TournamentSelection.__init__(tournament_size)[source]
Parameters:

tournament_size (int)

TournamentSelection.select(ctx, population, n_pair, n_parents, rng=Generator(PCG64) at 0x7F65E9C917E0)[source]

Execute tournament selection.

Parameters:
  • ctx (OptimizationContext) – Optimization context.

  • population (Population) – Population to select from.

  • n_pair (int) – Number of pairs to select.

  • n_parents (int) – Number of parents per pair.

  • rng (np.random.Generator, optional) – Random number generator, by default np.random.default_rng()

Returns:

Selected parent indices. shape = (n_pair, n_parents)

Return type:

np.ndarray