Gene.h

Go to the documentation of this file.
00001 
00006 #ifndef GENETIK_GP_GENE
00007 #define GENETIK_GP_GENE
00008 
00009 
00010 #include <string>
00011 
00012 #include "../util/Variant.h"
00013 using namespace std;
00014 
00015 
00016 namespace genetiK
00017 {
00018 namespace gp
00019 {
00020 class IndividualFactory;
00021 
00022 
00029 class Gene
00030 {
00031 private:
00032         unsigned int                                            cardinality; 
00033         unsigned char                                           height; 
00034         unsigned char                                           branchDepth;
00035         unsigned int                                            label; 
00036 
00037         unsigned char                                           arity;
00038         Gene**                                                  argument;
00039 
00040 public:
00041 
00048         Gene(unsigned char arity);
00053         virtual ~Gene();
00054         
00055         
00062         virtual util::Variant                                   evaluate()=0;
00063 
00064 
00069         virtual std::string                                     toString()const;
00070         
00076         unsigned char                                           getArity() const
00077         {
00078                 return arity;
00079         }
00084         Gene*                                                   getArgument(unsigned char i);
00090         void                                                    setArgument(unsigned char i, Gene* newArgument);
00091 
00098         unsigned int                                            getCardinality() const
00099         {
00100                 return cardinality;
00101         }
00108         unsigned int                                            getLabel() const
00109         {
00110                 return label;
00111         }
00112         
00120         unsigned char                                           getHeight() const
00121         {
00122                 return height;
00123         }
00128         void                                                    setHeight(unsigned char height)
00129         {
00130                 this->height = height;
00131         }
00137         unsigned char                                           getBranchDepth() const
00138         {
00139                 return branchDepth;
00140         }
00141 
00149         Gene*                                                   extract( unsigned int label);
00158         Gene*                                                   substituteBranch( unsigned int label, Gene* newSubTree);
00159 
00167         unsigned int                                            setLabels(unsigned int label);
00168 
00174         virtual Gene*                                           copyBranch() const;
00175 
00181         virtual Gene*                                           copy() const=0;
00182 
00183 };
00184 
00185 }
00186 }
00187 
00188 #endif

Generated on Thu Feb 23 12:20:45 2006 for GenetiK by  doxygen 1.4.6