Migration from SVN

This commit is contained in:
quemy 2012-08-30 11:30:11 +02:00
commit 8cd56f37db
29069 changed files with 0 additions and 4096888 deletions

View file

@ -0,0 +1,99 @@
/*
* <moeoDetArchiveSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
* Jérémie Humeau
* François Legillon
* Thibaut demaret
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODETARCHIVESELECT_H
#define MOEODETARCHIVESELECT_H
#include <eoSelect.h>
#include <cassert>
template<class MOEOT>
class moeoDetArchiveSelect : public eoSelect<MOEOT>
{
public:
moeoDetArchiveSelect(moeoArchive < MOEOT > & _archive, unsigned int _max, unsigned int _min=0) :
archive(_archive), max(_max), min(_min) {}
/**
* Repopulate copying the archive, selecting randomly if the archive size is over bounds (min and max)
* @param _source compatibility parameter, not used
* @param _dest destination population, selected from archive
*/
void operator()(const eoPop < MOEOT > & _source, eoPop < MOEOT > & _dest)
{
if(max < min){
std::cout << "Warning! moeoDetArchiveSelect: min value > max value!!! Nothing is done." << std::endl;
}
else{
unsigned int archive_size = archive.size();
_dest.resize(0);
if ((archive_size >= min) && (archive_size <= max)){
for (unsigned int i=0; i<archive_size; i++)
_dest.push_back(archive[i]);
}
else if (archive_size > max){
UF_random_generator<unsigned int> rndGen;
std::vector <int> permutation;
for(unsigned int i=0; i < archive_size; i++)
permutation.push_back(i);
random_shuffle(permutation.begin(), permutation.end(), rndGen);
for (unsigned int i=0; i<max; i++)
_dest.push_back(archive[permutation[i]]);
}
else {
for (unsigned int i=0; i<min; i++){
_dest.push_back(archive[i%archive_size]);
}
}
}
}
private :
/** archive used to select MOEOT*/
moeoArchive < MOEOT > & archive;
/** max is the maximum size of the new population*/
unsigned int max;
/** min is the minimum size of the new population (default 0) */
unsigned int min;
};
#endif /*MOEODETARCHIVESELECT_H*/

View file

@ -0,0 +1,108 @@
/*
* <moeoDetTournamentSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEODETTOURNAMENTSELECT_H_
#define MOEODETTOURNAMENTSELECT_H_
#include <comparator/moeoComparator.h>
#include <comparator/moeoFitnessThenDiversityComparator.h>
#include <selection/moeoSelectOne.h>
#include <selection/moeoSelectors.h>
/**
* Selection strategy that selects ONE individual by deterministic tournament.
*/
template < class MOEOT > class moeoDetTournamentSelect:public moeoSelectOne < MOEOT >
{
public:
/**
* Full Ctor.
* @param _comparator the comparator (used to compare 2 individuals)
* @param _tSize the number of individuals in the tournament (default: 2)
*/
moeoDetTournamentSelect (moeoComparator < MOEOT > & _comparator, unsigned int _tSize = 2) : 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 _tSize the number of individuals in the tournament (default: 2)
*/
moeoDetTournamentSelect (unsigned int _tSize = 2) : comparator (defaultComparator), tSize (_tSize)
{
// consistency check
if (tSize < 2)
{
std::
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
tSize = 2;
}
}
/**
* Apply the tournament to the given population
* @param _pop the population
*/
const MOEOT & operator() (const eoPop < MOEOT > &_pop)
{
// use the selector
return mo_deterministic_tournament (_pop, tSize, comparator);
}
protected:
/** the comparator (used to compare 2 individuals) */
moeoComparator < MOEOT > & comparator;
/** a fitness then diversity comparator can be used as default */
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/** the number of individuals in the tournament */
unsigned int tSize;
};
#endif /*MOEODETTOURNAMENTSELECT_H_ */

View file

@ -0,0 +1,75 @@
/*
* <moeoExhaustiveUnvisitedSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOEXHAUSTIVEUNVISITEDSELECT_H
#define _MOEOEXHAUSTIVEUNVISITEDSELECT_H
#include <eoPop.h>
#include <selection/moeoUnvisitedSelect.h>
/**
* Selector which select all unvisited individuals of a population
*/
template < class MOEOT >
class moeoExhaustiveUnvisitedSelect : public moeoUnvisitedSelect < MOEOT >
{
public:
moeoExhaustiveUnvisitedSelect(){}
/**
* functor which return index of selected individuals of a population
* @param _src the population
* @return the vector contains index of all unvisited individuals of the population
*/
std::vector <unsigned int> operator()(eoPop < MOEOT > & _src)
{
std::vector <unsigned int> res;
res.resize(0);
for (unsigned int i=0; i<_src.size(); i++)
{
if (_src[i].flag() == 0)
res.push_back(i);
}
return res;
}
};
#endif /*_MOEOEXHAUSTIVEUNVISITEDSELECT_H_*/

View file

@ -0,0 +1,88 @@
/*
* <moeoNumberUnvisitedSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEONUMBERUNVISITEDSELECT_H
#define _MOEONUMBERUNVISITEDSELECT_H
#include <eoPop.h>
#include <selection/moeoUnvisitedSelect.h>
/**
* Selector which select a part of unvisited individuals of a population
*/
template < class MOEOT >
class moeoNumberUnvisitedSelect : public moeoUnvisitedSelect < MOEOT >
{
public:
/**
* Constructor
* @param _number the number of individuals to select
*/
moeoNumberUnvisitedSelect(unsigned int _number): number(_number){}
/**
* functor which return index of selected individuals of a population
* @param _src the population
* @return the vector contains index of the part of unvisited individuals of the population
*/
std::vector <unsigned int> operator()(eoPop < MOEOT > & _src)
{
std::vector <unsigned int> res;
res.resize(0);
for (unsigned int i=0; i<_src.size(); i++)
{
if (_src[i].flag() == 0)
res.push_back(i);
}
if(number < res.size()){
UF_random_generator<unsigned int> rndGen;
std::random_shuffle(res.begin(), res.end(), rndGen);
res.resize(number);
}
return res;
}
private:
/** number of individuals to select */
unsigned int number;
};
#endif /*_MOEONUMBERUNVISITEDSELECT_H_*/

View file

@ -0,0 +1,69 @@
/*
* <moeoRandomSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEORANDOMSELECT_H_
#define MOEORANDOMSELECT_H_
#include <eoRandomSelect.h>
#include <selection/moeoSelectOne.h>
/**
* Selection strategy that selects only one element randomly from a whole population.
*/
template < class MOEOT > class moeoRandomSelect:public moeoSelectOne < MOEOT >, public eoRandomSelect <MOEOT >
{
public:
/**
* Ctor.
*/
moeoRandomSelect()
{}
/**
* Return one individual at random by using an eoRandomSelect.
*/
const MOEOT & operator () (const eoPop < MOEOT > &_pop)
{
return eoRandomSelect < MOEOT >::operator ()(_pop);
}
};
#endif /*MOEORANDOMSELECT_H_ */

View file

@ -0,0 +1,87 @@
/*
* <moeoRouletteSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOROULETTESELECT_H_
#define MOEOROULETTESELECT_H_
#include <selection/moeoSelectOne.h>
#include <selection/moeoSelectors.h>
/**
* Selection strategy that selects ONE individual by using roulette wheel process.
* WARNING This selection only uses fitness values (and not diversity values).
*/
template < class MOEOT >
class moeoRouletteSelect:public moeoSelectOne < MOEOT >
{
public:
/**
* Ctor.
* @param _tSize the number of individuals in the tournament (default: 2)
*/
moeoRouletteSelect (unsigned int _tSize = 2) : tSize (_tSize)
{
// consistency check
if (tSize < 2)
{
std::
cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
tSize = 2;
}
}
/**
* Apply the tournament to the given population
* @param _pop the population
*/
const MOEOT & operator () (const eoPop < MOEOT > & _pop)
{
// use the selector
return mo_roulette_wheel(_pop,tSize);
}
protected:
/** size */
double & tSize;
};
#endif /*MOEOROULETTESELECT_H_ */

View file

@ -0,0 +1,120 @@
/*
* <moeoSelectFromPopAndArch.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSELECTONEFROMPOPANDARCH_H_
#define MOEOSELECTONEFROMPOPANDARCH_H_
#include <eoPop.h>
#include <utils/eoRNG.h>
#include <archive/moeoArchive.h>
#include <selection/moeoSelectOne.h>
#include <selection/moeoRandomSelect.h>
/**
* Elitist selection process that consists in choosing individuals in the archive as well as in the current population.
*/
template < class MOEOT >
class moeoSelectFromPopAndArch : 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
*/
moeoSelectFromPopAndArch (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
*/
moeoSelectFromPopAndArch (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) */
moeoRandomSelect < MOEOT > randomSelectOne;
};
#endif /*MOEOSELECTONEFROMPOPANDARCH_H_*/

View file

@ -0,0 +1,50 @@
/*
* <moeoSelectOne.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSELECTONE_H_
#define MOEOSELECTONE_H_
#include <eoSelectOne.h>
/**
* 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_*/

View file

@ -0,0 +1,183 @@
/*
* <moeoSelectors.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSELECTORS_H_
#define MOEOSELECTORS_H_
#include <comparator/moeoComparator.h>
template <class It,class MOEOT>
It mo_deterministic_tournament(It _begin, It _end, unsigned int _t_size,moeoComparator<MOEOT>& _comparator ,eoRng& _gen = rng)
{
It best = _begin + _gen.random(_end - _begin);
for (unsigned int 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 <class MOEOT>
const MOEOT& mo_deterministic_tournament(const eoPop<MOEOT>& _pop, unsigned int _t_size,moeoComparator<MOEOT>& _comparator, eoRng& _gen = rng)
{
return *mo_deterministic_tournament(_pop.begin(), _pop.end(),_t_size,_comparator, _gen);
}
template <class MOEOT>
MOEOT& mo_deterministic_tournament(eoPop<MOEOT>& _pop, unsigned int _t_size,moeoComparator<MOEOT>& _comparator,eoRng& _gen = rng)
{
return *mo_deterministic_tournament(_pop.begin(), _pop.end(), _t_size,_comparator, _gen);
}
template <class It,class MOEOT>
It mo_stochastic_tournament(It _begin, It _end, double _t_rate,moeoComparator<MOEOT>& _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 <class MOEOT>
const MOEOT& mo_stochastic_tournament(const eoPop<MOEOT>& _pop, double _t_rate,moeoComparator<MOEOT>& _comparator, eoRng& _gen = rng)
{
return *mo_stochastic_tournament(_pop.begin(), _pop.end(), _t_rate,_comparator, _gen);
}
template <class MOEOT>
MOEOT& mo_stochastic_tournament(eoPop<MOEOT>& _pop, double _t_rate, eoRng& _gen = rng)
{
return *mo_stochastic_tournament(_pop.begin(), _pop.end(), _t_rate, _gen);
}
template <class It>
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<double>(*(i++));
}
return --i;
}
template <class MOEOT>
const MOEOT& mo_roulette_wheel(const eoPop<MOEOT>& _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<MOEOT>::const_iterator i = _pop.begin();
while (roulette > 0.0)
{
roulette -= static_cast<double>((i++)->fitness());
}
return *--i;
}
template <class MOEOT>
MOEOT& mo_roulette_wheel(eoPop<MOEOT>& _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<MOEOT>::iterator i = _pop.begin();
while (roulette > 0.0)
{
// fitness only
roulette -= static_cast<double>((i++)->fitness());
}
return *--i;
}
#endif /*MOEOSELECTORS_H_*/

View file

@ -0,0 +1,116 @@
/*
* <moeoStochTournamentSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
*
* Arnaud Liefooghe
*
* 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
*
*/
//-----------------------------------------------------------------------------
#ifndef MOEOSTOCHTOURNAMENTSELECT_H_
#define MOEOSTOCHTOURNAMENTSELECT_H_
#include <comparator/moeoComparator.h>
#include <comparator/moeoFitnessThenDiversityComparator.h>
#include <selection/moeoSelectOne.h>
#include <selection/moeoSelectors.h>
/**
* Selection strategy that selects ONE individual by stochastic tournament.
*/
template < class MOEOT > class moeoStochTournamentSelect:public moeoSelectOne <MOEOT>
{
public:
/**
* Full Ctor
* @param _comparator the comparator (used to compare 2 individuals)
* @param _tRate the tournament rate
*/
moeoStochTournamentSelect (moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) : 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 _tRate the tournament rate
*/
moeoStochTournamentSelect (double _tRate = 1.0) : comparator (defaultComparator), 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;
}
}
/**
* Apply the tournament to the given population
* @param _pop the population
*/
const MOEOT & operator() (const eoPop < MOEOT > &_pop)
{
// use the selector
return mo_stochastic_tournament(_pop,tRate,comparator);
}
protected:
/** the comparator (used to compare 2 individuals) */
moeoComparator < MOEOT > & comparator;
/** a fitness then diversity comparator can be used as default */
moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
/** the tournament rate */
double tRate;
};
#endif /*MOEOSTOCHTOURNAMENTSELECT_H_ */

View file

@ -0,0 +1,50 @@
/*
* <moeoUnvisitedSelect.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2008
* (C) OPAC Team, LIFL, 2002-2008
*
* Arnaud Liefooghe
* Jérémie 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
*
*/
//-----------------------------------------------------------------------------
#ifndef _MOEOUNVISITEDSELECT_H
#define _MOEOUNVISITEDSELECT_H
#include <eoPop.h>
/**
* Abstract Selector
*/
template < class MOEOT >
class moeoUnvisitedSelect: public eoUF < eoPop < MOEOT > &, std::vector< unsigned int > >{};
#endif /*MOEOUNVISITEDSELECT_H_*/