moeoStochTournamentSelect.h

00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // moeoStochTournamentSelect.h
00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2007
00006 /*
00007     This library...
00008 
00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
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         // consistency checks
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         // consistency checks
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         // use the selector
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 /*MOEOSTOCHTOURNAMENTSELECT_H_ */

Generated on Tue Apr 17 16:53:21 2007 for ParadisEO-MOEO by  doxygen 1.5.1