From 2fa772ecce54e866438d816e2e269b6f627982cf Mon Sep 17 00:00:00 2001 From: legrand Date: Fri, 23 Feb 2007 13:22:33 +0000 Subject: [PATCH] git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@191 331e1502-861f-0410-8da2-ba01fb791d7f --- .../src/moeoRouletteSelect.h/MOEO.h | 283 ------------------ .../src/moeoRouletteSelect.h/Makefile.am | 1 - .../metric/moeoAdditiveEpsilonBinaryMetric.h | 39 --- .../metric/moeoBinaryMetricSavingUpdater.h | 88 ------ .../metric/moeoContributionMetric.h | 98 ------ .../metric/moeoEntropyMetric.h | 177 ----------- .../moeoRouletteSelect.h/metric/moeoMetric.h | 81 ----- .../src/moeoRouletteSelect.h/moeo | 43 --- .../src/moeoRouletteSelect.h/moeoArchive.h | 161 ---------- .../moeoArchiveFitnessSavingUpdater.h | 73 ----- .../moeoRouletteSelect.h/moeoArchiveUpdater.h | 56 ---- .../src/moeoRouletteSelect.h/moeoCombinedLS.h | 71 ----- .../src/moeoRouletteSelect.h/moeoComparator.h | 185 ------------ .../moeoDetTournamentSelect.h | 157 ---------- .../moeoDiversityAssignment.h | 48 --- .../src/moeoRouletteSelect.h/moeoEA.h | 26 -- .../moeoElitistReplacement.h | 114 ------- .../src/moeoRouletteSelect.h/moeoEvalFunc.h | 25 -- ...FastNonDominatedSortingFitnessAssignment.h | 183 ----------- .../moeoFitnessAssignment.h | 62 ---- .../moeoGenerationalReplacement.h | 28 -- .../src/moeoRouletteSelect.h/moeoHybridLS.h | 76 ----- .../src/moeoRouletteSelect.h/moeoLS.h | 28 -- .../moeoObjectiveVector.h | 274 ----------------- .../moeoObjectiveVectorComparator.h | 93 ------ .../moeoObjectiveVectorTraits.h | 122 -------- .../src/moeoRouletteSelect.h/moeoPopSorter.h | 50 ---- .../moeoRouletteSelect.h/moeoRandomSelect.h | 50 ---- .../moeoRandomSelectOne.h | 25 -- .../moeoRouletteSelect.h/moeoReplacement.h | 25 -- .../moeoRouletteSelect.h/moeoRouletteSelect.h | 119 -------- .../moeoSelectFromPopAndArch.h | 93 ------ .../src/moeoRouletteSelect.h/moeoSelectOne.h | 23 -- .../moeoSelectOneFromPopAndArch.h | 89 ------ .../src/moeoRouletteSelect.h/moeoSelectors.h | 157 ---------- .../moeoStochTournamentSelect.h | 166 ---------- 36 files changed, 3389 deletions(-) delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/MOEO.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/Makefile.am delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoAdditiveEpsilonBinaryMetric.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoBinaryMetricSavingUpdater.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoContributionMetric.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoEntropyMetric.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoMetric.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeo delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchive.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveFitnessSavingUpdater.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveUpdater.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoCombinedLS.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoComparator.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDetTournamentSelect.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDiversityAssignment.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEA.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoElitistReplacement.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEvalFunc.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFastNonDominatedSortingFitnessAssignment.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFitnessAssignment.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoGenerationalReplacement.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoHybridLS.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoLS.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVector.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorComparator.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorTraits.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoPopSorter.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelect.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelectOne.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoReplacement.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRouletteSelect.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectFromPopAndArch.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOne.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOneFromPopAndArch.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectors.h delete mode 100644 branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoStochTournamentSelect.h diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/MOEO.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/MOEO.h deleted file mode 100644 index 1ad4fc6fb..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/MOEO.h +++ /dev/null @@ -1,283 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// MOEO.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEO_H_ -#define MOEO_H_ - -#include -#include -#include -#include - -/** - * Base class allowing to represent a solution (an individual) for multi-objective optimization. - * The template argument MOEOObjectiveVector allows to represent the solution in the objective space (it can be a moeoObjectiveVector object). - * The template argument MOEOFitness is an object reflecting the quality of the solution in term of convergence (the fitness of a solution is always to be maximized). - * The template argument MOEODiversity is an object reflecting the quality of the solution in term of diversity (the diversity of a solution is always to be maximized). - * All template arguments must have a void and a copy constructor. - * Besides, note that, contrary to the mono-objective case (and to EO) where the fitness value of a solution is confused with its objective value, - * the fitness value differs of the objectives values in the multi-objective case. - * - * !!!!!!!!!!!!!!!!! !!!!! - * operator '<' et '>' ??? - * !!!!!!!!!!!!!!!!!!!!!!! - */ -template < class MOEOObjectiveVector, class MOEOFitness, class MOEODiversity > class MOEO:public EO < - MOEOFitness - > -{ -public: - - /** the objective vector type of a solution */ - typedef MOEOObjectiveVector ObjectiveVector; - - /** the fitness type of a solution */ - typedef MOEOFitness Fitness; - - /** the diversity type of a solution */ - typedef MOEODiversity Diversity; - - - /** - * Ctor - */ - MOEO () - { - // default values for every parameters - objectiveVectorValue = ObjectiveVector (); - fitnessValue = Fitness (); - diversityValue = Diversity (); - // invalidate all - invalidate (); - } - - - /** - * Virtual dtor - */ - virtual ~ MOEO () - { - }; - - - /** - * Returns the objective vector of the current solution - */ - ObjectiveVector objectiveVector () const - { - if (invalidObjectiveVector ()) - { - throw std::runtime_error ("invalid objective vector"); - } - return objectiveVectorValue; - } - - - /** - * Sets the objective vector of the current solution - * @param _objectiveVectorValue the new objective vector - */ - void objectiveVector (const ObjectiveVector & _objectiveVectorValue) - { - objectiveVectorValue = _objectiveVectorValue; - invalidObjectiveVectorValue = false; - } - - - /** - * Sets the objective vector as invalid - */ - void invalidateObjectiveVector () - { - invalidObjectiveVectorValue = true; - } - - - /** - * Returns true if the objective vector is invalid, false otherwise - */ - bool invalidObjectiveVector () const - { - return invalidObjectiveVectorValue; - } - - - /** - * Returns the fitness value of the current solution - */ - Fitness fitness () const - { - if (invalidFitness ()) - { - throw std::runtime_error ("invalid fitness"); - } - return fitnessValue; - } - - - /** - * Sets the fitness value of the current solution - * @param _fitnessValue the new fitness value - */ - void fitness (const Fitness & _fitnessValue) - { - fitnessValue = _fitnessValue; - invalidFitnessValue = false; - } - - - /** - * Sets the fitness value as invalid - */ - void invalidateFitness () - { - invalidFitnessValue = true; - } - - - /** - * Returns true if the fitness value is invalid, false otherwise - */ - bool invalidFitness () const - { - return invalidFitnessValue; - } - - - /** - * Returns the diversity value of the current solution - */ - Diversity diversity () const - { - if (invalidDiversity ()) - { - throw std::runtime_error ("invalid diversity"); - } - return diversityValue; - } - - - /** - * Sets the diversity value of the current solution - * @param _diversityValue the new diversity value - */ - void diversity (const Diversity & _diversityValue) - { - diversityValue = _diversityValue; - invalidDiversityValue = false; - } - - - /** - * Sets the diversity value as invalid - */ - void invalidateDiversity () - { - invalidDiversityValue = true; - } - - - /** - * Returns true if the diversity value is invalid, false otherwise - */ - bool invalidDiversity () const - { - return invalidDiversityValue; - } - - - /** - * Sets the objective vector, the fitness value and the diversity value as invalid - */ - void invalidate () - { - invalidateObjectiveVector (); - invalidateFitness (); - invalidateDiversity (); - } - - - /** - * Returns true if the fitness value is invalid, false otherwise - */ - bool invalid () const - { - return invalidObjectiveVector (); - } - - - /** - * Return the class id (the class name as a std::string) - */ - virtual std::string className () const - { - return "MOEO"; - } - - - /** - * Writing object - * @param _os output stream - */ - virtual void printOn (std::ostream & _os) const - { - if (invalidObjectiveVector ()) - { - _os << "INVALID\t"; - } - else - { - _os << objectiveVectorValue << '\t'; - } - } - - - /** - * Reading object - * @param _is input stream - */ - virtual void readFrom (std::istream & _is) - { - std::string objectiveVector_str; - int pos = _is.tellg (); - _is >> objectiveVector_str; - if (objectiveVector_str == "INVALID") - { - invalidateObjectiveVector (); - } - else - { - invalidObjectiveVectorValue = false; - _is.seekg (pos); // rewind - _is >> objectiveVectorValue; - } - } - - -private: - - /** the objective vector of this solution */ - ObjectiveVector objectiveVectorValue; - /** true if the objective vector is invalid */ - bool invalidObjectiveVectorValue; - /** the fitness value of this solution */ - Fitness fitnessValue; - /** true if the fitness value is invalid */ - bool invalidFitnessValue; - /** the diversity value of this solution */ - Diversity diversityValue; - /** true if the diversity value is invalid */ - bool invalidDiversityValue; - -}; - -#endif /*MOEO_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/Makefile.am b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/Makefile.am deleted file mode 100644 index ae1e51b3c..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/Makefile.am +++ /dev/null @@ -1 +0,0 @@ -# Nothing to compile ! diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoAdditiveEpsilonBinaryMetric.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoAdditiveEpsilonBinaryMetric.h deleted file mode 100644 index cfb543b9f..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoAdditiveEpsilonBinaryMetric.h +++ /dev/null @@ -1,39 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoAdditiveEpsilonBinaryMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOADDITIVEEPSILONBINARYMETRIC_H_ -#define MOEOADDITIVEEPSILONBINARYMETRIC_H_ - -#include - -/** - * - */ -template < class MOEOT > -class moeoAdditiveEpsilonBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < MOEOT, 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) - { - - } - -}; - -#endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoBinaryMetricSavingUpdater.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoBinaryMetricSavingUpdater.h deleted file mode 100644 index fd90e181a..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoBinaryMetricSavingUpdater.h +++ /dev/null @@ -1,88 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoBinaryMetricSavingUpdater.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOBINARYMETRICSAVINGUPDATER_H_ -#define MOEOBINARYMETRICSAVINGUPDATER_H_ - -#include -#include -#include -#include -#include - -/** - * 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 < class MOEOT > -class moeoBinaryMetricSavingUpdater : public eoUpdater -{ -public: - - /** - * The objective vector type of a solution - */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - /** - * Ctor - * @param _metric the binary metric comparing two Pareto sets - * @param _pop the main population - * @param _filename the target filename - */ - moeoBinaryMetricSavingUpdater (moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > & _metric, const eoPop < MOEOT > & _pop, std::string _filename) : - metric(_metric), pop(_pop), filename(_filename), counter(1) - {} - - /** - * Saves the metric's value for the current generation - */ - void operator()() { - if (pop.size()) { - if (firstGen) { - firstGen = false; - } - else { - // creation of the two Pareto sets - std::vector < ObjectiveVector > from; - std::vector < ObjectiveVector > to; - for (unsigned i=0; i & metric; - /** main population */ - const eoPop < MOEOT > & pop; - /** (n-1) population */ - eoPop< MOEOT > oldPop; - /** target filename */ - std::string filename; - /** is it the first generation ? */ - bool firstGen; - /** counter */ - unsigned counter; - -}; - -#endif /*MOEOBINARYMETRICSAVINGUPDATER_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoContributionMetric.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoContributionMetric.h deleted file mode 100644 index dffe490cc..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoContributionMetric.h +++ /dev/null @@ -1,98 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoContributionMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOCONTRIBUTIONMETRIC_H_ -#define MOEOCONTRIBUTIONMETRIC_H_ - -#include - -/** - * 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 ObjectiveVector > -class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > -{ -public: - - /** - * 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 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); - } - - -private: - - /** - * Returns the number of solutions both in '_set1' and '_set2' - * @param _set1 the first Pareto set - * @param _set2 the second Pareto set - */ - unsigned card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { - unsigned c=0; - for (unsigned i=0; i<_set1.size(); i++) - for (unsigned j=0; j<_set2.size(); j++) - if (_set1[i] == _set2[j]) { - c++; - break; - } - return c; - } - - /** - * Returns the number of solutions in '_set1' dominating at least one solution of '_set2' - * @param _set1 the first Pareto set - * @param _set2 the second Pareto set - */ - unsigned card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { - unsigned w=0; - for (unsigned i=0; i<_set1.size(); i++) - for (unsigned j=0; j<_set2.size(); j++) - if (_set1[i].dominates(_set2[j])) { - w++; - break; - } - return w; - } - - /** - * Returns the number of solutions in '_set1' having no relation of dominance with those from '_set2' - * @param _set1 the first Pareto set - * @param _set2 the second Pareto set - */ - unsigned card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { - unsigned n=0; - for (unsigned i=0; i<_set1.size(); i++) { - bool domin_rel = false; - for (unsigned j=0; j<_set2.size(); j++) - if (_set1[i].dominates(_set2[j]) || _set2[j].dominates(_set1 [i])) { - domin_rel = true; - break; - } - if (! domin_rel) - n++; - } - return n; - } - -}; - -#endif /*MOEOCONTRIBUTIONMETRIC_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoEntropyMetric.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoEntropyMetric.h deleted file mode 100644 index fa63acd40..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoEntropyMetric.h +++ /dev/null @@ -1,177 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoEntropyMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOENTROPYMETRIC_H_ -#define MOEOENTROPYMETRIC_H_ - -#include - -/** - * 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 ObjectiveVector > -class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double > -{ -public: - - /** - * Returns the entropy 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 std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) { - // normalization - std::vector< ObjectiveVector > set1 = _set1; - std::vector< ObjectiveVector > set2= _set2; - removeDominated (set1); - removeDominated (set2); - prenormalize (set1); - normalize (set1); - normalize (set2); - - // making of PO* - std::vector< ObjectiveVector > star; // rotf :-) - computeUnion (set1, set2, star); - removeDominated (star); - - // making of PO1 U PO* - std::vector< ObjectiveVector > union_set1_star; // rotf again ... - computeUnion (set1, star, union_set1_star); - - unsigned C = union_set1_star.size(); - float omega=0; - float entropy=0; - - for (unsigned i=0 ; i 0) { - omega += 1.0 / N_i; - entropy += (float) n_i / (N_i * C) * log (((float) n_i / C) / log (2.0)); - } - } - entropy /= - log (omega); - entropy *= log (2.0); - return entropy; - } - - -private: - - /** vector of min values */ - std::vector vect_min_val; - /** vector of max values */ - std::vector vect_max_val; - - - /** - * 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++) - if (i != j && _f[j].dominates(_f[i])) { - dom = true; - break; - } - if (dom) { - _f[i] = _f.back(); - _f.pop_back(); - i--; - } - } - } - - - /** - * Prenormalization - * @param _f a Pareto set - */ - void prenormalize (const std::vector< ObjectiveVector > & _f) { - vect_min_val.clear(); - vect_max_val.clear(); - - for (unsigned char i=0 ; imax_val) - max_val = _f[j][i]; - } - vect_min_val.push_back(min_val); - vect_max_val.push_back (max_val); - } - } - - - /** - * 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++) { - bool b = false; - for (unsigned j=0; j<_f1.size(); j ++) - if (_f1[j] == _f2[i]) { - b = true; - break; - } - if (! b) - _f.push_back(_f2[i]); - } - } - - - /** - * 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++) { - if (euclidianDistance(_f[i], _s) < (_s.size() / (double) _size)) - n++; - } - 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++) - dist += pow(fabs(_set1[i] - _to[i]), (int)_deg); - return pow(dist, 1.0 / _deg); - } - -}; - -#endif /*MOEOENTROPYMETRIC_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoMetric.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoMetric.h deleted file mode 100644 index f279b38e0..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/metric/moeoMetric.h +++ /dev/null @@ -1,81 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoMetric.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOMETRIC_H_ -#define MOEOMETRIC_H_ - -#include - -/** - * Base class for performance metrics (also known as quality indicators). - */ -class moeoMetric : public eoFunctorBase -{}; - - -/** - * Base class for unary metrics. - */ -template < class A, class R > -class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric -{}; - - -/** - * Base class for binary metrics. - */ -template < class A1, class A2, class R > -class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric -{}; - - -/** - * Base class for unary metrics dedicated to the performance evaluation of a single solution's objective vector. - */ -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 objective vectors) - */ -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 objective vectors. - */ -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 objective vectors) and a single solution's objective vector. - */ -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 objective vectors) - */ -template < class ObjectiveVector, class R > -class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const std::vector < ObjectiveVector > &, R > -{}; - - -#endif /*MOEOMETRIC_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeo b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeo deleted file mode 100644 index aeb808560..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeo +++ /dev/null @@ -1,43 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeo -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEO_ -#define MOEO_ - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#endif /*MOEO_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchive.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchive.h deleted file mode 100644 index 3f18105ef..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchive.h +++ /dev/null @@ -1,161 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoArchive.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOARCHIVE_H_ -#define MOEOARCHIVE_H_ - -#include - -/** - * An archive is a secondary population that stores non-dominated solutions - */ -template < class MOEOT > class moeoArchive:public eoPop < MOEOT > -{ -public: - - using std::vector < MOEOT >::size; - using std::vector < MOEOT >::operator[]; - using std::vector < MOEOT >::back; - using std::vector < MOEOT >::pop_back; - - - /** - * The type of an objective vector for a solution - */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - - /** - * Default ctor. - * The moeoObjectiveVectorComparator used to compare solutions is based on Pareto dominance - */ -moeoArchive ():eoPop < MOEOT > (), comparator (paretoComparator) - { - } - - - /** - * Ctor - * @param _comparator the moeoObjectiveVectorComparator used to compare solutions - */ -moeoArchive (moeoObjectiveVectorComparator < ObjectiveVector > &_comparator):eoPop < MOEOT > (), - comparator - (_comparator) - { - } - - - /** - * Returns true if the current archive dominates _objectiveVector according to the moeoObjectiveVectorComparator given in the constructor - * @param _objectiveVector the objective vector to compare with the current archive - */ - bool dominates (const ObjectiveVector & _objectiveVector) const - { - for (unsigned i = 0; i < size (); i++) - { - if (comparator (operator[](i).fitness (), _objectiveVector) == 1) - { - return true; - } - } - return false; - } - - - /** - * Returns true if the current archive already contains a solution with the same objective values than _objectiveVector - * @param _objectiveVector the objective vector to compare with the current archive - */ - bool contains (const ObjectiveVector & _objectiveVector) const - { - for (unsigned i = 0; i < size; i++) - { - if (operator[](i).fitness () == _objectiveVector) - { - return true; - } - } - return false; - } - - - /** - * Updates the archive with a given individual _moeo - * @param _moeo the given individual - */ - void update (const MOEOT & _moeo) - { - // first step: removing the dominated solutions from the archive - for (unsigned j = 0; j < size ();) - { - // if _moeo.fitness() dominates operator[](j).fitness() - //if ( comparator(_moeo.fitness(), operator[](j).fitness())==1 ) - if (comparator - (_moeo.objectiveVector (), operator[](j).objectiveVector ()) == 1) - { - operator[](j) = back (); - pop_back (); - } - //else if (_moeo.fitness() == operator[](j).fitness()) - else if (_moeo.objectiveVector () == operator[](j).objectiveVector ()) - { - operator[](j) = back (); - pop_back (); - } - else - { - j++; - } - } - // second step: is _moeo dominated? - bool dom = false; - for (unsigned j = 0; j < size (); j++) - { - // if operator[](j).fitness() dominates _moeo.fitness() - //if ( comparator(operator[](j).fitness(), _moeo.fitness())==1 ) - if (comparator - (operator[](j).objectiveVector (), _moeo.objectiveVector ()) == 1) - { - dom = true; - break; - } - } - if (!dom) - { - push_back (_moeo); - } - } - - - /** - * Updates the archive with a given population _pop - * @param _pop the given population - */ - void update (const eoPop < MOEOT > &_pop) - { - for (unsigned i = 0; i < _pop.size (); i++) - { - update (_pop[i]); - } - } - - -private: - - /** The moeoObjectiveVectorComparator used to compare solutions */ - moeoObjectiveVectorComparator < ObjectiveVector > &comparator; - /** A moeoObjectiveVectorComparator based on Pareto dominance (used as default) */ - moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; - -}; - -#endif /*MOEOARCHIVE_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveFitnessSavingUpdater.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveFitnessSavingUpdater.h deleted file mode 100644 index e4f0f62a9..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveFitnessSavingUpdater.h +++ /dev/null @@ -1,73 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoArchiveFitnessSavingUpdater.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOARCHIVEFITNESSSAVINGUPDATER_H_ -#define MOEOARCHIVEFITNESSSAVINGUPDATER_H_ - -#include -#include -#include -#include -#include - -#define MAX_BUFFER_SIZE 1000 - -/** - * This class allows to save the fitnesses of solutions contained in an archive into a file at each generation. - */ -template < class EOT > class moeoArchiveFitnessSavingUpdater:public eoUpdater -{ -public: - - /** - * Ctor - * @param _arch local archive - * @param _filename target filename - * @param _id own ID - */ -moeoArchiveFitnessSavingUpdater (moeoArchive < EOT > &_arch, const std::string & _filename = "Res/Arch", int _id = -1):arch (_arch), filename (_filename), id (_id), - counter - (0) - { - } - - /** - * Saves the fitness of the archive's members into the file - */ - void operator () () - { - char buff[MAX_BUFFER_SIZE]; - if (id == -1) - sprintf (buff, "%s.%u", filename.c_str (), counter++); - else - sprintf (buff, "%s.%u.%u", filename.c_str (), id, counter++); - std::ofstream f (buff); - for (unsigned i = 0; i < arch.size (); i++) - f << arch[i].objectiveVector () << std::endl; - f.close (); - } - - -private: - - /** local archive */ - moeoArchive < EOT > &arch; - /** target filename */ - std::string filename; - /** own ID */ - int id; - /** counter */ - unsigned counter; - -}; - -#endif /*MOEOARCHIVEFITNESSSAVINGUPDATER_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveUpdater.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveUpdater.h deleted file mode 100644 index 581742849..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoArchiveUpdater.h +++ /dev/null @@ -1,56 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoArchiveUpdater.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOARCHIVEUPDATER_H_ -#define MOEOARCHIVEUPDATER_H_ - -#include -#include -#include - -/** - * This class allows to update the archive at each generation with newly found non-dominated solutions - */ -template < class EOT > class moeoArchiveUpdater:public eoUpdater -{ -public: - - /** - * Ctor - * @param _arch an archive of non-dominated solutions - * @param _pop the main population - */ - moeoArchiveUpdater (moeoArchive < EOT > &_arch, - const eoPop < EOT > &_pop):arch (_arch), pop (_pop) - { - } - - - /** - * Updates the archive with newly found non-dominated solutions contained in the main population - */ - void operator () () - { - arch.update (pop); - } - - -private: - - /** the archive of non-dominated solutions */ - moeoArchive < EOT > &arch; - /** the main population */ - const eoPop < EOT > &pop; - -}; - -#endif /*MOEOARCHIVEUPDATER_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoCombinedLS.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoCombinedLS.h deleted file mode 100644 index 615e06b47..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoCombinedLS.h +++ /dev/null @@ -1,71 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoCombinedLS.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOCOMBINEDLS_H_ -#define MOEOCOMBINEDLS_H_ - -#include -#include -#include - -/** - * This class allows to embed a set of local searches that are sequentially applied, - * and so working and updating the same archive of non-dominated solutions - */ -template < class MOEOT > class moeoCombinedLS:public moeoLS < MOEOT > -{ -public: - - /** - * Ctor - * @param _eval the full evaluator of a solution - * @param _first_ls the first multi-objective local search to add - */ -moeoCombinedLS (moeoEvalFunc < MOEOT > &_eval, moeoLS < MOEOT > &_first_ls):eval - (_eval) - { - combinedLS.push_back (&_first_ls); - } - - /** - * Adds a new local search to combine - * @param _ls the multi-objective local search to add - */ - void add (moeoLS < MOEOT > &_ls) - { - combinedMOLS.push_back (&_ls); - } - - /** - * Gives a new solution in order to explore the neigborhood. - * The new non-dominated solutions are added to the archive - * @param _eo the solution - * @param _arch the archive of non-dominated solutions - */ - void operator () (const MOEOT & _eo, moeoArchive < MOEOT > &_arch) - { - eval (const_cast < MOEOT & >(_eo)); - for (unsigned i = 0; i < combinedLS.size (); i++) - combinedLS[i]->operator ()(_eo, _arch); - } - - -private: - - /** the full evaluator of a solution */ - moeoEvalFunc < MOEOT > &eval; - /** the vector that contains the combined LS */ - std::vector < moeoLS < MOEOT > *>combinedLS; - -}; - -#endif /*MOEOCOMBINEDLS_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoComparator.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoComparator.h deleted file mode 100644 index 6b6467c32..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoComparator.h +++ /dev/null @@ -1,185 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoComparator.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOCOMPARATOR_H_ -#define MOEOCOMPARATOR_H_ - -#include -#include - -/** - * Functor allowing to compare two solutions - */ -template < class MOEOT > class moeoComparator:public eoBF < const MOEOT &, const MOEOT &, - const bool > -{ -public: - // virtual const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo){} -}; - - -/** - * Functor allowing to compare two solutions according to their first objective value, then their second, and so on - */ -template < class MOEOT > class moeoObjectiveComparator:public moeoComparator < - MOEOT > -{ -public: - /** - * Returns true if _moeo1 is smaller than _moeo2 on the first objective, then on the second, and so on - * @param _moeo1 the first solution - * @param _moeo2 the second solution - */ - const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo2) - { - return _moeo1.objectiveVector () < _moeo2.objectiveVector (); - } -}; - - -/** - * Functor allowing to compare two solutions according to their fitness values - */ -//template < class MOEOT > -//class moeoFitnessComparator : public moeoComparator < MOEOT > -//{ -//public: -// /** -// * Returns true if the fitness value of _moeo1 is smaller than the fitness value of _moeo2 -// * @param _moeo1 the first solution -// * @param _moeo2 the second solution -// */ -// const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) -// { -// return _moeo1.fitness() < _moeo2.fitness(); -// } -//}; -// -// -///** -// * Functor allowing to compare two solutions according to their diversity values -// */ -//template < class MOEOT > -//class moeoDiversityComparator : public moeoComparator < MOEOT > -//{ -//public: -// /** -// * Returns true if the diversity value of _moeo1 is smaller than the diversity value of _moeo2 -// * @param _moeo1 the first solution -// * @param _moeo2 the second solution -// */ -// const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) -// { -// return _moeo1.diversity() < _moeo2.diversity(); -// } -//}; - - -/** - * Functor allowing to compare two solutions according to their fitness values, then according to their diversity values - */ -template < class MOEOT > class moeoFitnessThenDiversityComparator:public moeoComparator < - MOEOT > -{ -public: - /** - * Returns true if _moeo1 is smaller than _moeo2 according to their fitness values, then according to their diversity values - * @param _moeo1 the first solution - * @param _moeo2 the second solution - */ - const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo2) - { - if (_moeo1.fitness () == _moeo2.fitness ()) - { - return _moeo1.diversity () < _moeo2.diversity (); - } - else - { - return _moeo1.fitness () < _moeo2.fitness (); - } - } -}; - - -/** - * Functor allowing to compare two solutions according to their diversity values, then according to their fitness values - */ -template < class MOEOT > class moeoDiversityThenFitnessComparator:public moeoComparator < - MOEOT > -{ -public: - /** - * Returns true if _moeo1 is smaller than _moeo2 according to their diversity values, then according to their fitness values - * @param _moeo1 the first solution - * @param _moeo2 the second solution - */ - const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo2) - { - if (_moeo1.diversity () == _moeo2.diversity ()) - { - return _moeo1.fitness () < _moeo2.fitness (); - } - else - { - return _moeo1.diversity () < _moeo2.diversity (); - } - } -}; - - -/** - * Functor allowing to compare two solutions according to Pareto dominance relation => USEFULL ??? - * -template < class MOEOT > -class moeoParetoDominanceComparator : public moeoComparator < MOEOT > -{ -public: - /** - * Returns true if _moeo1 is dominated by _moeo2 according to Pareto dominance relation - * @param _moeo1 the first solution - * @param _moeo2 the second solution - * - const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) - { - bool result = false; - typedef typename MOEOT::ObjectiveVector::Traits ObjectiveVectorTraits; - for (unsigned i=0; i ObjectiveVectorTraits::tolerance() ) - { - // if the ith objective have to be minimized... - if (ObjectiveVectorTraits::minimizing(i)) - { - if (_moeo1.objectiveVector()[i] < _moeo2.objectiveVector()[i]) - { - return false; // _moeo2 cannot dominate _moeo1 - } - result = true; - } - // if the ith objective have to be maximized... - else if (ObjectiveVectorTraits::maximizing(i)) - { - if (_moeo1.objectiveVector()[i] > _moeo2.objectiveVector()[i]) - { - return false; // _moeo2 cannot dominate _moeo1 - } - result = true; - } - } - } - return result; - } -}; -*/ - -#endif /*MOEOCOMPARATOR_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDetTournamentSelect.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDetTournamentSelect.h deleted file mode 100644 index 403e338e2..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDetTournamentSelect.h +++ /dev/null @@ -1,157 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoDetTournamentSelect.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEODETTOURNAMENTSELECT_H_ -#define MOEODETTOURNAMENTSELECT_H_ - -#include -#include - -/** - * moeoDetTournamentSelect: a selection method that selects ONE individual by - * deterministic tournament - */ -template < class MOEOT > - class moeoDetTournamentSelect:public moeoSelectOne -{ -public: - /** - * Full Ctor - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignment - * @param _comparator the comparator to compare the individuals$ - * @param _tSize the number of individuals in the tournament (default: 2) - */ - moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):evalFitness (_evalFitness), evalDiversity (_evalDiversity), - comparator (_comparator), tSize (_tSize) - { - // consistency check - if (tSize < 2) - { - std:: - cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n"; - tSize = 2; - } - } - - - /** - * Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default. - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignme - * @param _tSize the number of individuals in the tournament (default: 2) - */ - moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, unsigned _tSize = 2) - :evalFitness (_evalFitness),evalDiversity(_evalDiversity),tSize(_tSize) - { - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - - // consistency check - if (tSize < 2) - { - std:: - cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n"; - tSize = 2; - } - } - - - /** - * Ctor without diversity assignment. A dummy diversity assignment is used. - * @param _evalFitness the population fitness assignment - * @param _comparator the comparator to compare the individuals - * @param _tSize the number of individuals in the tournament (default: 2) - */ -moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):evalFitness (_evalFitness), comparator (_comparator), - tSize - (_tSize) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // consistency check - if (tSize < 2) - { - std:: - cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n"; - tSize = 2; - } - } - - - /** - * Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default. - * @param _evalFitness the population fitness assignment - * @param _tSize the number of individuals in the tournament (default: 2) - */ -moeoDetTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, unsigned _tSize = 2):evalFitness (_evalFitness), - tSize - (_tSize) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - - // consistency check - if (tSize < 2) - { - std:: - cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n"; - tSize = 2; - } - } - - - - - /* - * Evaluate the fitness and the diversity of each individual of the population. - */ - void setup (eoPop& _pop) - { - // eval fitness - evalFitness(_pop); - - // eval diversity - evalDiversity(_pop); - } - - /** - * Apply the tournament to the given population - */ - const MOEOT & operator () (const eoPop < MOEOT > &_pop) - { - // use the selector - return mo_deterministic_tournament(_pop,tSize,comparator); - } - - -protected: - - moeoFitnessAssignment < MOEOT > &evalFitness; - - moeoDiversityAssignment < MOEOT > &evalDiversity; - - moeoComparator < MOEOT > &comparator; - - unsigned tSize; - -}; - -#endif /*MOEODETTOURNAMENTSELECT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDiversityAssignment.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDiversityAssignment.h deleted file mode 100644 index de5195c39..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoDiversityAssignment.h +++ /dev/null @@ -1,48 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoDiversityAssignment.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEODIVERSITYASSIGNMENT_H_ -#define MOEODIVERSITYASSIGNMENT_H_ - -#include -#include - -/** - * Functor that sets the diversity values of a whole population - */ -template < class MOEOT > class moeoDiversityAssignment:public eoUF < eoPop < MOEOT > &, - void > -{ -}; - - -/** - * moeoDummyDiversityAssignment is a moeoDiversityAssignment which gives 0 as the diversity for the whole population. - */ -template < class MOEOT > class moeoDummyDiversityAssignment:public moeoDiversityAssignment < - MOEOT > -{ - // main operator - void operator () (eoPop < MOEOT > &_pop) - { - for (int idx = 0; idx < _pop.size (); idx++) - { - // set the diversity to 0 - _pop[idx].diversity (0); - } - } - -}; - - - -#endif /*MOEODIVERSITYASSIGNMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEA.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEA.h deleted file mode 100644 index 3e7d554bc..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEA.h +++ /dev/null @@ -1,26 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoEA.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOEA_H_ -#define MOEOEA_H_ - -#include - -/** - * Abstract class for multi-objective evolutionary algorithms - */ -template < class MOEOT > class moeoEA:public eoAlgo < MOEOT > -{ -}; - - -#endif /*MOEOEA_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoElitistReplacement.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoElitistReplacement.h deleted file mode 100644 index 0fe86986d..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoElitistReplacement.h +++ /dev/null @@ -1,114 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoElitistReplacement.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - - -#ifndef MOEOELITISTREPLACEMENT_H_ -#define MOEOELITISTREPLACEMENT_H_ - -//----------------------------------------------------------------------------- -#include -#include -#include -#include -//----------------------------------------------------------------------------- - - -/** - * Elitist replacement strategy for multi-objective optimization. - */ -template < class MOEOT > class moeoElitistReplacement:public moeoReplacement < - MOEOT > -{ - -public: - - /** Full constructor */ -moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > _comparator):evalFitness (_evalFitness), evalDiversity (_evalDiversity), - comparator - (_comparator) - { - } - - /** constructor without comparator */ - moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity) - :evalFitness (_evalFitness), evalDiversity (_evalDiversity) - - { - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - } - - - /** Constructor without moeoDiversityAssignement */ -moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > _comparator):evalFitness (_evalFitness), - comparator - (_comparator) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - } - - - /** Constructor without moeoDiversityAssignement nor moeoComparator */ -moeoElitistReplacement (moeoFitnessAssignment < MOEOT > &_evalFitness):evalFitness - (_evalFitness) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - } - - - /** - * Replace the first population by adding the individuals of the second one, sorting with a moeoComparator and resizing the whole population obtained. - * @param _parents the population composed of the parents (the population you want to replace) - * @param _offspring - */ - void operator () (eoPop < MOEOT > &_parents, eoPop < MOEOT > &_offspring) - { - unsigned sz = _parents.size (); - - // merge offspring and parents into a global population ... - _parents.reserve (_parents.size () + _offspring.size ()); - copy (_offspring.begin (), _offspring.end (), back_inserter (_parents)); - - // evaluate the fitness and the diversity of this global population - evalFitness (_parents); - evalDiversity (_parents); - - // ... that we sort according to the comparator - std::sort (_parents.begin (), _parents.end (), comparator); - - // finally, resize this global population - _parents.resize (sz); - - _offspring.clear (); - } - -protected: - - moeoFitnessAssignment < MOEOT > &evalFitness; - - moeoDiversityAssignment < MOEOT > &evalDiversity; - - moeoComparator < MOEOT > &comparator; -}; - - - -#endif /*MOEOELITISTREPLACEMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEvalFunc.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEvalFunc.h deleted file mode 100644 index 0e3497f7e..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoEvalFunc.h +++ /dev/null @@ -1,25 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoEvalFunc.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOEVALFUNC_H_ -#define MOEOEVALFUNC_H_ - -#include - -/* - * Functor that evaluates one MOEO by setting all its objective values. - */ -template < class MOEOT > class moeoEvalFunc:public eoEvalFunc < MOEOT > -{ -}; - -#endif /*MOEOEVALFUNC_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFastNonDominatedSortingFitnessAssignment.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFastNonDominatedSortingFitnessAssignment.h deleted file mode 100644 index 106ebf650..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFastNonDominatedSortingFitnessAssignment.h +++ /dev/null @@ -1,183 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoFastNonDominatedSortingFitnessAssignment.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_ -#define MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_ - -#include -#include -#include -#include - -/** - * Fitness assignment sheme based on Pareto-dominance count proposed in - * N. Srinivas, K. Deb, "Multiobjective Optimization Using Nondominated Sorting in Genetic Algorithms", Evolutionary Computation vol. 2, no. 3, pp. 221-248 (1994) - * and in - * K. Deb, A. Pratap, S. Agarwal, T. Meyarivan, "A Fast and Elitist Multi-Objective Genetic Algorithm: NSGA-II", IEEE Transactions on Evolutionary Computation, vol. 6, no. 2 (2002). - * This strategy is, for instance, used in NSGA and NSGA-II. - */ -template < class MOEOT > class moeoFastNonDominatedSortingFitnessAssignment:public moeoParetoBasedFitnessAssignment < - MOEOT - > -{ -public: - - /** - * Ctor - */ - moeoFastNonDominatedSortingFitnessAssignment () - { - } - - - /** - * Computes fitness values for every solution contained in the population _pop - * @param _pop the population - */ - void operator () (eoPop < MOEOT > &_pop) - { - // number of objectives for the problem under consideration - unsigned nObjectives = MOEOT::ObjectiveVector::nObjectives (); - if (nObjectives == 1) - { - // one objective - oneObjective (_pop); - } - else if (nObjectives == 2) - { - // two objectives (the two objectives function is still to do) - mObjectives (_pop); - } - else if (nObjectives > 2) - { - // more than two objectives - mObjectives (_pop); - } - else - { - // problem with the number of objectives - throw std:: - runtime_error - ("Problem with the number of objectives in moeoFastNonDominatedSortingFitnessAssignment"); - } - } - - -private: - - /** the objective vector type of the solutions */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - /** Functor to compare two objective vectors according to Pareto dominance relation */ - moeoParetoObjectiveVectorComparator < ObjectiveVector > comparator; - /** Functor to compare two solutions on the first objective, then on the second, and so on */ - moeoObjectiveComparator < MOEOT > objComparator; - - - /** - * Sets the fitness values for mono-objective problems - * @param _pop the population - */ - void oneObjective (eoPop < MOEOT > &_pop) - { - std::sort (_pop.begin (), _pop.end (), objComparator); - for (unsigned i = 0; i < _pop.size (); i++) - { - _pop[i].fitness (i + 1); - } - } - - - /** - * Sets the fitness values for bi-objective problems with a complexity of O(n log n), where n stands for the population size - * @param _pop the population - */ - void twoObjectives (eoPop < MOEOT > &_pop) - { - //... TO DO ! - } - - - /** - * Sets the fitness values for problems with more than two objectives with a complexity of O(n² log n), where n stands for the population size - * @param _pop the population - */ - void mObjectives (eoPop < MOEOT > &_pop) - { - // S[i] = indexes of the individuals dominated by _pop[i] - std::vector < std::vector < unsigned >>S (_pop.size ()); - // n[i] = number of individuals that dominate the individual _pop[i] - std::vector < unsigned >n (_pop.size (), 0); - // fronts: F[i] = indexes of the individuals contained in the ith front - std::vector < std::vector < unsigned >>F (_pop.size () + 1); - // used to store the number of the first front - F[1].reserve (_pop.size ()); - // flag to comparae solutions - int comparatorFlag; - for (unsigned p = 0; p < _pop.size (); p++) - { - for (unsigned q = 0; q < _pop.size (); q++) - { - // comparison of the 2 solutions according to Pareto dominance - comparatorFlag = - comparator (_pop[p].objectiveVector (), - _pop[q].objectiveVector ()); - // if p dominates q - if (comparatorFlag == 1) - { - // add q to the set of solutions dominated by p - S[p].push_back (q); - } - // if q dominates p - else if (comparatorFlag == -1) - { - // increment the domination counter of p - n[p]++; - } - } - // if no individual dominates p - if (n[p] == 0) - { - // p belongs to the first front - _pop[p].fitness (1); - F[1].push_back (p); - } - } - // front counter - unsigned counter = 1; - unsigned p, q; - while (!F[counter].empty ()) - { - // used to store the number of the next front - F[counter + 1].reserve (_pop.size ()); - for (unsigned i = 0; i < F[counter].size (); i++) - { - p = F[counter][i]; - for (unsigned j = 0; j < S[p].size (); j++) - { - q = S[p][j]; - n[q]--; - // if no individual dominates q anymore - if (n[q] == 0) - { - // q belongs to the next front - _pop[q].fitness (counter + 1); - F[counter + 1].push_back (q); - } - } - } - counter++; - } - } - -}; - -#endif /*MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFitnessAssignment.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFitnessAssignment.h deleted file mode 100644 index 2c545a0ca..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoFitnessAssignment.h +++ /dev/null @@ -1,62 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoFitnessAssignment.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOFITNESSASSIGNMENT_H_ -#define MOEOFITNESSASSIGNMENT_H_ - -#include -#include - -/** - * Functor that sets the fitness values of a whole population - */ -template < class MOEOT > class moeoFitnessAssignment:public eoUF < eoPop < MOEOT > &, - void > -{ -}; - - -/** - * moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies - */ -template < class MOEOT > class moeoScalarFitnessAssignment:public moeoFitnessAssignment < - MOEOT > -{ -}; - - -/** - * moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies - */ -template < class MOEOT > class moeoCriterionBasedFitnessAssignment:public moeoFitnessAssignment < - MOEOT > -{ -}; - - -/** - * moeoParetoBasedFitnessAssignment is a moeoFitnessAssignment for Pareto-based strategies - */ -template < class MOEOT > class moeoParetoBasedFitnessAssignment:public moeoFitnessAssignment < - MOEOT > -{ - void operator () (eoPop < MOEOT > &_pop) - { - // do nothing for the moment ... - } -}; - - - - - -#endif /*MOEOFITNESSASSIGNMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoGenerationalReplacement.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoGenerationalReplacement.h deleted file mode 100644 index c6804ccac..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoGenerationalReplacement.h +++ /dev/null @@ -1,28 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoGenerationalReplacement.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOGENERATIONALREPLACEMENT_H_ -#define MOEOGENERATIONALREPLACEMENT_H_ - -#include -#include - -/** - * Generational replacement: only the new individuals are preserved - */ -template < class MOEOT > class moeoGenerationalReplacement:public moeoReplacement < MOEOT >, - public eoGenerationalReplacement < - MOEOT > -{ -}; - -#endif /*MOEOGENERATIONALREPLACEMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoHybridLS.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoHybridLS.h deleted file mode 100644 index 8891d1ab5..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoHybridLS.h +++ /dev/null @@ -1,76 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoHybridLS.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOHYBRIDLS_H_ -#define MOEOHYBRIDLS_H_ - -#include -#include -#include -#include -#include -#include - -/** - * This class allows to apply a multi-objective local search to a number of selected individuals contained in the archive - * at every generation until a stopping criteria is verified. - */ -template < class MOEOT > class moeoHybridLS:public eoUpdater -{ -public: - - /** - * Ctor - * @param _term stopping criteria - * @param _select selector - * @param _ls a multi-objective local search - * @param _arch the archive - */ -eoHybridLS (eoContinue < MOEOT > &_term, eoSelect < MOEOT > &_select, moeoLS < MOEOT > &_ls, moeoArchive < MOEOT > &_arch):term (_term), select (_select), ls (_ls), - arch - (_arch) - { - } - - /** - * Applies the multi-objective local search to selected individuals contained in the archive if the stopping criteria is not verified - */ - void operator () () - { - if (!cont (arch)) - { - // selection of solutions - eoPop < MOEOT > selectedSolutions; - select (arch, selectedSolutions); - // apply the local search to every selected solution - for (unsigned i = 0; i < selectedSolutions.size (); i++) - { - ls (selectedSolutions[i], arch); - } - } - } - - -private: - - /** stopping criteria*/ - eoContinue < MOEOT > &term; - /** selector */ - eoSelect < MOEOT > &select; - /** multi-objective local search */ - moeoLS < MOEOT > &ls; - /** archive */ - moeoArchive < MOEOT > &arch; - -}; - -#endif /*MOEOHYBRIDLS_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoLS.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoLS.h deleted file mode 100644 index 7f9504597..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoLS.h +++ /dev/null @@ -1,28 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoLS.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOLS_H_ -#define MOEOLS_H_ - -#include -#include - -/** - * Abstract class for local searches applied to multi-objective optimization. - * Starting from only one solution, it produces a set of new non-dominated solutions. - */ -template < class MOEOT > class moeoLS:public eoBF < const MOEOT &, moeoArchive < MOEOT > &, - void > -{ -}; - -#endif /*MOEOLS_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVector.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVector.h deleted file mode 100644 index ddabe0af6..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVector.h +++ /dev/null @@ -1,274 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoObjectiveVector.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOOBJECTIVEVECTOR_H_ -#define MOEOOBJECTIVEVECTOR_H_ - -#include -#include -#include -#include - -/** - * Abstract class allowing to represent a solution in the objective space (phenotypic representation). - * The template argument ObjectiveVectorTraits defaults to moeoObjectiveVectorTraits, - * but it can be replaced at will by any other class that implements the static functions defined therein. - * Some static funtions to access to the traits characteristics are re-defined in order not to write a lot of typedef's. - */ -template < class ObjectiveVectorTraits > class moeoObjectiveVector -{ -public: - - /** The traits of objective vectors */ - typedef ObjectiveVectorTraits Traits; - - - /** - * Parameters setting (for the objective vector of any solution) - * @param _nObjectives the number of objectives - * @param _bObjectives the min/max vector (true = min / false = max) - */ - static void setup (unsigned _nObjectives, - std::vector < bool > &_bObjectives) - { - ObjectiveVectorTraits::setup (_nObjectives, _bObjectives); - } - - - /** - * Returns the number of objectives - */ - static unsigned nObjectives () - { - return ObjectiveVectorTraits::nObjectives (); - } - - - /** - * Returns true if the _ith objective have to be minimized - * @param _i the index - */ - static bool minimizing (unsigned _i) - { - return ObjectiveVectorTraits::minimizing (_i); - } - - - /** - * Returns true if the _ith objective have to be maximized - * @param _i the index - */ - static bool maximizing (unsigned _i) - { - return ObjectiveVectorTraits::maximizing (_i); - } - -}; - - -/** - * This class allows to represent a solution in the objective space (phenotypic representation) by a std::vector of doubles, - * i.e. that an objective value is represented using a double, and this for any objective. - */ -template < class ObjectiveVectorTraits > class moeoObjectiveVectorDouble:public moeoObjectiveVector < ObjectiveVectorTraits >, - public std::vector < - double > -{ -public: - - using - std::vector < double >::size; - using - std::vector < double >::operator[]; - - /** - * Ctor - */ - moeoObjectiveVectorDouble (): - std::vector < double >(ObjectiveVectorTraits::nObjectives (), 0.0) - { - } - - - /** - * Ctor from a vector of doubles - * @param _v the std::vector < double > - */ - moeoObjectiveVectorDouble (std::vector < double >&_v): - std::vector < double >(_v) - { - } - - - /** - * Returns true if the current objective vector dominates _other according to the Pareto dominance relation - * (but it's better to use a moeoObjectiveVectorComparator object to compare solutions) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - dominates (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - moeoParetoObjectiveVectorComparator < - moeoObjectiveVectorDouble < - ObjectiveVectorTraits > > - comparator; - return - comparator (*this, _other) == 1; - } - - - /** - * Returns true if the current objective vector is equal to _other (according to a tolerance value) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator== (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - for (unsigned i = 0; i < size (); i++) - { - if (fabs (operator[](i) - _other[i]) > - ObjectiveVectorTraits::tolerance ()) - { - return false; - } - } - return - true; - } - - - /** - * Returns true if the current objective vector is different than _other (according to a tolerance value) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator!= (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - return ! - operator== (_other); - } - - - /** - * Returns true if the current objective vector is smaller than _other on the first objective, then on the second, and so on - * (can be usefull for sorting/printing) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator< (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - for (unsigned i = 0; i < size (); i++) - { - if (fabs (operator[](i) - _other[i]) > - ObjectiveVectorTraits::tolerance ()) - { - if (operator[](i) < _other[i]) - { - return true; - } - else - { - return false; - } - } - } - return false; - } - - - /** - * Returns true if the current objective vector is greater than _other on the first objective, then on the second, and so on - * (can be usefull for sorting/printing) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator> (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - return - _other < * - this; - } - - - /** - * Returns true if the current objective vector is smaller than or equal to _other on the first objective, then on the second, and so on - * (can be usefull for sorting/printing) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator<= (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - return - operator== (_other) || - operator< (_other); - } - - - /** - * Returns true if the current objective vector is greater than or equal to _other on the first objective, then on the second, and so on - * (can be usefull for sorting/printing) - * @param _other the other moeoObjectiveVectorDouble object to compare with - */ - bool - operator>= (const moeoObjectiveVectorDouble < ObjectiveVectorTraits > - &_other) const - { - return - operator== (_other) || - operator> (_other); - } - -}; - - -/** - * Output for a moeoObjectiveVectorDouble object - * @param _os output stream - * @param _objectiveVector the objective vector to write - */ -template < class ObjectiveVectorTraits > - std::ostream & operator<< (std::ostream & _os, - const moeoObjectiveVectorDouble < - ObjectiveVectorTraits > &_objectiveVector) -{ - for (unsigned i = 0; i < _objectiveVector.size (); i++) - { - _os << _objectiveVector[i] << ' '; - } - return _os; -} - -/** - * Input for a moeoObjectiveVectorDouble object - * @param _is input stream - * @param _objectiveVector the objective vector to read - */ -template < class ObjectiveVectorTraits > - std::istream & operator>> (std::istream & _is, - moeoObjectiveVectorDouble < - ObjectiveVectorTraits > &_objectiveVector) -{ - _objectiveVector = moeoObjectiveVectorDouble < ObjectiveVectorTraits > (); - for (unsigned i = 0; i < _objectiveVector.size (); i++) - { - _is >> _objectiveVector[i]; - } - return _is; -} - -#endif /*MOEOOBJECTIVEVECTOR_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorComparator.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorComparator.h deleted file mode 100644 index bd4491f19..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorComparator.h +++ /dev/null @@ -1,93 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoObjectiveVectorComparator.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOOBJECTIVEVECTORCOMPARATOR_H_ -#define MOEOOBJECTIVEVECTORCOMPARATOR_H_ - -#include -#include - -/** - * Abstract class allowing to compare 2 objective vectors. - * The template argument ObjectiveVector have to be a moeoObjectiveVector. - */ -template < class ObjectiveVector > class moeoObjectiveVectorComparator:public eoBF < const ObjectiveVector &, const ObjectiveVector &, - int > -{ -}; - - -/** - * This functor class allows to compare 2 objective vectors according to Pareto dominance - */ -template < class ObjectiveVector > class moeoParetoObjectiveVectorComparator:public moeoObjectiveVectorComparator < - ObjectiveVector - > -{ -public: - - /** - * Returns 1 if _objectiveVector1 dominates _objectiveVector2, -1 if _objectiveVector2 dominates _objectiveVector1 and 0 if no one dominates the other - * @param _objectiveVector1 the first objective vector - * @param _objectiveVector2 the second objective vector - */ - int operator () (const ObjectiveVector & _objectiveVector1, - const ObjectiveVector & _objectiveVector2) - { - bool dom1 = false; - bool dom2 = false; - for (unsigned i = 0; i < ObjectiveVector::nObjectives (); i++) - { - // first, we have to check if the 2 objective values are not equal for the ith objective - if (fabs (_objectiveVector1[i] - _objectiveVector2[i]) > - ObjectiveVector::Traits::tolerance ()) - { - // if the ith objective have to be minimized... - if (ObjectiveVector::minimizing (i)) - { - if (_objectiveVector1[i] > _objectiveVector2[i]) - { - dom2 = true; //_objectiveVector2[i] is better than _objectiveVector1[i] - } - else // _objectiveVector1[i] < _objectiveVector2[i] - { - dom1 = true; //_objectiveVector1[i] is better than _objectiveVector2[i] - } - } - // if the ith objective have to be maximized... - else if (ObjectiveVector::maximizing (i)) - { - if (_objectiveVector1[i] > _objectiveVector2[i]) - { - dom1 = true; //_objectiveVector1[i] is better than _objectiveVector2[i] - } - else // _objectiveVector1[i] < _objectiveVector2[i] - { - dom2 = true; //_objectiveVector2[i] is better than _objectiveVector1[i] - } - } - } - } - if (dom1 == dom2) - { - return 0; // no one dominates the other - } - if (dom1) - { - return 1; //_objectiveVector1 dominates _objectiveVector2 - } - return -1; //_objectiveVector2 dominates _objectiveVector1 - } - -}; - -#endif /*MOEOOBJECTIVEVECTORCOMPARATOR_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorTraits.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorTraits.h deleted file mode 100644 index 5fd360c4b..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoObjectiveVectorTraits.h +++ /dev/null @@ -1,122 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoObjectiveVectorTraits.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOOBJECTIVEVECTORTRAITS_H_ -#define MOEOOBJECTIVEVECTORTRAITS_H_ - -#include -#include -#include - -/** - * A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized - */ -class moeoObjectiveVectorTraits -{ -public: - - /** The tolerance value (used to compare solutions) */ - const static double tol = 1e-6; - - /** - * Parameters setting - * @param _nObjectives the number of objectives - * @param _bObjectives the min/max vector (true = min / false = max) - */ - static void setup (unsigned _nObjectives, - std::vector < bool > &_bObjectives) - { - // in case the number of objectives was already set to a different value - if (nObj && (nObj != _nObjectives)) - { - std::cout << "WARNING\n"; - std::cout << "WARNING : the number of objectives are changing\n"; - std:: - cout << "WARNING : Make sure all existing objects are destroyed\n"; - std::cout << "WARNING\n"; - } - // number of objectives - nObj = _nObjectives; - // min/max vector - bObj = _bObjectives; - // in case the number of objectives and the min/max vector size don't match - if (nObj != bObj.size ()) - throw std:: - runtime_error - ("Number of objectives and min/max size don't match in moeoObjectiveVectorTraits::setup"); - } - - /** - * Returns the number of objectives - */ - static unsigned nObjectives () - { - // in case the number of objectives would not be assigned yet - if (!nObj) - throw std:: - runtime_error - ("Number of objectives not assigned in moeoObjectiveVectorTraits"); - return nObj; - } - - /** - * Returns true if the _ith objective have to be minimized - * @param _i the index - */ - static bool minimizing (unsigned _i) - { - // in case the min/max vector would not be assigned yet - if (!bObj[_i]) - throw std:: - runtime_error - ("We don't know if the ith objective have to be minimized or maximized in moeoObjectiveVectorTraits"); - // in case there would be a wrong index - if (_i >= bObj.size ()) - throw std::runtime_error ("Wrong index in moeoObjectiveVectorTraits"); - return bObj[_i]; - } - - /** - * Returns true if the _ith objective have to be maximized - * @param _i the index - */ - static bool maximizing (unsigned _i) - { - return (!minimizing (_i)); - } - - /** - * Returns the tolerance value (to compare solutions) - */ - static double tolerance () - { - return tol; - } - - -private: - - /** The number of objectives */ - static unsigned nObj; - /** The min/max vector */ - static std::vector < bool > bObj; - -}; - -#endif /*MOEOOBJECTIVEVECTORTRAITS_H_ */ - - -// The static variables of the moeoObjectiveVectorTraits class need to be allocated -// (maybe it would have been better to put this on a moeoObjectiveVectorTraits.cpp file) -unsigned - moeoObjectiveVectorTraits::nObj; -std::vector < bool > moeoObjectiveVectorTraits::bObj; diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoPopSorter.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoPopSorter.h deleted file mode 100644 index bc9d32471..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoPopSorter.h +++ /dev/null @@ -1,50 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoPopSorter.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - - -#ifndef MOEOPOPSORTER_H_ -#define MOEOPOPSORTER_H_ - -#include - -/** - * Sorter. - */ -template < class MOEOT > class moeoPopSorter -{ - -public: - - /** Ctor taking a moeoComparator */ -moeoPopSorter (moeoComparator _comparator,):comparator (_comparator) - { - } - - - /** - * Sort a population by applying the comparator - */ - const bool operator () (eoPop < MOEOT > &_pop) - { - // eval fitness and diversity : need "assignement" classes - - // apply comparator - std::sort (_pop.begin (), _pop.end (), comparator); - } - -protected: - /** Comparator attribute */ - moeoComparator & comparator; - -}; - -#endif /*MOEOPOPSORTER_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelect.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelect.h deleted file mode 100644 index 98e802c91..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelect.h +++ /dev/null @@ -1,50 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoRandomSelect.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEORANDOMSELECT_H_ -#define MOEORANDOMSELECT_H_ - -#include -#include - -/** - * Selection strategy that selects only one element randomly from a whole population. Neither the fitness nor the diversity of the individuals is required here. - */ -template < class MOEOT > class moeoRandomSelect:public moeoSelectOne < MOEOT >, public eoRandomSelect -{ -public: - - /** - * CTor. - */ - moeoRandomSelect(){} - - /* - * Do nothing: we don't need to evaluate the fitness and the diversity; we only select one individual at random. - */ - void setup (eoPop < MOEOT > &_pop) - { - // do nothing - } - - /** - * Return one individual at random. // Need to have a "const" pop ? - */ - const MOEOT & operator () (const eoPop < MOEOT > &_pop) - { - - eoRandomSelect < MOEOT >::operator ()(_pop); - } - -}; - -#endif /*MOEORANDOMSELECT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelectOne.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelectOne.h deleted file mode 100644 index e7e636300..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRandomSelectOne.h +++ /dev/null @@ -1,25 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoRandomSelectOne.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEORANDOMSELECTONE_H_ -#define MOEORANDOMSELECTONE_H_ - -#include -#include - -/** - * Selection strategy that selects only one element randomly from a whole population. - */ -template < class MOEOT > -class moeoRandomSelectOne : public moeoSelectOne < MOEOT >, public eoRandomSelect < MOEOT > {}; - -#endif /*MOEORANDOMSELECTONE_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoReplacement.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoReplacement.h deleted file mode 100644 index 62b1b9f66..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoReplacement.h +++ /dev/null @@ -1,25 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoReplacement.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOREPLACEMENT_H_ -#define MOEOREPLACEMENT_H_ - -#include - -/** - * Replacement strategy for multi-objective optimization - */ -template < class MOEOT > class moeoReplacement:public eoReplacement < MOEOT > -{ -}; - -#endif /*MOEOREPLACEMENT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRouletteSelect.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRouletteSelect.h deleted file mode 100644 index 1a811a5b7..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoRouletteSelect.h +++ /dev/null @@ -1,119 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoRouletteSelect.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOROULETTESELECT_H_ -#define MOEOROULETTESELECT_H_ - -#include -#include - -/** - * moeoRouletteSelect: a selection method that selects ONE individual by - * using roulette wheel process - */ -template < class MOEOT > - class moeoRouletteSelect:public moeoSelectOne -{ -public: - /** - * Full Ctor - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignment - * @param _comparator the comparator to compare the individuals - * @param _total - */ - moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, double _total=1 ):evalFitness (_evalFitness), evalDiversity (_evalDiversity), - comparator (_comparator), total (_total) {} - - /** - * Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default. - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignment - * @param _total - */ - moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity) - :evalFitness (_evalFitness), evalDiversity (_evalDiversity) - - { - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - } - - /** - * Ctor without diversity assignment. A dummy diversity assignment is used. - * @param _evalFitness the population fitness assignment - * @param _comparator the comparator to compare the individuals - * @param _total - */ -moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, double _total=1):evalFitness (_evalFitness), comparator (_comparator), - total - (_total) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - } - - - /** - * Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default. - * @param _evalFitness the population fitness assignment - * @param _total - */ -moeoRouletteSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _total=1):evalFitness (_evalFitness), - total (_total) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - } - - /* - * Evaluate the fitness and the diversity of each individual of the population. - */ - void setup (eoPop& _pop) - { - // eval fitness - evalFitness(_pop); - - // eval diversity - evalDiversity(_pop); - } - - /** - * Apply the tournament to the given population - */ - const MOEOT & operator () (const eoPop < MOEOT > &_pop) - { - // use the selector - return mo_roulette_wheel(_pop,total); //comparator ?? - } - - -protected: - - moeoFitnessAssignment < MOEOT > &evalFitness; - - moeoDiversityAssignment < MOEOT > &evalDiversity; - - moeoComparator < MOEOT > &comparator; - - double total; - -}; - -#endif /*MOEOROULETTESELECT_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectFromPopAndArch.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectFromPopAndArch.h deleted file mode 100644 index 1c26b747f..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectFromPopAndArch.h +++ /dev/null @@ -1,93 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoSelectFormPopAndArch.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOSELECTFROMPOPANDARCH_H_ -#define MOEOSELECTFROMPOPANDARCH_H_ - -#include -#include -#include -#include -#include - -/** - * Elitist selection process that consists in choosing individuals in the archive as well as in the current population. - */ -template < class EOT > class moeoSelectFromPopAndArch:public moeoSelectOne < - EOT > -{ -public: - - /** - * Ctor - * @param _popSelect the population's selection operator - * @param _archSelect the archive's selection operator - * @param _arch the archive - * @param _ratioFromPop the ratio of selected individuals from the population - */ -moeoSelectFromPopAndArch (moeoSelectOne < EOT > &_popSelect, moeoSelectOne < EOT > &_archSelect, moeoArchive < EOT > &_arch, double _ratioFromPop = 0.5):popSelect (_popSelect), archSelect (_archSelect), arch (_arch), - ratioFromPop - (_ratioFromPop) - { - } - - /** - * Ctor - the archive's selection operator is a random selector - * @param _popSelect the population's selection operator - * @param _arch the archive - * @param _ratioFromPop the ratio of selected individuals from the population - */ -moeoSelectFromPopAndArch (moeoSelectOne < EOT > &_popSelect, moeoArchive < EOT > &_arch, double _ratioFromPop = 0.5):popSelect (_popSelect), archSelect (randomSelect), arch (_arch), - ratioFromPop - (_ratioFromPop) - { - } - - /** - * The selection process - */ - virtual const EOT & operator () (const eoPop < EOT > &pop) - { - if (arch.size () > 0) - if (rng.flip (ratioFromPop)) - return popSelect (pop); - else - return archSelect (arch); - else - return popSelect (pop); - } - - /** - * Setups some population stats - */ - virtual void setup (const eoPop < EOT > &_pop) - { - popSelect.setup (_pop); - } - - -private: - - /** The population's selection operator */ - moeoSelectOne < EOT > &popSelect; - /** The archive's selection operator */ - moeoSelectOne < EOT > &archSelect; - /** The archive */ - moeoArchive < EOT > &arch; - /** The ratio of selected individuals from the population*/ - double ratioFromPop; - /** A random selection operator */ - moeoRandomSelect < EOT > randomSelect; - -}; - -#endif /*MOEOSELECTFROMPOPANDARCH_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOne.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOne.h deleted file mode 100644 index 1094a89ec..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOne.h +++ /dev/null @@ -1,23 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoSelectOne.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOSELECTONE_H_ -#define MOEOSELECTONE_H_ - -#include - -/** - * Selection strategy for multi-objective optimization that selects only one element from a whole population - */ -template < class MOEOT > class moeoSelectOne : public eoSelectOne < MOEOT > {}; - -#endif /*MOEOSELECTONE_H_ */ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOneFromPopAndArch.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOneFromPopAndArch.h deleted file mode 100644 index aac1b0641..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectOneFromPopAndArch.h +++ /dev/null @@ -1,89 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoSelectOneFormPopAndArch.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOSELECTONEFROMPOPANDARCH_H_ -#define MOEOSELECTONEFROMPOPANDARCH_H_ - -#include -#include -#include -#include -#include - -/** - * Elitist selection process that consists in choosing individuals in the archive as well as in the current population. - */ -template < class MOEOT > -class moeoSelectOneFromPopAndArch : public moeoSelectOne < MOEOT > -{ -public: - - /** - * Ctor - * @param _popSelectOne the population's selection operator - * @param _archSelectOne the archive's selection operator - * @param _arch the archive - * @param _ratioFromPop the ratio of selected individuals from the population - */ - moeoSelectOneFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoSelectOne < MOEOT > _archSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5) - : popSelectOne(_popSelectOne), archSelectOne(_archSelectOne), arch(_arch), ratioFromPop(_ratioFromPop) - {} - - /** - * Defaulr ctor - the archive's selection operator is a random selector - * @param _popSelectOne the population's selection operator - * @param _arch the archive - * @param _ratioFromPop the ratio of selected individuals from the population - */ - moeoSelectOneFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5) - : popSelectOne(_popSelectOne), archSelectOne(randomSelectOne), arch(_arch), ratioFromPop(_ratioFromPop) - {} - - /** - * The selection process - */ - virtual const MOEOT & operator () (const eoPop < MOEOT > & pop) - { - if (arch.size() > 0) - if (rng.flip(ratioFromPop)) - return popSelectOne(pop); - else - return archSelectOne(arch); - else - return popSelectOne(pop); - } - - /** - * Setups some population stats - */ - virtual void setup (const eoPop < MOEOT > & _pop) - { - popSelectOne.setup(_pop); - } - - -private: - - /** The population's selection operator */ - moeoSelectOne < MOEOT > & popSelectOne; - /** The archive's selection operator */ - moeoSelectOne < MOEOT > & archSelectOne; - /** The archive */ - moeoArchive < MOEOT > & arch; - /** The ratio of selected individuals from the population*/ - double ratioFromPop; - /** A random selection operator (used as default for archSelectOne) */ - moeoRandomSelectOne< MOEOT > randomSelectOne; - -}; - -#endif /*MOEOSELECTONEFROMPOPANDARCH_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectors.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectors.h deleted file mode 100644 index 3921e6bb6..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoSelectors.h +++ /dev/null @@ -1,157 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoSelectors.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOSELECTORS_H_ -#define MOEOSELECTORS_H_ - -#include - - -template -It mo_deterministic_tournament(It _begin, It _end, unsigned _t_size,moeoComparator& _comparator ,eoRng& _gen = rng) -{ - It best = _begin + _gen.random(_end - _begin); - - for (unsigned i = 0; i < _t_size - 1; ++i) - { - It competitor = _begin + _gen.random(_end - _begin); - - // compare the two individuals by using the comparator - if(_comparator(*best,*competitor)) - - // best "better" than competitor - best=competitor; - } - - return best; -} - - -template -const MOEOT& mo_deterministic_tournament(const eoPop& _pop, unsigned _t_size,moeoComparator& _comparator, eoRng& _gen = rng) -{ - return *mo_deterministic_tournament(_pop.begin(), _pop.end(),_t_size,_comparator, _gen); -} - -template -MOEOT& mo_deterministic_tournament(eoPop& _pop, unsigned _t_size,moeoComparator& _comparator,eoRng& _gen = rng) -{ - return *mo_deterministic_tournament(_pop.begin(), _pop.end(), _t_size,_comparator, _gen); -} - - - -template -It mo_stochastic_tournament(It _begin, It _end, double _t_rate,moeoComparator& _comparator ,eoRng& _gen = rng) -{ - It i1 = _begin + _gen.random(_end - _begin); - It i2 = _begin + _gen.random(_end - _begin); - - bool return_better = _gen.flip(_t_rate); - - if (_comparator(*i1 , *i2)) - { - if (return_better) return i2; - // else - - return i1; - } - else - { - if (return_better) return i1; - // else - } - // else - - return i2; -} - -template -const MOEOT& mo_stochastic_tournament(const eoPop& _pop, double _t_rate,moeoComparator& _comparator, eoRng& _gen = rng) -{ - return *mo_stochastic_tournament(_pop.begin(), _pop.end(), _t_rate,_comparator, _gen); -} - -template -MOEOT& mo_stochastic_tournament(eoPop& _pop, double _t_rate, eoRng& _gen = rng) -{ - return *mo_stochastic_tournament(_pop.begin(), _pop.end(), _t_rate, _gen); -} - - - -template -It mo_roulette_wheel(It _begin, It _end, double total, eoRng& _gen = rng) -{ - - float roulette = _gen.uniform(total); - - if (roulette == 0.0) // covers the case where total==0.0 - return _begin + _gen.random(_end - _begin); // uniform choice - - It i = _begin; - - while (roulette > 0.0) - { - roulette -= static_cast(*(i++)); - } - - return --i; -} - -template -const MOEOT& mo_roulette_wheel(const eoPop& _pop, double total, eoRng& _gen = rng) -{ - float roulette = _gen.uniform(total); - - if (roulette == 0.0) // covers the case where total==0.0 - return _pop[_gen.random(_pop.size())]; // uniform choice - - typename eoPop::const_iterator i = _pop.begin(); - - while (roulette > 0.0) - { - roulette -= static_cast((i++)->fitness()); - } - - return *--i; -} - -template -MOEOT& mo_roulette_wheel(eoPop& _pop, double total, eoRng& _gen = rng) -{ - float roulette = _gen.uniform(total); - - if (roulette == 0.0) // covers the case where total==0.0 - return _pop[_gen.random(_pop.size())]; // uniform choice - - typename eoPop::iterator i = _pop.begin(); - - while (roulette > 0.0) - { - // fitness ? - roulette -= static_cast((i++)->fitness()); - } - - return *--i; -} - -#endif /*MOEOSELECTORS_H_*/ - - - - - - - - - diff --git a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoStochTournamentSelect.h b/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoStochTournamentSelect.h deleted file mode 100644 index 283f6a9c2..000000000 --- a/branches/paradiseo-moeo-1.0/src/moeoRouletteSelect.h/moeoStochTournamentSelect.h +++ /dev/null @@ -1,166 +0,0 @@ -// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- - -//----------------------------------------------------------------------------- -// moeoStochTournamentSelect.h -// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 -/* - This library... - - Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr - */ -//----------------------------------------------------------------------------- - -#ifndef MOEOSTOCHTOURNAMENTSELECT_H_ -#define MOEOSTOCHTOURNAMENTSELECT_H_ - -#include -#include - -/** - * ??? - */ -template < class MOEOT > class moeoStochTournamentSelect:public moeoSelectOne -{ -public: - /** - * Full Ctor - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignment - * @param _comparator the comparator to compare the individuals - * @param _tRate the tournament rate - */ -moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity, moeoComparator < MOEOT > &_comparator, double _tRate = 1.0):evalFitness (_evalFitness), evalDiversity (_evalDiversity), - comparator (_comparator), - tRate (_tRate) - { - // consistency checks - if (tRate < 0.5) - { - std:: - cerr << - "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n"; - tRate = 0.55; - } - if (tRate > 1) - { - std:: - cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n"; - tRate = 1; - } - } - - /** - * Ctor without comparator. A moeoFitnessThenDiversityComparator is used as default. - * @param _evalFitness the population fitness assignment - * @param _evalDiversity the population diversity assignment - * @param _tRate the tournament rate - */ - moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoDiversityAssignment < MOEOT > &_evalDiversity) - :evalFitness (_evalFitness), evalDiversity (_evalDiversity) - - { - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - } - - - /** - * Ctor without diversity assignment. A dummy diversity assignment is used. - * @param _evalFitness the population fitness assignment - * @param _comparator the comparator to compare the individuals - */ -moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, moeoComparator < MOEOT > &_comparator, double _tRate = 1.0):evalFitness (_evalFitness), comparator (_comparator), - tRate - (_tRate) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // consistency checks - if (tRate < 0.5) - { - std:: - cerr << - "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n"; - tRate = 0.55; - } - if (tRate > 1) - { - std:: - cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n"; - tRate = 1; - } - } - - - /** - * Ctor without diversity assignment nor comparator. A moeoDummyDiversityAssignment and a moeoFitnessThenDiversityComparator are used as default. - * @param _evalFitness the population fitness assignment - */ -moeoStochTournamentSelect (moeoFitnessAssignment < MOEOT > &_evalFitness, double _tRate = 1.0):evalFitness (_evalFitness), - tRate - (_tRate) - { - // a dummy diversity is used as default - moeoDummyDiversityAssignment < MOEOT > &dummyDiversityAssignment; - evalDiversity = dummyDiversityAssignment; - - // a moeoFitThenDivComparator is used as default - moeoFitnessThenDiversityComparator < MOEOT > &fitThenDivComparator; - comparator = fitThenDivComparator; - - // consistency checks - if (tRate < 0.5) - { - std:: - cerr << - "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n"; - tRate = 0.55; - } - if (tRate > 1) - { - std:: - cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n"; - tRate = 1; - } - } - - - /* - * Evaluate the fitness and the diversity of each individual of the population. - */ - void setup (eoPop& _pop) - { - // eval fitness - evalFitness(_pop); - - // eval diversity - evalDiversity(_pop); - } - - /** - * Apply the tournament to the given population - */ - const MOEOT & operator() (const eoPop < MOEOT > &_pop) - { - // use the selector - return mo_stochastic_tournament(_pop,tRate,comparator); - } - - - -protected: - - moeoFitnessAssignment < MOEOT > &evalFitness; - - moeoDiversityAssignment < MOEOT > &evalDiversity; - - moeoComparator < MOEOT > &comparator; - - double tRate; -}; - - -#endif /*MOEOSTOCHTOURNAMENTSELECT_H_ */