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 @@
/*
/*
* <moeoContributionMetric.h>
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
* (C) OPAC Team, LIFL, 2002-2007
@ -47,44 +47,47 @@
*/
template < class ObjectiveVector >
class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
{
public:
{
public:
/**
* Returns the contribution of the Pareto set '_set1' relatively to the Pareto set '_set2'
* @param _set1 the first Pareto set
* @param _set2 the second Pareto set
*/
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
unsigned int c = card_C(_set1, _set2);
unsigned int w1 = card_W(_set1, _set2);
unsigned int n1 = card_N(_set1, _set2);
unsigned int w2 = card_W(_set2, _set1);
unsigned int n2 = card_N(_set2, _set1);
return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int c = card_C(_set1, _set2);
unsigned int w1 = card_W(_set1, _set2);
unsigned int n1 = card_N(_set1, _set2);
unsigned int w2 = card_W(_set2, _set1);
unsigned int n2 = card_N(_set2, _set1);
return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
}
private:
private:
/** Functor to compare two objective vectors according to Pareto dominance relation */
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
/**
* Returns the number of solutions both in '_set1' and '_set2'
* @param _set1 the first Pareto set
* @param _set2 the second Pareto set
*/
unsigned int card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
unsigned int c=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int j=0; j<_set2.size(); j++)
if (_set1[i] == _set2[j]) {
c++;
break;
}
return c;
unsigned int card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int c=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int j=0; j<_set2.size(); j++)
if (_set1[i] == _set2[j])
{
c++;
break;
}
return c;
}
@ -93,16 +96,17 @@ private:
* @param _set1 the first Pareto set
* @param _set2 the second Pareto set
*/
unsigned int card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
unsigned int w=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int j=0; j<_set2.size(); j++)
if (paretoComparator(_set2[j], _set1[i]))
{
w++;
break;
}
return w;
unsigned int card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int w=0;
for (unsigned int i=0; i<_set1.size(); i++)
for (unsigned int j=0; j<_set2.size(); j++)
if (paretoComparator(_set2[j], _set1[i]))
{
w++;
break;
}
return w;
}
@ -111,22 +115,24 @@ private:
* @param _set1 the first Pareto set
* @param _set2 the second Pareto set
*/
unsigned int card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2) {
unsigned int n=0;
for (unsigned int i=0; i<_set1.size(); i++) {
bool domin_rel = false;
for (unsigned int j=0; j<_set2.size(); j++)
if ( (paretoComparator(_set2[j], _set1[i])) || (paretoComparator(_set1[i], _set2[j])) )
{
domin_rel = true;
break;
}
if (! domin_rel)
n++;
unsigned int card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
{
unsigned int n=0;
for (unsigned int i=0; i<_set1.size(); i++)
{
bool domin_rel = false;
for (unsigned int j=0; j<_set2.size(); j++)
if ( (paretoComparator(_set2[j], _set1[i])) || (paretoComparator(_set1[i], _set2[j])) )
{
domin_rel = true;
break;
}
if (! domin_rel)
n++;
}
return n;
return n;
}
};
};
#endif /*MOEOCONTRIBUTIONMETRIC_H_*/