edo.operators package¶
Submodules¶
edo.operators.crossover module¶
Functions for the crossover process.
-
edo.operators.crossover.
crossover
(parent1, parent2, col_limits, families, random_state, prob=0.5)[source]¶ Blend the information from two parents to create a new
Individual
. Dimensions are inherited first, forming a “skeleton” that is filled with column-metadata pairs. These pairs are selected from either parent uniformly. Missing values are filled in as necessary.- Parameters
- parent1Individual
The first individual to be blended.
- parent2Individual
The second individual to be blended.
- col_limitslist
Lower and upper bounds on the number of columns
offspring
can have. Used in case of tuple limits.- familieslist
Families of distributions with which to create new columns. Used in case of tuple column limits.
- random_statenumpy.random.RandomState
The PRNG associated with the offspring.
- probfloat, optional
The cut-off probability with which to inherit dimensions from
parent1
overparent2
.- Returns
- ——-
- offspringIndividual
A new individual formed from the dimensions and columns of its parents.
edo.operators.mutation module¶
Functions related to the mutation operator.
-
edo.operators.mutation.
mutate_ncols
(dataframe, metadata, col_limits, families, weights, random_state, prob)[source]¶ Mutate the number of columns an individual has by adding a new column and/or dropping a column at random. In either case, the bounds defined in
col_limits
cannot be exceeded.
-
edo.operators.mutation.
mutate_nrows
(dataframe, metadata, row_limits, random_state, prob)[source]¶ Mutate the number of rows an individual has by adding a new row and/or dropping a row at random so as not to exceed the bounds of
row_limits
.
-
edo.operators.mutation.
mutate_values
(dataframe, metadata, random_state, prob)[source]¶ Iterate over the values of
dataframe
and mutate them each with probabilityprob
. Mutating a value is done by resampling from the associated column distribution inmetadata
.
-
edo.operators.mutation.
mutation
(individual, prob, row_limits, col_limits, families, weights=None)[source]¶ Mutate an individual. Here, the characteristics of an individual can be split into two parts: their dimensions, and their values. Each of these parts is mutated in a different way using the same probability,
prob
.- Parameters
- individualIndividual
The individual to be mutated.
- probfloat
The probability with which any characteristic of
individual
should be mutated.- row_limitslist
Lower and upper limits on the number of rows an individual can have.
- col_limitslist
Lower and upper limits on the number of columns an individual can have.
- families: list
Families of distributions with which to create new columns.
- weightslist, optional
Probabilities with which to sample a distribution
families
. IfNone
, sample uniformly.
- Returns
- mutantIndividual
A (potentially) mutated individual.
edo.operators.selection module¶
The selection operator.
-
edo.operators.selection.
selection
(population, pop_fitness, best_prop, lucky_prop, random_state, maximise=False)[source]¶ Given a population, select a proportion of the “best” individuals and another of the “lucky” individuals (if they are available) to form a set of potential parents.
- Parameters
- populationlist
All current individuals.
- pop_fitnesslist
The fitness of each individual in
population
.- best_propfloat
The proportion of the fittest individuals in
population
to be selected.- lucky_propfloat
The proportion of lucky individuals left in
population
to be selected after the “best” have been selected.- maximisebool, optional
Determines whether an individual’s fitness should be maximal or not. Defaults to
False
.
- Returns
- parentsdict
The individuals chosen to potentially become parents and their index in the current population.
edo.operators.shrink module¶
Functions for shrinking the search space.
-
edo.operators.shrink.
shrink
(parents, families, itr, shrinkage)[source]¶ Given the current progress of the evolutionary algorithm, shrink its search space, i.e. the parameter spaces for each of the distribution classes in
families
.- Parameters
- parentslist of Individual instances
The parent individuals for this iteration.
- familieslist of Distribution instances
The families of distributions to be shrunk.
- itrint
The current iteration.
- shrinkagefloat
The shrinkage factor between 0 and 1.
- Returns
- familieslist of Distribution instances
The altered families.
edo.operators.util module¶
A collection of functions for use across several operators.
Module contents¶
-
edo.operators.
crossover
(parent1, parent2, col_limits, families, random_state, prob=0.5)[source]¶ Blend the information from two parents to create a new
Individual
. Dimensions are inherited first, forming a “skeleton” that is filled with column-metadata pairs. These pairs are selected from either parent uniformly. Missing values are filled in as necessary.- Parameters
- parent1Individual
The first individual to be blended.
- parent2Individual
The second individual to be blended.
- col_limitslist
Lower and upper bounds on the number of columns
offspring
can have. Used in case of tuple limits.- familieslist
Families of distributions with which to create new columns. Used in case of tuple column limits.
- random_statenumpy.random.RandomState
The PRNG associated with the offspring.
- probfloat, optional
The cut-off probability with which to inherit dimensions from
parent1
overparent2
.- Returns
- ——-
- offspringIndividual
A new individual formed from the dimensions and columns of its parents.
-
edo.operators.
mutation
(individual, prob, row_limits, col_limits, families, weights=None)[source]¶ Mutate an individual. Here, the characteristics of an individual can be split into two parts: their dimensions, and their values. Each of these parts is mutated in a different way using the same probability,
prob
.- Parameters
- individualIndividual
The individual to be mutated.
- probfloat
The probability with which any characteristic of
individual
should be mutated.- row_limitslist
Lower and upper limits on the number of rows an individual can have.
- col_limitslist
Lower and upper limits on the number of columns an individual can have.
- families: list
Families of distributions with which to create new columns.
- weightslist, optional
Probabilities with which to sample a distribution
families
. IfNone
, sample uniformly.
- Returns
- mutantIndividual
A (potentially) mutated individual.
-
edo.operators.
selection
(population, pop_fitness, best_prop, lucky_prop, random_state, maximise=False)[source]¶ Given a population, select a proportion of the “best” individuals and another of the “lucky” individuals (if they are available) to form a set of potential parents.
- Parameters
- populationlist
All current individuals.
- pop_fitnesslist
The fitness of each individual in
population
.- best_propfloat
The proportion of the fittest individuals in
population
to be selected.- lucky_propfloat
The proportion of lucky individuals left in
population
to be selected after the “best” have been selected.- maximisebool, optional
Determines whether an individual’s fitness should be maximal or not. Defaults to
False
.
- Returns
- parentsdict
The individuals chosen to potentially become parents and their index in the current population.
-
edo.operators.
shrink
(parents, families, itr, shrinkage)[source]¶ Given the current progress of the evolutionary algorithm, shrink its search space, i.e. the parameter spaces for each of the distribution classes in
families
.- Parameters
- parentslist of Individual instances
The parent individuals for this iteration.
- familieslist of Distribution instances
The families of distributions to be shrunk.
- itrint
The current iteration.
- shrinkagefloat
The shrinkage factor between 0 and 1.
- Returns
- familieslist of Distribution instances
The altered families.