00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOFRONTBYFRONTSHARINGDIVERSITYASSIGNMENT_H_
00014 #define MOEOFRONTBYFRONTSHARINGDIVERSITYASSIGNMENT_H_
00015
00016 #include <diversity/moeoSharingDiversityAssignment.h>
00017
00021 template < class MOEOT >
00022 class moeoFrontByFrontSharingDiversityAssignment : public moeoSharingDiversityAssignment < MOEOT >
00023 {
00024 public:
00025
00027 typedef typename MOEOT::ObjectiveVector ObjectiveVector;
00028
00029
00036 moeoFrontByFrontSharingDiversityAssignment(moeoDistance<MOEOT,double> & _distance, double _nicheSize = 0.5, double _alpha = 2.0) : moeoSharingDiversityAssignment < MOEOT >(_distance, _nicheSize, _alpha)
00037 {}
00038
00039
00045 moeoFrontByFrontSharingDiversityAssignment(double _nicheSize = 0.5, double _alpha = 2.0) : moeoSharingDiversityAssignment < MOEOT >(_nicheSize, _alpha)
00046 {}
00047
00048
00056 void updateByDeleting(eoPop < MOEOT > & _pop, ObjectiveVector & _objVec)
00057 {
00058 std::cout << "WARNING : updateByDeleting not implemented in moeoSharingDiversityAssignment" << std::endl;
00059 }
00060
00061
00062 private:
00063
00064 using moeoSharingDiversityAssignment < MOEOT >::distance;
00065 using moeoSharingDiversityAssignment < MOEOT >::nicheSize;
00066 using moeoSharingDiversityAssignment < MOEOT >::sh;
00067 using moeoSharingDiversityAssignment < MOEOT >::operator();
00068
00069
00074 void setSimilarities(eoPop < MOEOT > & _pop)
00075 {
00076
00077 moeoDistanceMatrix < MOEOT , double > dMatrix (_pop.size(), distance);
00078 dMatrix(_pop);
00079
00080 for (unsigned int i=0; i<_pop.size(); i++)
00081 {
00082 for (unsigned int j=0; j<i; j++)
00083 {
00084 if (_pop[i].fitness() != _pop[j].fitness())
00085 {
00086 dMatrix[i][j] = nicheSize;
00087 dMatrix[j][i] = nicheSize;
00088 }
00089 }
00090 }
00091
00092 double sum;
00093 for (unsigned int i=0; i<_pop.size(); i++)
00094 {
00095 sum = 0.0;
00096 for (unsigned int j=0; j<_pop.size(); j++)
00097 {
00098 sum += sh(dMatrix[i][j]);
00099 }
00100 _pop[i].diversity(sum);
00101 }
00102 }
00103
00104 };
00105
00106 #endif