diff --git a/src/ibea/ibea.cpp b/src/ibea/ibea.cpp index 7147c8e773d1e7d4822dfdbc53e8a6d9f49f6636..a175e8a9d52db3bfe8ae0e127aa0f08db4cdcc5b 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 705e8bb55f130722a996f09a008911826ceb646e..e89a2cf891fa0dedaf6a11823add7f8fb127e3ec 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 106dd16883166b934a6f5f143cbfec89d851d884..5af0b0a4b10f08893055cc36dd9b1ca95a6db32d 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_;