5 #include "chromosome.h"
6 #include "generation.h"
9 using namespace genetic;
12 typedef Gene<int> _Gene;
13 typedef Chromosome<_Gene> _Chromosome;
14 typedef Generation<_Chromosome> _Generation;
16 const unsigned int chromosomeSize = 20;
17 const unsigned int generationSize = 100;
19 std::vector<_Gene> chromosomeData;
20 std::vector<_Chromosome> generationData;
22 for (unsigned int i = 0; i < generationSize; i++) {
23 for (unsigned int j = 0; j < chromosomeSize; j++) {
24 chromosomeData.push_back(_Gene(i*j));
26 generationData.push_back(_Chromosome(chromosomeData));
29 _Generation generation(generationData);
31 _Generation generation2 = generation;
33 if (generation2.size() != generation.size()) {
34 cout << "Generation contained incorrect size after copying\n";
38 for (unsigned int i = 0; i < generation.size(); i++) {
39 for (unsigned int j = 0; j < generation[i].size(); j++) {
40 if (generation[i][j].get() != generationData[i][j].get()) {
41 cout << "Generation contained bad data after copying\n";
47 cout << "Generation is created correctly\n";