saealib.RouletteWheelSelection

class saealib.RouletteWheelSelection[source]

Bases: ParentSelection

Roulette wheel selection operator using linear rank-based probabilities.

Selection probability is proportional to rank: the best individual has the highest probability and the worst has the lowest. This avoids numerical issues with raw fitness values (negative values, scale sensitivity) while preserving a fitness-proportionate behaviour.

Methods

__init__

Initialize roulette wheel selection operator.

select

Execute roulette wheel selection.

Method Details

RouletteWheelSelection.__init__()[source]

Initialize roulette wheel selection operator.

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

Execute roulette wheel 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