23/02/07 modifications
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@184 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
parent
8312d91a84
commit
086b51c370
20 changed files with 772 additions and 970 deletions
|
|
@ -14,24 +14,20 @@
|
|||
#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 >
|
||||
{
|
||||
public:
|
||||
// virtual const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo){}
|
||||
};
|
||||
template < class MOEOT >
|
||||
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 >
|
||||
template < class MOEOT >
|
||||
class moeoObjectiveComparator : public moeoComparator < MOEOT >
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -39,56 +35,18 @@ public:
|
|||
* @param _moeo1 the first solution
|
||||
* @param _moeo2 the second solution
|
||||
*/
|
||||
const bool operator () (const MOEOT & _moeo1, const MOEOT & _moeo2)
|
||||
{
|
||||
return _moeo1.objectiveVector () < _moeo2.objectiveVector ();
|
||||
}
|
||||
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
|
||||
* Functor allowing to compare two solutions according to their fitness values, then according to their diversity 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 >
|
||||
template < class MOEOT >
|
||||
class moeoFitnessThenDiversityComparator : public moeoComparator < MOEOT >
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -96,25 +54,25 @@ public:
|
|||
* @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 ();
|
||||
}
|
||||
}
|
||||
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
|
||||
* 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 >
|
||||
template < class MOEOT >
|
||||
class moeoDiversityThenFitnessComparator : public moeoComparator < MOEOT >
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
@ -122,64 +80,18 @@ public:
|
|||
* @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::nObjectives(); i++)
|
||||
if (_moeo1.diversity() == _moeo2.diversity())
|
||||
{
|
||||
// first, we have to check if the 2 objective values are not equal on the ith objective
|
||||
if ( fabs(_moeo1.objectiveVector()[i] - _moeo2.objectiveVector()[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 _moeo1.fitness() < _moeo2.fitness();
|
||||
}
|
||||
else
|
||||
{
|
||||
return _moeo1.diversity() < _moeo2.diversity();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
#endif /*MOEOCOMPARATOR_H_ */
|
||||
|
||||
#endif /*MOEOCOMPARATOR_H_*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue