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 00016 class MutationOp 00017 { 00018 public: 00019 MutationOp() 00020 { probability_ = 0; } 00021 00026 virtual bool mutate(GenotypeP) = 0; 00027 00029 virtual bool initialize(StateP) 00030 { return true; } 00031 00033 virtual void registerParameters(StateP) 00034 { } 00035 00036 virtual ~MutationOp() 00037 { } 00038 00039 StateP state_; 00040 double probability_; 00041 GenotypeP myGenotype_; 00042 }; 00043 typedef boost::shared_ptr<MutationOp> MutationOpP; 00044 00045 00054 class Mutation 00055 { 00056 public: 00057 bool mutate(IndividualP ind); 00058 uint mutation(const std::vector<IndividualP>&); 00059 void registerParameters(StateP); 00060 bool initialize(StateP); 00061 double getIndMutProb(); 00062 double setIndMutProb(double); 00063 00064 std::vector< std::vector<MutationOpP> > operators; 00065 std::vector< std::vector<double> > opProb; 00066 00067 IndividualP currentInd; // samo za ad hoc lokalnu pretragu! 00068 00069 protected: 00070 StateP state_; 00071 double indMutProb_; 00072 uint mutateGenotypes_; 00073 std::vector<bool> protectedGenotypes_; 00074 00075 }; 00076 typedef boost::shared_ptr<Mutation> MutationP; 00077 00078 #endif // Mutation_h