9 #include <GABinStr.hpp>
19 GADefineIdentity(
"GA2DBinaryStringGenome", GAID::BinaryStringGenome2D);
21 static void UniformInitializer(
GAGenome &);
22 static void UnsetInitializer(
GAGenome &);
23 static void SetInitializer(
GAGenome &);
24 static int FlipMutator(
GAGenome &,
float);
35 GAGenome::Evaluator f = (GAGenome::Evaluator)
nullptr,
45 for (
unsigned int i = 0; i < nx; i++)
47 for (
unsigned int j = 0; j < ny; j++)
49 gene(i, j, *(array + j * nx + i));
56 for (
unsigned int i = 0; i < nx; i++)
58 for (
unsigned int j = 0; j < ny; j++)
60 gene(i, j, *(array + j * nx + i));
66 GAGenome *clone(GAGenome::CloneMethod flag = CloneMethod::CONTENTS)
const override;
67 void copy(
const GAGenome &chrom)
override;
69 int read(std::istream &)
override;
70 int write(std::ostream &)
const override;
72 bool equal(
const GAGenome &c)
const override;
75 short gene(
unsigned int x,
unsigned int y)
const {
return bit(x + nx * y); }
76 short gene(
unsigned int x,
unsigned int y,
short value)
79 return ((bit(x + nx * y) == value) ? value : bit(x + nx * y, value));
81 int width()
const {
return nx; }
87 int height()
const {
return ny; }
93 int resize(
int x,
int y);
94 int resizeBehaviour(Dimension which)
const;
95 int resizeBehaviour(Dimension which,
unsigned int lowerX,
97 int resizeBehaviour(
unsigned int lowerX,
unsigned int upperX,
98 unsigned int lowerY,
unsigned int upperY)
100 return (resizeBehaviour(Dimension::WIDTH, lowerX, upperX) *
101 resizeBehaviour(Dimension::HEIGHT, lowerY, upperY));
104 unsigned int,
unsigned int,
unsigned int,
unsigned int);
106 unsigned int,
unsigned int,
unsigned int,
unsigned int)
const;
107 void set(
unsigned int,
unsigned int,
unsigned int,
unsigned int);
108 void unset(
unsigned int,
unsigned int,
unsigned int,
unsigned int);
109 void randomize(
unsigned int,
unsigned int,
unsigned int,
unsigned int);
110 void randomize() { GABinaryString::randomize(); }
111 void move(
unsigned int,
unsigned int,
unsigned int,
unsigned int,
112 unsigned int,
unsigned int);
115 unsigned int nx, ny, minX, minY, maxX, maxY;
This header defines the interface for the 2D binary string genome, including crossover objects and al...
Definition: GA2DBinStrGenome.h:17
This header defines the interface for the binary string.
Definition: GABinStr.hpp:24
The base genome class just defines the genome interface - how to mutate, crossover,...
Definition: GAGenome.h:200