paradiseo/trunk/paradiseo-moeo/src/old/moeoParetoPhenDist.h
liefooga 48fae831e4 old update
git-svn-id: svn://scm.gforge.inria.fr/svnroot/paradiseo@156 331e1502-861f-0410-8da2-ba01fb791d7f
2007-01-15 13:51:42 +00:00

50 lines
1.2 KiB
C++

// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
//-----------------------------------------------------------------------------
// moeoParetoPhenDist.h
// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
/*
This library...
Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
*/
//-----------------------------------------------------------------------------
#include<eoParetoFitness.h>
template < class EOT, class DistType > class moeoParetoPhenDist
{
public:
virtual DistType operator ()(const EOT & eopf1, const EOT & eopf2) = 0;
};
//Euclidien distance
template < class EOT, class DistType =
double >class moeoParetoEuclidDist:public moeoParetoPhenDist < EOT,
DistType >
{
public:
DistType operator () (const EOT & eopf1, const EOT & eopf2)
{
double res = 0.0;
double max = 0.0;
double temp;
for (unsigned i = 0; i < eopf1.fitness ().size (); ++i)
{
temp =
(eopf1.fitness ().operator[](i) -
eopf2.fitness ().operator[](i)) * (eopf1.fitness ().operator[](i) -
eopf2.fitness ().operator[](i));
if (temp > max)
max = temp; /* for normalization */
res = res + temp;
}
return sqrt (res / max);
}
};