GPLIB++
BinaryPopulation.cpp
Go to the documentation of this file.
1 #include "BinaryPopulation.h"
2 
3 namespace gplib
4  {
5  BinaryPopulation::BinaryPopulation(const int popsize, const int genesize,
6  GeneralRNG &LocalRandom, const bool init) :
7  GeneralPopulation(popsize, genesize), Random(LocalRandom)
8  {
9  if (init)
10  InitPop();
11  }
12 
14  {
15  }
16 
18  {
19  const size_t popsize = Population.size1();
20  const size_t genesize = Population.size2();
21  for (size_t i = 0; i < popsize; ++i)
22  for (size_t j = 0; j < genesize; ++j)
23  Population(i, j) = (Random.GetNumber() > 0.5);
24  }
25 
27  const BinaryPopulation &source)
28  {
29  if (this == &source)
30  return *this;
32  Random = source.Random;
33  return *this;
34  }
35  }
The base class for the population of a genetic algorithm, implements storage and access functions...
tpopulation Population
The population of the current iteration.
A population that is encoded as a simple binary string.
virtual BinaryPopulation & operator=(const BinaryPopulation &source)
BinaryPopulation(const int popsize, const int genesize, GeneralRNG &LocalRandom, const bool init=false)
void init(int *nd, float *ranges)
Definition: cadianiso.cpp:37
virtual float GetNumber()=0
virtual GeneralPopulation & operator=(const GeneralPopulation &source)
The base class for all random number generators, defines the basic interface.
Definition: GeneralRNG.h:9