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 00041 template<class EOT> 00042 class eoPropGAGenOp : public eoGenOp<EOT> 00043 { 00044 public: 00045 00051 eoPropGAGenOp(double _wClone, eoQuadOp<EOT>& _cross, double _wCross, 00052 eoMonOp<EOT>& _mut, double _wMut) 00053 : wClone(_wClone), 00054 cross(_cross), 00055 wCross(_wCross), 00056 mut(_mut), 00057 wMut(_wMut) 00058 { 00059 propOp.add(cross, wCross); // the crossover - with weight wCross 00060 propOp.add(mut, wMut); // mutation with weight wMut 00061 propOp.add(monClone, wClone); 00062 } 00063 00065 virtual void apply(eoPopulator<EOT>& _pop) 00066 { 00067 propOp.apply(_pop); 00068 } 00069 00071 virtual unsigned max_production(void) {return 2;} 00072 00073 virtual std::string className() const {return "eoPropGAGenOp";} 00074 00075 00076 private: 00077 double wClone; 00078 eoQuadOp<EOT> ✗ // eoInvalidateXXX take the boolean output 00079 double wCross; 00080 eoMonOp<EOT> & mut; // of the XXX op and invalidate the EOT 00081 double wMut; 00082 eoProportionalOp<EOT> propOp; 00083 eoMonCloneOp<EOT> monClone; 00084 }; 00085 00086 00087 #endif