EvolutionaryAlgorithm(initial_population, fitness_calculator, mutator, crosser, generation_selector, mutation_selector, crossover_selector, fitness_normalizer=<stk.ea.fitness_normalizers.null.NullFitnessNormalizer object>, key_maker=Inchi(), num_processes=None)¶
An abstract base class for evolutionary algorithms.
You might notice that the public methods of this abstract base class are implemented. This is purely for convenience, so that there is a default evolutionary algorithm implementation that users can use. However, feel free to override the default implementation when implementing subclasses.
If you do want to use the default implementation, here is a summary of the roles of the different components:
The source code of this class can work as a good example. There is only one method that a subclass of
EvolutionaryAlgorithmneeds to implement,
get_generations(), which yields
Generationinstances. These correspond to the generations of your evolutionary algorithm implementation.
There are a couple of tutorials on how to use the
EvolutionaryAlgorithm, which can be found in the sidebar.
Yield the generations of the evolutionary algorithm.
__init__(initial_population, fitness_calculator, mutator, crosser, generation_selector, mutation_selector, crossover_selector, fitness_normalizer=<stk.ea.fitness_normalizers.null.NullFitnessNormalizer object>, key_maker=Inchi(), num_processes=None)¶
FitnessCalculator) – Calculates fitness values.
MoleculeMutator) – Carries out mutation operations.
MoleculeCrosser) – Carries out crossover operations.
Selector) – Selects the next generation.
Selector) – Selects molecules for mutation.
Selector) – Selects molecules for crossover.
FitnessNormalizer) – Normalizes fitness values.
MoleculeKeyMaker, optional) – Used to detect duplicate molecules in the EA. If two molecules in a generation return the same key, one of them is removed.
int, optional) – The number of parallel processes the EA should create. If
None, all available cores will be used.