documentation modifications

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@178 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
liefooga 2007-02-06 16:35:01 +00:00
commit 4b45aadd5d
16 changed files with 76 additions and 73 deletions

View file

@ -14,19 +14,20 @@
#define MOEOARCHIVE_H_
#include <eoPop.h>
#include <moeoObjectiveVectorComparator.h>
/**
* An archive is a secondary population that stores non-dominated solutions
* 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;
using std::vector < MOEOT > :: size;
using std::vector < MOEOT > :: operator[];
using std::vector < MOEOT > :: back;
using std::vector < MOEOT > :: pop_back;
/**
@ -57,9 +58,9 @@ public:
*/
bool dominates (const ObjectiveVector & _objectiveVector) const
{
for (unsigned i = 0; i < size(); i++)
for (unsigned i = 0; i<size(); i++)
{
if ( comparator(operator[](i).fitness(), _objectiveVector)==1 )
if ( comparator(operator[](i).fitness(), _objectiveVector) == 1 )
{
return true;
}
@ -74,9 +75,9 @@ public:
*/
bool contains (const ObjectiveVector & _objectiveVector) const
{
for (unsigned i = 0; i < size; i++)
for (unsigned i = 0; i<size(); i++)
{
if (operator[](i).fitness () == _objectiveVector)
if (operator[](i).fitness() == _objectiveVector)
{
return true;
}
@ -92,16 +93,14 @@ public:
void update (const MOEOT & _moeo)
{
// first step: removing the dominated solutions from the archive
for (unsigned j = 0; j < size();)
for (unsigned j=0; j<size();)
{
// if _moeo.fitness() dominates operator[](j).fitness()
//if ( comparator(_moeo.fitness(), operator[](j).fitness())==1 )
// if _moeo dominates the jth solution contanied in the archive
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();
@ -116,9 +115,8 @@ public:
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 )
// if the jth solution contanied in the archive dominates _moeo
if ( comparator(operator[](j).objectiveVector(), _moeo.objectiveVector()) == 1 )
{
dom = true;
break;

View file

@ -18,7 +18,7 @@
#include <moeoArchive.h>
/**
* This class allows to update the archive at each generation with newly found non-dominated solutions
* This class allows to update the archive at each generation with newly found non-dominated solutions.
*/
template < class EOT >
class moeoArchiveUpdater : public eoUpdater

View file

@ -19,27 +19,30 @@
/**
* 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
* and so working and updating the same archive of non-dominated solutions.
*/
template < class MOEOT >
class moeoCombinedLS : public moeoLS < 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
* @param _first_mols the first multi-objective local search to add
*/
moeoCombinedLS(moeoEvalFunc < MOEOT > & _eval, moeoLS < MOEOT > & _first_ls) : eval (_eval) {
combinedLS.push_back (& _first_ls);
moeoCombinedLS(moeoEvalFunc < MOEOT > & _eval, moeoLS < MOEOT > & _first_mols) : eval (_eval)
{
combinedLS.push_back (& _first_mols);
}
/**
* Adds a new local search to combine
* @param _ls the multi-objective local search to add
* @param _mols the multi-objective local search to add
*/
void add(moeoLS < MOEOT > & _ls) {
combinedMOLS.push_back(& _ls);
void add(moeoLS < MOEOT > & _mols)
{
combinedMOLS.push_back(& _mols);
}
/**
@ -48,10 +51,11 @@ public:
* @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));
void operator () (const MOEOT & _moeo, moeoArchive < MOEOT > & _arch)
{
eval(const_cast < MOEOT & > (_moeo));
for (unsigned i=0; i<combinedLS.size(); i++)
combinedLS[i] -> operator()(_eo, _arch);
combinedLS[i] -> operator()(_moeo, _arch);
}

View file

@ -10,14 +10,13 @@
*/
//-----------------------------------------------------------------------------
#ifndef MOEOPOPSORTER_H_
#define MOEOPOPSORTER_H_
#ifndef MOEOCOMPARATOR_H_
#define MOEOCOMPARATOR_H_
#include <eoFunctor.h>
#include <eoPop.h>
/**
* Functor allowing to compare two solutions
* Functor allowing to compare two solutions.
*/
template < class MOEOT >
class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool >
@ -25,7 +24,7 @@ class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool >
/**
* Functor allowing to compare two solutions according to their first objective value, then their second, and so on
* 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 >
@ -44,7 +43,7 @@ public:
/**
* Functor allowing to compare two solutions according to their fitness values
* Functor allowing to compare two solutions according to their fitness values.
*/
template < class MOEOT >
class moeoFitnessComparator : public moeoComparator < MOEOT >
@ -63,7 +62,7 @@ public:
/**
* Functor allowing to compare two solutions according to their diversity values
* Functor allowing to compare two solutions according to their diversity values.
*/
template < class MOEOT >
class moeoDiversityComparator : public moeoComparator < MOEOT >
@ -82,7 +81,7 @@ public:
/**
* Functor allowing to compare two solutions according to their fitness values, then according to their diversity values
* 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 >
@ -108,7 +107,7 @@ public:
/**
* Functor allowing to compare two solutions according to their diversity values, then according to their fitness values
* 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 >
@ -134,7 +133,7 @@ public:
/**
* Functor allowing to compare two solutions according to Pareto dominance relation => USEFULL ???
* Functor allowing to compare two solutions according to Pareto dominance relation. => USEFULL ???
*
template < class MOEOT >
class moeoParetoDominanceComparator : public moeoComparator < MOEOT >
@ -179,4 +178,4 @@ public:
};
*/
#endif /*MOEOPOPSORTER_H_*/
#endif /*MOEOCOMPARATOR_H_*/

View file

@ -17,7 +17,7 @@
#include <eoPop.h>
/**
* Functor that sets the diversity values of a whole population
* Functor that sets the diversity values of a whole population.
*/
template < class MOEOT >
class moeoDiversityAssignment : public eoUF < eoPop < MOEOT > &, void >

View file

@ -16,7 +16,7 @@
#include <eoAlgo.h>
/**
* Abstract class for multi-objective evolutionary algorithms
* Abstract class for multi-objective evolutionary algorithms.
*/
template < class MOEOT >
class moeoEA : public eoAlgo < MOEOT > {};

View file

@ -14,15 +14,15 @@
#define MOEOFASTNONDOMINATEDSORTINGFITNESSASSIGNMENT_H_
#include <eoPop.h>
#include <moeoFitnessAssignment.h>
#include <moeoComparator.h>
#include <moeoFitnessAssignment.h>
#include <moeoObjectiveVectorComparator.h>
/**
* 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).
* 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 >

View file

@ -17,7 +17,7 @@
#include <eoPop.h>
/**
* Functor that sets the fitness values of a whole population
* Functor that sets the fitness values of a whole population.
*/
template < class MOEOT >
class moeoFitnessAssignment : public eoUF < eoPop < MOEOT > &, void >
@ -25,7 +25,7 @@ class moeoFitnessAssignment : public eoUF < eoPop < MOEOT > &, void >
/**
* moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies
* moeoScalarFitnessAssignment is a moeoFitnessAssignment for scalar strategies.
*/
template < class MOEOT >
class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT >
@ -33,7 +33,7 @@ class moeoScalarFitnessAssignment : public moeoFitnessAssignment < MOEOT >
/**
* moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies
* moeoCriterionBasedFitnessAssignment is a moeoFitnessAssignment for criterion-based strategies.
*/
template < class MOEOT >
class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >
@ -41,7 +41,7 @@ class moeoCriterionBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT
/**
* moeoParetoBasedFitnessAssignment is a moeoFitnessAssignment for Pareto-based strategies
* moeoParetoBasedFitnessAssignment is a moeoFitnessAssignment for Pareto-based strategies.
*/
template < class MOEOT >
class moeoParetoBasedFitnessAssignment : public moeoFitnessAssignment < MOEOT >

View file

@ -17,7 +17,7 @@
#include <moeoGenerationalReplacement.h>
/**
* Generational replacement: only the new individuals are preserved
* Generational replacement: only the new individuals are preserved.
*/
template < class MOEOT >
class moeoGenerationalReplacement : public moeoReplacement < MOEOT >, public eoGenerationalReplacement < MOEOT > {};

View file

@ -33,10 +33,10 @@ public:
* Ctor
* @param _term stopping criteria
* @param _select selector
* @param _ls a multi-objective local search
* @param _mols 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)
eoHybridLS (eoContinue < MOEOT > & _term, eoSelect < MOEOT > & _select, moeoLS < MOEOT > & _mols, moeoArchive < MOEOT > & _arch) : term(_term), select(_select), mols(_mols), arch(_arch)
{}
/**
@ -50,9 +50,9 @@ public:
eoPop < MOEOT > selectedSolutions;
select(arch, selectedSolutions);
// apply the local search to every selected solution
for (unsigned i=0; i<selectedSolutions.size(); i ++)
for (unsigned i=0; i<selectedSolutions.size(); i++)
{
ls(selectedSolutions[i], arch);
mols(selectedSolutions[i], arch);
}
}
}
@ -65,7 +65,7 @@ private:
/** selector */
eoSelect < MOEOT > & select;
/** multi-objective local search */
moeoLS < MOEOT > & ls;
moeoLS < MOEOT > & mols;
/** archive */
moeoArchive < MOEOT > & arch;

View file

@ -26,7 +26,7 @@ class moeoObjectiveVectorComparator : public eoBF < const ObjectiveVector &, con
/**
* This functor class allows to compare 2 objective vectors according to Pareto dominance
* This functor class allows to compare 2 objective vectors according to Pareto dominance.
*/
template < class ObjectiveVector >
class moeoParetoObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >

View file

@ -18,7 +18,7 @@
#include <stdexcept>
/**
* A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized
* A traits class for moeoObjectiveVector to specify the number of objectives and which ones have to be minimized or maximized.
*/
class moeoObjectiveVectorTraits
{

View file

@ -17,7 +17,7 @@
#include <eoRandomSelect.h>
/**
* Selection strategy that selects only one element randomly from a whole population
* Selection strategy that selects only one element randomly from a whole population.
*/
template < class MOEOT >
class moeoRandomSelectOne : public moeoSelectOne < MOEOT >, public eoRandomSelect < MOEOT > {};

View file

@ -16,7 +16,7 @@
#include <eoReplacement.h>
/**
* Replacement strategy for multi-objective optimization
* Replacement strategy for multi-objective optimization.
*/
template < class MOEOT >
class moeoReplacement : public eoReplacement < MOEOT > {};

View file

@ -16,7 +16,7 @@
#include <eoSelectOne.h>
/**
* Selection strategy for multi-objective optimization that selects only one element from a whole population
* Selection strategy for multi-objective optimization that selects only one element from a whole population.
*/
template < class MOEOT >
class moeoSelectOne : public eoSelectOne < MOEOT > {};

View file

@ -22,8 +22,8 @@
/**
* Elitist selection process that consists in choosing individuals in the archive as well as in the current population.
*/
template<class EOT>
class moeoSelectOneFromPopAndArch : public moeoSelectOne<EOT>
template < class MOEOT >
class moeoSelectOneFromPopAndArch : public moeoSelectOne < MOEOT >
{
public:
@ -34,24 +34,25 @@ public:
* @param _arch the archive
* @param _ratioFromPop the ratio of selected individuals from the population
*/
moeoSelectOneFromPopAndArch (moeoSelectOne<EOT> & _popSelectOne, moeoSelectOne<EOT> _archSelectOne, moeoArchive <EOT> & _arch, double _ratioFromPop=0.5)
moeoSelectOneFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoSelectOne < MOEOT > _archSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5)
: popSelectOne(_popSelectOne), archSelectOne(_archSelectOne), arch(_arch), ratioFromPop(_ratioFromPop)
{}
/**
* Ctor - the archive's selection operator is a random selector
* 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<EOT> & _popSelectOne, moeoArchive <EOT> & _arch, double _ratioFromPop=0.5)
moeoSelectOneFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5)
: popSelectOne(_popSelectOne), archSelectOne(randomSelectOne), arch(_arch), ratioFromPop(_ratioFromPop)
{}
/**
* The selection process
*/
virtual const EOT & operator () (const eoPop<EOT> & pop) {
virtual const MOEOT & operator () (const eoPop < MOEOT > & pop)
{
if (arch.size() > 0)
if (rng.flip(ratioFromPop))
return popSelectOne(pop);
@ -64,7 +65,8 @@ public:
/**
* Setups some population stats
*/
virtual void setup (const eoPop<EOT> & _pop) {
virtual void setup (const eoPop < MOEOT > & _pop)
{
popSelectOne.setup(_pop);
}
@ -72,15 +74,15 @@ public:
private:
/** The population's selection operator */
moeoSelectOne<EOT> & popSelectOne;
moeoSelectOne < MOEOT > & popSelectOne;
/** The archive's selection operator */
moeoSelectOne<EOT> & archSelectOne;
moeoSelectOne < MOEOT > & archSelectOne;
/** The archive */
moeoArchive <EOT> & arch;
moeoArchive < MOEOT > & arch;
/** The ratio of selected individuals from the population*/
double ratioFromPop;
/** A random selection operator */
moeoRandomSelectOne<EOT> randomSelectOne;
/** A random selection operator (used as default for archSelectOne) */
moeoRandomSelectOne< MOEOT > randomSelectOne;
};