# eoMergeReduce.h

    00001
    00023 //-----------------------------------------------------------------------------
    00024
    00025 #ifndef _eoMergeReduce_h
    00026 #define _eoMergeReduce_h
    00027
    00028
    00029 //-----------------------------------------------------------------------------
    00030 #include <eoPop.h>
    00031 #include <eoFunctor.h>
    00032 #include <eoMerge.h>
    00033 #include <eoReduce.h>
    00034 #include <eoReplacement.h>
    00035 #include <utils/eoHowMany.h>
    00036 //-----------------------------------------------------------------------------
    00049 template <class EOT>
    00050 class eoMergeReduce : public eoReplacement<EOT>
    00051 {
    00052     public:
    00053         eoMergeReduce(eoMerge<EOT>& _merge, eoReduce<EOT>& _reduce) :
    00054         merge(_merge), reduce(_reduce)
    00055         {}
    00056
    00057         void operator()(eoPop<EOT>& _parents, eoPop<EOT>& _offspring)
    00058         {
    00059             merge(_parents, _offspring); // parents untouched, result in offspring
    00060             reduce(_offspring, _parents.size());
    00061             _parents.swap(_offspring);
    00062         }
    00063
    00064     private :
    00065         eoMerge<EOT>& merge;
    00066         eoReduce<EOT>& reduce;
    00067 };
    00068
    00072 template <class EOT>
    00073 class eoPlusReplacement : public eoMergeReduce<EOT>
    00074 {
    00075     public :
    00076         eoPlusReplacement() : eoMergeReduce<EOT>(plus, truncate) {}
    00077
    00078     private :
    00079         eoPlus<EOT> plus;
    00080         eoTruncate<EOT> truncate;
    00081 };
    00082
    00086 template <class EOT>
    00087 class eoCommaReplacement : public eoMergeReduce<EOT>
    00088 {
    00089     public :
    00090         eoCommaReplacement() : eoMergeReduce<EOT>(no_elite, truncate) {}
    00091
    00092     private :
    00093         eoNoElitism<EOT> no_elite;
    00094         eoTruncate<EOT> truncate;
    00095 };
    00096
    00101 template <class EOT>
    00102 class eoEPReplacement : public eoMergeReduce<EOT>
    00103 {
    00104 public :
    00105   eoEPReplacement(int _tSize) : eoMergeReduce<EOT>(plus, truncate), truncate(_tSize)
    00106     //  {truncate.setSize(_tSize);}
    00107   {}
    00108 private :
    00109   eoPlus<EOT> plus;
    00110   eoEPReduce<EOT> truncate;
    00111 };
    00112
    00113
    00114
    00115 #endif