diff --git a/branches/paradiseo-moeo-1.0/src/distance/moeoDistance.h b/branches/paradiseo-moeo-1.0/src/distance/moeoDistance.h index 0b55890c0..61b8fb670 100644 --- a/branches/paradiseo-moeo-1.0/src/distance/moeoDistance.h +++ b/branches/paradiseo-moeo-1.0/src/distance/moeoDistance.h @@ -13,9 +13,7 @@ #ifndef MOEODISTANCE_H_ #define MOEODISTANCE_H_ -#include #include -#include /** * The base class for distance computation. @@ -25,203 +23,32 @@ class moeoDistance : public eoBF < const MOEOT &, const MOEOT &, const Type > { public: - /** - * Nothing to do - * @param _pop the population - */ + * Nothing to do + * @param _pop the population + */ virtual void setup(const eoPop < MOEOT > & _pop) {} + /** * Nothing to do * @param _min lower bound * @param _max upper bound * @param _obj the objective index */ - virtual void setup(double _min, double _max, unsigned _obj) + virtual void setup(double _min, double _max, unsigned int _obj) {} /** - * Nothing to do - * @param _realInterval the eoRealInterval object - * @param _obj the objective index - */ - virtual void setup(eoRealInterval _realInterval, unsigned _obj) + * Nothing to do + * @param _realInterval the eoRealInterval object + * @param _obj the objective index + */ + virtual void setup(eoRealInterval _realInterval, unsigned int _obj) {} }; - -/** - * The base class for double distance computation with normalized objective values (i.e. between 0 and 1). - */ -template < class MOEOT , class Type = double > -class moeoNormalizedDistance : public moeoDistance < MOEOT , Type > -{ -public: - - /** the objective vector type of the solutions */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - - /** - * Default ctr - */ - moeoNormalizedDistance() - { - bounds.resize(ObjectiveVector::Traits::nObjectives()); - // initialize bounds in case someone does not want to use them - for (unsigned i=0; i & _pop) - { - double min, max; - for (unsigned i=0; i bounds; - -}; - - -/** - * A class allowing to compute an euclidian distance between two solutions in the objective space with normalized objective values (i.e. between 0 and 1). - * A distance value then lies between 0 and sqrt(nObjectives). - */ -template < class MOEOT > -class moeoEuclideanDistance : public moeoNormalizedDistance < MOEOT > -{ -public: - - /** the objective vector type of the solutions */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - - /** - * Returns the euclidian distance between _moeo1 and _moeo2 in the objective space - * @param _moeo1 the first solution - * @param _moeo2 the second solution - */ - const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) - { - double result = 0.0; - double tmp1, tmp2; - for (unsigned i=0; i :: bounds; - -}; - -/** - * A class allowing to compute the Manhattan distance between two solutions in the objective space normalized objective values (i.e. between 0 and 1). - * A distance value then lies between 0 and nObjectives. - */ -template < class MOEOT > -class moeoManhattanDistance : public moeoNormalizedDistance < MOEOT > -{ -public: - - /** the objective vector type of the solutions */ - typedef typename MOEOT::ObjectiveVector ObjectiveVector; - - - /** - * Returns the Manhattan distance between _moeo1 and _moeo2 in the objective space - * @param _moeo1 the first solution - * @param _moeo2 the second solution - */ - const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) - { - double result = 0.0; - double tmp1, tmp2; - for (unsigned i=0; i :: bounds; - -}; - #endif /*MOEODISTANCE_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/distance/moeoDistanceMatrix.h b/branches/paradiseo-moeo-1.0/src/distance/moeoDistanceMatrix.h index ed6c088ce..b9a9e924e 100644 --- a/branches/paradiseo-moeo-1.0/src/distance/moeoDistanceMatrix.h +++ b/branches/paradiseo-moeo-1.0/src/distance/moeoDistanceMatrix.h @@ -13,6 +13,7 @@ #ifndef MOEODISTANCEMATRIX_H_ #define MOEODISTANCEMATRIX_H_ +#include #include #include @@ -33,10 +34,10 @@ public: * @param _size size for every dimension of the matrix * @param _distance the distance to use */ - moeoDistanceMatrix (unsigned _size, moeoDistance < MOEOT , Type > & _distance) : distance(_distance) + moeoDistanceMatrix (unsigned int _size, moeoDistance < MOEOT , Type > & _distance) : distance(_distance) { this->resize(_size); - for (unsigned i=0; i<_size; i++) + for (unsigned int i=0; i<_size; i++) { this->operator[](i).resize(_size); } @@ -53,10 +54,10 @@ public: distance.setup(_pop); // 2 - compute distances this->operator[](0).operator[](0) = Type(); - for (unsigned i=0; ioperator[](i).operator[](i) = Type(); - for (unsigned j=0; joperator[](i).operator[](j) = distance(_pop[i], _pop[j]); this->operator[](j).operator[](i) = this->operator[](i).operator[](j); diff --git a/branches/paradiseo-moeo-1.0/src/distance/moeoEuclideanDistance.h b/branches/paradiseo-moeo-1.0/src/distance/moeoEuclideanDistance.h new file mode 100644 index 000000000..2d8d8ec49 --- /dev/null +++ b/branches/paradiseo-moeo-1.0/src/distance/moeoEuclideanDistance.h @@ -0,0 +1,58 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// moeoEuclideanDistance.h +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 +/* + This library... + + Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOEUCLIDEANDISTANCE_H_ +#define MOEOEUCLIDEANDISTANCE_H_ + +#include +#include + +/** + * A class allowing to compute an euclidian distance between two solutions in the objective space with normalized objective values (i.e. between 0 and 1). + * A distance value then lies between 0 and sqrt(nObjectives). + */ +template < class MOEOT > +class moeoEuclideanDistance : public moeoNormalizedDistance < MOEOT > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * Returns the euclidian distance between _moeo1 and _moeo2 in the objective space + * @param _moeo1 the first solution + * @param _moeo2 the second solution + */ + const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) + { + double result = 0.0; + double tmp1, tmp2; + for (unsigned int i=0; i :: bounds; + +}; + +#endif /*MOEOEUCLIDEANDISTANCE_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/distance/moeoManhattanDistance.h b/branches/paradiseo-moeo-1.0/src/distance/moeoManhattanDistance.h new file mode 100644 index 000000000..f4c145fe7 --- /dev/null +++ b/branches/paradiseo-moeo-1.0/src/distance/moeoManhattanDistance.h @@ -0,0 +1,58 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// moeoManhattanDistance.h +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 +/* + This library... + + Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr + */ +//----------------------------------------------------------------------------- + +#ifndef MOEOMANHATTANDISTANCE_H_ +#define MOEOMANHATTANDISTANCE_H_ + +#include +#include + +/** + * A class allowing to compute the Manhattan distance between two solutions in the objective space normalized objective values (i.e. between 0 and 1). + * A distance value then lies between 0 and nObjectives. + */ +template < class MOEOT > +class moeoManhattanDistance : public moeoNormalizedDistance < MOEOT > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * Returns the Manhattan distance between _moeo1 and _moeo2 in the objective space + * @param _moeo1 the first solution + * @param _moeo2 the second solution + */ + const double operator()(const MOEOT & _moeo1, const MOEOT & _moeo2) + { + double result = 0.0; + double tmp1, tmp2; + for (unsigned int i=0; i :: bounds; + +}; + +#endif /*MOEOMANHATTANDISTANCE_H_*/ diff --git a/branches/paradiseo-moeo-1.0/src/distance/moeoNormalizedDistance.h b/branches/paradiseo-moeo-1.0/src/distance/moeoNormalizedDistance.h new file mode 100644 index 000000000..ee1a2caa8 --- /dev/null +++ b/branches/paradiseo-moeo-1.0/src/distance/moeoNormalizedDistance.h @@ -0,0 +1,112 @@ +// -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*- + +//----------------------------------------------------------------------------- +// moeoNormalizedDistance.h +// (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007 +/* + This library... + + Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr + */ +//----------------------------------------------------------------------------- + +#ifndef MOEONORMALIZEDDISTANCE_H_ +#define MOEONORMALIZEDDISTANCE_H_ + +#include +#include +#include + +/** + * The base class for double distance computation with normalized objective values (i.e. between 0 and 1). + */ +template < class MOEOT , class Type = double > +class moeoNormalizedDistance : public moeoDistance < MOEOT , Type > +{ +public: + + /** the objective vector type of the solutions */ + typedef typename MOEOT::ObjectiveVector ObjectiveVector; + + + /** + * Default ctr + */ + moeoNormalizedDistance() + { + bounds.resize(ObjectiveVector::Traits::nObjectives()); + // initialize bounds in case someone does not want to use them + for (unsigned int i=0; i & _pop) + { + double min, max; + for (unsigned int i=0; i bounds; + +}; + +#endif /*MOEONORMALIZEDDISTANCE_H_*/