ECF 1.5
APGenotype.h
1#ifndef APGENOTYPE_H_
2#define APGENOTYPE_H_
3
4#include "../ECF_base.h"
5
6#include "../tree/Tree.h"
7#include "../tree/PrimitiveSet.h"
8#include "../tree/Primitive.h"
9
10#include "../RealValueGenotype.h"
11#include "../floatingpoint/FloatingPointMutSimple.h"
12#include "../floatingpoint/FloatingPointCrsOnePoint.h"
13#include "../floatingpoint/FloatingPointCrsArithmetic.h"
14#include "../floatingpoint/FloatingPointCrsDiscrete.h"
15#include "../floatingpoint/FloatingPointCrsArithmeticSimple.h"
16#include "../floatingpoint/FloatingPointCrsArithmeticSingle.h"
17#include "../floatingpoint/FloatingPointCrsAverage.h"
18#include "../floatingpoint/FloatingPointCrsFlat.h"
19#include "../floatingpoint/FloatingPointCrsBlx.h"
20#include "../floatingpoint/FloatingPointCrsHeuristic.h"
21#include "../floatingpoint/FloatingPointCrsRandom.h"
22#include "../floatingpoint/FloatingPointCrsSbx.h"
23#include "../floatingpoint/FloatingPointCrsBga.h"
24#include "../floatingpoint/FloatingPointCrsLocal.h"
25#include "../floatingpoint/FloatingPointCrsBlxAlpha.h"
26#include "../floatingpoint/FloatingPointCrsBlxAlphaBeta.h"
27
28#include "PrimitiveSetAP.h"
29#include <vector>
30
31
32namespace Tree {
33
51
52public:
53
54 PrimitiveSetAPP primitiveSet;
55 std::vector<PrimitiveP> userFunctions_;
56 std::vector<PrimitiveP> userTerminals_;
57
58 StateP state_;
59
60 std::vector<NodeP> nodes;
61
62 uint toEnd;
63
65 {
66 name_ = "APGenotype";
67 }
68
69 void registerParameters(StateP);
70
71 bool initialize(StateP state);
72 virtual void initializeFirst(APGenotype* persistent);
73
74 bool addFunction(PrimitiveP);
75 bool addTerminal(PrimitiveP);
76
77 void buildTree(std::vector<uint> indices, uint current, uint depth);
78
79 std::vector<uint> getDiscreteIndices();
80 Tree* convertToPhenotype();
81
83 double getLBound()
84 {
85 return minValue_;
86 }
87
89 double getUBound()
90 {
91 return maxValue_;
92 }
93
95 {
96 APGenotype *newObject = new APGenotype(*this);
97 return newObject;
98 }
99
101 std::vector<CrossoverOpP> getCrossoverOp()
102 {
103 std::vector<CrossoverOpP> crx;
104 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsOnePoint));
105 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmetic));
106 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsDiscrete));
107 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmeticSimple));
108 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmeticSingle));
109 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsAverage));
110 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsFlat));
111 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsHeuristic));
112 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsSbx));
113 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBga));
114 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsLocal));
115 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBlxAlpha));
116 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBlxAlphaBeta));
117 // control operator - not to be used in optimization
118 //crx.push_back(static_cast<CrossoverOpP> (new FloatingPointCrsRandom));
119 return crx;
120 }
121
123 std::vector<MutationOpP> getMutationOp()
124 {
125 std::vector<MutationOpP> mut;
126 mut.push_back(static_cast<MutationOpP> (new FloatingPoint::FloatingPointMutSimple));
127 return mut;
128 }
129
130 void setTerminalValue(Tree* tree, std::string name, void* value);
131
132 void write(XMLNode& xFloatingPoint);
133 void read(XMLNode& xFloatingPoint);
134};
135
136}
137
138typedef boost::shared_ptr<Tree::APGenotype> APGenotypeP;
139#endif
FloatingPoint genotype: offspring is defined as a linear combination of two vectors.
FloatingPoint genotype: take recombination point k. Child 1 is parent1 until k, rest is arithmetic av...
FloatingPoint genotype: take random allele k. That point is arithmetic average of parents,...
FloatingPoint genotype: child is average value of parent genes.
FloatingPoint genotype: BGA crossover (http://bib.irb.hr/datoteka/640222.CEC_2013....
FloatingPoint genotype: BLX alpha-beta crossover (http://bib.irb.hr/datoteka/640222....
FloatingPoint genotype: BLX alpha crossover (http://bib.irb.hr/datoteka/640222.CEC_2013....
FloatingPoint genotype: allele value for each gene is either from parent1 or from parent2 with equal ...
FloatingPoint genotype: value on allele i is random value taken from min-max interval from parents.
FloatingPoint genotype: value on allele i smaller gene value + rand value * (greater - smaller value)
FloatingPoint genotype: local crossover (http://bib.irb.hr/datoteka/640222.CEC_2013....
FloatingPoint genotype: one point crossover operator with permissible split points only between dimen...
FloatingPoint genotype: SBX crossover (http://citeseerx.ist.psu.edu/viewdoc/download?...
FloatingPoint genotype: simple mutation where a single vector element is mutated. New value is random...
std::string name_
genotype's name
Definition: Genotype.h:109
RealValueGenotype class - abstract genotype class for genotypes that represent a vector of real value...
double minValue_
lower bound
double maxValue_
upper bound
Analytical Programing genotype class - implements genotype as a vector of floating point values that ...
Definition: APGenotype.h:50
void write(XMLNode &xFloatingPoint)
Write genotype data to XMLNode.
Definition: APGenotype.cpp:379
std::vector< MutationOpP > getMutationOp()
return usable mut operators
Definition: APGenotype.h:123
void read(XMLNode &xFloatingPoint)
Read genotype data from XMLNode.
Definition: APGenotype.cpp:393
std::vector< CrossoverOpP > getCrossoverOp()
return usable crx operators
Definition: APGenotype.h:101
double getUBound()
return upper bound of the defined interval
Definition: APGenotype.h:89
double getLBound()
return lower bound of the defined interval
Definition: APGenotype.h:83
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data)
Definition: APGenotype.cpp:39
void registerParameters(StateP)
Register genotype's parameters (called before Genotype::initialize)
Definition: APGenotype.cpp:9
APGenotype * copy()
Create an identical copy of the genotype object.
Definition: APGenotype.h:94
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29