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 @@
/*
/*
* <moeoDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -45,8 +45,8 @@
*/
template < class MOEOT , class Type >
class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type >
{
public:
{
public:
/**
* Nothing to do
@ -74,6 +74,6 @@ public:
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
{}
};
};
#endif /*MOEODISTANCE_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoDistanceMatrix.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,8 +47,8 @@
*/
template < class MOEOT , class Type >
class moeoDistanceMatrix : public eoUF < const eoPop < MOEOT > &, void > , public std::vector< std::vector < Type > >
{
public:
{
public:
using std::vector< std::vector < Type > > :: size;
using std::vector< std::vector < Type > > :: operator[];
@ -61,10 +61,10 @@ public:
*/
moeoDistanceMatrix (unsigned int _size, moeoDistance < MOEOT , Type > & _distance) : distance(_distance)
{
this->resize(_size);
for (unsigned int i=0; i<_size; i++)
this->resize(_size);
for (unsigned int i=0; i<_size; i++)
{
this->operator[](i).resize(_size);
this->operator[](i).resize(_size);
}
}
@ -75,27 +75,27 @@ public:
*/
void operator()(const eoPop < MOEOT > & _pop)
{
// 1 - setup the bounds (if necessary)
distance.setup(_pop);
// 2 - compute distances
this->operator[](0).operator[](0) = Type();
for (unsigned int i=0; i<size(); i++)
// 1 - setup the bounds (if necessary)
distance.setup(_pop);
// 2 - compute distances
this->operator[](0).operator[](0) = Type();
for (unsigned int i=0; i<size(); i++)
{
this->operator[](i).operator[](i) = Type();
for (unsigned int j=0; j<i; j++)
this->operator[](i).operator[](i) = Type();
for (unsigned int j=0; j<i; j++)
{
this->operator[](i).operator[](j) = distance(_pop[i], _pop[j]);
this->operator[](j).operator[](i) = this->operator[](i).operator[](j);
this->operator[](i).operator[](j) = distance(_pop[i], _pop[j]);
this->operator[](j).operator[](i) = this->operator[](i).operator[](j);
}
}
}
private:
private:
/** the distance to use */
moeoDistance < MOEOT , Type > & distance;
};
};
#endif /*MOEODISTANCEMATRIX_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoEuclideanDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,8 +47,8 @@
*/
template < class MOEOT >
class moeoEuclideanDistance : public moeoNormalizedDistance < MOEOT >
{
public:
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -61,23 +61,23 @@ public:
*/
const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
double result = 0.0;
double tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
double result = 0.0;
double tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
tmp1 = (_moeo1.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
tmp2 = (_moeo2.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
result += (tmp1-tmp2) * (tmp1-tmp2);
tmp1 = (_moeo1.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
tmp2 = (_moeo2.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
result += (tmp1-tmp2) * (tmp1-tmp2);
}
return sqrt(result);
return sqrt(result);
}
private:
private:
/** the bounds for every objective */
using moeoNormalizedDistance < MOEOT > :: bounds;
};
};
#endif /*MOEOEUCLIDEANDISTANCE_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoManhattanDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,8 +47,8 @@
*/
template < class MOEOT >
class moeoManhattanDistance : public moeoNormalizedDistance < MOEOT >
{
public:
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -61,23 +61,23 @@ public:
*/
const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2)
{
double result = 0.0;
double tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
double result = 0.0;
double tmp1, tmp2;
for (unsigned int i=0; i<ObjectiveVector::nObjectives(); i++)
{
tmp1 = (_moeo1.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
tmp2 = (_moeo2.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
result += fabs(tmp1-tmp2);
tmp1 = (_moeo1.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
tmp2 = (_moeo2.objectiveVector()[i] - bounds[i].minimum()) / bounds[i].range();
result += fabs(tmp1-tmp2);
}
return result;
return result;
}
private:
private:
/** the bounds for every objective */
using moeoNormalizedDistance < MOEOT > :: bounds;
};
};
#endif /*MOEOMANHATTANDISTANCE_H_*/

View file

@ -1,4 +1,4 @@
/*
/*
* <moeoNormalizedDistance.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,8 +47,8 @@
*/
template < class MOEOT , class Type = double >
class moeoNormalizedDistance : public moeoDistance < MOEOT , Type >
{
public:
{
public:
/** the objective vector type of the solutions */
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
@ -59,11 +59,11 @@ public:
*/
moeoNormalizedDistance()
{
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
bounds.resize(ObjectiveVector::Traits::nObjectives());
// initialize bounds in case someone does not want to use them
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
bounds[i] = eoRealInterval(0,1);
bounds[i] = eoRealInterval(0,1);
}
}
@ -73,7 +73,7 @@ public:
*/
static double tiny()
{
return 1e-6;
return 1e-6;
}
@ -83,18 +83,18 @@ public:
*/
virtual void setup(const eoPop < MOEOT > & _pop)
{
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
double min, max;
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
min = _pop[0].objectiveVector()[i];
max = _pop[0].objectiveVector()[i];
for (unsigned int j=1; j<_pop.size(); j++)
{
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
min = std::min(min, _pop[j].objectiveVector()[i]);
max = std::max(max, _pop[j].objectiveVector()[i]);
}
// setting of the bounds for the objective i
setup(min, max, i);
// setting of the bounds for the objective i
setup(min, max, i);
}
}
@ -107,12 +107,12 @@ public:
*/
virtual void setup(double _min, double _max, unsigned int _obj)
{
if (_min == _max)
if (_min == _max)
{
_min -= tiny();
_max += tiny();
_min -= tiny();
_max += tiny();
}
bounds[_obj] = eoRealInterval(_min, _max);
bounds[_obj] = eoRealInterval(_min, _max);
}
@ -123,15 +123,15 @@ public:
*/
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
{
bounds[_obj] = _realInterval;
bounds[_obj] = _realInterval;
}
protected:
protected:
/** the bounds for every objective (bounds[i] = bounds for the objective i) */
std::vector < eoRealInterval > bounds;
};
};
#endif /*MOEONORMALIZEDDISTANCE_H_*/