diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoBinaryMetricSavingUpdater.h b/branches/paradiseo-moeo-1.0/src/metric/moeoBinaryMetricSavingUpdater.h index 8b66e1714..fd90e181a 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoBinaryMetricSavingUpdater.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoBinaryMetricSavingUpdater.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // moeoBinaryMetricSavingUpdater.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006 +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 /* This library... @@ -20,18 +20,18 @@ #include /** - * This class allows to save the progression of a binary metric comparing the fitness values of the current population (or archive) - * with the fitness values of the population (or archive) of the generation (n-1) into a file + * This class allows to save the progression of a binary metric comparing the objective vectors of the current population (or archive) + * with the objective vectors of the population (or archive) of the generation (n-1) into a file */ -template +template < class MOEOT > class moeoBinaryMetricSavingUpdater : public eoUpdater { public: /** - * The fitness type of a solution + * The objective vector type of a solution */ - typedef typename EOT::ObjectiveVector ObjectiveVector; + typedef typename MOEOT::ObjectiveVector ObjectiveVector; /** * Ctor @@ -39,7 +39,7 @@ public: * @param _pop the main population * @param _filename the target filename */ - moeoBinaryMetricSavingUpdater (moeoPopVsPopBinaryMetric & _metric, const eoPop & _pop, std::string _filename) : + moeoBinaryMetricSavingUpdater (moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & _metric, const eoPop < MOEOT > & _pop, std::string _filename) : metric(_metric), pop(_pop), filename(_filename), counter(1) {} @@ -53,17 +53,15 @@ public: } else { // creation of the two Pareto sets - /* - std::vector from; - std::vector to; + std::vector < ObjectiveVector > from; + std::vector < ObjectiveVector > to; for (unsigned i=0; i & metric; + moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & metric; /** main population */ - const eoPop & pop; + const eoPop < MOEOT > & pop; /** (n-1) population */ - eoPop oldPop; + eoPop< MOEOT > oldPop; /** target filename */ std::string filename; /** is it the first generation ? */ diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h b/branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h index 34ebb3963..dffe490cc 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoContributionMetric.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // moeoContributionMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006 +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 /* This library... @@ -17,37 +17,24 @@ /** * The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set - * * (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324) */ -template < class MOEOT > -class moeoContributionMetric : public moeoPopVsPopBinaryMetric < MOEOT, double > +template < class ObjectiveVector > +class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > { public: - - /** the objective vector type of a solution */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - /** * Returns the contribution of the Pareto set '_set1' relatively to the Pareto set '_set2' * @param _set1 the first Pareto set * @param _set2 the second Pareto set */ - double operator()(const eoPop < MOEOT > & _pop1, const eoPop < MOEOT > & _pop2) { - /************/ - std::vector set1; - std::vector set2; - for (unsigned i=0; i<_pop1.size(); i++) - set1.push_back(_pop1[i].objectiveVector()); - for (unsigned i=0 ; i<_pop2.size(); i++) - set2.push_back(_pop2[i].objectiveVector()); - /****************/ - unsigned c = card_C(set1, set2); - unsigned w1 = card_W(set1, set2); - unsigned n1 = card_N(set1, set2); - unsigned w2 = card_W(set2, set1); - unsigned n2 = card_N(set2, set1); + double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { + unsigned c = card_C(_set1, _set2); + unsigned w1 = card_W(_set1, _set2); + unsigned n1 = card_N(_set1, _set2); + unsigned w2 = card_W(_set2, _set1); + unsigned n2 = card_N(_set2, _set1); return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2); } diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h b/branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h index 2f4ff5328..fa63acd40 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoEntropyMetric.h @@ -2,7 +2,7 @@ //----------------------------------------------------------------------------- // moeoEntropyMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006 +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 /* This library... @@ -16,18 +16,14 @@ #include /** - * The entropy gives an idea of the diversity of a Pareto set relatively to another Pareto set - * + * The entropy gives an idea of the diversity of a Pareto set relatively to another * (Basseur, Seynhaeve, Talbi: 'Design of Multi-objective Evolutionary Algorithms: Application to the Flow-shop Scheduling Problem', in Proc. of the 2002 Congress on Evolutionary Computation, IEEE Press, pp. 1155-1156) */ -template < class MOEOT > -class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < MOEOT, double > +template < class ObjectiveVector > +class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > { public: - - /** the objective vector type of a solution */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - + /** * Returns the entropy of the Pareto set '_set1' relatively to the Pareto set '_set2' * @param _set1 the first Pareto set @@ -72,10 +68,17 @@ public: private: + /** vector of min values */ std::vector vect_min_val; + /** vector of max values */ std::vector vect_max_val; - void removeDominated(std::vector< ObjectiveVector > & _f) { + + /** + * Removes the dominated individuals contained in _f + * @param _f a Pareto set + */ + void removeDominated(std::vector < ObjectiveVector > & _f) { for (unsigned i=0 ; i<_f.size(); i++) { bool dom = false; for (unsigned j=0; j<_f.size(); j++) @@ -91,6 +94,11 @@ private: } } + + /** + * Prenormalization + * @param _f a Pareto set + */ void prenormalize (const std::vector< ObjectiveVector > & _f) { vect_min_val.clear(); vect_max_val.clear(); @@ -108,12 +116,24 @@ private: } } + + /** + * Normalization + * @param _f a Pareto set + */ void normalize (std::vector< ObjectiveVector > & _f) { for (unsigned i=0 ; i & _f1, const std::vector< ObjectiveVector > & _f2, std::vector< ObjectiveVector > & _f) { _f = _f1 ; for (unsigned i=0; i<_f2.size(); i++) { @@ -128,6 +148,10 @@ private: } } + + /** + * How many in niche + */ unsigned howManyInNicheOf (const std::vector< ObjectiveVector > & _f, const ObjectiveVector & _s, unsigned _size) { unsigned n=0; for (unsigned i=0 ; i<_f.size(); i++) { @@ -137,6 +161,10 @@ private: return n; } + + /** + * Euclidian distance + */ double euclidianDistance (const ObjectiveVector & _set1, const ObjectiveVector & _to, unsigned _deg = 2) { double dist=0; for (unsigned i=0; i<_set1.size(); i++) diff --git a/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h b/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h index 2163770ba..f279b38e0 100644 --- a/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h +++ b/branches/paradiseo-moeo-1.0/src/metric/moeoMetric.h @@ -16,14 +16,14 @@ #include /** - * Base class for performance metrics (also called quality indicators) + * Base class for performance metrics (also known as quality indicators). */ class moeoMetric : public eoFunctorBase {}; /** - * Base class for unary metrics + * Base class for unary metrics. */ template < class A, class R > class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric @@ -31,7 +31,7 @@ class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric /** - * Base class for binary metrics + * Base class for binary metrics. */ template < class A1, class A2, class R > class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric @@ -39,47 +39,42 @@ class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric /** - * Base class for unary metrics dedicated to the performance evaluation of a single solution's Pareto fitness + * Base class for unary metrics dedicated to the performance evaluation of a single solution's objective vector. */ -template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector > -//class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjVector &, R > -class moeoSolutionUnaryMetric : public moeoUnaryMetric < const MOEOT &, R > +template < class ObjectiveVector, class R > +class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjectiveVector &, R > {}; /** - * Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of Pareto fitnesses) + * Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of objective vectors) */ -template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector > -//class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjVector > &, R > -class moeoPopUnaryMetric : public moeoUnaryMetric < const eoPop < MOEOT > &, R > +template < class ObjectiveVector, class R > +class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjectiveVector > &, R > {}; /** - * Base class for binary metrics dedicated to the performance comparison between two solutions's Pareto fitnesses + * Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors. */ -template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector > -//class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjVector &, const ObjVector &, R > -class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const MOEOT &, const MOEOT &, R > +template < class ObjectiveVector, class R > +class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjectiveVector &, const ObjectiveVector &, R > {}; /** - * Base class for binary metrics dedicated to the performance comparison between a Pareto set (a vector of Pareto fitnesses) and a single solution's Pareto fitness + * 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. */ -template < class MOEOT, class R>//, class ObjVector = typename MOEOT::ObjectiveVector > -//class moeoVectorVsSolutionBinaryMetric : public moeoBinaryMetric < const std::vector < ObjVector > &, const ObjVector &, R > -class moeoPopVsSolutionBinaryMetric : public moeoBinaryMetric < const eoPop < MOEOT > &, const MOEOT &, R > +template < class ObjectiveVector, class R > +class moeoVectorVsSolutionBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const ObjectiveVector &, R > {}; /** - * Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of Pareto fitnesses) + * Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of objective vectors) */ -template < class MOEOT, class R >//, class ObjVector = typename MOEOT::ObjectiveVector > -//class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjVector > &, const std::vector < ObjVector > &, R > -class moeoPopVsPopBinaryMetric : public moeoBinaryMetric < const eoPop < MOEOT > &, const eoPop < MOEOT > &, R > +template < class ObjectiveVector, class R > +class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const std::vector < ObjectiveVector > &, R > {};