ECF 1.7
GEPChromosome.h
1#ifndef GEPCHROMOSOME_H
2#define GEPCHROMOSOME_H
3
4#include "../ECF.h"
5#include "../tree/Tree.h"
6#include "GEPChromosomeCrsOnePoint.h"
7#include "GEPChromosomeCrsTwoPoint.h"
8#include "GEPChromosomeCrsGene.h"
9#include "GEPChromosomeMutOp.h"
10#include "GEPChromosomeMutGauss.h"
11#include <vector>
12#define GEP_GENE_PREFIX "GENE_"
13
14namespace GEP{
15
33 class GEPChromosome : public std::vector<Tree::NodeP>, public Genotype
34 {
35 protected:
36 StateP state_;
37 std::vector<Tree::PrimitiveP> userFunctions_; // programatically added functions
38 std::vector<Tree::PrimitiveP> userTerminals_; // programatically added terminals
39 public:
42 uint dcLength;
46 uint genes;
47 Tree::PrimitiveSetP primitiveSet_; // contains all functions, terminals and the ERC placeholder (if needed)
48 Tree::PrimitiveSetP linkFunctionSet_; // contains all linking functions and genic terminals (integers)
49 Tree::PrimitiveSetP ercSet_; // contains only the ERC ranges
50 bool usesERC;
52 Tree::Tree *cellTree;
53 std::vector<Tree::Tree*> subtrees;
54
55 GEPChromosome();
56 GEPChromosome* copy();
57 std::vector<CrossoverOpP> getCrossoverOp();
58 std::vector<MutationOpP> getMutationOp();
59 bool addFunction(Tree::PrimitiveP func);
60 void registerParameters(StateP state);
61 bool initialize(StateP state);
62 void initializeFirst(GEPChromosome* home);
63 void write(XMLNode &xGEPChromosome);
64 void read(XMLNode& xGEPChromosomeInd);
65 void execute(void*);
66 Tree::Tree* toTree(uint gene);
67 Tree::Tree* makeCellTree();
68 void assemble();
69 void generateChromosome();
70 void setTerminalValue(std::string name, void* value);
71 };
72}
73typedef std::shared_ptr<GEP::GEPChromosome> GEPChromosomeP;
74#endif // GEPChromosome_h
uint genes
number of genes
void read(XMLNode &xGEPChromosomeInd)
Read genotype data from XMLNode.
bool initialize(StateP state)
Initialize a genotype object (read parameters, perform sanity check, build data).
bool usesERC
whether or not the chromosome uses random constants
std::vector< CrossoverOpP > getCrossoverOp()
Create and return a vector of crossover operators.
void write(XMLNode &xGEPChromosome)
Write genotype data to XMLNode.
uint tailLength
length of the tail. Automatically calculated.
GEPChromosome * copy()
Create an identical copy of the genotype object.
uint linkTailLength
length of the linking function gene's tail
uint geneLength
total length of each gene
void setTerminalValue(std::string name, void *value)
Set a terminal's value.
uint linkHeadLength
length of the linking function gene's head
uint dcLength
length of the constant values domain
uint headLength
length of the head. User-specified
void registerParameters(StateP state)
Register genotype's parameters (called before Genotype::initialize).
std::vector< MutationOpP > getMutationOp()
Create and return a vector of mutation operators.
bool addFunction(Tree::PrimitiveP func)
Add user defined function primitive. Must be called prior to initialization (no impact otherwise).
bool staticLink
whether we are using a static linking function or if it should be allowed to evolve
Tree class - implements genotype as a tree.
Definition Tree_c.h:29