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 @@
/*
/*
* <moeoHypervolumeBinaryMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -52,8 +52,8 @@
*/
template < class ObjectiveVector >
class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
{
public:
{
public:
/**
* Ctor
@ -61,20 +61,20 @@ public:
*/
moeoHypervolumeBinaryMetric(double _rho = 1.1) : rho(_rho)
{
// not-a-maximization problem check
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
// not-a-maximization problem check
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
{
if (ObjectiveVector::Traits::maximizing(i))
if (ObjectiveVector::Traits::maximizing(i))
{
throw std::runtime_error("Hypervolume binary metric not yet implemented for a maximization problem in moeoHypervolumeBinaryMetric");
throw std::runtime_error("Hypervolume binary metric not yet implemented for a maximization problem in moeoHypervolumeBinaryMetric");
}
}
// consistency check
if (rho < 1)
// consistency check
if (rho < 1)
{
std::cout << "Warning, value used to compute the reference point rho for the hypervolume calculation must not be smaller than 1" << std::endl;
std::cout << "Adjusted to 1" << std::endl;
rho = 1;
std::cout << "Warning, value used to compute the reference point rho for the hypervolume calculation must not be smaller than 1" << std::endl;
std::cout << "Adjusted to 1" << std::endl;
rho = 1;
}
}
@ -87,21 +87,21 @@ public:
*/
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
{
double result;
// if _o2 is dominated by _o1
if ( paretoComparator(_o2,_o1) )
double result;
// if _o2 is dominated by _o1
if ( paretoComparator(_o2,_o1) )
{
result = - hypervolume(_o1, _o2, ObjectiveVector::Traits::nObjectives()-1);
result = - hypervolume(_o1, _o2, ObjectiveVector::Traits::nObjectives()-1);
}
else
else
{
result = hypervolume(_o2, _o1, ObjectiveVector::Traits::nObjectives()-1);
result = hypervolume(_o2, _o1, ObjectiveVector::Traits::nObjectives()-1);
}
return result;
return result;
}
private:
private:
/** value used to compute the reference point from the worst values for each objective */
double rho;
@ -120,47 +120,47 @@ private:
*/
double hypervolume(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj, const bool _flag = false)
{
double result;
double range = rho * bounds[_obj].range();
double max = bounds[_obj].minimum() + range;
// value of _1 for the objective _obj
double v1 = _o1[_obj];
// value of _2 for the objective _obj (if _flag=true, v2=max)
double v2;
if (_flag)
double result;
double range = rho * bounds[_obj].range();
double max = bounds[_obj].minimum() + range;
// value of _1 for the objective _obj
double v1 = _o1[_obj];
// value of _2 for the objective _obj (if _flag=true, v2=max)
double v2;
if (_flag)
{
v2 = max;
v2 = max;
}
else
else
{
v2 = _o2[_obj];
v2 = _o2[_obj];
}
// computation of the volume
if (_obj == 0)
// computation of the volume
if (_obj == 0)
{
if (v1 < v2)
if (v1 < v2)
{
result = (v2 - v1) / range;
result = (v2 - v1) / range;
}
else
else
{
result = 0;
result = 0;
}
}
else
else
{
if (v1 < v2)
if (v1 < v2)
{
result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range );
result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range );
}
else
else
{
result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range;
result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range;
}
}
return result;
return result;
}
};
};
#endif /*MOEOHYPERVOLUMEBINARYMETRIC_H_*/