00001 /* 00002 Teem - an open source evolutionary software framework 00003 http://lis.epfl.ch/resources/Teem 00004 Stephane Magnenat <stephane.magnenat@epfl.ch>, 00005 Antoine Beyeler <antoine.beyeler@epfl.ch>, 00006 and other contributors. See AUTHORS for details 00007 Laboratory of Intelligent Systems, EPFL, Lausanne 00008 00009 This program is free software; you can redistribute it and/or modify 00010 it under the terms of the GNU General Public License as published by 00011 the Free Software Foundation; either version 2 of the License, or 00012 (at your option) any later version. 00013 00014 This program is distributed in the hope that it will be useful, 00015 but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00017 GNU General Public License for more details. 00018 00019 You should have received a copy of the GNU General Public License 00020 along with this program; if not, write to the Free Software 00021 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00022 */ 00023 00024 #ifndef EVOLUTION_H 00025 #define EVOLUTION_H 00026 00027 #include <valarray> 00028 #include <ishtar/network.h> 00029 00038 namespace Teem 00039 { 00040 class GenotypeDecoder; 00041 class Experiment; 00042 00045 struct Serializable 00046 { 00048 virtual ~Serializable() { } 00050 virtual void load(Ishtar::InputStream *stream) = 0; 00052 virtual void save(Ishtar::OutputStream *stream) = 0; 00053 }; 00054 00057 typedef std::valarray<GenotypeDecoder *> GenotypeDecoders; 00058 00061 class Setupable 00062 { 00063 public: 00065 virtual ~Setupable() { } 00067 virtual void setupDecoders(GenotypeDecoders &decoders) = 0; 00068 }; 00069 00071 class EvolutionRun 00072 { 00073 protected: 00075 GenotypeDecoders genotypeDecoders; 00076 00077 protected: 00079 void deleteGenotypeDecoders(); 00080 00081 public: 00083 virtual ~EvolutionRun(); 00084 00086 virtual void createGenotypeDecoders(Setupable *experiment) = 0; 00087 00089 virtual void createRandomPopulation() = 0; 00090 00092 virtual bool loadPopulation(Experiment *experiment) = 0 ; 00094 virtual bool loadPopulation(Experiment *experiment, const char *) = 0; 00095 00097 virtual void run(Setupable *experiment) = 0; 00098 00100 virtual void testBestIndividual(Setupable *experiment) = 0; 00102 virtual void testIndividual(Setupable *experiment, const char *) = 0; 00103 }; 00104 } 00105 00106 #endif