00001 /*************************************************************************** 00002 * Copyright (C) 2008-2011 LpzRobots development team * 00003 * Joerg Weider <joergweide84 at aol dot com> (robot12) * 00004 * Georg Martius <georg dot martius at web dot de> * 00005 * Frank Guettler <guettler at informatik dot uni-leipzig dot de * 00006 * Frank Hesse <frank at nld dot ds dot mpg dot de> * 00007 * Ralf Der <ralfder at mis dot mpg dot de> * 00008 * Joern Hoffmann <jhoffmann at informatik dot uni-leipzig dot de * 00009 * * 00010 * This program is free software; you can redistribute it and/or modify * 00011 * it under the terms of the GNU General Public License as published by * 00012 * the Free Software Foundation; either version 2 of the License, or * 00013 * (at your option) any later version. * 00014 * * 00015 * This program is distributed in the hope that it will be useful, * 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00018 * GNU General Public License for more details. * 00019 * * 00020 * You should have received a copy of the GNU General Public License * 00021 * along with this program; if not, write to the * 00022 * Free Software Foundation, Inc., * 00023 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00024 * * 00025 ***************************************************************************/ 00026 00027 #ifndef VALUEMUTATIONSTRATEGY_H_ 00028 #define VALUEMUTATIONSTRATEGY_H_ 00029 00030 //forward declarations 00031 class Gen; 00032 class Individual; 00033 class GenContext; 00034 class SingletonGenFactory; 00035 class IMutationFactorStrategy; 00036 00037 //ga_tools includes 00038 #include "IMutationStrategy.h" 00039 00040 /** 00041 * this mutation strategy clculate a mutation factor by using a 00042 * mutation factor strategy an add this factor to the old gen. 00043 */ 00044 class ValueMutationStrategy : public IMutationStrategy { 00045 public: 00046 /** 00047 * constructor 00048 * @param strategy (IMutationFactorStrategy*) this strategie is used to calculate the mutation factor. 00049 * @param mutationProbability (int) the mutation probability which is give back. 00050 */ 00051 ValueMutationStrategy(IMutationFactorStrategy* strategy, int mutationProbability); 00052 00053 /** 00054 * default destructor 00055 */ 00056 virtual ~ValueMutationStrategy(); 00057 00058 /** 00059 * mutate a gen 00060 * @param context (GenContext*) the context in which the new gen comes (needed by the factory 00061 * @param individual (Individual*) the individual, which the new gen becomes 00062 * @param oldGen (Gen*) the old gen, which mutate 00063 * @param oldContext (GenContext*) the Context in which the old gen are. 00064 * @param factory (SingletonGenFactory*) the GenFactory which create the new gen. 00065 * @return (Gen*) the new mutated gen 00066 */ 00067 virtual Gen* mutate(GenContext* context, Individual* individual, Gen* oldGen, GenContext* oldContext, SingletonGenFactory* factory); 00068 00069 /** 00070 * gives the Probability of a mutation back. 00071 * @return 00072 */ 00073 virtual int getMutationProbability(void); 00074 00075 protected: 00076 /** 00077 * the mutation factor strategy 00078 */ 00079 IMutationFactorStrategy* m_strategy; 00080 00081 /** 00082 * the mutation probability 00083 */ 00084 int m_mutationProbability; 00085 00086 private: 00087 /** 00088 * disable the default constructor 00089 */ 00090 ValueMutationStrategy(); 00091 }; 00092 00093 #endif /* VALUEMUTATIONSTRATEGY_H_ */