diff --git a/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h b/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h index 2296d1ad0..a6416ecc2 100644 --- a/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h +++ b/trunk/paradiseo-moeo/src/algo/moeoSPEA2.h @@ -129,7 +129,7 @@ public: /** * Ctor with a crossover, a mutation and their corresponding rates. * @param _continuator stopping criteria - popEval * @param _eval evaluation function + * @param _eval evaluation function * @param _op general operator * @param _archive archive * @param _k the k-ieme distance used to fixe diversity @@ -218,19 +218,21 @@ public: protected: /** dummy evaluation */ -class eoDummyEval : public eoEvalFunc< MOEOT > + class eoDummyEval : public eoEvalFunc< MOEOT > { public: void operator()(MOEOT &) {} } dummyEval; + /** dummy transform */ -class eoDummyTransform : public eoTransform + class eoDummyTransform : public eoTransform { public : void operator()(eoPop&) {} } dummyTransform; + /** a continuator based on the number of generations (used as default) */ eoGenContinue < MOEOT > defaultGenContinuator; /** stopping criteria */ @@ -243,31 +245,31 @@ class eoDummyTransform : public eoTransform eoPopEvalFunc < MOEOT > & popEval; /**archive*/ moeoArchive < MOEOT >& archive; - /** selectMany */ - eoSelectMany selectMany; - /** select Transform*/ - eoSelectTransform selectTransform; /**SelectOne*/ moeoDetTournamentSelect < MOEOT > defaultSelect; /** binary tournament selection */ moeoSelectFromPopAndArch < MOEOT > select; + /** a default mutation */ + eoMonCloneOp < MOEOT > defaultMonOp; + /** a default crossover */ + eoQuadCloneOp < MOEOT > defaultQuadOp; + /** an object for genetic operators (used as default) */ + eoSGAGenOp < MOEOT > defaultSGAGenOp; /** fitness assignment used in NSGA-II */ moeoDominanceCountRankingFitnessAssignment < MOEOT > fitnessAssignment; + /** general breeder */ + eoGeneralBreeder < MOEOT > genBreed; + /** selectMany */ + eoSelectMany selectMany; + /** select Transform*/ + eoSelectTransform selectTransform; + /** breeder */ + eoBreed < MOEOT > & breed; /** diversity assignment used in NSGA-II */ moeoNearestNeighborDiversityAssignment < MOEOT > diversityAssignment; /** elitist replacement */ moeoGenerationalReplacement < MOEOT > replace; - /** a default crossover */ - eoQuadCloneOp < MOEOT > defaultQuadOp; - /** a default mutation */ - eoMonCloneOp < MOEOT > defaultMonOp; - /** an object for genetic operators (used as default) */ - eoSGAGenOp < MOEOT > defaultSGAGenOp; - /** general breeder */ - eoGeneralBreeder < MOEOT > genBreed; - /** breeder */ - eoBreed < MOEOT > & breed; - /**distance*/ + /**distance*/ moeoEuclideanDistance < MOEOT > dist; diff --git a/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h b/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h index 6818b82d5..45e1e92d2 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoBoundedArchive.h @@ -71,7 +71,7 @@ public: */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; - + /** * Ctor where you can choose your own moeoComparator, moeoObjectiveVectorComparator, moeoFitnessAssignment, moeoDiversityAssignment and archive size. * @param _indiComparator the functor used to compare MOEOT @@ -82,7 +82,7 @@ public: */ moeoBoundedArchive(moeoComparator < MOEOT > & _indiComparator, moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoFitnessAssignment < MOEOT > & _fitness, moeoDiversityAssignment < MOEOT > & _diversity, unsigned int _maxSize=100) : moeoArchive < MOEOT >(_comparator), maxSize(_maxSize), indiComparator(_indiComparator), fitness(_fitness), diversity(_diversity) {} - + /** * Ctor with moeoParetoObjectiveVectorComparator where you can choose your own moeoComparator, moeoFitnessAssignment, moeoDiversityAssignment and archive size. * @param _indiComparator the functor used to compare MOEOT @@ -92,8 +92,8 @@ public: */ moeoBoundedArchive(moeoComparator < MOEOT > & _indiComparator, moeoFitnessAssignment < MOEOT > & _fitness, moeoDiversityAssignment < MOEOT > & _diversity, unsigned int _maxSize=100) : moeoArchive < MOEOT >(), maxSize(_maxSize), indiComparator(_indiComparator), fitness(_fitness), diversity(_diversity) {} - - + + /** @@ -103,7 +103,7 @@ public: void operator()(const MOEOT & _moeo) { update(_moeo); - + if(size() > maxSize){ fitness(*this); diversity(*this); @@ -120,7 +120,7 @@ public: void operator()(const eoPop < MOEOT > & _pop) { update(_pop); - + if(size() > maxSize){ fitness(*this); diversity(*this); @@ -133,11 +133,6 @@ private: /** archive max size */ unsigned int maxSize; - /** fitness assignment */ - moeoFitnessAssignment < MOEOT > & fitness; - /** diversity assignment */ - moeoDiversityAssignment < MOEOT > & diversity; - /** * Wrapper which allow to used an moeoComparator in std::sort * @param _comp the comparator to used @@ -164,7 +159,12 @@ private: moeoComparator < MOEOT > & comp; } indiComparator; - + + /** fitness assignment */ + moeoFitnessAssignment < MOEOT > & fitness; + /** diversity assignment */ + moeoDiversityAssignment < MOEOT > & diversity; + }; - + #endif /*MOEOBOUNDEDARCHIVE_H_*/ diff --git a/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h b/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h index 65e764068..af3678e1f 100644 --- a/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h +++ b/trunk/paradiseo-moeo/src/archive/moeoSPEA2Archive.h @@ -85,7 +85,7 @@ public: {} - /** + /**l * Ctor where you can choose your own moeoDistance * @param _dist the distance used * @param _maxSize the size of archive (must be smaller or egal to the population size) @@ -285,6 +285,32 @@ private: unsigned int maxSize; /** archive size */ unsigned int borne; + /** + * Wrapper which allow to used an moeoComparator in std::sort + * @param _comp the comparator to used + */ + class Wrapper + { + public: + /** + * Ctor. + * @param _comp the comparator + */ + Wrapper(moeoComparator < MOEOT > & _comp) : comp(_comp) {} + /** + * Returns true if _moeo1 is greater than _moeo2 according to the comparator + * _moeo1 the first individual + * _moeo2 the first individual + */ + bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) + { + return comp(_moeo1,_moeo2); + } + private: + /** the comparator */ + moeoComparator < MOEOT > & comp; + } + indiComparator; /** default moeoComparator*/ moeoFitnessThenDiversityComparator < MOEOT > defaultComparator; /** distance */ @@ -352,33 +378,6 @@ private: }; - /** - * Wrapper which allow to used an moeoComparator in std::sort - * @param _comp the comparator to used - */ - class Wrapper - { - public: - /** - * Ctor. - * @param _comp the comparator - */ - Wrapper(moeoComparator < MOEOT > & _comp) : comp(_comp) {} - /** - * Returns true if _moeo1 is greater than _moeo2 according to the comparator - * _moeo1 the first individual - * _moeo2 the first individual - */ - bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) - { - return comp(_moeo1,_moeo2); - } - private: - /** the comparator */ - moeoComparator < MOEOT > & comp; - } - indiComparator; - }; #endif /*MOEOSPEA2ARCHIVE_H_*/ diff --git a/trunk/paradiseo-moeo/src/metric/moeoHyperVolumeMetric.h b/trunk/paradiseo-moeo/src/metric/moeoHyperVolumeMetric.h index 4eea48424..1a18bc33c 100644 --- a/trunk/paradiseo-moeo/src/metric/moeoHyperVolumeMetric.h +++ b/trunk/paradiseo-moeo/src/metric/moeoHyperVolumeMetric.h @@ -346,10 +346,12 @@ class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , d double rho; + ObjectiveVector ref_point; + /*vectors contains bounds for normalization*/ std::vector < eoRealInterval > bounds; - ObjectiveVector ref_point; + }; diff --git a/trunk/paradiseo-moeo/src/utils/moeoDominanceMatrix.h b/trunk/paradiseo-moeo/src/utils/moeoDominanceMatrix.h index 15bdb5412..474e492f3 100644 --- a/trunk/paradiseo-moeo/src/utils/moeoDominanceMatrix.h +++ b/trunk/paradiseo-moeo/src/utils/moeoDominanceMatrix.h @@ -59,18 +59,20 @@ public: /** The type for objective vector */ typedef typename MOEOT::ObjectiveVector ObjectiveVector; + /** + * Constructor which allow to choose the comparator + * @param _nocopy boolean allow to consider copy and doublons as bad element whose were dominated by all other MOEOT + * @param _comparator the comparator you want to use for the comparaison of two MOEOT + */ + moeoDominanceMatrix(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true):std::vector < std::vector >(),comparator(_comparator), nocopy(_nocopy) {} + /** * Default constructor with paretoComparator * @param _nocopy boolean allow to consider copy and doublons as bad element whose were dominated by all other MOEOT */ moeoDominanceMatrix(bool _nocopy=false):std::vector < std::vector >(),comparator(paretoComparator), nocopy(_nocopy) {} - /** - * Constructor which allow to choose the comparator - * @param _nocopy boolean allow to consider copy and doublons as bad element whose were dominated by all other MOEOT - * @param _comparator the comparator you want to use for the comparaison of two MOEOT - */ - moeoDominanceMatrix(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true):std::vector < std::vector >(),comparator(_comparator), nocopy(_nocopy) {} + /** * Filling up the Dominance Matrix on one population @@ -214,6 +216,10 @@ public: } private: + /** Functor to compare two objective vectors */ + moeoObjectiveVectorComparator < ObjectiveVector > & comparator; + /** Functor to compare two objective vectors according to Pareto dominance relation */ + moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; /** boolean allow or not to pull away a copy*/ bool nocopy; /** vector contains CountDominanceFitnessAssignment */ @@ -222,10 +228,7 @@ private: std::vector rankVector; /** vector contains index of copys */ std::set copySet; - /** Functor to compare two objective vectors */ - moeoObjectiveVectorComparator < ObjectiveVector > & comparator; - /** Functor to compare two objective vectors according to Pareto dominance relation */ - moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + };