5 #ifndef DIGNEA_WEIGHTED_H
6 #define DIGNEA_WEIGHTED_H
8 #include <dignea/generator/evaluations/InstanceFitness.h>
9 #include <dignea/searches/NoveltySearch.h>
13 #include <string_view>
23 template <
class AbstractInstance>
26 Weighted(
const float &fRatio,
const float &dRatio);
39 return {fitnessRatio, diversityRatio};
45 unique_ptr<InstanceFitness> fitnessFunc;
56 template <
class AbstractInstance>
58 : fitnessRatio(fRatio), diversityRatio(dRatio), fitnessFunc() {}
69 template <
class AbstractInstance>
71 vector<AbstractInstance> &solutions) {
72 for (
unsigned int i = 0; i < solutions.size(); i++) {
73 auto fullFitness = solutions[i].getBiasedFitness() * fitnessRatio +
74 solutions[i].getDiversity() * diversityRatio;
77 std::cout << fmt::format(
"{:>20}\t{:>20}\t{:>20}",
78 solutions[i].getBiasedFitness(),
79 solutions[i].getDiversity(), fullFitness)
83 solutions[i].setFitness(fullFitness);
Weighted Fitness Function used from evaluating the instances in EIG. This functions performs a linear...
Definition: Weighted.h:24
void computeFitness(vector< AbstractInstance > &solutions)
Computes the actual fitness of the solutions based on the fitness pre-defined in the instances and th...
Definition: Weighted.h:70
std::tuple< float, float > getFAndNRatios()
Returns a tuple containing the fitness and novelty ratio in that order!
Definition: Weighted.h:38
Weighted(const float &fRatio, const float &dRatio)
Construct a new Weighted object with the corresponding fitness ratio and diversity ratio.
Definition: Weighted.h:57