evolutionary_optimization.phenotype.phenotype_model package

Submodules

evolutionary_optimization.phenotype.phenotype_model.abstract_phenotype module

class AbstractPhenotype(genotype)[source]

Bases: ABC

abstract __init__(genotype)[source]

Initialise AbstractPhenotype object.

Args

genotype: an AbstractGenotype that defines the phenotype.

abstract crossover(parent_2)[source]

Perform crossover between two phenotypes.

Calls crossover method from the genotype attribute.

Parameters

parent_2 (AbstractPhenotype) – a phenotype of the same class whose genotype will be mixed with

Return type

Tuple[AbstractPhenotype, AbstractPhenotype]

Returns

Two new phenotype instances based on the combined genotypes of the two parents.

abstract evaluate_phenotype()[source]

Calculate phenotype value using genotype.

abstract static evaluate_phenotype_using_arrays(x_values, y_values)[source]

Calculate multiple phenotype values from numpy arrays.

Return type

ndarray

abstract classmethod from_phenotype(base_phenotype)[source]

Create new phenotype with the same attributes as the base phenotype.

abstract property genotype

AbstractGenotype that defines the phenotype.

abstract mutate()[source]

In place modification of the genotype by randomly changing genes based on mutation probability.

abstract property phenotype_value

Stores value of the phenotype based on the genotype - calculated using evaluate_phenotype.

evolutionary_optimization.phenotype.phenotype_model.phenotype_interface module

class Phenotype[source]

Bases: object

Map Phenotypes to their associated concrete class based on AbstractPhenotype.

classmethod get_phenotype(phenotypes_enum)[source]

Return class of desired AbstractPhenotype.

Return type

ABCMeta

phenotypes_dictionary = {Phenotypes.BOOTH: <class 'evolutionary_optimization.phenotype.implemented_phenotypes.booth_phenotype.BoothPhenotype'>, Phenotypes.INVERTED_PARABOLA: <class 'evolutionary_optimization.phenotype.implemented_phenotypes.inverted_parabola_phenotype.InvertedParabolaPhenotype'>, Phenotypes.PARABOLA: <class 'evolutionary_optimization.phenotype.implemented_phenotypes.parabola_phenotype.ParabolaPhenotype'>, Phenotypes.SADDLE_POINT: <class 'evolutionary_optimization.phenotype.implemented_phenotypes.saddle_point_phenotype.SaddlePointPhenotype'>}
class Phenotypes(value)[source]

Bases: str, Enum

Enum containing implemented phenotypes.

BOOTH = 'booth'
INVERTED_PARABOLA = 'inverted_parabola'
PARABOLA = 'parabola'
SADDLE_POINT = 'saddle_point'

evolutionary_optimization.phenotype.phenotype_model.phenotype_utils module

class PlottingData(x, y, z=None)[source]

Bases: object

Dataclass containing plotting information.

__init__(x, y, z=None)
x: ndarray
y: ndarray
z: Optional[ndarray] = None
generate_points_for_function(phenotype, bottom_plotting_limit=-50, upper_plotting_limit=50, number_of_points=100)[source]

Generate datapoints to plot a phenotype function.

Parameters
  • phenotype (AbstractPhenotype) – AbstractPhenotype which we want to plot.

  • bottom_plotting_limit (Union[float, int]) – the bottom limit for plotting.

  • upper_plotting_limit (Union[float, int]) – the upper limit for plotting.

  • number_of_points (int) – number of points to generate within the plotting range.

Return type

Union[NameError, PlottingData]

Returns

Data necessary to generate a plot of the phenotype.

Module contents