00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013 #ifndef MOEOROULETTESELECT_H_
00014 #define MOEOROULETTESELECT_H_
00015
00016 #include <moeoSelectOne.h>
00017 #include <moeoSelectors.h>
00018
00022 template < class MOEOT >
00023 class moeoRouletteSelect:public moeoSelectOne <MOEOT>
00024 {
00025 public:
00026
00027
00033 moeoRouletteSelect (moeoComparator < MOEOT > &_comparator, unsigned _tSize = 2):
00034 comparator (_comparator), tSize (_tSize)
00035 {
00036
00037 if (tSize < 2)
00038 {
00039 std::
00040 cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
00041 tSize = 2;
00042 }
00043 }
00044
00045
00050 moeoRouletteSelect (unsigned _tSize = 2):
00051 comparator (*(new moeoFitnessThenDiversityComparator < MOEOT > ())),
00052 tSize (_tSize)
00053 {
00054
00055 if (tSize < 2)
00056 {
00057 std::
00058 cout << "Warning, Tournament size should be >= 2\nAdjusted to 2\n";
00059 tSize = 2;
00060 }
00061 }
00062
00066 const MOEOT & operator () (const eoPop < MOEOT > &_pop)
00067 {
00068
00069 return mo_roulette_wheel(_pop,tSize);
00070 }
00071
00072
00073 protected:
00074
00076 moeoComparator < MOEOT > &comparator;
00078 double & tSize;
00079
00080 };
00081
00082 #endif