eoOneMax.h

00001 
00006 /*
00007 Template for creating a new representation in EO
00008 ================================================
00009 */
00010 
00011 #ifndef _eoOneMax_h
00012 #define _eoOneMax_h
00013 
00030 template< class FitT>
00031 class eoOneMax: public EO<FitT> {
00032 public:
00037   eoOneMax() 
00038   { 
00039     // START Code of default Ctor of an eoOneMax object
00040     // END   Code of default Ctor of an eoOneMax object
00041   }
00042 
00043   virtual ~eoOneMax()
00044   {
00045     // START Code of Destructor of an eoEASEAGenome object
00046     // END   Code of Destructor of an eoEASEAGenome object
00047   }
00048 
00049   virtual string className() const { return "eoOneMax"; }
00050 
00052     void printOn(ostream& _os) const
00053     {
00054       // First write the fitness
00055       EO<FitT>::printOn(_os);
00056       _os << ' ';
00057     // START Code of default output 
00058 
00063       _os << b.size() << ' ' ;
00064       for (unsigned i=0; i<b.size(); i++)
00065         _os << b[i] << ' ' ;
00066     // END   Code of default output
00067     }
00068 
00072   void readFrom(istream& _is)
00073   {
00074     // of course you should read the fitness first!
00075     EO<FitT>::readFrom(_is);
00076     // START Code of input
00077 
00082     unsigned s;
00083     _is >> s;
00084     b.resize(s);
00085     for (unsigned i=0; i<s; i++)
00086       {
00087         bool bTmp;
00088         _is >> bTmp;
00089         b[i] = bTmp;
00090       }                 
00091     // END   Code of input
00092   }
00093 
00094   // accessing and setting values
00095   void setB(vector<bool> & _b)
00096   {
00097     b=_b;
00098   }
00099   const vector<bool> & B()
00100   {
00101     return b;
00102   }
00103 
00104 private:                           // put all data here
00105     // START Private data of an eoOneMax object
00106   std::vector<bool> b;
00107     // END   Private data of an eoOneMax object
00108 };
00109 
00110 #endif
00111 

Generated on Thu Oct 19 05:06:36 2006 for EO by  doxygen 1.3.9.1