X-Git-Url: https://git.dlugolecki.net.pl/?a=blobdiff_plain;f=src%2Fselection%2FlinearRankSelection.h;h=8bbd3cea323013f721ded44fed6e0bec4c5ef7c5;hb=c9db29f895be287471f280bbed6cfb5271de3803;hp=8a090461801675d919147f228781f951e95263b2;hpb=5e4a04634f1d31d4c774b44184cf08d3faf4d02a;p=genetic.git diff --git a/src/selection/linearRankSelection.h b/src/selection/linearRankSelection.h index 8a09046..8bbd3ce 100644 --- a/src/selection/linearRankSelection.h +++ b/src/selection/linearRankSelection.h @@ -29,7 +29,12 @@ namespace genetic { */ typedef typename GeneticFitness::ValueType FitnessValueType; protected: + /** + * Type representing mapped Chromosome by its Rank value + */ typedef typename std::multimap ChromosomeMap; + + /** Iterator for ChromosomeMap */ typedef typename ChromosomeMap::iterator ChromosomeMapIterator; /** @@ -59,7 +64,6 @@ namespace genetic { double denominator = generationSize * (generationSize - 1); for (ChromosomeMapIterator it = generationFitness.begin(); it != generationFitness.end(); it++) { -// cout << "rank: " << rank << " denominator: " << denominator << " res: " << (rank-1)/denominator << "\n"; rankedGeneration.insert(std::make_pair(rank--/denominator, it->second)); } @@ -67,7 +71,7 @@ namespace genetic { } /** - * Selection calculations should be done here. + * Invokes Selection calculations of the Linear Rank Selection * * @return new Generation of Chromosome's that passed the Selection */ @@ -87,7 +91,6 @@ namespace genetic { random = (rand() % size) / (double)denominator; for (ChromosomeMapIterator it = probabilities.begin(); it != probabilities.end(); it++) { -// cout << "Random: " << random << " First: " << it->first << "\n"; if (random < it->first) { found = true; selected.push_back(it->second);