From 1199168e7759ff363f9927e72f0b8f3d39580bad Mon Sep 17 00:00:00 2001 From: Jonathan CROUZET <jonathan.crouzet@ensiie.fr> Date: Mon, 17 Oct 2016 11:07:06 +0200 Subject: [PATCH] Debug : Fixed some int that should be double --- src/ibea/ibea.cpp | 5 ++--- src/ibea/population.cpp | 22 +++++++++++----------- src/ibea/tournament.cpp | 2 ++ 3 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/ibea/ibea.cpp b/src/ibea/ibea.cpp index a175e8a..f519519 100644 --- a/src/ibea/ibea.cpp +++ b/src/ibea/ibea.cpp @@ -50,17 +50,16 @@ void ibea(evaluate_function_t evaluate, /* 3 Environemental select */ cout << "Darwin begin" << endl; pop.darwin(kappa); - pop.printFitnesses(); cout << "Darwin done" << endl; - + pop.printFitnesses(); /* 4 */ /* 5 Fill mating pool */ cout << "Tournament begin" << endl; binary_tournament(pop, new_pop, mu, random_generator); - pop.printFitnesses(); cout << "Tournament done" << endl; + pop.printFitnesses(); } cout << "Shit done" << endl; diff --git a/src/ibea/population.cpp b/src/ibea/population.cpp index e89a2cf..5311781 100644 --- a/src/ibea/population.cpp +++ b/src/ibea/population.cpp @@ -103,16 +103,16 @@ int Population::getMin(){ void Population::random_init(const double *lower_bounds, const double *upper_bounds, coco_random_state_t *random_generator) - { - double range; - for (int i=0; i < size_; i++){ - for (int j=0; j < dimension_; j++) { - range = upper_bounds[j] - lower_bounds[j]; - population_[i][j] = lower_bounds[j] + coco_random_uniform(random_generator) * range; - } +{ + double range; + for (int i=0; i < size_; i++){ + for (int j=0; j < dimension_; j++) { + range = upper_bounds[j] - lower_bounds[j]; + population_[i][j] = lower_bounds[j] + coco_random_uniform(random_generator) * range; } - current_size_ = size_; } + current_size_ = size_; +} void Population::evaluate(evaluate_function_t evaluate_function){ for (int i=0; i<current_size_; i++){ @@ -133,9 +133,9 @@ void Population::compute_indicators(){ } void Population::compute_fitnesses(double kappa){ - int d = c_ * kappa; - int min; + double d = c_ * kappa; double fitness; + int min; for (int i=0; i<current_size_; i++){ fitness = 0; @@ -158,7 +158,7 @@ void Population::compute_fitnesses(double kappa){ } void Population::darwin(double kappa){ - int d = c_ * kappa; + double d = c_ * kappa; double * tmp_p; double tmp; int min; diff --git a/src/ibea/tournament.cpp b/src/ibea/tournament.cpp index fac4623..e5c5833 100644 --- a/src/ibea/tournament.cpp +++ b/src/ibea/tournament.cpp @@ -30,6 +30,8 @@ void binary_tournament(Population & population_in, } else { for (int m = 0; m < population_out.getDim(); m++){ + population_in.printPopulation(); + population_in.printFitnesses(); cout << "test" << endl; population_out.setIndiv(size_out + k, m, population_in.getIndiv(j,m)); cout << "test1" << endl; -- GitLab