bingo.evolutionary_algorithms package#

Submodules#

bingo.evolutionary_algorithms.age_fitness module#

The Age-Fitness Evolutionary Algorithm

This module defines the evolutionary algorithm that implements, VarOr variation on a population then performs Age-Fitness selection among the variation result, the initial population, and a random chromosome.

class bingo.evolutionary_algorithms.age_fitness.AgeFitnessEA(evaluation, generator, crossover, mutation, crossover_probability, mutation_probability, population_size, selection_size=2)#

Bases: MuPlusLambda

The algorithm used to perform generational steps.

This class extends MuPlusLambda and executes generational_step.

Parameters:
  • evaluation (evaluation) – The evaluation algorithm that sets the fitness on the population.

  • generator (Generator) – The individual generator for the random individual.

  • crossover (Crossover) – The algorithm that performs crossover during variation.

  • mutation (Mutation) – The algorithm that performs mutation during variation.

  • crossover_probability (float) – Probability that crossover will occur on an individual.

  • mutation_probability (float) – Probability that mutation will occur on an individual.

  • population_size (int) – The targeted population size and the number of offspring produced from variation.

  • selection_size (int) – The size of the group of individuals to be randomly compared. The size must be an integer greater than 1.

variation#

Public access to the variation phase of the Base

Type:

variation

evaluation#

Public access to the evaluation phase of the Base

Type:

evaluation

selection#

Public access to the selection phase of the Base

Type:

selection

bingo.evolutionary_algorithms.ea_diagnostics module#

Evolutionary algorithm diagnostics

EA diagnostics are tracked to allow for investigating convergence properties, etc. Currently ony diagnostics associated with the variation phase of a EA are tracked.

class bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnostics(crossover_types=None, mutation_types=None)#

Bases: object

Evolutionary Algorithm Diagnostic Information

EA diagnostics are tracked to allow for investigating convergence properties, etc. Currently ony diagnostics associated with the variation phase of a EA are tracked.

Parameters:
  • crossover_types (iterable of str, optional) – possible crossover types (excluding None)

  • mutation_types (iterable of str, optional) – possible mutation types (excluding None)

summary#

namedtuple describing the summary of the diagnostic information

Type:

EaDiagnosticsSummary

crossover_type_summary#

dict mapping crossover types to GeneticOperatorSummary, describing the diagnostic information of cases when only a particular crossover type was applied

Type:

dict(str: GeneticOperatorSummary)

mutation_type_summary#

dict mapping mutation types to GeneticOperatorSummary, describing the diagnostic information of cases when only a particular mutation type was applied

Type:

dict(str: GeneticOperatorSummary)

crossover_mutation_type_summary#

dict mapping a tuple of crossover type and mutation type (in that order) to the diagnostic information of cases when both the crossover and mutation type were applied

Type:

dict(tuple(str, str): GeneticOperatorSummary) # pylint: disable=line-too-long

property crossover_mutation_type_summary#

Summary of diagnostic data when both crossover and mutation happened

property crossover_type_summary#

Summary of diagnostic data when only crossover happened

get_log_header()#

Gets a comma separated header for use in diagnstics logging

Returns:

A comma separated desription of stats that will be logged

Return type:

str

get_log_stats()#

Gets a list of statistics that describe the effects of each type of genetic variation

Return: array :

the number, beneficial (improved firness compared to parents), and detrimental (worsened compared to parents) for each possible variation

property mutation_type_summary#

Summary of diagnostic data when only mutation happened

property summary#

Summary statistics of the diagnostic data

update(population, offspring, offspring_parents, crossover_offspring_type, mutation_offspring_type)#

Updates the diagnostic information associated with a single step in an EA

Parameters:
  • population (list of Chromosome) – population at the beginning of the generational step

  • offspring (list of Chromosome) – the result of the EAs variation phase

  • offspring_parents (list of list of int) – list indicating the parents (by index in population) of the corresponding member of offspring

  • crossover_offspring_type (numpy array of str) – numpy array indicating the crossover type that the corresponding offspring underwent (or None)

  • mutation_offspring_type (numpy array of str) – numpy array indicating the mutation type that the corresponding offspring underwent (or None)

class bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnosticsSummary(beneficial_crossover_rate, detrimental_crossover_rate, beneficial_mutation_rate, detrimental_mutation_rate, beneficial_crossover_mutation_rate, detrimental_crossover_mutation_rate)#

Bases: tuple

beneficial_crossover_mutation_rate#

Alias for field number 4

beneficial_crossover_rate#

Alias for field number 0

beneficial_mutation_rate#

Alias for field number 2

detrimental_crossover_mutation_rate#

Alias for field number 5

detrimental_crossover_rate#

Alias for field number 1

detrimental_mutation_rate#

Alias for field number 3

class bingo.evolutionary_algorithms.ea_diagnostics.GeneticOperatorSummary(beneficial_rate, detrimental_rate)#

Bases: tuple

beneficial_rate#

Alias for field number 0

detrimental_rate#

Alias for field number 1

bingo.evolutionary_algorithms.evolutionary_algorithm module#

The base of evolutionary algorithm definition

This module defines the basis of evolutionary algorithms in bingo analyses. An evolutionary algorithms in bingo is defined by three phases: variation, evaluation, and selection. These phases, when repeated, define the evolution of a population.

class bingo.evolutionary_algorithms.evolutionary_algorithm.EvolutionaryAlgorithm(variation, evaluation, selection)#

Bases: object

The algorithm used to perform generational steps.

The basic implementation used in this base Base implementation is a simple steady-state Base (akin to simpleEA in DEAP)

Parameters:
  • variation (variation) – The phase of bingo EAs that is responsible for varying the population (usually through some form of crossover and/or mutation).

  • evaluation (evaluation) – The phase in bingo EAs responsible for the evaluation of the fitness of the individuals in the population.

  • selection (selection) – The phase of bingo EAs responsible for selecting the individuals in a population which survive into the next generation.

variation#

Public access to the variation phase of the EA

Type:

variation

evaluation#

Public access to the evaluation phase of the EA

Type:

evaluation

selection#

Public access to the selection phase of the EA

Type:

selection

diagnostics#

Public to the EA diagnostics

Type:

bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnostics

generational_step(population)#

Performs a generational step on population.

Parameters:

population (list of chromosomes) – The population at the start of the generational step

Returns:

The next generation of the population

Return type:

list of chromosomes

update_diagnostics(population, offspring)#

Update the evolutionary algorithms diagnostic information based on a new generation of offspring

Parameters:
  • population (list of Chromosome) – The original population fo the generation

  • offspring (list of Chromosome) – The potential new members of the population

bingo.evolutionary_algorithms.generalized_crowding module#

The generalized crowding evolutionary algorithm

This module defines the basis of the generalized crowding evolutionary algorithm in bingo analyses. The next generation is selected by pairing parents with their offspring and advancing the most fit of the two.

class bingo.evolutionary_algorithms.generalized_crowding.GeneralizedCrowdingEA(evaluation, crossover, mutation, crossover_probability, mutation_probability, selection=None)#

Bases: EvolutionaryAlgorithm

The algorithm used to perform generational steps.

A class for the generalized crowding evolutionary algorithm in bingo.

Parameters:
  • evaluation (evaluation) – The evaluation algorithm that sets the fitness on the population.

  • crossover (Crossover) – The algorithm that performs crossover during variation.

  • mutation (Mutation) – The algorithm that performs mutation during variation.

  • crossover_probability (float) – Probability that crossover will occur on an individual.

  • mutation_probability (float) – Probability that mutation will occur on an individual.

  • selection (CrowdingSelection) – Selection phase. Default DeterministicCrowding.

evaluation#

evaluation instance to perform evaluation on a population

Type:

Evaluation

selection#

Performs selection on a population via deterministic crowding

Type:

CrowdingSelection

variation#

Performs VarAnd variation on a population

Type:

VarAnd

diagnostics#

Public to the EA diagnostics

Type:

bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnostics

generational_step(population)#

Performs selection on individuals.

Parameters:

population (list of chromosomes) – The population at the start of the generational step

Returns:

The next generation of the population

Return type:

list of chromosomes

bingo.evolutionary_algorithms.mu_comma_lambda module#

The “Mu , Lambda”

This module defines the basis of the “mu comma lambda” evolutionary algorithm in bingo analyses. The next generation is selected only from the offspring of the parent population.

class bingo.evolutionary_algorithms.mu_comma_lambda.MuCommaLambda(evaluation, selection, crossover, mutation, crossover_probability, mutation_probability, number_offspring)#

Bases: EvolutionaryAlgorithm

The algorithm used to perform generational steps.

A class for the “mu comma lambda” evolutionary algorithm in bingo.

Parameters:
  • evaluation (evaluation) – The evaluation algorithm that sets the fitness on the population.

  • selection (selection) – selection instance to perform selection on a population

  • crossover (Crossover) – The algorithm that performs crossover during variation.

  • mutation (Mutation) – The algorithm that performs mutation during variation.

  • crossover_probability (float) – Probability that crossover will occur on an individual.

  • mutation_probability (float) – Probability that mutation will occur on an individual.

  • number_offspring (int) – The number of offspring produced from variation.

variation#

VarOr variation to perform variation on a population

Type:

VarOr

evaluation#

evaluation instance to perform evaluation on a population

Type:

evaluation

selection#

selection instance to perform selection on a population

Type:

selection

diagnostics#

Public to the EA diagnostics

Type:

bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnostics

generational_step(population)#

Performs selection on individuals.

Parameters:

population (list of chromosomes) – The population at the start of the generational step

Returns:

The next generation of the population

Return type:

list of chromosomes

bingo.evolutionary_algorithms.mu_plus_lambda module#

The “Mu + Lambda”

This module defines the basis of the “mu plus lambda” evolutionary algorithm in bingo analyses. The next generation is evaluated and selected from both the parent and offspring populations.

class bingo.evolutionary_algorithms.mu_plus_lambda.MuPlusLambda(evaluation, selection, crossover, mutation, crossover_probability, mutation_probability, number_offspring, target_population_size=None)#

Bases: EvolutionaryAlgorithm

The algorithm used to perform generational steps.

A class for the “mu plus lambda” evolutionary algorithm in bingo.

Parameters:
  • evaluation (evaluation) – The evaluation algorithm that sets the fitness on the population.

  • selection (selection) – selection instance to perform selection on a population

  • crossover (Crossover) – The algorithm that performs crossover during variation.

  • mutation (Mutation) – The algorithm that performs mutation during variation.

  • crossover_probability (float) – Probability that crossover will occur on an individual.

  • mutation_probability (float) – Probability that mutation will occur on an individual.

  • number_offspring (int) – The number of offspring produced from variation.

  • target_population_size (int (optional)) – The targeted population size. Default is to keep the population the same size as the starting population

variation#

VarOr variation to perform variation on a population

Type:

VarOr

evaluation#

evaluation instance to perform evaluation on a population

Type:

evaluation

selection#

selection instance to perform selection on a population

Type:

selection

diagnostics#

Public to the EA diagnostics

Type:

bingo.evolutionary_algorithms.ea_diagnostics.EaDiagnostics

generational_step(population)#

Performs selection on individuals.

Parameters:

population (list of chromosomes) – The population at the start of the generational step

Returns:

The next generation of the population

Return type:

list of chromosomes

Module contents#