00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOSTOCHTOURNAMENTSELECT_H_
00014 #define MOEOSTOCHTOURNAMENTSELECT_H_
00015
00016 #include <comparator/moeoComparator.h>
00017 #include <comparator/moeoFitnessThenDiversityComparator.h>
00018 #include <selection/moeoSelectOne.h>
00019 #include <selection/moeoSelectors.h>
00020
00024 template < class MOEOT > class moeoStochTournamentSelect:public moeoSelectOne <MOEOT>
00025 {
00026 public:
00027
00033 moeoStochTournamentSelect (moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) : comparator (_comparator), tRate (_tRate)
00034 {
00035
00036 if (tRate < 0.5)
00037 {
00038 std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
00039 tRate = 0.55;
00040 }
00041 if (tRate > 1)
00042 {
00043 std::cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
00044 tRate = 1;
00045 }
00046 }
00047
00048
00053 moeoStochTournamentSelect (double _tRate = 1.0) : comparator (defaultComparator), tRate (_tRate)
00054 {
00055
00056 if (tRate < 0.5)
00057 {
00058 std::cerr << "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
00059 tRate = 0.55;
00060 }
00061 if (tRate > 1)
00062 {
00063 std::cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
00064 tRate = 1;
00065 }
00066 }
00067
00068
00073 const MOEOT & operator() (const eoPop < MOEOT > &_pop)
00074 {
00075
00076 return mo_stochastic_tournament(_pop,tRate,comparator);
00077 }
00078
00079
00080 protected:
00081
00083 moeoComparator < MOEOT > & comparator;
00085 moeoFitnessThenDiversityComparator < MOEOT > defaultComparator;
00087 double tRate;
00088
00089 };
00090
00091 #endif