- 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 <archive/moeoArchive.h>
    00019 #include <selection/moeoSelectOne.h>
    00020 #include <selection/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
    00041
    00048     moeoSelectFromPopAndArch (moeoSelectOne < MOEOT > & _popSelectOne, moeoArchive < MOEOT > & _arch, double _ratioFromPop=0.5)
    00049             : popSelectOne(_popSelectOne), archSelectOne(randomSelectOne), arch(_arch), ratioFromPop(_ratioFromPop)
    00050     {}
    00051
    00052
    00056     virtual const MOEOT & operator () (const eoPop < MOEOT > & pop)
    00057     {
    00058         if (arch.size() > 0)
    00059             if (rng.flip(ratioFromPop))
    00060                 return popSelectOne(pop);
    00061             else
    00062                 return archSelectOne(arch);
    00063         else
    00064             return popSelectOne(pop);
    00065     }
    00066
    00067
    00071     virtual void setup (const eoPop < MOEOT > & _pop)
    00072     {
    00073         popSelectOne.setup(_pop);
    00074     }
    00075
    00076
    00077 private:
    00078
    00080     moeoSelectOne < MOEOT > & popSelectOne;
    00082     moeoSelectOne < MOEOT > & archSelectOne;
    00084     moeoArchive < MOEOT > & arch;
    00086     double ratioFromPop;
    00088     moeoRandomSelect < MOEOT > randomSelectOne;
    00089
    00090 };
    00091
    00092 #endif /*MOEOSELECTONEFROMPOPANDARCH_H_*/