ECF 1.5
AlgClonalg.h
1#ifndef Clonalg_h
2#define Clonalg_h
3
4#include "Algorithm.h"
5#include "floatingpoint/FloatingPoint.h"
6
24class Clonalg : public Algorithm
25{
26protected:
27
28 double ubound;
29 double lbound;
30 uint dimension;
31 bool areGenotypesAdded_;
32
33 uint n;
34 double beta;
35 double c;
36 double d;
37 std::string cloningVersion;
38 std::string selectionScheme;
39
41 static bool sortPopulationByFitness (IndividualP ab1,IndividualP ab2) { return ( ab1->fitness->isBetterThan(ab2->fitness)); }
42
44 static bool sortPopulationByParentAndFitness (IndividualP ab1,IndividualP ab2)
45 {
46 FloatingPointP flp = boost::dynamic_pointer_cast<FloatingPoint::FloatingPoint> (ab1->getGenotype(1));
47 double &parentAb1 = flp->realValue[0];
48 flp = boost::dynamic_pointer_cast<FloatingPoint::FloatingPoint> (ab2->getGenotype(1));
49 double &parentAb2 = flp->realValue[0];
50
51 if (parentAb1 <parentAb2) return true;
52 if (parentAb1 == parentAb2) return (ab1->fitness->isBetterThan(ab2->fitness));
53
54 return false;
55 }
56
57public:
58
59 Clonalg();
60 void registerParameters(StateP state);
61 bool initialize(StateP state);
62 bool advanceGeneration(StateP state, DemeP deme);
63
64 bool markAntibodies(DemeP deme);
65 bool cloningPhase(StateP state, DemeP deme, std::vector<IndividualP> &clones);
66 bool hypermutationPhase(StateP state, DemeP deme, std::vector<IndividualP> &clones);
67 bool selectionPhase(StateP state, DemeP deme, std::vector<IndividualP> &clones);
68 bool birthPhase(StateP state, DemeP deme, std::vector<IndividualP> &clones);
69 bool replacePopulation(StateP state, DemeP deme, std::vector<IndividualP> &clones);
70
71};
72typedef boost::shared_ptr<Clonalg> ClonalgP;
73
74
75#endif // Clonalg_h
76
Algorithm base class.
Definition: Algorithm.h:20
Clonal Selection Algorithm (see e.g. http://en.wikipedia.org/wiki/Clonal_Selection_Algorithm).
Definition: AlgClonalg.h:25
double d
fraction of population regenerated every generation
Definition: AlgClonalg.h:36
static bool sortPopulationByFitness(IndividualP ab1, IndividualP ab2)
sort vector of antibodies in regards to their fitness
Definition: AlgClonalg.h:41
static bool sortPopulationByParentAndFitness(IndividualP ab1, IndividualP ab2)
sort vector of antibodies first by their antibody parents and then by their fitness
Definition: AlgClonalg.h:44
std::string cloningVersion
specifies whether to use static or proportional cloning
Definition: AlgClonalg.h:37
bool initialize(StateP state)
Initialize the algorithm, read parameters from the system, do a sanity check.
Definition: AlgClonalg.cpp:33
bool markAntibodies(DemeP deme)
mark antibodies so the alg can know which clone belongs to which parent Antibody
Definition: AlgClonalg.cpp:141
uint n
number of antibodies cloned every generation
Definition: AlgClonalg.h:33
double beta
parameter which determines the number of clones for every antibody
Definition: AlgClonalg.h:34
bool advanceGeneration(StateP state, DemeP deme)
Perform a single generation on a single deme.
Definition: AlgClonalg.cpp:125
bool replacePopulation(StateP state, DemeP deme, std::vector< IndividualP > &clones)
replace population with the contents of clones vector
Definition: AlgClonalg.cpp:296
double c
mutation parameter
Definition: AlgClonalg.h:35
std::string selectionScheme
specifies which selection scheme to use CLONALG1 or CLONALG2
Definition: AlgClonalg.h:38
void registerParameters(StateP state)
Register algorithm's parameters (if any).
Definition: AlgClonalg.cpp:16