Small optimizations on performance and memory.
[genetic.git] / include / algorithm.h
index 9386607347fa9039a999ebf6b9dbd222ce6499f7..cb6acf3cf30a9fbf8227748355e215d4608785d8 100644 (file)
@@ -80,8 +80,8 @@ namespace genetic {
         Algorithm(
             generator::Generator<_Chromosome>& _generator,
            _Fitness& _fitness,
-            double crossoverChance,
-            double mutationChance) :
+            float crossoverChance,
+            float mutationChance) :
                 generator(_generator),
                 fitness(_fitness),
                 crossover(crossoverChance),
@@ -135,7 +135,7 @@ namespace genetic {
          * Displays average fitness value of the entire generation.
          */
         void showAvgFitness() {
-            double avg = 0;
+            float avg = 0;
             unsigned int generationSize = this->generation.size();
 
             for (unsigned int i = 0; i < generationSize; i++) {
@@ -150,14 +150,14 @@ namespace genetic {
          * Displays best fitness value of the entire generation.
          */
         void showBestFitness() {
-            double best = -100000;
+            float best = -100000;
             unsigned int generationSize = this->generation.size();
 
             for (unsigned int i = 0; i < generationSize; i++) {
                 _Fitness fit(this->generation[i]);
                 fit.parseArguments(fitness.getArguments());
 
-                double tmp = fit.calculate();
+                float tmp = fit.calculate();
                 if (tmp > best) {
                     best = tmp;
                 }