- Main Page
- Classes
- Files

- Search for |

# moeoSelectFromPopAndArch.h

    00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
    00002
    00003 //-----------------------------------------------------------------------------
    00004 // moeoSelectFormPopAndArch.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 MOEOSELECTONEFROMPOPANDARCH_H_
    00014 #define MOEOSELECTONEFROMPOPANDARCH_H_
    00015
    00016 #include <eoPop.h>
    00017 #include <utils/eoRNG.h>
    00018 #include <moeoArchive.h>
    00019 #include <moeoSelectOne.h>
    00020 #include <moeoRandomSelect.h>
    00021
    00025 template < class MOEOT >
    00026 class moeoSelectFromPopAndArch : public moeoSelectOne < MOEOT >
    00027 {
    00028 public:
    00029
    00037     moeoSelectFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoSelectOne < MOEOT > _archSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5)
    00038             : popSelectOne(_popSelectOne), archSelectOne(_archSelectOne), arch(_arch), ratioFromPop(_ratioFromPop)
    00039     {}
    00040
    00047     moeoSelectFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5)
    00048             : popSelectOne(_popSelectOne), archSelectOne(randomSelectOne), arch(_arch), ratioFromPop(_ratioFromPop)
    00049     {}
    00050
    00054     virtual const MOEOT & operator () (const eoPop < MOEOT > & pop)
    00055     {
    00056         if (arch.size() > 0)
    00057             if (rng.flip(ratioFromPop))
    00058                 return popSelectOne(pop);
    00059             else
    00060                 return archSelectOne(arch);
    00061         else
    00062             return popSelectOne(pop);
    00063     }
    00064
    00068     virtual void setup (const eoPop < MOEOT > & _pop)
    00069     {
    00070         popSelectOne.setup(_pop);
    00071     }
    00072
    00073
    00074 private:
    00075
    00077     moeoSelectOne < MOEOT > & popSelectOne;
    00079     moeoSelectOne < MOEOT > & archSelectOne;
    00081     moeoArchive < MOEOT > & arch;
    00083     double ratioFromPop;
    00085     moeoRandomSelect < MOEOT > randomSelectOne;
    00086
    00087 };
    00088
    00089 #endif /*MOEOSELECTONEFROMPOPANDARCH_H_*/