Population Selectors

Provides different strategies for population selection

ga_solver.pop_selectors.build_roullete(population)

Returns a RangeDict with keys related to the value’s probability of being chosen in a Roullete Selection

Parameters:population (dict) – A dictionary whose keys are the individuals in the population and the keys are their fitness value
>>> build_roullete({"a": 10, "b": 10, "c": 20})
{(0, 0.25): "a", (0.25, 0.5): "b", (0.5, 1): "c"}
ga_solver.pop_selectors.roullete(population, random_seed=None)

Uses a classic roullete strategy for selection. Every individual has a probability of being selected equal to

(its goal value)/(the sum of all goal values)

Parameters:
  • population (dict) – A dictionary whose keys are the individuals in the population and the keys are their fitness value
  • random_seed (int, optional) – if supplied, Python PRNG’s seed is set to it. Use only if you need a total reproducible behavior such as in testing.
Returns:

One selected member