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 <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         // consistency checks
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         // consistency checks
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         // use the selector
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 /*MOEOSTOCHTOURNAMENTSELECT_H_ */

Generated on Tue Jun 26 15:13:04 2007 for ParadisEO-MOEO by  doxygen 1.4.7