00001 /*************************************************************************** 00002 * Copyright (C) 2005-2009 by Robot Group Leipzig * 00003 * martius@informatik.uni-leipzig.de * 00004 * fhesse@informatik.uni-leipzig.de * 00005 * der@informatik.uni-leipzig.de * 00006 * guettler@informatik.uni-leipzig.de * 00007 * jhoffmann@informatik.uni-leipzig.de * 00008 * joergweide84@aol.com (robot12) * 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 * This is a example implementation for a fitness strategy. It use a * 00027 * other fitness strategy to calculate a value. If the value is lower * 00028 * than 10 it will give value*value back. Else it will be 100. * 00029 * So the most values are by 100 and of one plane. The gen. Alg lose by * 00030 * this strategy his information how to optimize the individual. Because * 00031 * all individual are equal good. Only small part of it are better. * 00032 * This is the worst case for a gen. Alg. * 00033 * * 00034 * $Log: ExtreamTestFitnessStrategy.h,v $ 00035 * Revision 1.2 2009/07/21 08:37:59 robot12 00036 * add some comments 00037 * 00038 * Revision 1.1 2009/06/15 13:58:36 robot12 00039 * 3 new fitness strategys and IFitnessStrategy and SumFitnessStragegy with comments. 00040 * 00041 * 00042 * 00043 ***************************************************************************/ 00044 00045 #ifndef EXTREAMTESTFITNESSSTRATEGY_H_ 00046 #define EXTREAMTESTFITNESSSTRATEGY_H_ 00047 00048 //forward declaration 00049 class Individual; 00050 00051 //ga_tools includes 00052 #include "IFitnessStrategy.h" 00053 00054 /** 00055 * An example implementation and a extreme test for gen. Alg. 00056 */ 00057 class ExtreamTestFitnessStrategy: public IFitnessStrategy { 00058 public: 00059 /** 00060 * constructor 00061 * This strategy needs a other fitness strategy to calculate the resulting fitness. 00062 * @param fitness (IFitnessStrategy*) the other fitness 00063 */ 00064 ExtreamTestFitnessStrategy(IFitnessStrategy* fitness); 00065 00066 /** 00067 * default destructor 00068 * do nothing 00069 */ 00070 virtual ~ExtreamTestFitnessStrategy(); 00071 00072 /** 00073 * implementation for getFitness of IFitnessStrategy. 00074 * return aČ of the other fitness strategy if the value is lower than 10. 00075 * Else it return 100. 00076 * @param individual (const Indivual*) the individual for which the value is calculated 00077 * @return (double) the result 00078 */ 00079 virtual double getFitness(const Individual* individual); 00080 00081 private: 00082 /** 00083 * a other fitness strategy which is used as base calculation. 00084 */ 00085 IFitnessStrategy* m_strategy; 00086 00087 /** 00088 * disable the default constructor 00089 */ 00090 ExtreamTestFitnessStrategy(); 00091 }; 00092 00093 #endif /* EXTREAMTESTFITNESSSTRATEGY_H_ */