00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOCONTRIBUTIONMETRIC_H_
00014 #define MOEOCONTRIBUTIONMETRIC_H_
00015
00016 #include <metric/moeoMetric.h>
00017
00023 template < class EOT > class moeoContributionMetric:public moeoVectorVsVectorBM < EOT,
00024 double >
00025 {
00026 public:
00027
00031 typedef typename EOT::Fitness EOFitness;
00032
00038 double operator () (const std::vector < EOFitness > &_set1,
00039 const std::vector < EOFitness > &_set2)
00040 {
00041 unsigned c = card_C (_set1, _set2);
00042 unsigned w1 = card_W (_set1, _set2);
00043 unsigned n1 = card_N (_set1, _set2);
00044 unsigned w2 = card_W (_set2, _set1);
00045 unsigned n2 = card_N (_set2, _set1);
00046 return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
00047 }
00048
00049
00050 private:
00051
00057 unsigned card_C (const std::vector < EOFitness > &_set1,
00058 const std::vector < EOFitness > &_set2)
00059 {
00060 unsigned c = 0;
00061 for (unsigned i = 0; i < _set1.size (); i++)
00062 for (unsigned j = 0; j < _set2.size (); j++)
00063 if (_set1[i] == _set2[j])
00064 {
00065 c++;
00066 break;
00067 }
00068 return c;
00069 }
00070
00076 unsigned card_W (const std::vector < EOFitness > &_set1,
00077 const std::vector < EOFitness > &_set2)
00078 {
00079 unsigned w = 0;
00080 for (unsigned i = 0; i < _set1.size (); i++)
00081 for (unsigned j = 0; j < _set2.size (); j++)
00082 if (_set1[i].dominates (_set2[j]))
00083 {
00084 w++;
00085 break;
00086 }
00087 return w;
00088 }
00089
00095 unsigned card_N (const std::vector < EOFitness > &_set1,
00096 const std::vector < EOFitness > &_set2)
00097 {
00098 unsigned n = 0;
00099 for (unsigned i = 0; i < _set1.size (); i++)
00100 {
00101 bool domin_rel = false;
00102 for (unsigned j = 0; j < _set2.size (); j++)
00103 if (_set1[i].dominates (_set2[j]) || _set2[j].dominates (_set1[i]))
00104 {
00105 domin_rel = true;
00106 break;
00107 }
00108 if (!domin_rel)
00109 n++;
00110 }
00111 return n;
00112 }
00113
00114 };
00115
00116 #endif