From 7f70be8f2aa0a414518edd5ebd399ecbfb6f4076 Mon Sep 17 00:00:00 2001 From: jhumeau Date: Wed, 28 May 2008 13:24:12 +0000 Subject: [PATCH] New fitness assignments extended moeoParetoBasedFitnessAssignment. git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@1193 331e1502-861f-0410-8da2-ba01fb791d7f --- .../moeoDominanceCountFitnessAssignment.h | 130 ++++++++++++++ ...eoDominanceCountRankingFitnessAssignment.h | 159 ++++++++++++++++++ .../moeoDominanceRankFitnessAssignment.h | 137 +++++++++++++++ 3 files changed, 426 insertions(+) create mode 100644 trunk/paradiseo-moeo/src/fitness/moeoDominanceCountFitnessAssignment.h create mode 100644 trunk/paradiseo-moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h create mode 100644 trunk/paradiseo-moeo/src/fitness/moeoDominanceRankFitnessAssignment.h diff --git a/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountFitnessAssignment.h b/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountFitnessAssignment.h new file mode 100644 index 000000000..450ec9c69 --- /dev/null +++ b/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountFitnessAssignment.h @@ -0,0 +1,130 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- +// moeoDominanceCountFitnessAssignment.h +//----------------------------------------------------------------------------- +#ifndef MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_ +#define MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * moeoDominanceCountFitnessAssignment is a fitness assignment which count for each moeot the others moeot it dominates. + */ +template < class MOEOT > +class moeoDominanceCountFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + /** + * Default ctor + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own archive + * @param _archive the archive used + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy) + {} + + /** + * Ctor where you can choose your own archive and your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _archive the archive used + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy) + {} + + /** + * Sets the fitness values for every solution contained in the population _pop and in archive + * @param _pop the population + */ + void operator()(eoPop < MOEOT > & _pop) { + unsigned int j= _pop.size(); + unsigned int i= archive.size(); + matrix(archive,_pop); + for (unsigned int k=0; k & _pop, ObjectiveVector & _objVec) + { + //not yet implemented + } + +private: + /** Functor to compare two objective vectors */ + moeoObjectiveVectorComparator < ObjectiveVector > & comparator; + /** Functor to compare two objective vectors according to Pareto dominance relation */ + moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + /** Archive */ + moeoArchive < MOEOT > & archive; + /** Default archive */ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** Dominance Matrix */ + moeoDominanceMatrix < MOEOT > matrix; +}; + +#endif /*MOEODOMINANCECOUNTFITNESSASSIGNMENT_H_*/ diff --git a/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h b/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h new file mode 100644 index 000000000..c23c07dbb --- /dev/null +++ b/trunk/paradiseo-moeo/src/fitness/moeoDominanceCountRankingFitnessAssignment.h @@ -0,0 +1,159 @@ +/* +* +* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- +// moeoDominanceCountRankingFitnessAssignment.h +//----------------------------------------------------------------------------- + +#ifndef MOEODOMINANCECOUNTRANKINGFITNESSASSIGNMENT_H_ +#define MOEODOMINANCECOUNTRANKINGFITNESSASSIGNMENT_H_ + +#include +#include +#include +#include +#include +#include +#include +#include + +/** + * moeoDominanceCountRankingFitnessAssignment is a rank fitness assignment with value determine by a count fitness assignment. + */ +template < class MOEOT > +class moeoDominanceCountRankingFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + /** + * Default ctor + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountRankingFitnessAssignment(bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own archive + * @param _archive the archive used + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountRankingFitnessAssignment(moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountRankingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), matrix(_comparator, _nocopy) + {} + + /** + * Ctor where you can choose your own archive and your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _archive the archive used + * @param _nocopy boolean to move away copies + */ + moeoDominanceCountRankingFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, bool _nocopy=true) : comparator(_comparator), archive(_archive), matrix(_comparator, _nocopy) + {} + + + /** + * Sets the fitness values for every solution contained in the population _pop and in archive + * @param _pop the population + */ + void operator()(eoPop < MOEOT > & _pop) + { + /*std::cout <<"\n\n"; + for(unsigned k=0;k<_pop.size();k++){ + std::cout << "pop " << k << " :\n"; + for(unsigned l=0 ; l<2 ; l++) + std::cout << "\tobjVec " << l << " : " << _pop[k].objectiveVector()[l] << "\n"; + } + for(unsigned k=0;k & _pop, ObjectiveVector & _objVec) + { + //not yet implemented + } + + +private: + /** Functor to compare two objective vectors */ + moeoObjectiveVectorComparator < ObjectiveVector > & comparator; + /** Functor to compare two objective vectors according to Pareto dominance relation */ + moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + /** Archive */ + moeoArchive < MOEOT > & archive; + /** Default archive */ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** Dominance Matrix*/ + moeoDominanceMatrix matrix; + + double countRanking(unsigned int _i) { + double res=0; + for (unsigned int k=0; k +* Copyright (C) DOLPHIN Project-Team, INRIA Lille-Nord Europe, 2006-2008 +* (C) OPAC Team, LIFL, 2002-2008 +* +* Arnaud Liefooghe +* Jeremie Humeau +* +* This software is governed by the CeCILL license under French law and +* abiding by the rules of distribution of free software. You can use, +* modify and/ or redistribute the software under the terms of the CeCILL +* license as circulated by CEA, CNRS and INRIA at the following URL +* "http://www.cecill.info". +* +* As a counterpart to the access to the source code and rights to copy, +* modify and redistribute granted by the license, users are provided only +* with a limited warranty and the software's author, the holder of the +* economic rights, and the successive licensors have only limited liability. +* +* In this respect, the user's attention is drawn to the risks associated +* with loading, using, modifying and/or developing or reproducing the +* software by the user in light of its specific status of free software, +* that may mean that it is complicated to manipulate, and that also +* therefore means that it is reserved for developers and experienced +* professionals having in-depth computer knowledge. Users are therefore +* encouraged to load and test the software's suitability as regards their +* requirements in conditions enabling the security of their systems and/or +* data to be ensured and, more generally, to use and operate it in the +* same conditions as regards security. +* The fact that you are presently reading this means that you have had +* knowledge of the CeCILL license and that you accept its terms. +* +* ParadisEO WebSite : http://paradiseo.gforge.inria.fr +* Contact: paradiseo-help@lists.gforge.inria.fr +* +*/ +//----------------------------------------------------------------------------- +// moeoDominanceRankFitnessAssignment.cpp +//----------------------------------------------------------------------------- +#ifndef MOEODOMINANCERANKFITNESSASSIGNEMENT_H_ +#define MOEODOMINANCERANKFITNESSASSIGNEMENT_H_ + +#include +#include +#include +#include +#include +#include +#include + +/** + * moeoDominanceRankFitnessAssignment is a fitness assignment which count for each moeot how many others dominates it. + */ +template < class MOEOT > +class moeoDominanceRankFitnessAssignment : public moeoParetoBasedFitnessAssignment < MOEOT > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + /** + * Default ctor + * @param _start a start value used to determine the fitness (default _start = 1.0) + * @param _nocopy boolean to move away copies + */ + moeoDominanceRankFitnessAssignment(double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(defaultArchive), start(_start), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own archive + * @param _archive the archive used + * @param _start a start value used to determine the fitness (default _start = 1.0) + * @param _nocopy boolean to move away copies + */ + moeoDominanceRankFitnessAssignment(moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(paretoComparator), archive(_archive), start(_start), matrix(_nocopy) + {} + + /** + * Ctor where you can choose your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _start a start value used to determine the fitness (default _start = 1.0) + * @param _nocopy boolean to move away copies + */ + moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(defaultArchive), start(_start), matrix(_comparator, _nocopy) + {} + + /** + * Ctor where you can choose your own archive and your own way to compare objective vectors + * @param _comparator the functor used to compare objective vectors + * @param _archive the archive used + * @param _start a start value used to determine the fitness (default _start = 1.0) + * @param _nocopy boolean to move away copies + */ + moeoDominanceRankFitnessAssignment(moeoObjectiveVectorComparator < ObjectiveVector > & _comparator, moeoArchive < MOEOT > & _archive, double _start=1.0, bool _nocopy=true) : comparator(_comparator), archive(_archive), start(_start), matrix(_comparator, _nocopy) + {} + + /** + * Sets the fitness values for every solution contained in the population _pop and in archive + * @param _pop the population + */ + void operator()(eoPop < MOEOT > & _pop) + { + unsigned int i= archive.size(); + unsigned int j= _pop.size(); + matrix(archive, _pop); + for (unsigned int k=0; k & _pop, ObjectiveVector & _objVec) + { + //not yet implemented + } + +private: + /** Functor to compare two objective vectors */ + moeoObjectiveVectorComparator < ObjectiveVector > & comparator; + /** Functor to compare two objective vectors according to Pareto dominance relation */ + moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator; + /** Archive*/ + moeoArchive < MOEOT > & archive; + /** Default archive*/ + moeoUnboundedArchive < MOEOT > defaultArchive; + /** start value*/ + double start; + /** Dominance Matrix*/ + moeoDominanceMatrix < MOEOT > matrix; + +}; + +#endif /*MOEODOMINANCERANKFITNESSASSIGNMENT_H_*/