9 #include "GABinStr.hpp"
45 GADefineIdentity(
"GA1DBinaryStringGenome", GAID::BinaryStringGenome);
47 static void UniformInitializer(
GAGenome &);
48 static void UnsetInitializer(
GAGenome &);
49 static void SetInitializer(
GAGenome &);
50 static int FlipMutator(
GAGenome &,
float);
67 for (
unsigned int i = 0; i <
data.size(); i++)
69 gene(i, *(array + i));
75 for (
unsigned int i = 0; i <
data.size(); i++)
77 gene(i, *(array + i));
82 GAGenome *clone(GAGenome::CloneMethod flag = CloneMethod::CONTENTS)
const override;
83 void copy(
const GAGenome &)
override;
85 int read(std::istream &is)
override;
86 int write(std::ostream &os)
const override;
88 bool equal(
const GAGenome &c)
const override;
90 short gene(
unsigned int x = 0)
const {
return bit(x); }
91 short gene(
unsigned int x,
short value)
94 return ((bit(x) == value) ? value : bit(x, value));
96 short operator[](
unsigned int x) {
return gene(x); }
97 int length()
const {
return nx; }
104 int resizeBehaviour()
const;
105 int resizeBehaviour(
unsigned int lower,
unsigned int upper);
107 unsigned int x,
unsigned int length);
109 unsigned int x,
unsigned int length)
const;
110 void set(
unsigned int x,
unsigned int length);
111 void unset(
unsigned int x,
unsigned int length);
112 void randomize(
unsigned int x,
unsigned int length);
113 void randomize() { GABinaryString::randomize(); }
114 void move(
unsigned int destx,
unsigned int srcx,
unsigned int length);
123 unsigned int r,
unsigned int x,
126 if (l > 0 && x < orig.nx && r < nx)
140 inline void GA1DBinaryStringGenome::set(
unsigned int x,
unsigned int l)
146 GABinaryString::set(x, l);
149 inline void GA1DBinaryStringGenome::unset(
unsigned int x,
unsigned int l)
155 GABinaryString::unset(x, l);
158 inline void GA1DBinaryStringGenome::randomize(
unsigned int x,
unsigned int l)
164 GABinaryString::randomize(x, l);
167 inline void GA1DBinaryStringGenome::move(
unsigned int x,
unsigned int srcx,
Interface for the 1D binary string genome, including crossover objects and all the default and built-...
Definition: GA1DBinStrGenome.h:43
This header defines the interface for the binary string.
Definition: GABinStr.hpp:24
std::vector< GABit > data
the data themselves
Definition: GABinStr.hpp:137
void copy(const GABinaryString &orig)
Copy the contents of the bitstream.
Definition: GABinStr.hpp:35
void move(unsigned int destIdx, unsigned int sourceIdx, unsigned int l)
Copy (sub) bitstream.
Definition: GABinStr.hpp:98
The base genome class just defines the genome interface - how to mutate, crossover,...
Definition: GAGenome.h:200