ECF 1.5
APGenotype.h
1#ifndef APGENOTYPE_H_
2#define APGENOTYPE_H_
3
4#include "../../ECF/tree/Tree.h"
5#include "../../ECF/tree/PrimitiveSet.h"
6#include "../../ECF/tree/Primitive.h"
7
8#include "../../ECF/RealValueGenotype.h"
9#include "../../ECF/floatingpoint/FloatingPointMutSimple.h"
10#include "../../ECF/floatingpoint/FloatingPointCrsOnePoint.h"
11#include "../../ECF/floatingpoint/FloatingPointCrsArithmetic.h"
12#include "../../ECF/floatingpoint/FloatingPointCrsDiscrete.h"
13#include "../../ECF/floatingpoint/FloatingPointCrsArithmeticSimple.h"
14#include "../../ECF/floatingpoint/FloatingPointCrsArithmeticSingle.h"
15#include "../../ECF/floatingpoint/FloatingPointCrsAverage.h"
16#include "../../ECF/floatingpoint/FloatingPointCrsFlat.h"
17#include "../../ECF/floatingpoint/FloatingPointCrsBlx.h"
18#include "../../ECF/floatingpoint/FloatingPointCrsHeuristic.h"
19#include "../../ECF/floatingpoint/FloatingPointCrsRandom.h"
20#include "../../ECF/floatingpoint/FloatingPointCrsSbx.h"
21#include "../../ECF/floatingpoint/FloatingPointCrsBga.h"
22#include "../../ECF/floatingpoint/FloatingPointCrsLocal.h"
23#include "../../ECF/floatingpoint/FloatingPointCrsBlxAlpha.h"
24#include "../../ECF/floatingpoint/FloatingPointCrsBlxAlphaBeta.h"
25
26#include "PrimitiveSetAP.h"
27#include <vector>
28
29
30namespace Tree {
31
48class APGenotype : public RealValueGenotype {
49
50public:
51
52 PrimitiveSetAPP primitiveSet;
53 std::vector<PrimitiveP> userFunctions_;
54 std::vector<PrimitiveP> userTerminals_;
55
56 StateP state_;
57
58 std::vector<NodeP> nodes;
59
60 uint toEnd;
61
62 APGenotype()
63 {
64 name_ = "APGenotype";
65 }
66
67 void registerParameters(StateP);
68
69 bool initialize(StateP state);
70
71 bool addFunction(PrimitiveP);
72 bool addTerminal(PrimitiveP);
73
74 void buildTree(std::vector<uint> indices, uint current, uint depth);
75
76 std::vector<uint> getDiscreteIndices();
77 Tree* convertToPhenotype();
78
80 double getLBound()
81 {
82 return minValue_;
83 }
84
86 double getUBound()
87 {
88 return maxValue_;
89 }
90
92 {
93 APGenotype *newObject = new APGenotype(*this);
94 return newObject;
95 }
96
98 std::vector<CrossoverOpP> getCrossoverOp()
99 {
100 std::vector<CrossoverOpP> crx;
101 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsOnePoint));
102 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmetic));
103 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsDiscrete));
104 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmeticSimple));
105 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsArithmeticSingle));
106 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsAverage));
107 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsFlat));
108 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsHeuristic));
109 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsSbx));
110 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBga));
111 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsLocal));
112 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBlxAlpha));
113 crx.push_back(static_cast<CrossoverOpP> (new FloatingPoint::FloatingPointCrsBlxAlphaBeta));
114 // control operator - not to be used in optimization
115 //crx.push_back(static_cast<CrossoverOpP> (new FloatingPointCrsRandom));
116 return crx;
117 }
118
120 std::vector<MutationOpP> getMutationOp()
121 {
122 std::vector<MutationOpP> mut;
123 mut.push_back(static_cast<MutationOpP> (new FloatingPoint::FloatingPointMutSimple));
124 return mut;
125 }
126
127 void setTerminalValue(Tree* tree, std::string name, void* value);
128
129 void write(XMLNode& xFloatingPoint);
130 void read(XMLNode& xFloatingPoint);
131};
132
133}
134
135typedef boost::shared_ptr<Tree::APGenotype> APGenotypeP;
136#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.
std::vector< MutationOpP > getMutationOp()
return usable mut operators
Definition: APGenotype.h:120
void read(XMLNode &xFloatingPoint)
Read genotype data from XMLNode.
std::vector< CrossoverOpP > getCrossoverOp()
return usable crx operators
Definition: APGenotype.h:98
double getUBound()
return upper bound of the defined interval
Definition: APGenotype.h:86
double getLBound()
return lower bound of the defined interval
Definition: APGenotype.h:80
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data)
void registerParameters(StateP)
Register genotype's parameters (called before Genotype::initialize)
APGenotype * copy()
Create an identical copy of the genotype object.
Definition: APGenotype.h:91
Tree class - implements genotype as a tree.
Definition: Tree_c.h:29