AUTHORS modification
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@152 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
cde1586361
commit
4c21c72510
137 changed files with 2356 additions and 2369 deletions
|
|
@ -1,12 +1,14 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
moeoNDSorting.h
|
||||
(c) Deneche Abdelhakim, 2006
|
||||
//-----------------------------------------------------------------------------
|
||||
// moeoNDSorting.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*/
|
||||
//------------------------------------------------------------------------------
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef moeoNDSorting_h
|
||||
#define moeoNDSorting_h
|
||||
|
|
@ -14,78 +16,93 @@
|
|||
#include <cfloat>
|
||||
#include <eoNDSorting.h>
|
||||
|
||||
# define INF 1.0e14 // DBL_MAX
|
||||
# define INF 1.0e14 // DBL_MAX
|
||||
|
||||
/** @brief Fast Elitist Non-Dominant Sorting Genetic Algorithm
|
||||
|
||||
Note : This is a corrected version of the original eoNDSorting_II class
|
||||
.
|
||||
@see eoNDSorting_II
|
||||
*/
|
||||
template <class EOT>
|
||||
class moeoNDSorting_II : public eoNDSorting<EOT>
|
||||
/**
|
||||
* Fast Elitist Non-Dominant Sorting Genetic Algorithm assignment strategie
|
||||
* Note : This is a corrected version of the original eoNDSorting_II class
|
||||
* @see eoNDSorting_II
|
||||
*/
|
||||
template < class EOT > class moeoNDSorting_II:public eoNDSorting < EOT >
|
||||
{
|
||||
public:
|
||||
public:
|
||||
|
||||
moeoNDSorting_II(bool nasty_flag_ = false) : eoNDSorting<EOT>(nasty_flag_) {}
|
||||
/**
|
||||
* constructor
|
||||
*/
|
||||
moeoNDSorting_II (bool nasty_flag_ = false):eoNDSorting < EOT >
|
||||
(nasty_flag_)
|
||||
{
|
||||
}
|
||||
|
||||
typedef std::pair<double, unsigned> double_index_pair;
|
||||
/**
|
||||
* index pair
|
||||
*/
|
||||
typedef std::pair < double, unsigned >double_index_pair;
|
||||
|
||||
/**
|
||||
* A class to compare the nodes
|
||||
*/
|
||||
class compare_nodes
|
||||
{
|
||||
public :
|
||||
bool operator()(const double_index_pair& a, const double_index_pair& b) const
|
||||
public:bool operator () (const double_index_pair & a,
|
||||
const double_index_pair & b) const
|
||||
{
|
||||
return a.first < b.first;
|
||||
}
|
||||
};
|
||||
|
||||
/// _cf points into the elements that consist of the current front
|
||||
std::vector<double> niche_penalty(const std::vector<unsigned>& _cf, const eoPop<EOT>& _pop)
|
||||
std::vector < double >niche_penalty (const std::vector < unsigned >&_cf,
|
||||
const eoPop < EOT > &_pop)
|
||||
{
|
||||
typedef typename EOT::Fitness::fitness_traits traits;
|
||||
unsigned i;
|
||||
std::vector<double> niche_count(_cf.size(), 0.);
|
||||
std::vector < double >niche_count (_cf.size (), 0.);
|
||||
|
||||
|
||||
unsigned nObjectives = traits::nObjectives(); //_pop[_cf[0]].fitness().size();
|
||||
unsigned nObjectives = traits::nObjectives (); //_pop[_cf[0]].fitness().size();
|
||||
|
||||
for (unsigned o = 0; o < nObjectives; ++o)
|
||||
{
|
||||
std::vector<std::pair<double, unsigned> > performance(_cf.size());
|
||||
for (i =0; i < _cf.size(); ++i)
|
||||
{
|
||||
performance[i].first = _pop[_cf[i]].fitness()[o];
|
||||
performance[i].second = i;
|
||||
std::vector < std::pair < double,
|
||||
unsigned > >performance (_cf.size ());
|
||||
for (i = 0; i < _cf.size (); ++i)
|
||||
{
|
||||
performance[i].first = _pop[_cf[i]].fitness ()[o];
|
||||
performance[i].second = i;
|
||||
}
|
||||
|
||||
std::sort (performance.begin (), performance.end (), compare_nodes ()); // a lambda operator would've been nice here
|
||||
|
||||
// set boundary at INF (so it will get chosen over all the others
|
||||
niche_count[performance[0].second] = INF;
|
||||
niche_count[performance.back ().second] = INF;
|
||||
|
||||
if (performance[0].first != performance.back ().first)
|
||||
{
|
||||
for (i = 1; i < _cf.size () - 1; ++i)
|
||||
{
|
||||
if (niche_count[performance[i].second] != INF)
|
||||
{
|
||||
niche_count[performance[i].second] +=
|
||||
(performance[i + 1].first -
|
||||
performance[i -
|
||||
1].first) / (performance.back ().first -
|
||||
performance[0].first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::sort(performance.begin(), performance.end(), compare_nodes()); // a lambda operator would've been nice here
|
||||
// transform niche_count into penality
|
||||
for (i = 0; i < niche_count.size (); ++i)
|
||||
{
|
||||
niche_count[i] = INF - niche_count[i];
|
||||
}
|
||||
|
||||
// set boundary at INF (so it will get chosen over all the others
|
||||
niche_count[performance[0].second] = INF;
|
||||
niche_count[performance.back().second] = INF;
|
||||
|
||||
if (performance[0].first != performance.back().first)
|
||||
{
|
||||
for (i = 1; i < _cf.size()-1; ++i)
|
||||
{
|
||||
if (niche_count[performance[i].second] != INF)
|
||||
{
|
||||
niche_count[performance[i].second] += (performance[i+1].first - performance[i-1].first)/
|
||||
(performance.back().first-performance[0].first);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// transform niche_count into penality
|
||||
for (i = 0; i < niche_count.size(); ++i)
|
||||
{
|
||||
niche_count[i] = INF - niche_count[i];
|
||||
}
|
||||
|
||||
return niche_count;
|
||||
return niche_count;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -28,7 +28,8 @@
|
|||
|
||||
/**
|
||||
*/
|
||||
template<class EOT> class moeoNSGA_II: public eoAlgo<EOT> {
|
||||
template < class EOT > class moeoNSGA_II:public eoAlgo < EOT >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
|
|
@ -42,89 +43,64 @@ public:
|
|||
@param _op variation operator
|
||||
*/
|
||||
|
||||
moeoNSGA_II(
|
||||
unsigned _max_gen,
|
||||
eoEvalFunc<EOT>& _eval,
|
||||
eoGenOp<EOT>& _op
|
||||
): continuator(*(new eoGenContinue<EOT>(_max_gen))),
|
||||
eval(_eval),
|
||||
loopEval(_eval),
|
||||
popEval(loopEval),
|
||||
selectOne(sorting, 2), // binary tournament selection
|
||||
replace(sorting),
|
||||
genBreed(selectOne, _op),
|
||||
breed(genBreed)
|
||||
{}
|
||||
moeoNSGA_II (unsigned _max_gen, eoEvalFunc < EOT > &_eval, eoGenOp < EOT > &_op):continuator (*(new eoGenContinue < EOT > (_max_gen))), eval (_eval), loopEval (_eval), popEval (loopEval), selectOne (sorting, 2), // binary tournament selection
|
||||
replace (sorting), genBreed (selectOne, _op), breed (genBreed)
|
||||
{
|
||||
}
|
||||
|
||||
/// Ctor taking _max_gen, crossover and mutation
|
||||
moeoNSGA_II(
|
||||
unsigned _max_gen,
|
||||
eoEvalFunc<EOT>& _eval,
|
||||
eoQuadOp<EOT>& crossover,
|
||||
double pCross,
|
||||
eoMonOp<EOT>& mutation,
|
||||
double pMut
|
||||
): continuator(*(new eoGenContinue<EOT>(_max_gen))),
|
||||
eval(_eval),
|
||||
loopEval(_eval),
|
||||
popEval(loopEval),
|
||||
selectOne(sorting, 2), // binary tournament selection
|
||||
replace(sorting),
|
||||
genBreed(selectOne, *new eoSGAGenOp<EOT>(crossover, pCross, mutation, pMut)),
|
||||
breed(genBreed)
|
||||
{}
|
||||
/// Ctor taking _max_gen, crossover and mutation
|
||||
moeoNSGA_II (unsigned _max_gen, eoEvalFunc < EOT > &_eval, eoQuadOp < EOT > &crossover, double pCross, eoMonOp < EOT > &mutation, double pMut):continuator (*(new eoGenContinue < EOT > (_max_gen))), eval (_eval), loopEval (_eval), popEval (loopEval), selectOne (sorting, 2), // binary tournament selection
|
||||
|
||||
replace (sorting),
|
||||
genBreed (selectOne,
|
||||
*new eoSGAGenOp < EOT > (crossover, pCross, mutation, pMut)),
|
||||
breed (genBreed)
|
||||
{
|
||||
}
|
||||
|
||||
/// Ctor taking a continuator instead of _gen_max
|
||||
moeoNSGA_II(
|
||||
eoContinue<EOT>& _continuator,
|
||||
eoEvalFunc<EOT>& _eval,
|
||||
eoGenOp<EOT>& _op
|
||||
):
|
||||
continuator(_continuator),
|
||||
eval (_eval),
|
||||
loopEval(_eval),
|
||||
popEval(loopEval),
|
||||
selectOne(sorting, 2), // binary tournament selection
|
||||
replace(sorting),
|
||||
genBreed(selectOne, _op),
|
||||
breed(genBreed)
|
||||
{}
|
||||
/// Ctor taking a continuator instead of _gen_max
|
||||
moeoNSGA_II (eoContinue < EOT > &_continuator, eoEvalFunc < EOT > &_eval, eoGenOp < EOT > &_op):
|
||||
continuator (_continuator), eval (_eval), loopEval (_eval), popEval (loopEval), selectOne (sorting, 2), // binary tournament selection
|
||||
replace (sorting), genBreed (selectOne, _op), breed (genBreed)
|
||||
{
|
||||
}
|
||||
|
||||
///Apply a few generation of evolution to the population.
|
||||
virtual void operator()(eoPop<EOT>& _pop)
|
||||
{
|
||||
eoPop<EOT> offspring, empty_pop;
|
||||
popEval(empty_pop, _pop); // a first eval of _pop
|
||||
do
|
||||
{
|
||||
// generate offspring, worths are recalculated if necessary
|
||||
breed(_pop, offspring);
|
||||
|
||||
// eval of offspring
|
||||
popEval(_pop, offspring);
|
||||
///Apply a few generation of evolution to the population.
|
||||
virtual void operator () (eoPop < EOT > &_pop)
|
||||
{
|
||||
eoPop < EOT > offspring, empty_pop;
|
||||
popEval (empty_pop, _pop); // a first eval of _pop
|
||||
do
|
||||
{
|
||||
// generate offspring, worths are recalculated if necessary
|
||||
breed (_pop, offspring);
|
||||
|
||||
// after replace, the new pop is in _pop. Worths are recalculated if necessary
|
||||
replace(_pop, offspring);
|
||||
|
||||
} while (continuator(_pop));
|
||||
}
|
||||
// eval of offspring
|
||||
popEval (_pop, offspring);
|
||||
|
||||
// after replace, the new pop is in _pop. Worths are recalculated if necessary
|
||||
replace (_pop, offspring);
|
||||
|
||||
}
|
||||
while (continuator (_pop));
|
||||
}
|
||||
|
||||
protected:
|
||||
eoContinue<EOT>& continuator;
|
||||
|
||||
eoEvalFunc<EOT>& eval;
|
||||
eoPopLoopEval<EOT> loopEval;
|
||||
eoContinue < EOT > &continuator;
|
||||
|
||||
eoPopEvalFunc<EOT>& popEval;
|
||||
|
||||
/// NSGAII sorting
|
||||
moeoNDSorting_II<EOT> sorting;
|
||||
/// Binary tournament selection
|
||||
eoDetTournamentWorthSelect<EOT> selectOne;
|
||||
/// Elitist replacement
|
||||
moeoElitistReplacement<EOT> replace;
|
||||
eoGeneralBreeder<EOT> genBreed;
|
||||
eoBreed<EOT>& breed;
|
||||
eoEvalFunc < EOT > &eval;
|
||||
eoPopLoopEval < EOT > loopEval;
|
||||
|
||||
eoPopEvalFunc < EOT > &popEval;
|
||||
|
||||
/// NSGAII sorting
|
||||
moeoNDSorting_II < EOT > sorting;
|
||||
/// Binary tournament selection
|
||||
eoDetTournamentWorthSelect < EOT > selectOne;
|
||||
/// Elitist replacement
|
||||
moeoElitistReplacement < EOT > replace;
|
||||
eoGeneralBreeder < EOT > genBreed;
|
||||
eoBreed < EOT > &breed;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -1,25 +1,14 @@
|
|||
// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
|
||||
|
||||
// "make_algo_MOEO.h"
|
||||
//-----------------------------------------------------------------------------
|
||||
// make_algo_MOEO.h
|
||||
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
|
||||
/*
|
||||
This library...
|
||||
|
||||
// (c) OPAC Team, LIFL, June 2006
|
||||
|
||||
/* This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Contact: Arnaud.Liefooghe@lifl.fr
|
||||
*/
|
||||
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef _make_algo_MOEO_h
|
||||
#define _make_algo_MOEO_h
|
||||
|
|
@ -29,10 +18,10 @@
|
|||
#include "utils/eoState.h"
|
||||
// selections
|
||||
#include "eoNDSorting.h"
|
||||
#include "eoIBEA.h"
|
||||
#include "eoBinaryQualityIndicator.h"
|
||||
#include "old/moeoIBEA.h"
|
||||
#include "old/moeoBinaryQualityIndicator.h"
|
||||
#include "eoParetoRanking.h"
|
||||
#include "eoParetoSharing.h"
|
||||
#include "moeoParetoSharing.h"
|
||||
#include "eoSelectFromWorth.h"
|
||||
#include "moeoSelectOneFromPopAndArch.h"
|
||||
// replacements
|
||||
|
|
@ -88,21 +77,22 @@ template < class EOT >
|
|||
p2w = new eoNDSorting_I < EOT > (nicheSize);
|
||||
else if (selStr == string ("NSGA-II")) // NSGA-II
|
||||
p2w = new eoNDSorting_II < EOT > ();
|
||||
/*
|
||||
else if (selStr == string("IBEA")) { // IBEA
|
||||
// the binary quality indicator
|
||||
eoBinaryQualityIndicator<EOFitness>* I;
|
||||
if (indStr == string("Epsilon"))
|
||||
I = new eoAdditiveBinaryEpsilonIndicator<EOFitness>;
|
||||
else if (indStr == string("Hypervolume"))
|
||||
I = new eoBinaryHypervolumeIndicator<EOFitness>(rho);
|
||||
else {
|
||||
string stmp = string("Invalid binary quality indicator (for IBEA): ") + indStr;
|
||||
throw std::runtime_error(stmp.c_str());
|
||||
}
|
||||
p2w = new eoIBEASorting<EOT>(I, kappa);
|
||||
}
|
||||
*/
|
||||
else if (selStr == string ("IBEA"))
|
||||
{ // IBEA
|
||||
// the binary quality indicator
|
||||
moeoBinaryQualityIndicator < EOFitness > *I;
|
||||
if (indStr == string ("Epsilon"))
|
||||
I = new moeoAdditiveBinaryEpsilonIndicator < EOFitness >;
|
||||
else if (indStr == string ("Hypervolume"))
|
||||
I = new moeoBinaryHypervolumeIndicator < EOFitness > (rho);
|
||||
else
|
||||
{
|
||||
string stmp =
|
||||
string ("Invalid binary quality indicator (for IBEA): ") + indStr;
|
||||
throw std::runtime_error (stmp.c_str ());
|
||||
}
|
||||
p2w = new moeoIBEASorting < EOT > (I, kappa);
|
||||
}
|
||||
else if (selStr == string ("ParetoRanking"))
|
||||
{ // Pareto Ranking
|
||||
eoDominanceMap < EOT > &dominance =
|
||||
|
|
@ -111,7 +101,7 @@ template < class EOT >
|
|||
}
|
||||
else if (selStr == string ("ParetoSharing"))
|
||||
{ // Pareto Sharing
|
||||
p2w = new eoParetoSharing < EOT > (nicheSize);
|
||||
p2w = new moeoParetoSharing < EOT > (nicheSize);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -221,11 +211,17 @@ template < class EOT >
|
|||
'R', "Evolution Engine").value ();
|
||||
eoReplacement < EOT > *replace;
|
||||
if (repStr == string ("Plus")) // Plus
|
||||
replace = new moeoElitistReplacement < EOT, double >(*p2w);
|
||||
{
|
||||
replace = new moeoElitistReplacement < EOT, double >(*p2w);
|
||||
}
|
||||
else if (repStr == string ("DistinctPlus")) // DistinctPlus
|
||||
replace = new moeoDisctinctElitistReplacement < EOT, double >(*p2w);
|
||||
{
|
||||
replace = new moeoDisctinctElitistReplacement < EOT, double >(*p2w);
|
||||
}
|
||||
else if (repStr == string ("Generational")) // Generational
|
||||
replace = new eoGenerationalReplacement < EOT >;
|
||||
{
|
||||
replace = new eoGenerationalReplacement < EOT >;
|
||||
}
|
||||
else
|
||||
{
|
||||
string stmp = string ("Invalid replacement: ") + repStr;
|
||||
|
|
@ -242,7 +238,7 @@ template < class EOT >
|
|||
eoGeneralBreeder < EOT > *breed =
|
||||
new eoGeneralBreeder < EOT > (*select, _op, offspringRateParam.value ());
|
||||
_state.storeFunctor (breed);
|
||||
|
||||
|
||||
// the eoEasyEA
|
||||
eoAlgo < EOT > *algo =
|
||||
new eoEasyEA < EOT > (_continue, _eval, *breed, *replace);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue