00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038 #ifndef MOEOCONTRIBUTIONMETRIC_H_
00039 #define MOEOCONTRIBUTIONMETRIC_H_
00040
00041 #include <comparator/moeoParetoObjectiveVectorComparator.h>
00042 #include <metric/moeoMetric.h>
00043
00048 template < class ObjectiveVector >
00049 class moeoContributionMetric : public moeoVectorVsVectorBinaryMetric < ObjectiveVector, double >
00050 {
00051 public:
00052
00058 double operator()(const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
00059 {
00060 unsigned int c = card_C(_set1, _set2);
00061 unsigned int w1 = card_W(_set1, _set2);
00062 unsigned int n1 = card_N(_set1, _set2);
00063 unsigned int w2 = card_W(_set2, _set1);
00064 unsigned int n2 = card_N(_set2, _set1);
00065 return (double) (c / 2.0 + w1 + n1) / (c + w1 + n1 + w2 + n2);
00066 }
00067
00068
00069 private:
00070
00072 moeoParetoObjectiveVectorComparator < ObjectiveVector > paretoComparator;
00073
00074
00080 unsigned int card_C (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
00081 {
00082 unsigned int c=0;
00083 for (unsigned int i=0; i<_set1.size(); i++)
00084 for (unsigned int j=0; j<_set2.size(); j++)
00085 if (_set1[i] == _set2[j])
00086 {
00087 c++;
00088 break;
00089 }
00090 return c;
00091 }
00092
00093
00099 unsigned int card_W (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
00100 {
00101 unsigned int w=0;
00102 for (unsigned int i=0; i<_set1.size(); i++)
00103 for (unsigned int j=0; j<_set2.size(); j++)
00104 if (paretoComparator(_set2[j], _set1[i]))
00105 {
00106 w++;
00107 break;
00108 }
00109 return w;
00110 }
00111
00112
00118 unsigned int card_N (const std::vector < ObjectiveVector > & _set1, const std::vector < ObjectiveVector > & _set2)
00119 {
00120 unsigned int n=0;
00121 for (unsigned int i=0; i<_set1.size(); i++)
00122 {
00123 bool domin_rel = false;
00124 for (unsigned int j=0; j<_set2.size(); j++)
00125 if ( (paretoComparator(_set2[j], _set1[i])) || (paretoComparator(_set1[i], _set2[j])) )
00126 {
00127 domin_rel = true;
00128 break;
00129 }
00130 if (! domin_rel)
00131 n++;
00132 }
00133 return n;
00134 }
00135
00136 };
00137
00138 #endif