Skip to content
Extraits de code Groupes Projets
Valider ef6a002b rédigé par Jonathan CROUZET's avatar Jonathan CROUZET
Parcourir les fichiers

Fixed boundary problem on mutation

parent 0667bca8
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
/**
* An example of benchmarking random search on a COCO suite. A grid search optimizer is also
* implemented and can be used instead of random search.
*
* Set the global parameter BUDGET_MULTIPLIER to suit your needs.
*/
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
...@@ -68,7 +62,7 @@ static void timing_data_time_problem(timing_data_t *timing_data, coco_problem_t ...@@ -68,7 +62,7 @@ static void timing_data_time_problem(timing_data_t *timing_data, coco_problem_t
static void timing_data_finalize(timing_data_t *timing_data); static void timing_data_finalize(timing_data_t *timing_data);
/** /**
* The main method initializes the random number generator and calls the example experiment on the * The main method initializes the random number generator and calls the experiment on the
* bi-objective suite. * bi-objective suite.
*/ */
int main(void) { int main(void) {
...@@ -95,8 +89,7 @@ int main(void) { ...@@ -95,8 +89,7 @@ int main(void) {
} }
/** /**
* A simple example of benchmarking random search on a suite with instances from 2016 that can serve also as * The benchmarking experiment
* a timing experiment.
* *
* @param suite_name Name of the suite (use "bbob" for the single-objective and "bbob-biobj" for the * @param suite_name Name of the suite (use "bbob" for the single-objective and "bbob-biobj" for the
* bi-objective suite). * bi-objective suite).
...@@ -115,9 +108,9 @@ void experiment(const char *suite_name, ...@@ -115,9 +108,9 @@ void experiment(const char *suite_name,
/* Set some options for the observer. See documentation for other options. */ /* Set some options for the observer. See documentation for other options. */
char *observer_options = char *observer_options =
coco_strdupf("result_folder: RS_on_%s " coco_strdupf("result_folder: IBEA_EPS_on_%s "
"algorithm_name: RS " "algorithm_name: IBEA_EPS "
"algorithm_info: \"A simple random search algorithm\"", suite_name); "algorithm_info: \"IBEA algorithm with espsilon indicator\"", suite_name);
/* Initialize the suite and observer */ /* Initialize the suite and observer */
suite = coco_suite(suite_name, "year: 2016", "dimensions: 2,3,5,10,20,40"); suite = coco_suite(suite_name, "year: 2016", "dimensions: 2,3,5,10,20,40");
...@@ -170,7 +163,6 @@ void experiment(const char *suite_name, ...@@ -170,7 +163,6 @@ void experiment(const char *suite_name,
coco_observer_free(observer); coco_observer_free(observer);
coco_suite_free(suite); coco_suite_free(suite);
} }
/** /**
......
#include <cmath>
#include "../coco/coco.h" #include "../coco/coco.h"
#include "population.h" #include "population.h"
#include "tournament.h" #include "tournament.h"
...@@ -15,8 +17,8 @@ void ibea(evaluate_function_t evaluate, ...@@ -15,8 +17,8 @@ void ibea(evaluate_function_t evaluate,
{ {
/* Parameters */ /* Parameters */
int n_individus = 10; /* number of individus per generations */ int n_individus = 10; /* number of individus per generations */
int n_generations = 2; /* number of generations */ int n_generations = floor(max_budget/n_individus); /* number of generations */
int mu = 5; /* number of tournament */ int mu = 2; /* number of binary tournament */
double eta = 20; /* polynomiale mutation degree */ double eta = 20; /* polynomiale mutation degree */
double p_combination = 1; double p_combination = 1;
double p_mutation = 0.1; double p_mutation = 0.1;
......
#include <cstdlib> #include <cstdlib>
#include <cmath> #include <cmath>
#include <algorithm> #include <algorithm>
#include <cstdio>
#include "../coco/coco.h" #include "../coco/coco.h"
#include "population.h" #include "population.h"
...@@ -26,6 +27,13 @@ double polynomiale_mutation(double parent, ...@@ -26,6 +27,13 @@ double polynomiale_mutation(double parent,
} }
child = parent + delta_q*(upper_bound - lower_bound); child = parent + delta_q*(upper_bound - lower_bound);
if (child > upper_bound){
child = upper_bound;
}
if (child < lower_bound){
child = lower_bound;
}
return child; return child;
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter