#ifndef __CROSSOVER_CROSSOVER_H
#define __CROSSOVER_CROSSOVER_H
+#include <vector>
+
#include "chromosome.h"
#include "generation.h"
/**
* Type of probability of crossover chance
*/
- typedef double CrossoverChanceType;
+ typedef float CrossoverChanceType;
/**
* Type representing Chromosome Gene
* @param splitPlace Gene number on which the Genes should be swapped
* @return new Chromosome crossed between given two
*/
- _Chromosome do_cross(_Chromosome first, _Chromosome second, unsigned int splitPlace) {
+ _Chromosome do_cross(_Chromosome& first, _Chromosome& second, const unsigned int splitPlace) {
const unsigned int chromosomeSize = first.size();
// cout << " ";
// }
// }
- vector<GeneType> crossedChromosome;
+ std::vector<GeneType> crossedChromosome;
for (unsigned int i = 0; i < chromosomeSize; i++) {
if (i < splitPlace) {
crossedChromosome.push_back(first[i].get());
*
* @param chance probability of Crossover (0 = 0%, 1 = 100%)
*/
- Crossover(CrossoverChanceType chance) :
+ Crossover(const CrossoverChanceType& chance) :
chance(chance) {
}
* @param _generation Generation for which the crossover should be applied
* @return new Generation of Chromosome's after the Crossover
*/
- Generation<_Chromosome> cross(Generation<_Chromosome> _generation) {
+ Generation<_Chromosome> cross(Generation<_Chromosome>& _generation) {
const unsigned int generationSize = _generation.size();
- vector<_Chromosome> newGeneration;
+ std::vector<_Chromosome> newGeneration;
for (unsigned int i = 0; i < generationSize; i++) {
CrossoverChanceType random = (rand() + 1 % 10000) / 10000.0;