ECF 1.5
Binary.h
1#ifndef BINARY_H_
2#define BINARY_H_
3
4#include "BinaryCrsOnePoint.h"
5#include "BinaryCrsTwoPoint.h"
6#include "BinaryMutSimple.h"
7#include "BinaryMutMix.h"
8#include "BinaryCrsUniform.h"
9#include "BinaryCrsHalfUniform.h"
10#include "BinaryCrsReducedSurrogate.h"
11#include "BinaryCrsSegmented.h"
12#include "BinaryCrsShuffle.h"
13#include "BinaryCrsNonGeometric.h"
14#include "BinaryCrsRandomRespectful.h"
15#include "BinaryCrsMasked.h"
16
17#include "../RealValueGenotype.h"
18
19namespace Binary
20{
21
39 friend class BinaryMutSimple; // za potrebe ad-hoc lokalnog operatora!
40protected:
41 uint nDecimal_;
42 uint nBits_;
43 long potention_;
45 typedef std::vector<bool> v_bool;
46 v_bool vBool_;
47
48 double logbase(double a, double base);
49 double round(double, int);
50
51public:
52 std::vector<long int> decValue;
53 std::vector<v_bool> variables;
54
55 Binary ()
56 { name_ = "Binary"; }
57
60 { return nBits_; }
61
62 bool initialize (StateP state);
63
64 void registerParameters(StateP state);
65
67 bool update (void);
68
70 {
71 Binary *newObject = new Binary(*this);
72 return newObject;
73 }
74
75 std::vector<CrossoverOpP> getCrossoverOp()
76 {
77 std::vector<CrossoverOpP> crx;
78 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsOnePoint));
79 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsTwoPoint));
80 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsUniform));
81 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsHalfUniform));
82 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsReducedSurrogate));
83 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsSegmented));
84 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsShuffle));
85 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsNonGeometric));
86 crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsRandomRespectful));
87 // TODO: reimplement
88 //crx.push_back(static_cast<CrossoverOpP> (new BinaryCrsMasked));
89 return crx;
90 }
91
92 std::vector<MutationOpP> getMutationOp()
93 {
94 std::vector<MutationOpP> mut;
95 mut.push_back(static_cast<MutationOpP> (new BinaryMutSimple));
96 mut.push_back(static_cast<MutationOpP> (new BinaryMutMix));
97 return mut;
98 }
99
100 void write(XMLNode& xBinary);
101
102 void read(XMLNode& xBinary);
103};
104
105}
106typedef boost::shared_ptr<Binary::Binary> BinaryP;
107#endif
Binary genotype: half uniform crossover operator.
Binary genotype: non geometric crossover operator.
Binary genotype: one point crossover operator.
Binary genotype: random respectful crossover operator. Described on http://www.tomaszgwiazda....
Binary genotype: reduced surrogate crossover operator.
Binary genotype: segmented crossover operator.
Binary genotype: shuffle crossover operator.
Binary genotype: two point crossover operator.
Binary genotype: uniform crossover operator.
Binary class - implements genotype as a vector of binary coded real values with variable interval and...
Definition: Binary.h:38
uint nDecimal_
number of digits after the decimal point
Definition: Binary.h:41
std::vector< long int > decValue
integer values of bit representation
Definition: Binary.h:52
std::vector< v_bool > variables
vector of bit vectors
Definition: Binary.h:53
bool bRounding_
use rounding with 'precision' digits on real values in the chromosome
Definition: Binary.h:44
uint nBits_
number of bits for a single dimension
Definition: Binary.h:42
std::vector< MutationOpP > getMutationOp()
Create and return a vector of mutation operators.
Definition: Binary.h:92
std::vector< CrossoverOpP > getCrossoverOp()
Create and return a vector of crossover operators.
Definition: Binary.h:75
v_bool vBool_
temporary bool vector
Definition: Binary.h:46
uint getNumBits()
Return number of bits used in a single dimension in real domain.
Definition: Binary.h:59
Binary * copy()
Create an identical copy of the genotype object.
Definition: Binary.h:69
Binary genotype: mixing mutation operator.
Definition: BinaryMutMix.h:13
Binary genotype: simple (bit-flip) mutation operator.
RealValueGenotype class - abstract genotype class for genotypes that represent a vector of real value...