00001 #ifndef Mutation_h
00002 #define Mutation_h
00003
00004 class Individual;
00005 typedef boost::shared_ptr<Individual> IndividualP;
00006 class Genotype;
00007 typedef boost::shared_ptr<Genotype> GenotypeP;
00008
00015 class MutationOp
00016 {
00017 public:
00018 MutationOp()
00019 { probability_ = 0; }
00020
00025 virtual bool mutate(GenotypeP) = 0;
00026
00030 virtual bool initialize(StateP)
00031 { return true; }
00032
00036 virtual void registerParameters(StateP)
00037 { }
00038
00039 virtual ~MutationOp()
00040 { }
00041
00042 StateP state_;
00043 double probability_;
00044 GenotypeP myGenotype_;
00045 };
00046 typedef boost::shared_ptr<MutationOp> MutationOpP;
00047
00048
00055 class Mutation
00056 {
00057 public:
00058 bool mutate(IndividualP ind);
00059 uint mutation(const std::vector<IndividualP>&);
00060 void registerParameters(StateP);
00061 bool initialize(StateP);
00062
00063 std::vector< std::vector<MutationOpP> > operators;
00064 std::vector< std::vector<double> > opProb;
00065
00066 IndividualP currentInd;
00067
00068 protected:
00069 StateP state_;
00070 double indMutProb_;
00071 double geneMutProb_;
00072 uint mutateGenotypes_;
00073 std::vector<bool> protectedGenotypes_;
00074
00075 };
00076 typedef boost::shared_ptr<Mutation> MutationP;
00077
00078 #endif // Mutation_h