X-Git-Url: https://git.dlugolecki.net.pl/?p=genetic.git;a=blobdiff_plain;f=include%2Fmutation%2Fmutation.h;h=6c2b853b0855e72f89c75c6922e84a6835d96f7e;hp=a35b312b60d637359e7e5d028c79be6bdd5a730e;hb=1e175fb658e55f4cc8b894fff288be22998e78af;hpb=2a8fc81203107eb3495a50fb2666803fda3e0517 diff --git a/include/mutation/mutation.h b/include/mutation/mutation.h index a35b312..6c2b853 100644 --- a/include/mutation/mutation.h +++ b/include/mutation/mutation.h @@ -1,13 +1,11 @@ #ifndef __MUTATION_MUTATION_H #define __MUTATION_MUTATION_H -#include +#include #include "chromosome.h" #include "generation.h" -using namespace std; - namespace genetic { // namespace mutation { /** @@ -19,7 +17,7 @@ namespace genetic { /** * Type of probability of mutation chance */ - typedef double MutationChanceType; + typedef float MutationChanceType; /** * Type representing Chromosome Gene @@ -37,7 +35,7 @@ namespace genetic { * * @param chance Chance on which Mutation can occur. */ - Mutation(MutationChanceType chance) : + Mutation(const MutationChanceType& chance) : chance(chance) { } @@ -48,10 +46,10 @@ namespace genetic { * @param _generation Generation for which the mutation should be applied * @return new Generation of Chromosome's that passed the mutation */ - Generation<_Chromosome> mutate(Generation<_Chromosome> _generation) { + Generation<_Chromosome> mutate(Generation<_Chromosome>& _generation) { const unsigned int generationSize = _generation.size(); const unsigned int chromosomeSize = _generation[0].size(); - vector<_Chromosome> newGeneration; + std::vector<_Chromosome> newGeneration; for (unsigned int i = 0; i < generationSize; i++) { MutationChanceType random = (rand() % 10000) / 10000.0;