EvolvingObjects
eoPropGAGenOp.h
00001 // -*- mode: c++; c-indent-level: 4; c++-member-init-indent: 8; comment-column: 35; -*-
00002 
00003 //-----------------------------------------------------------------------------
00004 // eoPropGAGenOp.h
00005 // (c) Marc.Schoenauer 2005
00006 /*
00007     This library is free software; you can redistribute it and/or
00008     modify it under the terms of the GNU Lesser General Public
00009     License as published by the Free Software Foundation; either
00010     version 2 of the License, or (at your option) any later version.
00011 
00012     This library is distributed in the hope that it will be useful,
00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015     Lesser General Public License for more details.
00016 
00017     You should have received a copy of the GNU Lesser General Public
00018     License along with this library; if not, write to the Free Software
00019     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020 
00021     Contact: todos@geneura.ugr.es, http://geneura.ugr.es
00022              Marc.Schoenauer@inria.fr
00023              mak@dhi.dk
00024  */
00025 //-----------------------------------------------------------------------------
00026 
00027 #ifndef _eoPropGAGenOp_h
00028 #define _eoPropGAGenOp_h
00029 
00030 #include "eoGenOp.h"
00031 #include "eoInvalidateOps.h"
00033 // class eoSGAGenOp
00035 
00043 template<class EOT>
00044 class eoPropGAGenOp : public eoGenOp<EOT>
00045 {
00046  public:
00047 
00053   eoPropGAGenOp(double _wClone, eoQuadOp<EOT>& _cross, double _wCross,
00054                  eoMonOp<EOT>& _mut, double _wMut)
00055     : wClone(_wClone),
00056       cross(_cross),
00057       wCross(_wCross),
00058       mut(_mut),
00059       wMut(_wMut)
00060   {
00061     propOp.add(cross, wCross); // the crossover - with weight wCross
00062     propOp.add(mut, wMut); // mutation with weight wMut
00063     propOp.add(monClone, wClone);
00064   }
00065 
00067   virtual void apply(eoPopulator<EOT>& _pop)
00068   {
00069     propOp.apply(_pop);
00070   }
00071 
00073   virtual unsigned max_production(void) {return 2;}
00074 
00075   virtual std::string className() const {return "eoPropGAGenOp";}
00076 
00077 
00078  private:
00079   double wClone;
00080   eoQuadOp<EOT> &cross;   // eoInvalidateXXX take the boolean output
00081   double wCross;
00082   eoMonOp<EOT> & mut;      // of the XXX op and invalidate the EOT
00083   double wMut;
00084   eoProportionalOp<EOT> propOp;
00085   eoMonCloneOp<EOT> monClone;
00086 };
00087 
00088 
00089 #endif
 All Classes Namespaces Files Functions Variables Typedefs Friends