From b619a857188e9d08c66eae9173088fb62e06728f Mon Sep 17 00:00:00 2001 From: Johann Dreo Date: Thu, 6 Jun 2013 11:43:34 +0200 Subject: [PATCH] bugfix: do not allow null interval in hypervolume diff metric --- eo/src/utils/eoRealBounds.h | 2 +- .../metric/moeoHyperVolumeDifferenceMetric.h | 18 ++++++++++++++++-- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/eo/src/utils/eoRealBounds.h b/eo/src/utils/eoRealBounds.h index 9d046be1a..8d55d793a 100644 --- a/eo/src/utils/eoRealBounds.h +++ b/eo/src/utils/eoRealBounds.h @@ -234,7 +234,7 @@ public : assert( repRange >= 0 ); #ifndef NDEBUG if( repRange == 0 ) { - eo::log << eo::warnings << "Null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; + eo::log << eo::warnings << "Warning: null range in eoRealBounds (min=" << _min << ", max=" << _max << ")" << std::endl; } #endif } diff --git a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h index 906923b98..533d29296 100644 --- a/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h +++ b/moeo/src/metric/moeoHyperVolumeDifferenceMetric.h @@ -163,12 +163,26 @@ class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < min = std::min(min, _set2[j][i]); max = std::max(max, _set2[j][i]); } - bounds[i] = eoRealInterval(min, max); + if( min == max ) { + bounds[i] = eoRealInterval(min-tiny(), max+tiny()); + } else { + bounds[i] = eoRealInterval(min, max); + } } } } - private: + protected: + + /** + * Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound) + */ + static double tiny() + { + return 1e-6; + } + + private: /*boolean indicates if data must be normalized or not*/ bool normalize;