11 #ifndef DIGNEA_EGENERATIONAL_H
12 #define DIGNEA_EGENERATIONAL_H
14 #include <dignea/core/Replacement.h>
16 #include <dignea/utilities/exceptions/NotImplemented.h>
35 vector<S> replace(vector<S> &, vector<S> &)
override;
37 vector<S> replace(vector<S> &,
const S &,
const int &position)
override;
39 string getName()
const override {
return "EGenerational"; }
52 vector<S> &offspring) {
53 if (population.empty() || offspring.empty()) {
54 std::string what =
"vector of individuals empty";
55 throw(runtime_error(
"EGenerational Replacement" + what));
57 if (population.size() != offspring.size()) {
59 "population.siz() = " + to_string(population.size()) +
60 " != offspring.size = " + to_string(offspring.size());
61 throw(runtime_error(
"EGenerational Replacement" + what));
65 for (
unsigned int i = 1; i < population.size(); i++) {
66 population[i] = offspring[i];
81 const int &position) {
83 "Replace with position not allowed in EGenerational replacement";
84 throw NotImplemented(where);
void sortByFitness(vector< S > &population)
Sorts the population by fitness in descending order.
Definition: Sorter.h:69
Elitist Generational Replacement Operator Performs the generational replacement operator with elitism...
Definition: EGenerational.h:28
vector< S > replace(vector< S > &, vector< S > &) override
Performs the generational replacement operator between the two vectors of individuals....
Definition: EGenerational.h:51
Replacement skeleton operator.
Definition: Replacement.h:16