reproduction — Reproduction Components

Reproduction components for evolutionary algorithms.

class evoalgos.reproduction.Reproduction

Abstract base class for objects that generate new Individuals.

create(population, number)

Return number new individuals.

This is an abstract method.

Parameters:
  • population (list of Individual) – The parent population.
  • number (int) – The number of individuals to create.
Returns:

offspring – The new individuals.

Return type:

list of Individual

extend_by(population, number)

Extend the population by number individuals.

This method works by calling create() and appending these individuals to the population.

Parameters:
  • population (list of Individual) – The parent population.
  • number (int) – The number of individuals to add to the population.
class evoalgos.reproduction.ESReproduction(selection=None, recombination_prob=1.0, redetermine_first_parent=True)

A reproduction component suitable for most evolutionary algorithms.

__init__(selection=None, recombination_prob=1.0, redetermine_first_parent=True)

Constructor.

Parameters:
  • selection (Selection, optional) – This object is used for selecting parent individuals. Default is random uniform selection.
  • recombination_prob (float, optional) – A probability to determine how much sexual and asexual reproduction is carried out. Sexual reproduction means that a new offspring is generated by recombination and mutation. For asexual reproduction a single individual is cloned and then mutated. Default is to always use sexual reproduction.
  • redetermine_first_parent (bool, optional) – Indicates if a new parent is selected in each iteration, or if the same parent is used to produce all offspring in one call to create(). The other parents are always redetermined, so setting this to False probably only makes sense in scenarios without recombination.
create(population, number)

Return number new individuals.

This method works as follows: as long as more offspring are needed, a first parent is determined via the selection component. The first parent’s property num_parents determines how many other parents are drawn. If the population is smaller than this value, it is multiplied until it is larger. The other parents are then again determined by the selection component, and the offspring is created with first_parent.recombine(other_parents). If asexual reproduction is chosen, offspring is created by first_parent.clone(). If too many individuals were generated, random ones are deleted. Finally, every child is mutated.

Parameters:
  • population (list of Individual) – The parent population.
  • number (int) – The number of individuals to create.
Returns:

offspring – The new individuals.

Return type:

list of Individual