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 fitness strategy is for calculating the invert of a other * 00027 * fitness strategy. * 00028 * * 00029 * $Log: InvertedFitnessStrategy.h,v $ 00030 * Revision 1.2 2009/07/06 15:06:35 robot12 00031 * bugfix 00032 * 00033 * Revision 1.1 2009/07/02 15:24:53 robot12 00034 * update and add new class InvertedFitnessStrategy 00035 * 00036 * 00037 * 00038 ***************************************************************************/ 00039 00040 #ifndef INVERTEDFITNESSSTRATEGY_H_ 00041 #define INVERTEDFITNESSSTRATEGY_H_ 00042 00043 //forward declaration 00044 class Individual; 00045 00046 //ga_tools includes 00047 #include "IFitnessStrategy.h" 00048 00049 /** 00050 * This strategy calculate the invert to a other strategy. This can be used for other optimization targets than zero. 00051 * For example. Is the optimization target of the alg. infinity, than the inverted target is zero -> so the alg. can 00052 * optimize again zero and you have you infinity target. 00053 */ 00054 class InvertedFitnessStrategy: public IFitnessStrategy { 00055 public: 00056 /** 00057 * constructor 00058 * Needs a other fitness strategy, which should be inverted. 00059 * @param strategy (IFitnessStrategy*) the other fitness strategy 00060 */ 00061 InvertedFitnessStrategy(IFitnessStrategy* strategy); 00062 00063 /** 00064 * default destructor 00065 */ 00066 virtual ~InvertedFitnessStrategy(); 00067 00068 /** 00069 * returns the inverse fitness value what the other strategy returns for the individual "individual". 00070 * 00071 * @param individual (const Individual*) calculate the fitness for this individual 00072 * @return (double) The fitness value 00073 */ 00074 virtual double getFitness(const Individual* individual); 00075 00076 protected: 00077 /** 00078 * The other strategy 00079 */ 00080 IFitnessStrategy* m_strategy; 00081 00082 private: 00083 /** 00084 * disable the default constructor 00085 */ 00086 InvertedFitnessStrategy(); 00087 }; 00088 00089 #endif /* INVERTEDFITNESSSTRATEGY_H_ */