From c55fcdbb3f8c329ca848105a213dac865e0a82ec Mon Sep 17 00:00:00 2001 From: maartenkeijzer Date: Mon, 22 Jul 2002 13:31:55 +0000 Subject: [PATCH] added a 'nasty_declone_flag' to be able to declone a population --- eo/src/eoNDSorting.h | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/eo/src/eoNDSorting.h b/eo/src/eoNDSorting.h index 4c442492..fa4e2981 100644 --- a/eo/src/eoNDSorting.h +++ b/eo/src/eoNDSorting.h @@ -40,7 +40,10 @@ template class eoNDSorting : public eoPerf2WorthCached { public : - + + eoNDSorting() : nasty_declone_flag_that_only_is_implemented_for_two_objectives(false) + {} + /** Pure virtual function that calculates the 'distance' for each element in the current front Implement to create your own nondominated sorting algorithm. The size of the returned vector should be equal to the size of the current_front. @@ -113,8 +116,7 @@ private : * complexity O(n log n) where n is the population size * * This is the same complexity as for a single objective - * or truncation selection or sorting. A paper about this - * algorithm is quite likely forthcoming. + * or truncation selection or sorting. * * It will perform a sort on the two objectives seperately, * and from the information on the ranks of the individuals on @@ -168,8 +170,13 @@ private : { unsigned prev = sort1[i-1]; if ( _pop[index].fitness() == _pop[prev].fitness()) - { // it's a clone - fronts[prev_front].push_back(index); + { // it's a clone, give it the worst rank! + + if (nasty_declone_flag_that_only_is_implemented_for_two_objectives) + //declone + fronts.back().push_back(index); + else // assign it the rank of the previous + ronts[prev_front].push_back(index); continue; } } @@ -354,6 +361,7 @@ private : } } + public : bool nasty_declone_flag_that_only_is_implemented_for_two_objectives; }; /**