From ef6a002b4971ee8bfaa7246d0681c92298410fcf Mon Sep 17 00:00:00 2001 From: Jonathan CROUZET <jonathan.crouzet@ensiie.fr> Date: Mon, 17 Oct 2016 16:19:41 +0200 Subject: [PATCH] Fixed boundary problem on mutation --- src/experiment.c | 18 +++++------------- src/ibea/ibea.cpp | 6 ++++-- src/ibea/mutation.cpp | 8 ++++++++ 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/src/experiment.c b/src/experiment.c index efa6e80..de9b25d 100644 --- a/src/experiment.c +++ b/src/experiment.c @@ -1,9 +1,3 @@ -/** - * 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 <stdio.h> #include <string.h> @@ -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); /** - * 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. */ 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 - * a timing experiment. + * The benchmarking experiment * * @param suite_name Name of the suite (use "bbob" for the single-objective and "bbob-biobj" for the * bi-objective suite). @@ -115,9 +108,9 @@ void experiment(const char *suite_name, /* Set some options for the observer. See documentation for other options. */ char *observer_options = - coco_strdupf("result_folder: RS_on_%s " - "algorithm_name: RS " - "algorithm_info: \"A simple random search algorithm\"", suite_name); + coco_strdupf("result_folder: IBEA_EPS_on_%s " + "algorithm_name: IBEA_EPS " + "algorithm_info: \"IBEA algorithm with espsilon indicator\"", suite_name); /* Initialize the suite and observer */ suite = coco_suite(suite_name, "year: 2016", "dimensions: 2,3,5,10,20,40"); @@ -170,7 +163,6 @@ void experiment(const char *suite_name, coco_observer_free(observer); coco_suite_free(suite); - } /** diff --git a/src/ibea/ibea.cpp b/src/ibea/ibea.cpp index 21d052f..6a817a0 100644 --- a/src/ibea/ibea.cpp +++ b/src/ibea/ibea.cpp @@ -1,3 +1,5 @@ +#include <cmath> + #include "../coco/coco.h" #include "population.h" #include "tournament.h" @@ -15,8 +17,8 @@ void ibea(evaluate_function_t evaluate, { /* Parameters */ int n_individus = 10; /* number of individus per generations */ - int n_generations = 2; /* number of generations */ - int mu = 5; /* number of tournament */ + int n_generations = floor(max_budget/n_individus); /* number of generations */ + int mu = 2; /* number of binary tournament */ double eta = 20; /* polynomiale mutation degree */ double p_combination = 1; double p_mutation = 0.1; diff --git a/src/ibea/mutation.cpp b/src/ibea/mutation.cpp index e495753..d90488f 100644 --- a/src/ibea/mutation.cpp +++ b/src/ibea/mutation.cpp @@ -1,6 +1,7 @@ #include <cstdlib> #include <cmath> #include <algorithm> +#include <cstdio> #include "../coco/coco.h" #include "population.h" @@ -26,6 +27,13 @@ double polynomiale_mutation(double parent, } child = parent + delta_q*(upper_bound - lower_bound); + if (child > upper_bound){ + child = upper_bound; + } + if (child < lower_bound){ + child = lower_bound; + } + return child; } -- GitLab