ECF 1.5
Mutation.h
1#ifndef Mutation_h
2#define Mutation_h
3
4class Individual;
5typedef boost::shared_ptr<Individual> IndividualP;
6class Genotype;
7typedef boost::shared_ptr<Genotype> GenotypeP;
8
17{
18public:
20 { probability_ = 0; }
21
26 virtual bool mutate(GenotypeP) = 0;
27
29 virtual bool initialize(StateP)
30 { return true; }
31
33 virtual void registerParameters(StateP)
34 { }
35
36 virtual ~MutationOp()
37 { }
38
39 StateP state_;
40 double probability_;
41 GenotypeP myGenotype_;
42};
43typedef boost::shared_ptr<MutationOp> MutationOpP;
44
45
55{
56public:
57 bool mutate(IndividualP ind);
58 uint mutation(const std::vector<IndividualP>&);
59 void registerParameters(StateP);
60 bool initialize(StateP);
61 double getIndMutProb();
62 double setIndMutProb(double);
63
64 std::vector< std::vector<MutationOpP> > operators;
65 std::vector< std::vector<double> > opProb;
66
67 IndividualP currentInd; // samo za ad hoc lokalnu pretragu!
68
69protected:
70 StateP state_;
71 double indMutProb_;
73 std::vector<bool> protectedGenotypes_;
74
75};
76typedef boost::shared_ptr<Mutation> MutationP;
77
78#endif // Mutation_h
Genotype base class.
Definition: Genotype.h:36
Individual class - inherits a vector of Genotype objects.
Definition: Individual.h:12
Mutation class - handles mutation of individuals (as opposed to MutationOp class that mutates genotyp...
Definition: Mutation.h:55
double getIndMutProb()
Return current individual mutation probability.
Definition: Mutation.cpp:10
double setIndMutProb(double)
Set new individual mutation probability (ignored if not [0, 1])
Definition: Mutation.cpp:19
uint mutateGenotypes_
what genotypes (if more than one) to mutate (random, all)
Definition: Mutation.h:72
std::vector< bool > protectedGenotypes_
protected (non-mutatable) genotypes flags
Definition: Mutation.h:73
bool initialize(StateP)
Initialize all mutation operators of all active genotypes.
Definition: Mutation.cpp:45
uint mutation(const std::vector< IndividualP > &)
Perform mutation on a pool of individuals.
Definition: Mutation.cpp:133
bool mutate(IndividualP ind)
Mutate an individual.
Definition: Mutation.cpp:153
double indMutProb_
mutation probability of an individual
Definition: Mutation.h:71
void registerParameters(StateP)
Register mutation related but Genotype unrelated parameters.
Definition: Mutation.cpp:30
std::vector< std::vector< double > > opProb
usage probabilities for each MutationOp operator
Definition: Mutation.h:65
std::vector< std::vector< MutationOpP > > operators
vectors of mutation operators for each genotype
Definition: Mutation.h:64
MutationOp base class.
Definition: Mutation.h:17
virtual bool initialize(StateP)
Initialize mutation operator. Called before first mutation operation.
Definition: Mutation.h:29
virtual bool mutate(GenotypeP)=0
Performs mutation of a genotype object. The genotype object must be initialized!
virtual void registerParameters(StateP)
Register parameters with the system. Called before MutationOp::initialize.
Definition: Mutation.h:33
double probability_
probability of usage of this mutation operator
Definition: Mutation.h:40
GenotypeP myGenotype_
pointer to the Genotype that defines this MutationOp
Definition: Mutation.h:41