diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index e8562194..44b18b33 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -31,6 +31,7 @@ #include #include #include +#include /** Non dominated sorting, it *is a* vector of doubles, the integer part is the rank (to which front it belongs), @@ -90,8 +91,8 @@ private : void one_objective(const eoPop& _pop) { - unsigned i; - eoPop tmp_pop; + unsigned i; + vector tmp_pop; tmp_pop.resize(_pop.size()); // copy pop to dummy population (only need the fitnesses) @@ -101,10 +102,10 @@ private : tmp_pop[i].index = i; } - // sort it - tmp_pop.sort(); + // sort it in ascending + sort(tmp_pop.begin(), tmp_pop.end(), greater() ); - // + for (i = 0; i < _pop.size(); ++i) { value()[tmp_pop[i].index] = _pop.size() - i; // set rank @@ -438,10 +439,12 @@ class eoNDSorting_II : public eoNDSorting /// _cf points into the elements that consist of the current front vector niche_penalty(const vector& _cf, const eoPop& _pop) { + typedef typename EOT::Fitness::fitness_traits traits; unsigned i; vector niche_count(_cf.size(), 0.); - unsigned nObjectives = _pop[_cf[0]].fitness().size(); + + unsigned nObjectives = traits::nObjectives(); //_pop[_cf[0]].fitness().size(); for (unsigned o = 0; o < nObjectives; ++o) { @@ -470,14 +473,12 @@ class eoNDSorting_II : public eoNDSorting for (i = 0; i < nc.size(); ++i) { - niche_count[i] = (max_dist + 1) - nc[i]; + niche_count[i] = (max_dist + 1 - nc[i]); } } return niche_count; } - - }; #endif