- Main Page
- Classes
- Files
- Related Pages

- Search for |

# moeoSelectOneFromPopAndArch.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // moeoSelectOneFormPopAndArch.h
    00005 // (c) OPAC Team (LIFL), Dolphin Project (INRIA), 2006
    00006 /*
    00007     This library...
    00008
    00009     Contact: paradiseo-help@lists.gforge.inria.fr, http://paradiseo.gforge.inria.fr
    00010  */
    00011 //-----------------------------------------------------------------------------
    00012
    00013 #ifndef MOEOSELECTONEFROMPOPANDARCH_H_
    00014 #define MOEOSELECTONEFROMPOPANDARCH_H_
    00015
    00016 #include <eoPop.h>
    00017 #include <eoRandomSelect.h>
    00018 #include <eoSelectOne.h>
    00019 #include <utils/eoRNG.h>
    00020 #include <moeoArchive.h>
    00021
    00025 template < class EOT > class moeoSelectOneFromPopAndArch:public eoSelectOne <
    00026   EOT >
    00027 {
    00028 public:
    00029
    00037 moeoSelectOneFromPopAndArch (eoSelectOne < EOT > &_popSelectOne, eoSelectOne < EOT > _archSelectOne, moeoArchive < EOT > &_arch, double _ratioFromPop = 0.5):popSelectOne (_popSelectOne), archSelectOne (_archSelectOne), arch (_arch),
    00038     ratioFromPop
    00039     (_ratioFromPop)
    00040   {
    00041   }
    00042
    00049 moeoSelectOneFromPopAndArch (eoSelectOne < EOT > &_popSelectOne, moeoArchive < EOT > &_arch, double _ratioFromPop = 0.5):popSelectOne (_popSelectOne), archSelectOne (randomSelect), arch (_arch),
    00050     ratioFromPop
    00051     (_ratioFromPop)
    00052   {
    00053   }
    00054
    00058   virtual const EOT & operator  () (const eoPop < EOT > &pop)
    00059   {
    00060     if (arch.size () > 0)
    00061       if (rng.flip (ratioFromPop))
    00062         return popSelectOne (pop);
    00063       else
    00064         return archSelectOne (arch);
    00065     else
    00066       return popSelectOne (pop);
    00067   }
    00068
    00072   virtual void setup (const eoPop < EOT > &_pop)
    00073   {
    00074     popSelectOne.setup (_pop);
    00075   }
    00076
    00077
    00078 private:
    00079
    00081   eoSelectOne < EOT > &popSelectOne;
    00083   eoSelectOne < EOT > &archSelectOne;
    00085   moeoArchive < EOT > &arch;
    00087   double ratioFromPop;
    00089   eoRandomSelect < EOT > randomSelect;
    00090
    00091 };
    00092
    00093 #endif /*MOEOSELECTONEFROMPOPANDARCH_H_ */