From 4128f07ae6f3d597ed60abe1c30d2c6706dcd916 Mon Sep 17 00:00:00 2001 From: Jonathan CROUZET <jonathan.crouzet@ensiie.fr> Date: Mon, 17 Oct 2016 10:56:22 +0200 Subject: [PATCH] Debug : Improved print functions --- src/ibea/ibea.cpp | 10 ++++++++-- src/ibea/population.cpp | 16 +++++++++++++--- src/ibea/population.h | 1 + 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/src/ibea/ibea.cpp b/src/ibea/ibea.cpp index 7147c8e..a175e8a 100644 --- a/src/ibea/ibea.cpp +++ b/src/ibea/ibea.cpp @@ -18,9 +18,9 @@ void ibea(evaluate_function_t evaluate, coco_random_state_t *random_generator) { /* Parameters */ - int n_individus = 20; /* number of individus per generations */ + int n_individus = 10; /* number of individus per generations */ int n_generations = 2; /* number of generations */ - int mu = 10; /* number of tournament */ + int mu = 5; /* number of tournament */ double eta = 20; /* polynomiale mutation degree */ double p_combination = 1; double p_mutation = 0.1; @@ -41,19 +41,25 @@ void ibea(evaluate_function_t evaluate, pop.evaluate(evaluate); pop.compute_indicators(); pop.compute_fitnesses(kappa); + pop.printFitnesses(); cout << "Evaluation & Fitness done" << endl; new_pop.empty(); cout << "New population !" << endl; while (new_pop.getCurrentSize() < n_individus){ /* 3 Environemental select */ + cout << "Darwin begin" << endl; pop.darwin(kappa); + pop.printFitnesses(); cout << "Darwin done" << endl; /* 4 */ /* 5 Fill mating pool */ + + cout << "Tournament begin" << endl; binary_tournament(pop, new_pop, mu, random_generator); + pop.printFitnesses(); cout << "Tournament done" << endl; } diff --git a/src/ibea/population.cpp b/src/ibea/population.cpp index 705e8bb..e89a2cf 100644 --- a/src/ibea/population.cpp +++ b/src/ibea/population.cpp @@ -219,11 +219,21 @@ void Population::darwin(double kappa){ } } +void Population::printPopulation(){ + cout << "Population : " << endl; + for (int i=0; i < current_size_; i++){ + for (int j=0; j < dimension_; j++){ + printf("%+6.4lf ", population_[i][j]); + } + printf("\n"); + } +} + void Population::printValues(){ cout << "Values : " << endl; for (int i=0; i < current_size_; i++){ for (int j=0; j < dimension_; j++){ - printf("%5f", values_[i][j]); + printf("%+6.4lf ", values_[i][j]); } printf("\n"); } @@ -233,7 +243,7 @@ void Population::printIndicatorValues(){ cout << "Indicator Values : " << endl; for (int i=0; i < current_size_; i++){ for (int j=0; j < current_size_; j++){ - printf("%5f", indicator_values_[i][j]); + printf("%+6.4lf ", indicator_values_[i][j]); } printf("\n"); } @@ -242,7 +252,7 @@ void Population::printIndicatorValues(){ void Population::printFitnesses(){ cout << "Fitnesses : " << endl; for (int i=0; i < current_size_; i++){ - printf("%5f", fitnesses_[i]); + printf("%+6.4lf ", fitnesses_[i]); } printf("\n"); } diff --git a/src/ibea/population.h b/src/ibea/population.h index 106dd16..5af0b0a 100644 --- a/src/ibea/population.h +++ b/src/ibea/population.h @@ -32,6 +32,7 @@ public: void printFitnesses(); void printIndicatorValues(); void printValues(); + void printPopulation(); private: int size_; -- GitLab