00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOSTOCHTOURNAMENTSELECT_H_
00014 #define MOEOSTOCHTOURNAMENTSELECT_H_
00015
00016 #include <moeoSelectOne.h>
00017 #include <moeoSelectors.h>
00018
00022 template < class MOEOT > class moeoStochTournamentSelect:public moeoSelectOne <MOEOT>
00023 {
00024 public:
00025
00031 moeoStochTournamentSelect (moeoComparator < MOEOT > & _comparator, double _tRate = 1.0) :
00032 comparator (_comparator), tRate (_tRate)
00033 {
00034
00035 if (tRate < 0.5)
00036 {
00037 std::
00038 cerr <<
00039 "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
00040 tRate = 0.55;
00041 }
00042 if (tRate > 1)
00043 {
00044 std::
00045 cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
00046 tRate = 1;
00047 }
00048 }
00049
00054 moeoStochTournamentSelect (double _tRate = 1.0)
00055 :comparator (*(new moeoFitnessThenDiversityComparator < MOEOT > ())), tRate (_tRate)
00056
00057 {
00058
00059 if (tRate < 0.5)
00060 {
00061 std::
00062 cerr <<
00063 "Warning, Tournament rate should be > 0.5\nAdjusted to 0.55\n";
00064 tRate = 0.55;
00065 }
00066 if (tRate > 1)
00067 {
00068 std::
00069 cerr << "Warning, Tournament rate should be < 1\nAdjusted to 1\n";
00070 tRate = 1;
00071 }
00072 }
00073
00074
00079 const MOEOT & operator() (const eoPop < MOEOT > &_pop)
00080 {
00081
00082 return mo_stochastic_tournament(_pop,tRate,comparator);
00083 }
00084
00085
00086
00087 protected:
00088
00090 moeoComparator < MOEOT > & comparator;
00092 double tRate;
00093
00094 };
00095
00096 #endif