00001 00006 #ifndef GENETIK_GP_INDIVIDUAL 00007 #define GENETIK_GP_INDIVIDUAL 00008 00009 /*Include the standard genetiK::Individual*/ 00010 #include "../Individual.h" 00011 00012 00013 namespace genetiK 00014 { 00015 namespace gp 00016 { 00017 00018 00019 class IndividualFactory; 00020 class Gene; 00021 00029 class Individual : public genetiK::Individual 00030 { 00031 private: 00032 00033 IndividualFactory* individualFactory; 00034 00035 00036 Gene* root; 00037 00038 protected: 00046 Gene* extract( const unsigned int label ) const; 00047 00056 Gene* substituteBranch( const unsigned int label, Gene* newSubTree ); 00057 00063 void setLabels(); 00064 00073 unsigned int getCardinality() const; 00074 00081 IndividualFactory* getIndividualFactory() const; 00082 00088 Gene* getRoot() const{ return root; } 00089 public: 00095 Individual(IndividualFactory* individualFactory); 00096 00102 Individual(const Individual& individual); 00105 virtual ~Individual(void); 00111 virtual double fitness()=0; 00118 virtual genetiK::Individual* copy()const=0; 00124 virtual int mutate(const double mutationProbabilty); 00125 00132 virtual int crossOver( genetiK::Individual* i,genetiK::Individual** child1,genetiK::Individual** child2); 00133 00134 00139 virtual std::string toString()const; 00140 }; 00141 00142 } 00143 } 00144 00145 #endif