diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoAdditiveEpsilonBinaryMetric.h b/branches/paradiseo-moeo-1.0/src/metric/moeoAdditiveEpsilonBinaryMetric.h index cfb543b9f..2045ac701 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoAdditiveEpsilonBinaryMetric.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoAdditiveEpsilonBinaryMetric.h @@ -16,24 +16,69 @@ #include /** - * + * Additive epsilon binary metric allowing to compare two objective vectors as proposed in + * Zitzler E., Thiele L., Laumanns M., Fonseca C. M., Grunert da Fonseca V.: + * Performance Assessment of Multiobjective Optimizers: An Analysis and Review. IEEE Transactions on Evolutionary Computation 7(2), pp.117–132 (2003). */ -template < class MOEOT > -class moeoAdditiveEpsilonBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < MOEOT, double > +template < class ObjectiveVector > +class moeoAdditiveEpsilonBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > { public: - - /** the objective vector type of a solution */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - moeoAdditiveEpsilonBinaryMetric(); - - - double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) + + /** + * Returns the maximum epsilon value by which the objective vector _o1 must be translated in all objectives + * so that it weakly dominates the objective vector _o2 + * @warning don't forget to set the bounds for every objective before the call of this function + * @param _o1 the first objective vector + * @param _o2 the second objective vector + */ + double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2) { - + // computation of the epsilon value for the first objective + double result = epsilon(_o1, _o2, 0); + // computation of the epsilon value for the other objectives + double tmp; + for (unsigned i=1; i :: bounds; + + /** + * Returns the epsilon value by which the objective vector _o1 must be translated in the objective _obj + * so that it dominates the objective vector _o2 + * @param _o1 the first objective vector + * @param _o2 the second objective vector + * @param _obj the index of the objective + */ + double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned _obj) + { + double result; + // if the objective _obj have to be minimized + if (ObjectiveVector::Traits::minimizing(_obj)) + { + // _o1[_obj] - _o2[_obj] + result = ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ); + } + // if the objective _obj have to be maximized + else + { + // _o2[_obj] - _o1[_obj] + result = ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ); + } + return result; + } + }; #endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h b/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h index f279b38e0..e13a43925 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h @@ -62,6 +62,55 @@ class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const Objec {}; +/** + * Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors using normalized values. + * Then, indicator values lie in the interval [-1,1]. + * Note that you have to set the bounds for every objective before using the operator(). + */ +template < class ObjectiveVector, class R > +class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < ObjectiveVector, R > +{ +public: + + /** + * Default ctr for any moeoNormalizedSolutionVsSolutionBinaryMetric object + */ + moeoNormalizedSolutionVsSolutionBinaryMetric() + { + bounds.resize(ObjectiveVector::Traits::nObjectives()); + } + + + /** + * Sets the lower bound (_min) and the upper bound (_max) for the objective _obj + * _min lower bound + * _max upper bound + * _obj the objective index + */ + virtual void setup(double _min, double _max, unsigned _obj) + { + bounds[_obj] = eoRealInterval(_min, _max); + } + + /** + * Sets the lower bound and the upper bound for the objective _obj using a eoRealInterval object + * _realInterval the eoRealInterval object + * _obj the objective index + */ + virtual void setup(eoRealInterval _realInterval, unsigned _obj) + { + bounds[_obj] = _realInterval; + } + + +protected: + + /** the bounds for every objective (bounds[i] = bounds for the objective i) */ + std::vector < eoRealInterval > bounds; + +}; + + /** * Base class for binary metrics dedicated to the performance comparison between a Pareto set (a vector of objective vectors) and a single solution's objective vector. */