3 #include <geneial/algorithm/SteadyStateAlgorithm.h>
5 geneial_private_namespace(geneial)
7 geneial_private_namespace(algorithm)
9 using ::geneial::population::Population;
11 geneial_export_namespace
14 template<
typename FITNESS_TYPE>
15 void SteadyStateAlgorithm<FITNESS_TYPE>::solve()
18 using chromosome_container =
typename Population<FITNESS_TYPE>::chromosome_container;
20 this->_wasStarted =
true;
23 this->_manager->replenishPopulation();
25 long long int iterationCounter = 0;
27 bool wasReached = this->wasCriteriaReached();
29 const auto bookkeeper = this->_manager->getBookkeeper();
35 ScopedEvent trace_criteria(
"TIME_OBSERVERS",*bookkeeper);
36 this->notifyObservers(AlgorithmObserver<FITNESS_TYPE>::BEFORE_GENERATION);
39 ScopedEvent trace_iteration(
"TIME_ITERATION",*bookkeeper);
45 ScopedEvent trace_aging(
"TIME_AGING",*bookkeeper);
46 this->_manager->getPopulation().doAge();
50 chromosome_container mating_pool;
52 ScopedEvent trace_selection(
"TIME_SELECTION",*bookkeeper);
54 mating_pool = this->_selectionOperation->doSelect(this->_manager->getPopulation(), *this->_manager);
64 chromosome_container offspring;
66 ScopedEvent trace_coupling(
"TIME_OFFSPRING",*bookkeeper);
67 offspring = this->_couplingOperation->doCopulate(mating_pool, *this->_crossoverOperation, *this->_manager);
73 ScopedEvent trace_mutation(
"TIME_MUTATION",*bookkeeper);
74 offspring = this->_mutationOperation->doMutate(offspring, *this->_manager);
79 ScopedEvent trace_replacement(
"TIME_REPLACEMENT",*bookkeeper);
80 this->_replacementOperation->doReplace(this->_manager->getPopulation(), mating_pool, offspring, *this->_manager);
85 ScopedEvent trace_replenishment(
"TIME_REPLENISHMENT",*bookkeeper);
87 this->_manager->replenishPopulation();
92 ScopedEvent trace_criteria(
"TIME_CRITERIA",*bookkeeper);
93 wasReached = this->wasCriteriaReached();
98 ScopedEvent trace_criteria(
"TIME_OBSERVERS",*bookkeeper);
99 this->notifyObservers(AlgorithmObserver<FITNESS_TYPE>::AFTER_GENERATION);
105 this->_wasSolved =
true;