Add usage of operators in Generation and Chromosome.
[genetic.git] / src / crossover / crossover.h
index 0d9b309f7fc961f26594911f326a530727e028c5..d2eada8efb0bfe46b2d0a3edbdf6311c8bd7907b 100644 (file)
@@ -35,15 +35,15 @@ namespace genetic {
              * @return new Chromosome crossed between given two
              */
             _Chromosome do_cross(_Chromosome first, _Chromosome second, unsigned int splitPlace) {
-                const unsigned int chromosomeSize = first.get().size();
+                const unsigned int chromosomeSize = first.size();
 
 //                 cout << "        ";
 //                 for (unsigned int i = 0; i < chromosomeSize; i++) {
-//                     cout << first.get()[i].get();
+//                     cout << first[i].get();
 //                 }
 //                 cout << "\n      x ";
 //                 for (unsigned int i = 0; i < chromosomeSize; i++) {
-//                     cout << second.get()[i].get();
+//                     cout << second[i].get();
 //                 }
 //                 cout << "\n--------";
 //                 for (unsigned int i = 0; i < chromosomeSize; i++) {
@@ -58,16 +58,16 @@ namespace genetic {
                 vector<GeneType> crossedChromosome;
                 for (unsigned int i = 0; i < chromosomeSize; i++) {
                     if (i < splitPlace) {
-                        crossedChromosome.push_back(first.get()[i].get());
+                        crossedChromosome.push_back(first[i].get());
                     }
                     else {
-                        crossedChromosome.push_back(second.get()[i].get());
+                        crossedChromosome.push_back(second[i].get());
                     }
                 }
 
 //                 cout << "\n        ";
 //                 for (unsigned int i = 0; i < chromosomeSize; i++) {
-//                     cout << crossedChromosome[i].get();
+//                     cout << crossedChromosome[i];
 //                 }
 //                 cout << "\n";
 
@@ -91,14 +91,14 @@ namespace genetic {
              * @return new Generation of Chromosome's after the Crossover
              */
             Generation<_Chromosome> cross(Generation<_Chromosome> _generation) {
-                const unsigned int generationSize = _generation.get().size();
+                const unsigned int generationSize = _generation.size();
                 vector<_Chromosome> newGeneration;
 
                 for (unsigned int i = 0; i < generationSize; i++) {
                     CrossoverChanceType random = (rand() + 1 % 10000) / 10000.0;
-                    _Chromosome chromosome = _generation.get()[i];
+                    _Chromosome chromosome = _generation[i];
                     if (random < this->chance) {
-                        const unsigned int chromosomeSize = chromosome.get().size();
+                        const unsigned int chromosomeSize = chromosome.size();
                         const unsigned int splitPlace = rand() % chromosomeSize;
                         unsigned int pairedChromosome = 0;
 
@@ -109,7 +109,7 @@ namespace genetic {
                              pairedChromosome = rand() % generationSize;
                         } while(pairedChromosome == i);
 
-                        chromosome = do_cross(chromosome, _generation.get()[pairedChromosome], splitPlace);
+                        chromosome = do_cross(chromosome, _generation[pairedChromosome], splitPlace);
                     }
                     newGeneration.push_back(chromosome);
                 }