evolutionary_optimization.fitness_functions package

Submodules

evolutionary_optimization.fitness_functions.abstract_fitness_function module

class AbstractFitnessFunction[source]

Bases: ABC

abstract evaluate(phenotype)[source]

This method will return the fitness score from a phenotype.

Parameters

phenotype (AbstractPhenotype) – instance of AbstractPhenotype being evaluated.

Return type

Union[float, int]

Returns

Processed phenotype value depending on desired fitness function.

evolutionary_optimization.fitness_functions.fitness_interface module

class FitnessFunction[source]

Bases: object

Maps FitnessFunctions to their associated concrete class based on AbstractFitnessFunction.

fitness_functions_dictionary = {FitnessFunctions.APPROACH_VALUE: <class 'evolutionary_optimization.fitness_functions.implemented_fitness_functions.ApproachValueFitnessFunction'>, FitnessFunctions.MAXIMIZE: <class 'evolutionary_optimization.fitness_functions.implemented_fitness_functions.MaximizeFitnessFunction'>, FitnessFunctions.MINIMIZE: <class 'evolutionary_optimization.fitness_functions.implemented_fitness_functions.MinimizeFitnessFunction'>}
classmethod get_fitness_function(fitness_function)[source]

Return class of desired AbstractFitnessFunction.

Return type

ABCMeta

class FitnessFunctions(value)[source]

Bases: str, Enum

Enum containing implemented fitness functions.

APPROACH_VALUE = 'approach_value'
MAXIMIZE = 'maximize'
MINIMIZE = 'minimize'

evolutionary_optimization.fitness_functions.implemented_fitness_functions module

class ApproachValueFitnessFunction(expected_value)[source]

Bases: AbstractFitnessFunction

__init__(expected_value)[source]

Initialise class.

Parameters

expected_value (Union[float, int]) – the value of the phenotype we are looking to find.

evaluate(phenotype)[source]

Looking for a particular phenotype value.

Parameters

phenotype (AbstractPhenotype) – instance of Abstract phenotype being evaluated).

Return type

float

Returns

The value of 1 divided by the absolute value of the phenotype.

class MaximizeFitnessFunction[source]

Bases: AbstractFitnessFunction

evaluate(phenotype)[source]

Looking for maximum phenotype value.

Parameters

phenotype (AbstractPhenotype) – instance of Abstract phenotype being evaluated.

Return type

Union[float, int]

Returns

The phenotype_value directly as we are looking for the greatest value.

class MinimizeFitnessFunction[source]

Bases: AbstractFitnessFunction

evaluate(phenotype)[source]

Looking for minimum phenotype value.

Parameters

phenotype (AbstractPhenotype) – instance of Abstract phenotype being evaluated.

Return type

Union[float, int]

Returns

The negative version of phenotype_value as we are looking for the lowest value i.e.

the most negative phenotype will become the greatest fitness score.

Module contents