Reproduction Controller

class golem.core.optimisers.genetic.operators.reproduction.ReproductionController(parameters: golem.core.optimisers.genetic.gp_params.GPAlgorithmParameters, selection: golem.core.optimisers.genetic.operators.selection.Selection, mutation: golem.core.optimisers.genetic.operators.mutation.Mutation, crossover: golem.core.optimisers.genetic.operators.crossover.Crossover, window_size: int = 10)[source]

Bases: object

Task of the Reproduction Controller is to reproduce population while keeping population size as specified in optimizer settings.

It implements a simple proportional controller that compensates for invalid results each generation by computing average ratio of valid results. Invalid results include cases when Operators, Evaluator or GraphVerifier return output population that’s smaller than the input population.

Example. Let’s say we need a population of size 50. Let’s say about 20% of individuals are usually evaluated with an error. If we take select only 50 for the new population, we will get about 40 valid ones. Not enough. Therefore, we need to take more. How much more? Approximately by target_pop_size / mean_success_rate = 50 / 0.8 ~= 62’. Here `mean_success_rate estimates number of successfully evaluated individuals. Then we request 62, then approximately 62*0.8~=50 of them are valid in the end, and we achieve target size more reliably. This runs in a loop to control stochasticity.

Parameters
  • parameters – genetic algorithm parameters.

  • selection – operator used in reproduction.

  • mutation – operator used in reproduction.

  • crossover – operator used in reproduction.

  • window_size – size in iterations of the moving window to compute reproduction success rate.

property mean_success_rate: float

Returns mean success rate of reproduction + evaluation, fraction of how many individuals were reproduced and mutated successfully. Computed as average fraction for the last N iterations (N = window size param)

reproduce_uncontrolled(population: Sequence[golem.core.optimisers.opt_history_objects.individual.Individual], evaluator: Callable[[Sequence[golem.core.optimisers.opt_history_objects.individual.Individual]], Sequence[golem.core.optimisers.opt_history_objects.individual.Individual]], pop_size: Optional[int] = None) Sequence[golem.core.optimisers.opt_history_objects.individual.Individual][source]

Reproduces and evaluates population (select, crossover, mutate). Doesn’t implement any additional checks on population.

reproduce(population: Sequence[golem.core.optimisers.opt_history_objects.individual.Individual], evaluator: Callable[[Sequence[golem.core.optimisers.opt_history_objects.individual.Individual]], Sequence[golem.core.optimisers.opt_history_objects.individual.Individual]]) Sequence[golem.core.optimisers.opt_history_objects.individual.Individual][source]

Reproduces and evaluates population (select, crossover, mutate). Implements additional checks on population to ensure that population size follows required population size.