New style for MOEO

git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@788 331e1502-861f-0410-8da2-ba01fb791d7f
This commit is contained in:
canape 2007-11-16 11:29:25 +00:00
commit 39709d3d12
103 changed files with 2607 additions and 2521 deletions

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoAggregativeComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoAggregativeComparator : public moeoComparator < MOEOT >
{
public:
{
public:
/**
* Ctor.
@ -64,17 +64,17 @@ public:
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() );
return ( weightFitness * _moeo1.fitness() + weightDiversity * _moeo1.diversity() ) < ( weightFitness * _moeo2.fitness() + weightDiversity * _moeo2.diversity() );
}
private:
private:
/** the weight for fitness */
double weightFitness;
/** the weight for diversity */
double weightDiversity;
};
};
#endif /*MOEOAGGREGATIVECOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -44,6 +44,7 @@
* Functor allowing to compare two solutions.
*/
template < class MOEOT >
class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool > {};
class moeoComparator : public eoBF < const MOEOT &, const MOEOT &, const bool >
{};
#endif /*MOEOCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoDiversityThenFitnessComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoDiversityThenFitnessComparator : public moeoComparator < MOEOT >
{
public:
{
public:
/**
* Returns true if _moeo1 < _moeo2 according to their diversity values, then according to their fitness values
@ -55,16 +55,16 @@ public:
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
if (_moeo1.diversity() == _moeo2.diversity())
if (_moeo1.diversity() == _moeo2.diversity())
{
return _moeo1.fitness() < _moeo2.fitness();
return _moeo1.fitness() < _moeo2.fitness();
}
else
else
{
return _moeo1.diversity() < _moeo2.diversity();
return _moeo1.diversity() < _moeo2.diversity();
}
}
};
};
#endif /*MOEODIVERSITYTHENFITNESSCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoFitnessThenDiversityComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoFitnessThenDiversityComparator : public moeoComparator < MOEOT >
{
public:
{
public:
/**
* Returns true if _moeo1 < _moeo2 according to their fitness values, then according to their diversity values
@ -55,16 +55,16 @@ public:
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
if (_moeo1.fitness() == _moeo2.fitness())
if (_moeo1.fitness() == _moeo2.fitness())
{
return _moeo1.diversity() < _moeo2.diversity();
return _moeo1.diversity() < _moeo2.diversity();
}
else
else
{
return _moeo1.fitness() < _moeo2.fitness();
return _moeo1.fitness() < _moeo2.fitness();
}
}
};
};
#endif /*MOEOFITNESSTHENDIVERSITYCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoGDominanceObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -48,8 +48,8 @@
*/
template < class ObjectiveVector >
class moeoGDominanceObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
{
public:
/**
* Ctor.
@ -66,27 +66,27 @@ public:
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
unsigned int flag1 = flag(_objectiveVector1);
unsigned int flag2 = flag(_objectiveVector2);
if (flag2==0)
unsigned int flag1 = flag(_objectiveVector1);
unsigned int flag2 = flag(_objectiveVector2);
if (flag2==0)
{
// cannot dominate
return false;
// cannot dominate
return false;
}
else if ( (flag2==1) && (flag1==0) )
else if ( (flag2==1) && (flag1==0) )
{
// is dominated
return true;
// is dominated
return true;
}
else // (flag1==1) && (flag2==1)
else // (flag1==1) && (flag2==1)
{
// both are on the good region, so let's use the classical Pareto dominance
return paretoComparator(_objectiveVector1, _objectiveVector2);
// both are on the good region, so let's use the classical Pareto dominance
return paretoComparator(_objectiveVector1, _objectiveVector2);
}
}
private:
private:
/** the reference point */
ObjectiveVector & ref;
@ -100,28 +100,28 @@ private:
*/
unsigned int flag(const ObjectiveVector & _objectiveVector)
{
unsigned int result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
unsigned int result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
{
if (_objectiveVector[i] > ref[i])
if (_objectiveVector[i] > ref[i])
{
result=0;
result=0;
}
}
if (result==0)
if (result==0)
{
result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
result=1;
for (unsigned int i=0; i<ref.nObjectives(); i++)
{
if (_objectiveVector[i] < ref[i])
if (_objectiveVector[i] < ref[i])
{
result=0;
result=0;
}
}
}
return result;
return result;
}
};
};
#endif /*MOEOGDOMINANCEOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoObjectiveObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class ObjectiveVector >
class moeoObjectiveObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
{
public:
/**
* Returns true if _objectiveVector1 < _objectiveVector2 on the first objective, then on the second, and so on
@ -55,23 +55,23 @@ public:
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
if (_objectiveVector1[i] < _objectiveVector2[i])
if (_objectiveVector1[i] < _objectiveVector2[i])
{
return true;
return true;
}
else
else
{
return false;
return false;
}
}
}
return false;
return false;
}
};
};
#endif /*MOEOOBJECTIVEOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -46,6 +46,7 @@
* The template argument ObjectiveVector have to be a moeoObjectiveVector.
*/
template < class ObjectiveVector >
class moeoObjectiveVectorComparator : public eoBF < const ObjectiveVector &, const ObjectiveVector &, const bool > {};
class moeoObjectiveVectorComparator : public eoBF < const ObjectiveVector &, const ObjectiveVector &, const bool >
{};
#endif /*MOEOOBJECTIVEVECTORCOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoOneObjectiveComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT >
class moeoOneObjectiveComparator : public moeoComparator < MOEOT >
{
public:
{
public:
/**
* Ctor.
@ -54,9 +54,9 @@ public:
*/
moeoOneObjectiveComparator(unsigned int _obj) : obj(_obj)
{
if (obj > MOEOT::ObjectiveVector::nObjectives())
if (obj > MOEOT::ObjectiveVector::nObjectives())
{
throw std::runtime_error("Problem with the index of objective in moeoOneObjectiveComparator");
throw std::runtime_error("Problem with the index of objective in moeoOneObjectiveComparator");
}
}
@ -68,15 +68,15 @@ public:
*/
const bool operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj];
return _moeo1.objectiveVector()[obj] < _moeo2.objectiveVector()[obj];
}
private:
private:
/** the index of objective */
unsigned int obj;
};
};
#endif /*MOEOONEOBJECTIVECOMPARATOR_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoParetoObjectiveVectorComparator.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class ObjectiveVector >
class moeoParetoObjectiveVectorComparator : public moeoObjectiveVectorComparator < ObjectiveVector >
{
public:
{
public:
/**
* Returns true if _objectiveVector1 is dominated by _objectiveVector2
@ -55,41 +55,41 @@ public:
*/
const bool operator()(const ObjectiveVector & _objectiveVector1, const ObjectiveVector & _objectiveVector2)
{
bool dom = false;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
bool dom = false;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
// first, we have to check if the 2 objective values are not equal for the ith objective
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
// first, we have to check if the 2 objective values are not equal for the ith objective
if ( fabs(_objectiveVector1[i] - _objectiveVector2[i]) > ObjectiveVector::Traits::tolerance() )
{
// if the ith objective have to be minimized...
if (ObjectiveVector::minimizing(i))
// if the ith objective have to be minimized...
if (ObjectiveVector::minimizing(i))
{
if (_objectiveVector1[i] > _objectiveVector2[i])
if (_objectiveVector1[i] > _objectiveVector2[i])
{
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
}
else
else
{
return false; //_objectiveVector2 cannot dominate _objectiveVector1
return false; //_objectiveVector2 cannot dominate _objectiveVector1
}
}
// if the ith objective have to be maximized...
else if (ObjectiveVector::maximizing(i))
// if the ith objective have to be maximized...
else if (ObjectiveVector::maximizing(i))
{
if (_objectiveVector1[i] < _objectiveVector2[i])
if (_objectiveVector1[i] < _objectiveVector2[i])
{
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
dom = true; //_objectiveVector1[i] is not better than _objectiveVector2[i]
}
else
else
{
return false; //_objectiveVector2 cannot dominate _objectiveVector1
return false; //_objectiveVector2 cannot dominate _objectiveVector1
}
}
}
}
return dom;
return dom;
}
};
};
#endif /*MOEOPARETOOBJECTIVEVECTORCOMPARATOR_H_*/