Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | Related Pages | Search for

# eoReduceMerge.h

    00001
    00025 //-----------------------------------------------------------------------------
    00026
    00027 #ifndef _eoReduceMerge_h
    00028 #define _eoReduceMerge_h
    00029
    00030
    00031 //-----------------------------------------------------------------------------
    00032 #include <eoPop.h>
    00033 #include <eoFunctor.h>
    00034 #include <eoMerge.h>
    00035 #include <eoReduce.h>
    00036 #include <eoReplacement.h>
    00037 #include <utils/eoHowMany.h>
    00038 //-----------------------------------------------------------------------------
    00039
    00040
    00052 template <class EOT>
    00053 class eoReduceMerge : public eoReplacement<EOT>
    00054 {
    00055     public:
    00056         eoReduceMerge(eoReduce<EOT>& _reduce, eoMerge<EOT>& _merge) :
    00057         reduce(_reduce), merge(_merge)
    00058         {}
    00059
    00060         void operator()(eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
    00061         {
    00062           if (_parents.size() < _offspring.size())
    00063             throw std::logic_error("eoReduceMerge: More offspring than parents!\n");
    00064           reduce(_parents, _parents.size() - _offspring.size());
    00065           merge(_offspring, _parents);
    00066         }
    00067
    00068     private :
    00069         eoReduce<EOT>& reduce;
    00070         eoMerge<EOT>& merge;
    00071 };
    00072
    00076 template <class EOT>
    00077 class eoSSGAWorseReplacement : public eoReduceMerge<EOT>
    00078 {
    00079     public :
    00080         eoSSGAWorseReplacement() : eoReduceMerge<EOT>(truncate, plus) {}
    00081
    00082     private :
    00083         eoLinearTruncate<EOT> truncate;
    00084         eoPlus<EOT> plus;
    00085 };
    00086
    00090 template <class EOT>
    00091 class eoSSGADetTournamentReplacement : public eoReduceMerge<EOT>
    00092 {
    00093     public :
    00094         eoSSGADetTournamentReplacement(unsigned _t_size) :
    00095           eoReduceMerge<EOT>(truncate, plus), truncate(_t_size) {}
    00096
    00097     private :
    00098         eoDetTournamentTruncate<EOT> truncate;
    00099         eoPlus<EOT> plus;
    00100 };
    00101
    00107 template <class EOT>
    00108 class eoSSGAStochTournamentReplacement : public eoReduceMerge<EOT>
    00109 {
    00110     public :
    00111         eoSSGAStochTournamentReplacement(double _t_rate) :
    00112           eoReduceMerge<EOT>(truncate, plus), truncate(_t_rate) {}
    00113
    00114     private :
    00115         eoStochTournamentTruncate<EOT> truncate;
    00116         eoPlus<EOT> plus;
    00117 };
    00118
    00119 #endif