Migration from SVN
This commit is contained in:
parent
d7d6c3a217
commit
8cd56f37db
29069 changed files with 0 additions and 4096888 deletions
109
moeo/src/metric/moeoAdditiveEpsilonBinaryMetric.h
Normal file
109
moeo/src/metric/moeoAdditiveEpsilonBinaryMetric.h
Normal file
|
|
@ -0,0 +1,109 @@
|
|||
/*
|
||||
* <moeoAdditiveEpsilonBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOADDITIVEEPSILONBINARYMETRIC_H_
|
||||
#define MOEOADDITIVEEPSILONBINARYMETRIC_H_
|
||||
|
||||
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
|
||||
|
||||
/**
|
||||
* Additive epsilon binary metric allowing to compare two objective vectors as proposed in
|
||||
* Zitzler E., Thiele L., Laumanns M., Fonseca C. M., Grunert da Fonseca V.:
|
||||
* Performance Assessment of Multiobjective Optimizers: An Analysis and Review. IEEE Transactions on Evolutionary Computation 7(2), pp.117–132 (2003).
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoAdditiveEpsilonBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns the minimal distance by which the objective vector _o1 must be translated in all objectives
|
||||
* so that it weakly dominates the objective vector _o2
|
||||
* @warning don't forget to set the bounds for every objective before the call of this function
|
||||
* @param _o1 the first objective vector
|
||||
* @param _o2 the second objective vector
|
||||
*/
|
||||
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
|
||||
{
|
||||
// computation of the epsilon value for the first objective
|
||||
double result = epsilon(_o1, _o2, 0);
|
||||
// computation of the epsilon value for the other objectives
|
||||
double tmp;
|
||||
for (unsigned int i=1; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
{
|
||||
tmp = epsilon(_o1, _o2, i);
|
||||
result = std::max(result, tmp);
|
||||
}
|
||||
// returns the maximum epsilon value
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** the bounds for every objective */
|
||||
using moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > :: bounds;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the epsilon value by which the objective vector _o1 must be translated in the objective _obj
|
||||
* so that it dominates the objective vector _o2
|
||||
* @param _o1 the first objective vector
|
||||
* @param _o2 the second objective vector
|
||||
* @param _obj the index of the objective
|
||||
*/
|
||||
double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj)
|
||||
{
|
||||
double result;
|
||||
// if the objective _obj have to be minimized
|
||||
if (ObjectiveVector::Traits::minimizing(_obj))
|
||||
{
|
||||
// _o1[_obj] - _o2[_obj]
|
||||
result = ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
|
||||
}
|
||||
// if the objective _obj have to be maximized
|
||||
else
|
||||
{
|
||||
// _o2[_obj] - _o1[_obj]
|
||||
result = ( (_o2[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() ) - ( (_o1[_obj] - bounds[_obj].minimum()) / bounds[_obj].range() );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOADDITIVEEPSILONBINARYMETRIC_H_*/
|
||||
138
moeo/src/metric/moeoContributionMetric.h
Normal file
138
moeo/src/metric/moeoContributionMetric.h
Normal file
|
|
@ -0,0 +1,138 @@
|
|||
/*
|
||||
* <moeoContributionMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOCONTRIBUTIONMETRIC_H_
|
||||
#define MOEOCONTRIBUTIONMETRIC_H_
|
||||
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set
|
||||
* (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324)
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of solutions in '_set1' dominating at least one solution of '_set2'
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the number of solutions in '_set1' having no relation of dominance with those from '_set2'
|
||||
* @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++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOCONTRIBUTIONMETRIC_H_*/
|
||||
86
moeo/src/metric/moeoDistanceMetric.h
Normal file
86
moeo/src/metric/moeoDistanceMetric.h
Normal file
|
|
@ -0,0 +1,86 @@
|
|||
/*
|
||||
* <moeoDistanceMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
* François Legillon
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef MOEODISTANCEMETRIC_H_
|
||||
#define MOEODISTANCEMETRIC_H_
|
||||
|
||||
#include <cmath>
|
||||
#include <distance/moeoObjSpaceDistance.h>
|
||||
|
||||
/**
|
||||
Adapter to use Distances as a metric
|
||||
*/
|
||||
template < class MOEOT>
|
||||
class moeoDistanceMetric : public moeoUnaryMetric < typename MOEOT::ObjectiveVector , typename MOEOT::Fitness >
|
||||
{
|
||||
public:
|
||||
typedef typename MOEOT::ObjectiveVector ObjectiveVector;
|
||||
typedef typename MOEOT::Fitness Fitness;
|
||||
|
||||
/**
|
||||
constructor with a normalizer
|
||||
@param _distance the distance
|
||||
@param _referencePoint the point from which we evaluate the distance
|
||||
@param _normalizer the normalizer
|
||||
*/
|
||||
moeoDistanceMetric(moeoObjSpaceDistance<MOEOT> &_distance, const ObjectiveVector &_referencePoint,moeoObjectiveVectorNormalizer<MOEOT>& _normalizer): distance(_distance), reference(_referencePoint),normalizer(_normalizer){}
|
||||
|
||||
/**
|
||||
constructor with a dummy normalizer
|
||||
@param _distance the distance
|
||||
@param _referencePoint the point from which we evaluate the distance
|
||||
*/
|
||||
moeoDistanceMetric(moeoObjSpaceDistance<MOEOT> &_distance, const ObjectiveVector &_referencePoint): distance(_distance), reference(_referencePoint),normalizer(defaultNormalizer){}
|
||||
|
||||
/**
|
||||
fonction which apply the metric to calculate a fitness
|
||||
@param _obj the point to evaluate
|
||||
@return the fitness conrresponding to the distance
|
||||
*/
|
||||
Fitness operator()(ObjectiveVector _obj){
|
||||
return distance(normalizer(reference), normalizer(_obj));
|
||||
}
|
||||
|
||||
private:
|
||||
moeoObjSpaceDistance<MOEOT>& distance;
|
||||
const ObjectiveVector& reference;
|
||||
moeoObjectiveVectorNormalizer<MOEOT> defaultNormalizer;
|
||||
moeoObjectiveVectorNormalizer<MOEOT>& normalizer;
|
||||
|
||||
};
|
||||
#endif
|
||||
223
moeo/src/metric/moeoEntropyMetric.h
Normal file
223
moeo/src/metric/moeoEntropyMetric.h
Normal file
|
|
@ -0,0 +1,223 @@
|
|||
/*
|
||||
* <moeoEntropyMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOENTROPYMETRIC_H_
|
||||
#define MOEOENTROPYMETRIC_H_
|
||||
|
||||
#include <vector>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* The entropy gives an idea of the diversity of a Pareto set relatively to another
|
||||
* (Basseur, Seynhaeve, Talbi: 'Design of Multi-objective Evolutionary Algorithms: Application to the Flow-shop Scheduling Problem', in Proc. of the 2002 Congress on Evolutionary Computation, IEEE Press, pp. 1155-1156)
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoEntropyMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Returns the entropy 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)
|
||||
{
|
||||
// normalization
|
||||
std::vector< ObjectiveVector > set1 = _set1;
|
||||
std::vector< ObjectiveVector > set2= _set2;
|
||||
removeDominated (set1);
|
||||
removeDominated (set2);
|
||||
prenormalize (set1);
|
||||
normalize (set1);
|
||||
normalize (set2);
|
||||
|
||||
// making of PO*
|
||||
std::vector< ObjectiveVector > star; // rotf :-)
|
||||
computeUnion (set1, set2, star);
|
||||
removeDominated (star);
|
||||
|
||||
// making of PO1 U PO*
|
||||
std::vector< ObjectiveVector > union_set1_star; // rotf again ...
|
||||
computeUnion (set1, star, union_set1_star);
|
||||
|
||||
unsigned int C = union_set1_star.size();
|
||||
float omega=0;
|
||||
float entropy=0;
|
||||
|
||||
for (unsigned int i=0 ; i<C ; i++)
|
||||
{
|
||||
unsigned int N_i = howManyInNicheOf (union_set1_star, union_set1_star[i], star.size());
|
||||
unsigned int n_i = howManyInNicheOf (set1, union_set1_star[i], star.size());
|
||||
if (n_i > 0)
|
||||
{
|
||||
omega += 1.0 / N_i;
|
||||
entropy += (float) n_i / (N_i * C) * log (((float) n_i / C) / log (2.0));
|
||||
}
|
||||
}
|
||||
entropy /= - log (omega);
|
||||
entropy *= log (2.0);
|
||||
return entropy;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** vector of min values */
|
||||
std::vector<double> vect_min_val;
|
||||
/** vector of max values */
|
||||
std::vector<double> vect_max_val;
|
||||
/** Functor to compare two objective vectors according to Pareto dominance relation */
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
|
||||
/**
|
||||
* Removes the dominated individuals contained in _f
|
||||
* @param _f a Pareto set
|
||||
*/
|
||||
void removeDominated(std::vector < ObjectiveVector > & _f)
|
||||
{
|
||||
for (unsigned int i=0 ; i<_f.size(); i++)
|
||||
{
|
||||
bool dom = false;
|
||||
for (unsigned int j=0; j<_f.size(); j++)
|
||||
if (i != j && paretoComparator(_f[i],_f[j]))
|
||||
{
|
||||
dom = true;
|
||||
break;
|
||||
}
|
||||
if (dom)
|
||||
{
|
||||
_f[i] = _f.back();
|
||||
_f.pop_back();
|
||||
i--;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Prenormalization
|
||||
* @param _f a Pareto set
|
||||
*/
|
||||
void prenormalize (const std::vector< ObjectiveVector > & _f)
|
||||
{
|
||||
vect_min_val.clear();
|
||||
vect_max_val.clear();
|
||||
|
||||
for (unsigned int i=0 ; i<ObjectiveVector::nObjectives(); i++)
|
||||
{
|
||||
float min_val = _f.front()[i], max_val = min_val;
|
||||
for (unsigned int j=1 ; j<_f.size(); j++)
|
||||
{
|
||||
if (_f[j][i] < min_val)
|
||||
min_val = _f[j][i];
|
||||
if (_f[j][i]>max_val)
|
||||
max_val = _f[j][i];
|
||||
}
|
||||
vect_min_val.push_back(min_val);
|
||||
vect_max_val.push_back (max_val);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Normalization
|
||||
* @param _f a Pareto set
|
||||
*/
|
||||
void normalize (std::vector< ObjectiveVector > & _f)
|
||||
{
|
||||
for (unsigned int i=0 ; i<ObjectiveVector::nObjectives(); i++)
|
||||
for (unsigned int j=0; j<_f.size(); j++)
|
||||
_f[j][i] = (_f[j][i] - vect_min_val[i]) / (vect_max_val[i] - vect_min_val[i]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Computation of the union of _f1 and _f2 in _f
|
||||
* @param _f1 the first Pareto set
|
||||
* @param _f2 the second Pareto set
|
||||
* @param _f the final Pareto set
|
||||
*/
|
||||
void computeUnion(const std::vector< ObjectiveVector > & _f1, const std::vector< ObjectiveVector > & _f2, std::vector< ObjectiveVector > & _f)
|
||||
{
|
||||
_f = _f1 ;
|
||||
for (unsigned int i=0; i<_f2.size(); i++)
|
||||
{
|
||||
bool b = false;
|
||||
for (unsigned int j=0; j<_f1.size(); j ++)
|
||||
if (_f1[j] == _f2[i])
|
||||
{
|
||||
b = true;
|
||||
break;
|
||||
}
|
||||
if (! b)
|
||||
_f.push_back(_f2[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* How many in niche
|
||||
*/
|
||||
unsigned int howManyInNicheOf (const std::vector< ObjectiveVector > & _f, const ObjectiveVector & _s, unsigned int _size)
|
||||
{
|
||||
unsigned int n=0;
|
||||
for (unsigned int i=0 ; i<_f.size(); i++)
|
||||
{
|
||||
if (euclidianDistance(_f[i], _s) < (_s.size() / (double) _size))
|
||||
n++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Euclidian distance
|
||||
*/
|
||||
double euclidianDistance (const ObjectiveVector & _set1, const ObjectiveVector & _to, unsigned int _deg = 2)
|
||||
{
|
||||
double dist=0;
|
||||
for (unsigned int i=0; i<_set1.size(); i++)
|
||||
dist += pow(fabs(_set1[i] - _to[i]), (int)_deg);
|
||||
return pow(dist, 1.0 / _deg);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOENTROPYMETRIC_H_*/
|
||||
176
moeo/src/metric/moeoHyperVolumeDifferenceMetric.h
Normal file
176
moeo/src/metric/moeoHyperVolumeDifferenceMetric.h
Normal file
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* <moeoHyperVolumeDifferenceMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOHYPERVOLUMEDIFFERENCEMETRIC_H_
|
||||
#define MOEOHYPERVOLUMEDIFFERENCEMETRIC_H_
|
||||
|
||||
#include <metric/moeoMetric.h>
|
||||
#include <metric/moeoHyperVolumeMetric.h>
|
||||
|
||||
/**
|
||||
* The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set
|
||||
* (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324)
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoHyperVolumeDifferenceMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor with a coefficient (rho)
|
||||
* @param _normalize allow to normalize data (default true)
|
||||
* @param _rho coefficient to determine the reference point.
|
||||
*/
|
||||
moeoHyperVolumeDifferenceMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a reference point
|
||||
* @param _normalize allow to normalize data (default true)
|
||||
* @param _ref_point the reference point
|
||||
*/
|
||||
moeoHyperVolumeDifferenceMetric(bool _normalize=true, ObjectiveVector& _ref_point=NULL): normalize(_normalize), rho(0.0), ref_point(_ref_point){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* calculates and returns the HyperVolume value of a pareto front
|
||||
* @param _set1 the vector contains all objective Vector of the first pareto front
|
||||
* @param _set2 the vector contains all objective Vector of the second pareto front
|
||||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
|
||||
{
|
||||
double hypervolume_set1;
|
||||
double hypervolume_set2;
|
||||
|
||||
if(rho >= 1.0){
|
||||
//determine bounds
|
||||
setup(_set1, _set2);
|
||||
//determine reference point
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
|
||||
if(normalize){
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= rho;
|
||||
else
|
||||
ref_point[i]= 1-rho;
|
||||
}
|
||||
else{
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= bounds[i].maximum() * rho;
|
||||
else
|
||||
ref_point[i]= bounds[i].maximum() * (1-rho);
|
||||
}
|
||||
}
|
||||
//if no normalization, reinit bounds to O..1 for
|
||||
if(!normalize)
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
bounds[i] = eoRealInterval(0,1);
|
||||
|
||||
}
|
||||
else if(normalize)
|
||||
setup(_set1, _set2);
|
||||
|
||||
moeoHyperVolumeMetric <ObjectiveVector> unaryMetric(ref_point, bounds);
|
||||
hypervolume_set1 = unaryMetric(_set1);
|
||||
hypervolume_set2 = unaryMetric(_set2);
|
||||
|
||||
return hypervolume_set1 - hypervolume_set2;
|
||||
}
|
||||
|
||||
/**
|
||||
* getter on bounds
|
||||
* @return bounds
|
||||
*/
|
||||
std::vector < eoRealInterval > getBounds(){
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* method caclulate bounds for the normalization
|
||||
* @param _set1 the vector contains all objective Vector of the first pareto front
|
||||
* @param _set2 the vector contains all objective Vector of the second pareto front
|
||||
*/
|
||||
void setup(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2){
|
||||
if(_set1.size() < 1 || _set2.size() < 1)
|
||||
throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector<ObjectiveVector> size must be greater than 0");
|
||||
else{
|
||||
double min, max;
|
||||
unsigned int nbObj=ObjectiveVector::Traits::nObjectives();
|
||||
bounds.resize(nbObj);
|
||||
for (unsigned int i=0; i<nbObj; i++){
|
||||
min = _set1[0][i];
|
||||
max = _set1[0][i];
|
||||
for (unsigned int j=1; j<_set1.size(); j++){
|
||||
min = std::min(min, _set1[j][i]);
|
||||
max = std::max(max, _set1[j][i]);
|
||||
}
|
||||
for (unsigned int j=0; j<_set2.size(); j++){
|
||||
min = std::min(min, _set2[j][i]);
|
||||
max = std::max(max, _set2[j][i]);
|
||||
}
|
||||
bounds[i] = eoRealInterval(min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
/*boolean indicates if data must be normalized or not*/
|
||||
bool normalize;
|
||||
|
||||
double rho;
|
||||
|
||||
/*vectors contains bounds for normalization*/
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
ObjectiveVector ref_point;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOHYPERVOLUMEMETRIC_H_*/
|
||||
359
moeo/src/metric/moeoHyperVolumeMetric.h
Normal file
359
moeo/src/metric/moeoHyperVolumeMetric.h
Normal file
|
|
@ -0,0 +1,359 @@
|
|||
/*
|
||||
* <moeoHyperVolumeMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOHYPERVOLUMEMETRIC_H_
|
||||
#define MOEOHYPERVOLUMEMETRIC_H_
|
||||
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* The contribution metric evaluates the proportion of non-dominated solutions given by a Pareto set relatively to another Pareto set
|
||||
* (Meunier, Talbi, Reininger: 'A multiobjective genetic algorithm for radio network optimization', in Proc. of the 2000 Congress on Evolutionary Computation, IEEE Press, pp. 317-324)
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoHyperVolumeMetric : public moeoVectorUnaryMetric < ObjectiveVector , double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Constructor with a coefficient (rho)
|
||||
* @param _normalize allow to normalize data (default true)
|
||||
* @param _rho coefficient to determine the reference point.
|
||||
*/
|
||||
moeoHyperVolumeMetric(bool _normalize=true, double _rho=1.1): normalize(_normalize), rho(_rho), ref_point(NULL){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a reference point
|
||||
* @param _normalize allow to normalize data (default true)
|
||||
* @param _ref_point the reference point
|
||||
*/
|
||||
moeoHyperVolumeMetric(bool _normalize=true, ObjectiveVector& _ref_point=NULL): normalize(_normalize), rho(0.0), ref_point(_ref_point){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor with a reference point
|
||||
* @param _ref_point the reference point
|
||||
* @param _bounds bounds value
|
||||
*/
|
||||
moeoHyperVolumeMetric(ObjectiveVector& _ref_point=NULL, std::vector < eoRealInterval >& _bounds=NULL): normalize(false), rho(0.0), ref_point(_ref_point), bounds(_bounds){}
|
||||
|
||||
/**
|
||||
* calculates and returns the HyperVolume value of a pareto front
|
||||
* @param _set the vector contains all objective Vector of pareto front
|
||||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set)
|
||||
{
|
||||
std::vector < std::vector<double> > front;
|
||||
|
||||
//determine the reference point if a coefficient is passed in paremeter
|
||||
if(rho >= 1.0){
|
||||
//determine bounds
|
||||
setup(_set);
|
||||
//determine reference point
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++){
|
||||
if(normalize){
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= rho;
|
||||
else
|
||||
ref_point[i]= 1-rho;
|
||||
}
|
||||
else{
|
||||
if (ObjectiveVector::Traits::minimizing(i))
|
||||
ref_point[i]= bounds[i].maximum() * rho;
|
||||
else
|
||||
ref_point[i]= bounds[i].maximum() * (1-rho);
|
||||
}
|
||||
}
|
||||
//if no normalization, reinit bounds to O..1 for
|
||||
if(!normalize)
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
bounds[i] = eoRealInterval(0,1);
|
||||
|
||||
}
|
||||
else if(normalize)
|
||||
setup(_set);
|
||||
front.resize(_set.size());
|
||||
for(unsigned int i=0; i < _set.size(); i++){
|
||||
front[i].resize(ObjectiveVector::Traits::nObjectives());
|
||||
for (unsigned int j=0; j<ObjectiveVector::Traits::nObjectives(); j++){
|
||||
if (ObjectiveVector::Traits::minimizing(j)){
|
||||
front[i][j]=ref_point[j] - ((_set[i][j] - bounds[j].minimum()) /bounds[j].range());
|
||||
}
|
||||
else{
|
||||
front[i][j]=((_set[i][j] - bounds[j].minimum()) /bounds[j].range()) - ref_point[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return calc_hypervolume(front, front.size(),ObjectiveVector::Traits::nObjectives());
|
||||
}
|
||||
|
||||
/**
|
||||
* getter on bounds
|
||||
* @return bounds
|
||||
*/
|
||||
std::vector < eoRealInterval > getBounds(){
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* method caclulate bounds for the normalization
|
||||
* @param _set the vector of objective vectors
|
||||
*/
|
||||
void setup(const std::vector < ObjectiveVector > & _set){
|
||||
if(_set.size() < 1)
|
||||
throw("Error in moeoHyperVolumeUnaryMetric::setup -> argument1: vector<ObjectiveVector> size must be greater than 0");
|
||||
else{
|
||||
double min, max;
|
||||
unsigned int nbObj=ObjectiveVector::Traits::nObjectives();
|
||||
bounds.resize(nbObj);
|
||||
for (unsigned int i=0; i<nbObj; i++){
|
||||
min = _set[0][i];
|
||||
max = _set[0][i];
|
||||
for (unsigned int j=1; j<_set.size(); j++){
|
||||
min = std::min(min, _set[j][i]);
|
||||
max = std::max(max, _set[j][i]);
|
||||
}
|
||||
bounds[i] = eoRealInterval(min, max);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* method calculate if a point dominates another one regarding the x first objective
|
||||
* @param _point1 a vector of distances
|
||||
* @param _point2 a vector of distances
|
||||
* @param _no_objectives a number of objectives
|
||||
* @return true if '_point1' dominates '_point2' with respect to the first 'no_objectives' objectives
|
||||
*/
|
||||
bool dominates(std::vector<double>& _point1, std::vector<double>& _point2, unsigned int _no_objectives){
|
||||
unsigned int i;
|
||||
bool better_in_any_objective = false;
|
||||
bool worse_in_any_objective = false;
|
||||
|
||||
for(i=0; i < _no_objectives && !worse_in_any_objective; i++){
|
||||
if(_point1[i] > _point2[i])
|
||||
better_in_any_objective = true;
|
||||
else if(_point1[i] < _point2[i])
|
||||
worse_in_any_objective = true;
|
||||
}
|
||||
//_point1 dominates _point2 if it is better than _point2 on a objective and if it is never worse in any other objectives
|
||||
return(!worse_in_any_objective && better_in_any_objective);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* swap two elements of a vector
|
||||
* @param _front the vector
|
||||
* @param _i index of the first element to swap
|
||||
* @param _j index of the second element to swap
|
||||
*/
|
||||
void swap(std::vector< std::vector<double> >& _front, unsigned int _i, unsigned int _j){
|
||||
std::vector<double> tmp;
|
||||
tmp=_front[_i];
|
||||
_front[_i]=_front[_j];
|
||||
_front[_j]=tmp;
|
||||
//another way (don't work on visual studio)
|
||||
// _front.push_back(_front[_i]);
|
||||
// _front[_i]= _front[_j];
|
||||
// _front[_j]=_front.back();
|
||||
// _front.pop_back();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* collect all nondominated points regarding the first '_no_objectives' objectives (dominated points are stored at the end of _front)
|
||||
* @param _front the front
|
||||
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
|
||||
* @param _no_objectives the number of objective to consider
|
||||
* @return the index of the last nondominated point
|
||||
*/
|
||||
unsigned int filter_nondominated_set( std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _no_objectives){
|
||||
unsigned int i,j,n;
|
||||
|
||||
n=_no_points;
|
||||
i=0;
|
||||
while(i < n){
|
||||
j=i+1;
|
||||
while(j < n){
|
||||
//if a point 'A' (index i) dominates another one 'B' (index j), swap 'B' with the point of index n-1
|
||||
if( dominates(_front[i], _front[j], _no_objectives)){
|
||||
n--;
|
||||
swap(_front, j, n);
|
||||
}
|
||||
//if a point 'B'(index j) dominates another one 'A' (index i), swap 'A' with the point of index n-1
|
||||
else if( dominates(_front[j], _front[i], _no_objectives)){
|
||||
n--;
|
||||
swap(_front, i, n);
|
||||
i--;
|
||||
break;
|
||||
}
|
||||
else
|
||||
j++;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
return n;
|
||||
}
|
||||
|
||||
/**
|
||||
* find a minimum value
|
||||
* @param _front the front
|
||||
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
|
||||
* @param _objective the objective to consider
|
||||
* @return the minimum value regarding dimension '_objective' consider points O to _no_points in '_front'
|
||||
*/
|
||||
double surface_unchanged_to(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _objective){
|
||||
unsigned int i;
|
||||
double min, value;
|
||||
|
||||
if(_no_points < 1)
|
||||
throw("Error in moeoHyperVolumeUnaryMetric::surface_unchanged_to -> argument2: _no_points must be greater than 0");
|
||||
min = _front[0][_objective];
|
||||
|
||||
for(i=1; i < _no_points; i++){
|
||||
value = _front[i][_objective];
|
||||
if(value < min)
|
||||
min = value;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* remove all points having a value <= 'threshold' regarding the dimension 'objective', only points of index 0 to _no_points are considered.
|
||||
* points removed are swap at the end of the front.
|
||||
* @param _front the front
|
||||
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
|
||||
* @param _objective the objective to consider
|
||||
* @param _threshold the threshold
|
||||
* @return index of the last points of '_front' greater than the threshold
|
||||
*/
|
||||
unsigned int reduce_nondominated_set(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _objective, double _threshold){
|
||||
unsigned int i,n ;
|
||||
|
||||
n=_no_points;
|
||||
for(i=0; i < n ; i++)
|
||||
if(_front[i][_objective] <= _threshold){
|
||||
n--;
|
||||
swap(_front, i, n);
|
||||
i--; //ATTENTION I had this to reconsider the point copied to index i (it can be useless verify algorythimic in calc_hypervolume)
|
||||
}
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* calculate hypervolume of the front (data are redrafted before)
|
||||
* @param _front the front
|
||||
* @param _no_points the number of points of the front to consider (index 0 to _no_points are considered)
|
||||
* @param _no_objectives the number of objective to consider
|
||||
* @return the hypervolume of the front
|
||||
*/
|
||||
double calc_hypervolume(std::vector < std::vector< double > >& _front, unsigned int _no_points, unsigned int _no_objectives){
|
||||
unsigned int n;
|
||||
double volume, distance;
|
||||
|
||||
volume=0;
|
||||
distance=0;
|
||||
n=_no_points;
|
||||
while(n > 0){
|
||||
unsigned int no_nondominated_points;
|
||||
double temp_vol, temp_dist;
|
||||
|
||||
//get back the index of non dominated points of the front regarding the first "_nb_objectives - 1" objectives
|
||||
//So one dimension is not determinante for the dominance
|
||||
no_nondominated_points = filter_nondominated_set(_front, n, _no_objectives - 1);
|
||||
|
||||
temp_vol=0;
|
||||
|
||||
//if there are less than 3 objectifs take the fisrt objectif of the first point of front to begin computation of hypervolume
|
||||
if(_no_objectives < 3){
|
||||
if(_no_objectives < 1)
|
||||
throw("Error in moeoHyperVolumeUnaryMetric::calc_hypervolume -> argument3: _no_objectives must be greater than 0");
|
||||
temp_vol=_front[0][0];
|
||||
}
|
||||
//else if there at least 3 objectives, a recursive computation of hypervolume starts with _no_objectives -1 on the filter_nondominated_set calculating previously.
|
||||
else
|
||||
temp_vol= calc_hypervolume(_front, no_nondominated_points, _no_objectives - 1);
|
||||
|
||||
//search the next minimum distance on the dimension _no_objectives -1
|
||||
temp_dist = surface_unchanged_to(_front, n, _no_objectives - 1);
|
||||
//calculate the area
|
||||
volume+= temp_vol * (temp_dist - distance);
|
||||
//change distance to have the good lenght on next step
|
||||
distance= temp_dist;
|
||||
//remove all points <= distance on dimension _no_objectives
|
||||
n=reduce_nondominated_set(_front, n , _no_objectives - 1, distance);
|
||||
}
|
||||
return volume;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/*boolean indicates if data must be normalized or not*/
|
||||
bool normalize;
|
||||
|
||||
double rho;
|
||||
|
||||
ObjectiveVector ref_point;
|
||||
|
||||
/*vectors contains bounds for normalization*/
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOHYPERVOLUMEMETRIC_H_*/
|
||||
166
moeo/src/metric/moeoHypervolumeBinaryMetric.h
Normal file
166
moeo/src/metric/moeoHypervolumeBinaryMetric.h
Normal file
|
|
@ -0,0 +1,166 @@
|
|||
/*
|
||||
* <moeoHypervolumeBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOHYPERVOLUMEBINARYMETRIC_H_
|
||||
#define MOEOHYPERVOLUMEBINARYMETRIC_H_
|
||||
|
||||
#include <stdexcept>
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h>
|
||||
|
||||
/**
|
||||
* Hypervolume binary metric allowing to compare two objective vectors as proposed in
|
||||
* Zitzler E., Künzli S.: Indicator-Based Selection in Multiobjective Search. In Parallel Problem Solving from Nature (PPSN VIII).
|
||||
* Lecture Notes in Computer Science 3242, Springer, Birmingham, UK pp.832–842 (2004).
|
||||
* This indicator is based on the hypervolume concept introduced in
|
||||
* Zitzler, E., Thiele, L.: Multiobjective Optimization Using Evolutionary Algorithms - A Comparative Case Study.
|
||||
* Parallel Problem Solving from Nature (PPSN-V), pp.292-301 (1998).
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoHypervolumeBinaryMetric : public moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Ctor
|
||||
* @param _rho value used to compute the reference point from the worst values for each objective (default : 1.1)
|
||||
*/
|
||||
moeoHypervolumeBinaryMetric(double _rho = 1.1) : rho(_rho)
|
||||
{
|
||||
// not-a-maximization problem check
|
||||
for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
|
||||
{
|
||||
if (ObjectiveVector::Traits::maximizing(i))
|
||||
{
|
||||
throw std::runtime_error("Hypervolume binary metric not yet implemented for a maximization problem in moeoHypervolumeBinaryMetric");
|
||||
}
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho.
|
||||
* @warning don't forget to set the bounds for every objective before the call of this function
|
||||
* @param _o1 the first objective vector
|
||||
* @param _o2 the second objective vector
|
||||
*/
|
||||
double operator()(const ObjectiveVector & _o1, const ObjectiveVector & _o2)
|
||||
{
|
||||
double result;
|
||||
// if _o2 is dominated by _o1
|
||||
if ( paretoComparator(_o2,_o1) )
|
||||
{
|
||||
result = - hypervolume(_o1, _o2, ObjectiveVector::Traits::nObjectives()-1);
|
||||
}
|
||||
else
|
||||
{
|
||||
result = hypervolume(_o2, _o1, ObjectiveVector::Traits::nObjectives()-1);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
|
||||
/** value used to compute the reference point from the worst values for each objective */
|
||||
double rho;
|
||||
/** the bounds for every objective */
|
||||
using moeoNormalizedSolutionVsSolutionBinaryMetric < ObjectiveVector, double > :: bounds;
|
||||
/** Functor to compare two objective vectors according to Pareto dominance relation */
|
||||
moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
|
||||
|
||||
|
||||
/**
|
||||
* Returns the volume of the space that is dominated by _o2 but not by _o1 with respect to a reference point computed using rho for the objective _obj.
|
||||
* @param _o1 the first objective vector
|
||||
* @param _o2 the second objective vector
|
||||
* @param _obj the objective index
|
||||
* @param _flag used for iteration, if _flag=true _o2 is not talen into account (default : false)
|
||||
*/
|
||||
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)
|
||||
{
|
||||
v2 = max;
|
||||
}
|
||||
else
|
||||
{
|
||||
v2 = _o2[_obj];
|
||||
}
|
||||
// computation of the volume
|
||||
if (_obj == 0)
|
||||
{
|
||||
if (v1 < v2)
|
||||
{
|
||||
result = (v2 - v1) / range;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (v1 < v2)
|
||||
{
|
||||
result = ( hypervolume(_o1, _o2, _obj-1, true) * (v2 - v1) / range ) + ( hypervolume(_o1, _o2, _obj-1) * (max - v2) / range );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = hypervolume(_o1, _o2, _obj-1) * (max - v2) / range;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOHYPERVOLUMEBINARYMETRIC_H_*/
|
||||
99
moeo/src/metric/moeoMetric.h
Normal file
99
moeo/src/metric/moeoMetric.h
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* <moeoMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOMETRIC_H_
|
||||
#define MOEOMETRIC_H_
|
||||
|
||||
#include <vector>
|
||||
#include <eoFunctor.h>
|
||||
|
||||
/**
|
||||
* Base class for performance metrics (also known as quality indicators).
|
||||
*/
|
||||
class moeoMetric : public eoFunctorBase
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics.
|
||||
*/
|
||||
template < class A, class R >
|
||||
class moeoUnaryMetric : public eoUF < A, R >, public moeoMetric
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics.
|
||||
*/
|
||||
template < class A1, class A2, class R >
|
||||
class moeoBinaryMetric : public eoBF < A1, A2, R >, public moeoMetric
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics dedicated to the performance evaluation of a single solution's objective vector.
|
||||
*/
|
||||
template < class ObjectiveVector, class R >
|
||||
class moeoSolutionUnaryMetric : public moeoUnaryMetric < const ObjectiveVector &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for unary metrics dedicated to the performance evaluation of a Pareto set (a vector of objective vectors)
|
||||
*/
|
||||
template < class ObjectiveVector, class R >
|
||||
class moeoVectorUnaryMetric : public moeoUnaryMetric < const std::vector < ObjectiveVector > &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors.
|
||||
*/
|
||||
template < class ObjectiveVector, class R >
|
||||
class moeoSolutionVsSolutionBinaryMetric : public moeoBinaryMetric < const ObjectiveVector &, const ObjectiveVector &, R >
|
||||
{};
|
||||
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between two Pareto sets (two vectors of objective vectors)
|
||||
*/
|
||||
template < class ObjectiveVector, class R >
|
||||
class moeoVectorVsVectorBinaryMetric : public moeoBinaryMetric < const std::vector < ObjectiveVector > &, const std::vector < ObjectiveVector > &, R >
|
||||
{};
|
||||
|
||||
|
||||
#endif /*MOEOMETRIC_H_*/
|
||||
113
moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h
Normal file
113
moeo/src/metric/moeoNormalizedSolutionVsSolutionBinaryMetric.h
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* <moeoNormalizedSolutionVsSolutionBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
|
||||
#define MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_
|
||||
|
||||
#include <vector>
|
||||
#include <utils/eoRealBounds.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* Base class for binary metrics dedicated to the performance comparison between two solutions's objective vectors using normalized values.
|
||||
* Then, indicator values lie in the interval [-1,1].
|
||||
* Note that you have to set the bounds for every objective before using the operator().
|
||||
*/
|
||||
template < class ObjectiveVector, class R >
|
||||
class moeoNormalizedSolutionVsSolutionBinaryMetric : public moeoSolutionVsSolutionBinaryMetric < ObjectiveVector, R >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default ctr for any moeoNormalizedSolutionVsSolutionBinaryMetric object
|
||||
*/
|
||||
moeoNormalizedSolutionVsSolutionBinaryMetric()
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the lower bound (_min) and the upper bound (_max) for the objective _obj
|
||||
* @param _min lower bound
|
||||
* @param _max upper bound
|
||||
* @param _obj the objective index
|
||||
*/
|
||||
void setup(double _min, double _max, unsigned int _obj)
|
||||
{
|
||||
if (_min == _max)
|
||||
{
|
||||
_min -= tiny();
|
||||
_max += tiny();
|
||||
}
|
||||
bounds[_obj] = eoRealInterval(_min, _max);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the lower bound and the upper bound for the objective _obj using a eoRealInterval object
|
||||
* @param _realInterval the eoRealInterval object
|
||||
* @param _obj the objective index
|
||||
*/
|
||||
virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
|
||||
{
|
||||
bounds[_obj] = _realInterval;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a very small value that can be used to avoid extreme cases (where the min bound == the max bound)
|
||||
*/
|
||||
static double tiny()
|
||||
{
|
||||
return 1e-6;
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/** the bounds for every objective (bounds[i] = bounds for the objective i) */
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEONORMALIZEDSOLUTIONVSSOLUTIONBINARYMETRIC_H_*/
|
||||
93
moeo/src/metric/moeoVecVsVecAdditiveEpsilonBinaryMetric.h
Normal file
93
moeo/src/metric/moeoVecVsVecAdditiveEpsilonBinaryMetric.h
Normal file
|
|
@ -0,0 +1,93 @@
|
|||
/*
|
||||
* <moeoVecVsVecAdditiveEpsilonBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOVECVSVECADDITIVEEPSILONBINARYMETRIC_H_
|
||||
#define MOEOVECVSVECADDITIVEEPSILONBINARYMETRIC_H_
|
||||
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
#include <metric/moeoVecVsVecEpsilonBinaryMetric.h>
|
||||
|
||||
/**
|
||||
* moeoVecVsVecAdditiveEpsilonBinaryMetric is the implementation of moeoVecVsVecEpsilonBinaryMetric whose calculate an additive epsilon indicator
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoVecVsVecAdditiveEpsilonBinaryMetric : public moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Constructor: inherit of moeoVecVsVecEpsilonBinaryMetric
|
||||
*/
|
||||
moeoVecVsVecAdditiveEpsilonBinaryMetric(bool _normalize=true): moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >(_normalize){}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
/**
|
||||
* compute the additive epsilon indicator. Ieps+(A,B) equals the minimum factor eps such that any objective vector in B is eps-dominated by at least one objective vector in A.
|
||||
* a vector z1 is said to eps+-dominate another vector z2, if we can add each objective value in z2 by eps and the resulting objective vector is still weakly dominates by z1.
|
||||
* @param _o1 the first objective vector (correspond to A, must not have dominated elements)
|
||||
* @param _o2 the second objective vector (correspond to B, must not have dominated elements)
|
||||
* @param _obj the objective in consideration
|
||||
* @return the additive epsilon indicator between the two objective vector _o1 and _o2
|
||||
*/
|
||||
double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj){
|
||||
|
||||
double result;
|
||||
// if the objective _obj have to be minimized
|
||||
if (ObjectiveVector::Traits::minimizing(_obj))
|
||||
{
|
||||
// _o1[_obj] - _o2[_obj]
|
||||
result = ( (_o1[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() ) - ( (_o2[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() );
|
||||
}
|
||||
// if the objective _obj have to be maximized
|
||||
else
|
||||
{
|
||||
// _o2[_obj] - _o1[_obj]
|
||||
result = ( (_o2[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() ) - ( (_o1[_obj] - moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].minimum()) / moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >::bounds[_obj].range() );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOVECVSVECEPSILONBINARYMETRIC_H_*/
|
||||
153
moeo/src/metric/moeoVecVsVecEpsilonBinaryMetric.h
Normal file
153
moeo/src/metric/moeoVecVsVecEpsilonBinaryMetric.h
Normal file
|
|
@ -0,0 +1,153 @@
|
|||
/*
|
||||
* <moeoVecVsVecEpsilonBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOVECVSVECEPSILONBINARYMETRIC_H_
|
||||
#define MOEOVECVSVECEPSILONBINARYMETRIC_H_
|
||||
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
|
||||
/**
|
||||
* moeoVecVsVecEpsilonBinaryMetric is an abstract class allow to calculate the epsilon indicator betweend two Pareto sets
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoVecVsVecEpsilonBinaryMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Construtcor
|
||||
* @param _normalize allow to normalize data (default true)
|
||||
*/
|
||||
moeoVecVsVecEpsilonBinaryMetric(bool _normalize=true): normalize(_normalize){
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns the epsilon indicator between two pareto sets.
|
||||
* @param _set1 the first Pareto set (must not have dominated element)
|
||||
* @param _set2 the second Pareto set (must not have dominated element)
|
||||
*/
|
||||
double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
|
||||
{
|
||||
if (normalize)
|
||||
setup(_set1, _set2);
|
||||
double eps, eps_temp, eps_j, eps_k;
|
||||
|
||||
unsigned i, j, k;
|
||||
|
||||
for (i = 0; i < _set2.size(); i++) {
|
||||
for (j = 0; j < _set1.size(); j++) {
|
||||
for (k = 0; k < ObjectiveVector::Traits::nObjectives(); k++) {
|
||||
eps_temp=epsilon(_set1[j], _set2[i], k);
|
||||
if (k == 0)
|
||||
eps_k = eps_temp;
|
||||
else if (eps_k < eps_temp)
|
||||
eps_k = eps_temp;
|
||||
}
|
||||
if (j == 0)
|
||||
eps_j = eps_k;
|
||||
else if (eps_j > eps_k)
|
||||
eps_j = eps_k;
|
||||
}
|
||||
if (i == 0)
|
||||
eps = eps_j;
|
||||
else if (eps < eps_j)
|
||||
eps = eps_j;
|
||||
}
|
||||
return eps;
|
||||
}
|
||||
|
||||
std::vector < eoRealInterval > getBounds(){
|
||||
return bounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* method caclulate bounds for the normalization
|
||||
* @param _set1 the first vector of objective vectors
|
||||
* @param _set2 the second vector of objective vectors
|
||||
*/
|
||||
void setup(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2){
|
||||
double min, max;
|
||||
unsigned int nbObj=ObjectiveVector::Traits::nObjectives();
|
||||
bounds.resize(nbObj);
|
||||
for (unsigned int i=0; i<nbObj; i++){
|
||||
min = _set1[0][i];
|
||||
max = _set1[0][i];
|
||||
for (unsigned int j=1; j<_set1.size(); j++){
|
||||
min = std::min(min, _set1[j][i]);
|
||||
max = std::max(max, _set1[j][i]);
|
||||
}
|
||||
for (unsigned int j=0; j<_set2.size(); j++){
|
||||
min = std::min(min, _set2[j][i]);
|
||||
max = std::max(max, _set2[j][i]);
|
||||
}
|
||||
bounds[i] = eoRealInterval(min, max);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
/*vectors contains bounds for normalization*/
|
||||
std::vector < eoRealInterval > bounds;
|
||||
|
||||
|
||||
/*boolean indicates if data must be normalized or not*/
|
||||
bool normalize;
|
||||
|
||||
private :
|
||||
|
||||
/**
|
||||
* abstract method allow to use differents epsilon indicators
|
||||
* @param _o1 the first objective vector
|
||||
* @param _o2 the second objective vector
|
||||
* @param _obj the objective in consideration
|
||||
* @return an epsilon indicator between two objective vectors
|
||||
*/
|
||||
virtual double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj)=0;
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOVECVSVECEPSILONBINARYMETRIC_H_*/
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/*
|
||||
* <moeoVecVsVecMultiplicativeEpsilonBinaryMetric.h>
|
||||
* Copyright (C) DOLPHIN Project-Team, INRIA Futurs, 2006-2007
|
||||
* (C) OPAC Team, LIFL, 2002-2007
|
||||
*
|
||||
* Jeremie Humeau
|
||||
* Arnaud Liefooghe
|
||||
*
|
||||
* This software is governed by the CeCILL license under French law and
|
||||
* abiding by the rules of distribution of free software. You can use,
|
||||
* modify and/ or redistribute the software under the terms of the CeCILL
|
||||
* license as circulated by CEA, CNRS and INRIA at the following URL
|
||||
* "http://www.cecill.info".
|
||||
*
|
||||
* As a counterpart to the access to the source code and rights to copy,
|
||||
* modify and redistribute granted by the license, users are provided only
|
||||
* with a limited warranty and the software's author, the holder of the
|
||||
* economic rights, and the successive licensors have only limited liability.
|
||||
*
|
||||
* In this respect, the user's attention is drawn to the risks associated
|
||||
* with loading, using, modifying and/or developing or reproducing the
|
||||
* software by the user in light of its specific status of free software,
|
||||
* that may mean that it is complicated to manipulate, and that also
|
||||
* therefore means that it is reserved for developers and experienced
|
||||
* professionals having in-depth computer knowledge. Users are therefore
|
||||
* encouraged to load and test the software's suitability as regards their
|
||||
* requirements in conditions enabling the security of their systems and/or
|
||||
* data to be ensured and, more generally, to use and operate it in the
|
||||
* same conditions as regards security.
|
||||
* The fact that you are presently reading this means that you have had
|
||||
* knowledge of the CeCILL license and that you accept its terms.
|
||||
*
|
||||
* ParadisEO WebSite : http://paradiseo.gforge.inria.fr
|
||||
* Contact: paradiseo-help@lists.gforge.inria.fr
|
||||
*
|
||||
*/
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
#ifndef MOEOVECVSVECMULTIPLICATIVEEPSILONBINARYMETRIC_H_
|
||||
#define MOEOVECVSVECMULTIPLICATIVEEPSILONBINARYMETRIC_H_
|
||||
|
||||
#include <comparator/moeoParetoObjectiveVectorComparator.h>
|
||||
#include <metric/moeoMetric.h>
|
||||
#include <exception>
|
||||
|
||||
/**
|
||||
* moeoVecVsVecMultiplicativeEpsilonBinaryMetric is the implementation of moeoVecVsVecEpsilonBinaryMetric whose calculate a multiplicative epsilon indicator
|
||||
*/
|
||||
template < class ObjectiveVector >
|
||||
class moeoVecVsVecMultiplicativeEpsilonBinaryMetric : public moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Default Constructor: inherit of moeoVecVsVecEpsilonBinaryMetric
|
||||
*/
|
||||
moeoVecVsVecMultiplicativeEpsilonBinaryMetric(): moeoVecVsVecEpsilonBinaryMetric < ObjectiveVector >(false){}
|
||||
|
||||
private:
|
||||
|
||||
/**
|
||||
* Precondition : for a given _obj, _o1 and _o2 must both have a strictly positive or a strictly negative value else an exception is thrown
|
||||
* compute the epsilon indicator. Ieps(A,B) equals the minimum factor eps such that any objective vector in B is eps-dominated by at least one objective vector in A.
|
||||
* a vector z1 is said to eps-dominate another vector z2, if we can multiply each objective value in z2 by a factor of z2 and the resulting objective vector is still weakly dominates by z1.
|
||||
* @param _o1 the first objective vector (correspond to A, must not have dominated elements)
|
||||
* @param _o2 the second objective vector (correspond to B, must not have dominated elements)
|
||||
* @param _obj the objective in consideration
|
||||
* @return the epsilon indicator between the two objective vector _o1 and _o2
|
||||
*/
|
||||
double epsilon(const ObjectiveVector & _o1, const ObjectiveVector & _o2, const unsigned int _obj){
|
||||
|
||||
double result;
|
||||
|
||||
//test if values are correct
|
||||
if ( _o1[_obj] * _o2[_obj] <= 0.0){
|
||||
std::cout << "ERROR in moeoVecVsVecMultiplicativeEpsilonBinaryMetric::epsilon -> ObjectiveVectors contains bad values";
|
||||
throw("ERROR in moeoVecVsVecMultiplicativeEpsilonBinaryMetric::epsilon -> ObjectiveVectors contains bad values");
|
||||
}
|
||||
else{
|
||||
|
||||
// if the objective _obj have to be minimized
|
||||
if (ObjectiveVector::Traits::minimizing(_obj))
|
||||
{
|
||||
// _o1[_obj] / _o2[_obj]
|
||||
result = ( _o1[_obj] / _o2[_obj]);
|
||||
}
|
||||
// if the objective _obj have to be maximized
|
||||
else
|
||||
{
|
||||
// _o2[_obj] / _o1[_obj]
|
||||
result = (_o2[_obj] / _o1[_obj]);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
#endif /*MOEOVECVSVECEPSILONBINARYMETRIC_H_*/
|
||||
Loading…
Add table
Add a link
Reference in a new issue