* \attention Method is currently not in use.
*/
void showGeneration() {
- for (unsigned int i = 0; i < this->generation.size(); i++) {
+ unsigned int generationSize = this->generation.size();
+ unsigned int chromosomeSize = this->generation[0].size();
+
+ for (unsigned int i = 0; i < generationSize; i++) {
cout << "# " << i << ") ";
- for (unsigned int j = 0; j < this->generation[i].size(); j++) {
+ for (unsigned int j = 0; j < chromosomeSize; j++) {
cout << this->generation[i][j].get();
}
cout << "\n";
*/
void showAvgFitness() {
double avg = 0;
- for (unsigned int i = 0; i < this->generation.size(); i++) {
+ unsigned int generationSize = this->generation.size();
+
+ for (unsigned int i = 0; i < generationSize; i++) {
_Fitness fit(this->generation[i]);
fit.parseArguments(fitness.getArguments());
avg += fit.calculate();
}
- cout << " " << avg / this->generation.size();
+ cout << " " << avg / generationSize;
}
/**
*/
void showBestFitness() {
double best = -100000;
- for (unsigned int i = 0; i < this->generation.size(); i++) {
+ unsigned int generationSize = this->generation.size();
+
+ for (unsigned int i = 0; i < generationSize; i++) {
_Fitness fit(this->generation[i]);
fit.parseArguments(fitness.getArguments());