Algorithms

ea_generate_update(toolbox, generations, hof=None, stats=None, verbose=False)

An evolutionary algorithm. This function expects the ‘generate’, ‘update’, and ‘evaluate’ operators to be registered in the toolbox.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • generations (int) – The number of generations to compute.

  • hof (Hof) – A HallOfFame or a ParetoFront object, optional.

  • stats (Stats) – A Statistics or a MultiStatistics object, optional.

  • verbose (bool) – Whether to print debug messages, optional.

Returns

The final population and the logbook.

Return type

AlgoResult

ea_mu_comma_lambda(toolbox, population, generations, offsprings, survivors, cx_prob, mut_prob, hof=None, stats=None, verbose=False)

An evolutionary algorithm. This function expects the ‘mate’, ‘mutate’, ‘select’ and ‘evaluate’ operators to be registered in the toolbox. The survivors are selected only from the offspring population.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • population (list) – A list of individuals to evolve.

  • generations (int) – The number of generations to compute.

  • offsprings (int) – The number of individuals to produce at each generation.

  • survivors (int) – The number of individuals to select from the offspring.

  • cx_prob (float) – The probability of mating two individuals.

  • mut_prob (float) – The probability of mutating an individual.

  • hof (Hof) – A HallOfFame or a ParetoFront object, optional.

  • stats (Stats) – A Statistics or a MultiStatistics object, optional.

  • verbose (bool) – Whether to print debug messages, optional.

Returns

The final population and the logbook.

Return type

AlgoResult

ea_mu_plus_lambda(toolbox, population, generations, offsprings, survivors, cx_prob, mut_prob, hof=None, stats=None, verbose=False)

An evolutionary algorithm. This function expects the ‘mate’, ‘mutate’, ‘select’ and ‘evaluate’ operators to be registered in the toolbox. The survivors are selected from the offspring and the parent populations.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • population (list) – A list of individuals to evolve.

  • generations (int) – The number of generations to compute.

  • offsprings (int) – The number of individuals to produce at each generation.

  • survivors (int) – The number of individuals to select from the offspring.

  • cx_prob (float) – The probability of mating two individuals.

  • mut_prob (float) – The probability of mutating an individual.

  • hof (Hof) – A HallOfFame or a ParetoFront object, optional.

  • stats (Stats) – A Statistics or a MultiStatistics object, optional.

  • verbose (bool) – Whether to print debug messages, optional.

Returns

The final population and the logbook.

Return type

AlgoResult

ea_simple(toolbox, population, generations, cx_prob, mut_prob, hof=None, stats=None, verbose=False)

An evolutionary algorithm. This function expects the ‘mate’, ‘mutate’, ‘select’ and ‘evaluate’ operators to be registered in the toolbox.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • population (list) – A list of individuals to evolve.

  • generations (int) – The number of generations to compute.

  • cx_prob (float) – The probability of mating two individuals.

  • mut_prob (float) – The probability of mutating an individual.

  • hof (Hof) – A HallOfFame or a ParetoFront object, optional.

  • stats (Stats) – A Statistics or a MultiStatistics object, optional.

  • verbose (bool) – Whether to print debug messages, optional.

Returns

The final population and the logbook.

Return type

AlgoResult

var_and(toolbox, population, cx_prob, mut_prob)

A subcomponent for evolutionary algorithms, which mates AND mutates each individual in the given population according to the given probabilities. Each of the two probabilities must be in the range of [0, 1]. The returned population is independent of the input population and has their fitness invalidated.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • population (list) – A list of individuals to evolve.

  • cx_prob (float) – The probability of mating two individuals.

  • mut_prob (float) – The probability of mutating an individual.

Returns

A list of evolved individuals.

Return type

list

var_or(toolbox, population, offsprings, cx_prob, mut_prob)

A subcomponent for evolutionary algorithms, which mates OR mutates each individual in the given population according to the given probabilities. The sum of the two probabilities must be in the range of [0, 1]. The returned population is independent of the input population and has their fitness invalidated.

Parameters
  • toolbox (Toolbox) – A Toolbox which contains the evolution operators.

  • population (list) – A list of individuals to evolve.

  • offsprings (int) – The number of individuals to produce.

  • cx_prob (float) – The probability of mating two individuals.

  • mut_prob (float) – The probability of mutating an individual.

Returns

A list of evolved individuals.

Return type

list