ECF 1.7
IntGenotype.h
1#include "../Genotype.h"
2#include <cmath>
3#include <sstream>
4
5#include "IntGenotypeCrxOp.h"
6#include "IntGenotypeCrxTwoPoint.h"
7#include "IntGenotypeCrxAverage.h"
8#include "IntGenotypeMutOp.h"
9
10namespace IntGenotype
11{
12
17
27 class IntGenotype : public Genotype
28 {
29 public:
30 int minValue_, maxValue_;
31 uint nSize_;
32 std::vector<int> intValues;
33
34 IntGenotype()
35 {
36 name_ = "IntGenotype";
37 }
38
39 IntGenotype* copy()
40 {
41 IntGenotype *newObject = new IntGenotype(*this);
42 return newObject;
43 }
44
47 {
48 return minValue_;
49 }
50
53 {
54 return maxValue_;
55 }
56 std::vector<CrossoverOpP> getCrossoverOp()
57 {
58 std::vector<CrossoverOpP> crx;
59 crx.push_back(static_cast<CrossoverOpP> (new IntGenotypeCrxOp));
60 crx.push_back(static_cast<CrossoverOpP> (new IntGenotypeCrxTwoPoint));
61 crx.push_back(static_cast<CrossoverOpP> (new IntGenotypeCrxAverage));
62 return crx;
63 }
64
65 std::vector<MutationOpP> getMutationOp()
66 {
67 std::vector<MutationOpP> mut;
68 mut.push_back(static_cast<MutationOpP> (new IntGenotypeMutOp));
69 return mut;
70 }
71
72 void registerParameters(StateP state);
73
74 bool initialize(StateP state);
75
76 void write(XMLNode &xIntGenotype);
77
78 // mandatory if running parallel ECF or reading population from a milestone file
79 void read(XMLNode& xIntGenotype);
80 };
81}
82
83typedef std::shared_ptr<IntGenotype::IntGenotype> IntGenotypeP;
std::string name_
genotype's name
Definition Genotype.h:109
IntGenotype genotype: average crossover operator.
IntGenotype genotype: uniform crossover operator.
IntGenotype genotype: two-point crossover operator.
std::vector< MutationOpP > getMutationOp()
Create and return a vector of mutation operators.
Definition IntGenotype.h:65
IntGenotype * copy()
Create an identical copy of the genotype object.
Definition IntGenotype.h:39
int getLBound()
return lower bound of the defined interval
Definition IntGenotype.h:46
int getUBound()
return upper bound of the defined interval
Definition IntGenotype.h:52
std::vector< CrossoverOpP > getCrossoverOp()
Create and return a vector of crossover operators.
Definition IntGenotype.h:56
IntGenotype genotype: single-point mutation operator.