# eoOneMaxInit.h

    00001
    00006 /*
    00007 Template for EO objects initialization in EO
    00008 ============================================
    00009 */
    00010
    00011 #ifndef _eoOneMaxInit_h
    00012 #define _eoOneMaxInit_h
    00013
    00014 // include the base definition of eoInit
    00015 #include <eoInit.h>
    00016
    00025 template <class GenotypeT>
    00026 class eoOneMaxInit: public eoInit<GenotypeT> {
    00027 public:
    00029 // START eventually add or modify the anyVariable argument
    00030 //  eoOneMaxInit()
    00031     eoOneMaxInit( unsigned  _vecSize) : vecSize(_vecSize)
    00032 // END eventually add or modify the anyVariable argument
    00033   {
    00034     // START Code of Ctor of an eoOneMaxInit object
    00035     // END   Code of Ctor of an eoOneMaxInit object
    00036   }
    00037
    00038
    00044   void operator()(GenotypeT & _genotype)
    00045   {
    00046     // START Code of random initialization of an eoOneMax object
    00047     vector<bool> b(vecSize);
    00048     for (unsigned i=0; i<vecSize; i++)
    00049       b[i]=rng.flip();
    00050     _genotype.setB(b);
    00051     // END   Code of random initialization of an eoOneMax object
    00052     _genotype.invalidate();        // IMPORTANT in case the _genotype is old
    00053   }
    00054
    00055 private:
    00056 // START Private data of an eoOneMaxInit object
    00057   unsigned vecSize;     // size of all bitstrings that this eoInit randomize
    00058   //  varType anyVariable;                 // for example ...
    00059 // END   Private data of an eoOneMaxInit object
    00060 };
    00061
    00062 #endif
    00063