From 5b39705a20cd1161cc51df3a7141e1366678984c Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Wed, 26 Jun 2013 18:09:49 +0200 Subject: [PATCH] BUGFIX pop split everywhere in exp dual fitness assignment Apply the fitness assignment on both splited pop, not just one. Apply also the partial update on splited pop. Confine numeric valuesto double limits, to avoid overflows. --- ...inaryIndicatorBasedDualFitnessAssignment.h | 89 ++++++++++++++++--- 1 file changed, 77 insertions(+), 12 deletions(-) diff --git a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h index 959be717d..98c6a51d2 100644 --- a/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h +++ b/moeo/src/fitness/moeoExpBinaryIndicatorBasedDualFitnessAssignment.h @@ -57,21 +57,28 @@ public: // separate the pop in feasible/unfeasible _pop_split( pop ); - eoPop* ppop; // if there is at least one feasible individual, // it will supersede all the unfeasible ones - if( _pop_split.feasible().size() == 0 ) { - ppop = & _pop_split.unfeasible(); - } else { - ppop = & _pop_split.feasible(); + if( _pop_split.unfeasible().size() != 0 ) { + this->setup(_pop_split.unfeasible()); + this->computeValues(_pop_split.unfeasible()); + this->setFitnesses(_pop_split.unfeasible()); // NOTE: this alter individuals } - this->setup(*ppop); - this->computeValues(*ppop); - this->setFitnesses(*ppop); // NOTE: this alter individuals + if( _pop_split.feasible().size() != 0 ) { + this->setup(_pop_split.feasible()); + this->computeValues(_pop_split.feasible()); + this->setFitnesses(_pop_split.feasible()); // NOTE: this alter individuals + } // bring back altered individuals in the pop - pop = _pop_split.merge(); + // pop = _pop_split.merge(); + + eoPop merged = _pop_split.merge(); + assert( pop.size() == merged.size()); + for( unsigned int i=0; i & pop, ObjectiveVector & objVec) + { + _pop_split(pop); + + if( objVec.is_feasible() ) { + setup(_pop_split.feasible()); + updateFitnessByDeleting( _pop_split.feasible(), objVec); + } else { + setup(_pop_split.unfeasible()); + updateFitnessByDeleting( _pop_split.unfeasible(), objVec ); + } + // pop = _pop_split.merge(); + eoPop merged = _pop_split.merge(); + assert( pop.size() == merged.size()); + for( unsigned int i=0; i & pop, ObjectiveVector & objVec ) + { + std::vector < double > v; + v.resize(pop.size()); + for (unsigned int i=0; i + T confine( T n ) + { + T tmax = std::numeric_limits::max(); + T tmin = -1 * tmax; + + tmin.is_feasible( n.is_feasible() ); + tmax.is_feasible( n.is_feasible() ); + + if( n < tmin ) { + return tmin; + } else if( n > tmax ) { + return tmax; + } else { + return n; + } + } };