00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEONORMALIZEDDISTANCE_H_
00014 #define MOEONORMALIZEDDISTANCE_H_
00015
00016 #include <vector>
00017 #include <utils/eoRealBounds.h>
00018 #include <distance/moeoDistance.h>
00019
00023 template < class MOEOT , class Type = double >
00024 class moeoNormalizedDistance : public moeoDistance < MOEOT , Type >
00025 {
00026 public:
00027
00029 typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00030
00031
00035 moeoNormalizedDistance()
00036 {
00037 bounds.resize(ObjectiveVector::Traits::nObjectives());
00038
00039 for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
00040 {
00041 bounds[i] = eoRealInterval(0,1);
00042 }
00043 }
00044
00045
00049 static double tiny()
00050 {
00051 return 1e-6;
00052 }
00053
00054
00059 virtual void setup(const eoPop < MOEOT > & _pop)
00060 {
00061 double min, max;
00062 for (unsigned int i=0; i<ObjectiveVector::Traits::nObjectives(); i++)
00063 {
00064 min = _pop[0].objectiveVector()[i];
00065 max = _pop[0].objectiveVector()[i];
00066 for (unsigned int j=1; j<_pop.size(); j++)
00067 {
00068 min = std::min(min, _pop[j].objectiveVector()[i]);
00069 max = std::max(max, _pop[j].objectiveVector()[i]);
00070 }
00071
00072 setup(min, max, i);
00073 }
00074 }
00075
00076
00083 virtual void setup(double _min, double _max, unsigned int _obj)
00084 {
00085 if (_min == _max)
00086 {
00087 _min -= tiny();
00088 _max += tiny();
00089 }
00090 bounds[_obj] = eoRealInterval(_min, _max);
00091 }
00092
00093
00099 virtual void setup(eoRealInterval _realInterval, unsigned int _obj)
00100 {
00101 bounds[_obj] = _realInterval;
00102 }
00103
00104
00105 protected:
00106
00108 std::vector < eoRealInterval > bounds;
00109
00110 };
00111
00112 #endif