Main Page | Modules | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

SimpleGrowableGenome.h

Go to the documentation of this file.
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 __SIMPLE_GROWABLE_GENOME_H
00025 #define __SIMPLE_GROWABLE_GENOME_H
00026 
00027 #include "Genome.h"
00028 #include <list>
00029 
00034 namespace Teem
00035 {
00038     class SimpleGrowableGenome: public Genome
00039     {
00040     public:
00042         struct Link
00043         {
00044             unsigned in; 
00045             unsigned out; 
00046             double weight; 
00047             
00049             Link(unsigned in, unsigned out, double weight);
00051             Link(Ishtar::InputStream *stream);
00053             void save(Ishtar::OutputStream *stream);
00054         };
00055     
00056     protected:
00057         friend class NeatNeuralNetwork;
00058         //static unsigned innovationCount;
00059         std::list<Link> links; 
00060         unsigned minimumToPreserve; 
00061         
00062     protected:
00063         // Support function
00065         unsigned countNodes(void); 
00067         void defragNodes(void);
00068         
00069         // Mutation operator
00071         void mutateAddLink(unsigned nodeCount);
00073         void mutateDelLink(void);
00075         void mutateChangeLink(void);
00076         
00078         void mutateAddNode(unsigned nodeCount);
00080         void mutateDelNode(unsigned nodeCount);
00081         
00083         void mutateDuplicateGenome(void);
00084         
00085         // Ishtar parameters
00086         Ishtar::Variable<double> mutationAddLinkConstProbability; 
00087         Ishtar::Variable<double> mutationAddLinkPropProbability; 
00088         Ishtar::Variable<double> mutationDelLinkProbability; 
00089         Ishtar::Variable<double> mutationChangeLinkProbability; 
00090         
00091         Ishtar::Variable<double> mutationAddNodeProbability; 
00092         Ishtar::Variable<double> mutationDelNodeProbability; 
00093         
00094         Ishtar::Variable<double> mutationDuplicateGenomeProbability; 
00095     
00096     public:
00098         SimpleGrowableGenome(Ishtar::InputStream *stream);
00100         SimpleGrowableGenome(unsigned minToPreserve);
00101         
00103         virtual ~SimpleGrowableGenome() { }
00104         virtual void randomize(void);
00105         virtual void mutate(void);
00106         virtual void cross(const Genome *other);
00107         virtual Genome *clone(void);
00108         
00109         virtual void save(Ishtar::OutputStream *stream);
00110     };
00111 }
00112 
00113 #endif

Generated on Mon Oct 24 17:38:25 2005 for Teem by  doxygen 1.4.2