bingo.chromosomes package#

Submodules#

bingo.chromosomes.chromosome module#

chromosomes: the base class for all genetic individuals in bingo

This module defines a chromosomes, the base class for all genetic individuals in bingo evolutionary analyses. Extension of bingo can be performed by developing subclasses of chromosomes.

class bingo.chromosomes.chromosome.Chromosome(genetic_age=0, fitness=None, fit_set=False)#

Bases: object

A genetic individual

This class is the base of a genetic individual in bingo evolutionary analyses.

Parameters:
  • genetic_age (int) – age of the oldest component of the genetic material in the individual

  • fitness (numeric) – starting value of fitness

  • genetic_age – age of the oldest component of the genetic material in the individual

  • fit_set (bool) – whether the fitness has been calculated for the individual

fitness#
Type:

numeric

genetic_age#

age of the oldest component of the genetic material in the individual

Type:

int

fit_set#

whether the fitness has been calculated for the individual

Type:

bool

copy()#
Return type:

A deep copy of self

abstract distance(other)#

Distance from self to other

Parameters:

other (Chromosome) – The other to compare to.

Returns:

Distance from self to other

Return type:

float

property fit_set#

Indication of whether the fitness has been set

property fitness#

The fitness of the individual

Type:

numeric or tuple of numeric

property genetic_age#

The age of the oldest components of the individual

get_number_local_optimization_params()#

Get number of parameters in local optimization

Returns:

Number of parameters to be optimized

Return type:

int

needs_local_optimization()#

Does the Chromosome need local optimization

Returns:

Whether Chromosome needs optimization

Return type:

bool

set_local_optimization_params(params)#

Set local optimization parameters

Parameters:

params (list-like of numeric) – Values to set the parameters to

bingo.chromosomes.crossover module#

The genetic operation of crossover.

This module defines the basis of crossover in bingo evolutionary analyses.

class bingo.chromosomes.crossover.Crossover#

Bases: object

Crossover for chromosomes.

An abstract base class for the crossover between two genetic individuals in bingo.

bingo.chromosomes.generator module#

Generation of genetic individuals

This module defines the basis of the generation of individuals in bingo evolutionary analyses.

class bingo.chromosomes.generator.Generator#

Bases: object

A generator of individuals.

An abstract base class for the generation of genetic individuals in bingo.

bingo.chromosomes.multiple_floats module#

Multiple Floats for genetic information

This file contains the several classes that are used for chromosomes that contains a list of floats for their genetic information.

class bingo.chromosomes.multiple_floats.MultipleFloatChromosome(values, needs_opt_list=None)#

Bases: MultipleValueChromosome

Multiple float-value individual

Parameters:
  • values (list of floats) – The genetic information stored in an individual chromosome.

  • needs_opt_list (list of ints) – (optional) The indices of the individual_list in a chromosomes object that are subject local optimization. This list may be empty

get_local_optimization_params()#

Gets local optimization_params

Return type:

list

get_number_local_optimization_params()#

Get number of parameters in local optimization

Returns:

number of parameters to be optimized

Return type:

int

needs_local_optimization()#

Does the individual need local optimization

Returns:

Individual needs optimization

Return type:

bool

set_local_optimization_params(params)#

Set local optimization parameters

Parameters:

params (list-like of numeric) – Values to set the parameters

class bingo.chromosomes.multiple_floats.MultipleFloatChromosomeGenerator(random_value_function, values_per_chromosome, needs_opt_list=None)#

Bases: MultipleValueChromosomeGenerator

Generation of a population of Multi-Value chromosomes

Parameters:
  • random_value_function (user defined function) – A function that returns a randomly generated float value.

  • values_per_chromosome (int) – The number of values that each chromosome will hold

  • needs_opt_list (list of ints) – The indices of the individual_list in a chromosomes object that are subject local optimization. This list may be empty

bingo.chromosomes.multiple_values module#

Multiple Values for genetic information

This file contains several classes that are used for chromosomes that contains a list of genetic information.

class bingo.chromosomes.multiple_values.MultipleValueChromosome(values)#

Bases: Chromosome

Multiple value individual

The constructor for a chromosome that holds a list of values as opposed to a single value.

Parameters:

values (list of either ints, floats, or bools) – contains the chromosome’s list of values

values#

the genetic information of the individual

Type:

list

distance(other)#

Computes the distance (a measure of similarity) between two individuals.

Parameters:

other (MultipleValueChromosome) – The chromosome to compare to.

Returns:

dist – The distance between self and another chromosome

Return type:

float

get_number_local_optimization_params()#

Get number of parameters in local optimization

Returns:

Number of parameters to be optimized

Return type:

int

needs_local_optimization()#

Does the Chromosome need local optimization

Returns:

Whether Chromosome needs optimization

Return type:

bool

set_local_optimization_params(params)#

Set local optimization parameters

Parameters:

params (list-like of numeric) – Values to set the parameters to

class bingo.chromosomes.multiple_values.MultipleValueChromosomeGenerator(random_value_function, values_per_chromosome)#

Bases: Generator

Generation of a population of Multi-Value chromosomes

Parameters:
  • random_value_function (user defined function) – a function that returns randomly generated values to be used as components of the chromosomes.

  • values_per_chromosome (int) – the number of values that each chromosome will hold

class bingo.chromosomes.multiple_values.SinglePointCrossover#

Bases: Crossover

Crossover for multiple valued chromosomes

Crossover results in two individuals with single-point crossed-over lists whose values are provided by the parents. Crossover point is a random integer produced by numpy.

types#

an iterable of the possible crossover types

Type:

iterable of str

last_crossover_types#

the crossover type (or None) that happened to create the first child and second child, respectively

Type:

tuple(str, str)

class bingo.chromosomes.multiple_values.SinglePointMutation(mutation_function)#

Bases: Mutation

Mutation for multiple valued chromosomes

Performs single-point mutation on the offspring of a parent chromosome. The mutation is performed using a user-defined mutation function that must return a single randomly generated value.

Parameters:

mutation_function (user defined function) – a function that returns a random value that will replace (or “mutate”) a random value in the chromosome.

types#

an iterable of the possible mutation types

Type:

iterable of str

last_mutation_type#

the last mutation type that happened (or None)

Type:

str

bingo.chromosomes.mutation module#

The genetic operation of Mutation.

This module defines the basis of mutation in bingo evolutionary analyses.

class bingo.chromosomes.mutation.Mutation#

Bases: object

A mutator of individuals.

An abstract base class for the mutation of chromosomes in bingo.

Module contents#