ECF 1.5
Crossover.h
1#ifndef Crossover_h
2#define Crossover_h
3
4#include "Individual.h"
5
6class Individual;
7typedef boost::shared_ptr<Individual> IndividualP;
8class Genotype;
9typedef boost::shared_ptr<Genotype> GenotypeP;
10
19{
20public:
22 { probability_ = 0; }
23
28 virtual bool mate(GenotypeP, GenotypeP, GenotypeP) = 0;
29
31 virtual bool initialize(StateP)
32 { return true; }
33
35 virtual void registerParameters(StateP)
36 { }
37
38 virtual ~CrossoverOp()
39 { }
40
41 StateP state_;
42 double probability_;
43 GenotypeP myGenotype_;
44};
45typedef boost::shared_ptr<CrossoverOp> CrossoverOpP;
46
47
57{
58public:
59 bool mate(IndividualP ind1, IndividualP ind2, IndividualP child);
60 void registerParameters(StateP);
61 bool initialize(StateP);
62
63 std::vector< std::vector<CrossoverOpP> > operators;
64 std::vector< std::vector<double> > opProb;
65
66protected:
67 StateP state_;
69 std::vector<bool> protectedGenotypes_;
70};
71typedef boost::shared_ptr<Crossover> CrossoverP;
72
73#endif // Crossover_h
Crossover class - handles crossover of individuals (as opposed to CrossoverOp class that crosses geno...
Definition: Crossover.h:57
void registerParameters(StateP)
Register crossover related but Genotype unrelated parameters.
Definition: Crossover.cpp:10
uint crxGenotypes_
what genotypes (if more than one) to cross (random, all)
Definition: Crossover.h:68
std::vector< bool > protectedGenotypes_
protected (non-crossable) genotypes flags
Definition: Crossover.h:69
bool mate(IndividualP ind1, IndividualP ind2, IndividualP child)
Crosses 2 individuals.
Definition: Crossover.cpp:95
std::vector< std::vector< double > > opProb
usage probabilities for each CrossoverOp operator
Definition: Crossover.h:64
bool initialize(StateP)
Initialize all crossover operators of all active genotypes.
Definition: Crossover.cpp:22
std::vector< std::vector< CrossoverOpP > > operators
vectors of crx operators for each genotype
Definition: Crossover.h:63
CrossoverOp base class.
Definition: Crossover.h:19
double probability_
probability of usage of this crossover operator
Definition: Crossover.h:42
GenotypeP myGenotype_
pointer to the Genotype that defines this CrossoverOp
Definition: Crossover.h:43
virtual void registerParameters(StateP)
Register parameters with the system. Called before CrossoverOp::initialize.
Definition: Crossover.h:35
virtual bool initialize(StateP)
Initialize crossover operator. Called before first crossover operation.
Definition: Crossover.h:31
virtual bool mate(GenotypeP, GenotypeP, GenotypeP)=0
Genotype base class.
Definition: Genotype.h:36
Individual class - inherits a vector of Genotype objects.
Definition: Individual.h:12