diversity assignment corrected in moeoFrontByFrontCrowdingDiversityAssignment.h

This commit is contained in:
Arnaud Liefooghe 2016-04-19 17:34:39 +02:00
commit c0bf207fc1

View file

@ -5,6 +5,8 @@
* *
* Arnaud Liefooghe, Waldo Cancino * Arnaud Liefooghe, Waldo Cancino
* *
* April 2016: Bug fix in the sorting of population (corrected thanks to Martin Stehlik)
*
* This software is governed by the CeCILL license under French law and * This software is governed by the CeCILL license under French law and
* abiding by the rules of distribution of free software. You can use, * abiding by the rules of distribution of free software. You can use,
* modify and/ or redistribute the software under the terms of the CeCILL * modify and/ or redistribute the software under the terms of the CeCILL
@ -124,7 +126,10 @@ class moeoFrontByFrontCrowdingDiversityAssignment : public moeoCrowdingDiversity
// sort in the descending order using the values of the objective 'obj' // sort in the descending order using the values of the objective 'obj'
moeoOneObjectiveComparator < MOEOT > objComp(obj); moeoOneObjectiveComparator < MOEOT > objComp(obj);
moeoPtrComparator<MOEOT> cmp2( objComp ); moeoPtrComparator<MOEOT> cmp2( objComp );
std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2); // erroneous part
// std::sort(sortedptrpop.begin(), sortedptrpop.end(), cmp2);
// correct version
std::sort(sortedptrpop.begin()+a, sortedptrpop.begin()+b+1, cmp2);
// min & max // min & max
min = (sortedptrpop[b])->objectiveVector()[obj]; min = (sortedptrpop[b])->objectiveVector()[obj];
max = (sortedptrpop[a])->objectiveVector()[obj]; max = (sortedptrpop[a])->objectiveVector()[obj];