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 class is a implementation for the ISelectStrategy. It make a * 00027 * select by randomized comparison of two individual. The worse * 00028 * individual dosn't comes in the next generation. * 00029 * * 00030 * $Log: TournamentSelectStrategy.h,v $ 00031 * Revision 1.3 2009/07/21 08:37:59 robot12 00032 * add some comments 00033 * 00034 * Revision 1.2 2009/06/25 13:34:17 robot12 00035 * finish the select strategy and add some comments. 00036 * 00037 * Revision 1.1 2009/05/04 15:27:56 robot12 00038 * rename of some files and moving files to other positions 00039 * - SingletonGenAlgAPI has one error!!! --> is not ready now 00040 * 00041 * Revision 1.2 2009/05/04 09:06:00 robot12 00042 * some implements... Part7 00043 * 00044 * Revision 1.1 2009/04/30 11:51:26 robot12 00045 * some implements... new classes 00046 * 00047 * 00048 * 00049 ***************************************************************************/ 00050 00051 #ifndef TOURNAMENTSELECTSTRATEGY_H_ 00052 #define TOURNAMENTSELECTSTRATEGY_H_ 00053 00054 //includes 00055 #include <selforg/randomgenerator.h> 00056 00057 //forward declaration 00058 class Generation; 00059 00060 //ga_tools includes 00061 #include "ISelectStrategy.h" 00062 00063 /** 00064 * This class makes a select by randomized comparison of two individual of the old generation. 00065 * The worse individual dosn't comes in the next generation. If enough individual "killed", 00066 * comes the living in the next generation. 00067 * 00068 * With this method it is possible that a bad individual comes in the next generation. So you dosn't 00069 * becomes a to elite generation and save some alternatives in the gens. 00070 * This way is in this point better than the EliteSelectStrategy. 00071 */ 00072 class TournamentSelectStrategy : public ISelectStrategy { 00073 public: 00074 /** 00075 * constructor 00076 * @param random (RandGen*) a random generator for the randomized select of two individual. 00077 */ 00078 TournamentSelectStrategy(RandGen* random); 00079 00080 /** 00081 * default destructor 00082 */ 00083 virtual ~TournamentSelectStrategy(); 00084 00085 /** 00086 * implementation for the interface ISelectStrategy 00087 * @param oldGeneration (Generation*) the old generation 00088 * @param newGeneration (Generation*) the next generation 00089 */ 00090 virtual void select(Generation* oldGeneration, Generation* newGeneration); 00091 00092 protected: 00093 /** 00094 * the random generator 00095 */ 00096 RandGen* m_random; 00097 00098 private: 00099 /** 00100 * disable the default constructor 00101 */ 00102 TournamentSelectStrategy(); 00103 }; 00104 00105 #endif /* TOURNAMENTSELECTSTRATEGY_H_ */