From 430c769bd77cb72069393aa75b1f0b0070706622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matthieu=20R=C3=89?= <matthieu.re@ensiie.fr> Date: Mon, 17 Oct 2016 16:32:07 +0200 Subject: [PATCH] Fixed Normalized Indicators --- src/ibea/indicator.cpp | 13 ++++++++----- src/ibea/indicator.h | 2 +- src/ibea/population.cpp | 28 +++++++++++++++++++++++++++- src/ibea/population.h | 2 ++ 4 files changed, 38 insertions(+), 7 deletions(-) diff --git a/src/ibea/indicator.cpp b/src/ibea/indicator.cpp index fb74849..142cb1b 100644 --- a/src/ibea/indicator.cpp +++ b/src/ibea/indicator.cpp @@ -6,12 +6,15 @@ * sets of vectors. Furthermore, instead of calling in every * epsilon_indicator the method coco_evaluate, we better save every f(x) and * enter as parameters of the function the two vectors f(x1) and f(x2) we want -* to compare. -* @param fa: image of the first vector to compare by f -* @param fb: image of the second vector to compare by f +* to compare. Each indicator uses normalized terms : +* f_i'(x)=(f_i(x)-bmin[i])/(bmax[i]-bmin[i]) +* @param x: image of the first vector to compare by f +* @param y: image of the second vector to compare by f +* @param bmin: vector containing minimum bounds of the f(x) on the population +* @param bmin: vector containing maximum bounds of the f(x) on the population * @returns: the espsilon-indicator */ -double epsilon_indicator(double * a, double * b, int dim_obj) { +double epsilon_indicator(double * x, double * y, double * bmin, double * bmax, int dim_obj) { int k; double eps_k=0.0, eps_temp; @@ -23,7 +26,7 @@ double epsilon_indicator(double * a, double * b, int dim_obj) { */ for (k = 0; k < dim_obj; k++) { - eps_temp = b[k] - a[k]; + eps_temp = (y[k] - x[k]) / (bmax[k] - bmin[k]); if (k == 0) eps_k = eps_temp; else if (eps_k < eps_temp) diff --git a/src/ibea/indicator.h b/src/ibea/indicator.h index 5633c9e..43da337 100644 --- a/src/ibea/indicator.h +++ b/src/ibea/indicator.h @@ -1,6 +1,6 @@ #ifndef INDICATOR_H #define INDICATOR_H -double epsilon_indicator(double * a, double * b, int dim_obj ); +double epsilon_indicator(double * x, double * y, double * bmin, double * bmax, int dim_obj ); #endif diff --git a/src/ibea/population.cpp b/src/ibea/population.cpp index 07c86fe..31126bf 100644 --- a/src/ibea/population.cpp +++ b/src/ibea/population.cpp @@ -25,6 +25,10 @@ Population::Population(int size, int dimension, int n_objectives) : } fitnesses_ = (double *) coco_allocate_memory(size_*sizeof(double)); + + bmin_ = (double *) coco_allocate_memory(size_*sizeof(double)); + + bmax_ = (double *) coco_allocate_memory(size_*sizeof(double)); } Population::~Population(){ @@ -115,10 +119,32 @@ void Population::evaluate(evaluate_function_t evaluate_function){ } void Population::compute_indicators(){ + + double tmp_bmin, tmp_bmax; + + for (int i = 0; i < n_objectives_; i++) { + for (int j = 0; j < current_size_; j++ ) { + if (j==0) { + tmp_bmin = values_[j][i]; + tmp_bmax = values_[j][i]; + } + else { + if (values_[j][i]>tmp_bmax) { + tmp_bmax = values_[j][i]; + } + if (values_ [j][i]<tmp_bmin) { + tmp_bmin = values_[j][i]; + } + } + } + bmin_[i] = tmp_bmin; + bmax_[i] = tmp_bmax; + } + c_ = 0; for (int i=0; i<current_size_; i++){ for (int j=0; j<current_size_; j++){ - indicator_values_[i][j] = epsilon_indicator(values_[i], values_[j], n_objectives_); + indicator_values_[i][j] = epsilon_indicator(values_[i], values_[j], bmin_, bmax_, n_objectives_); if (abs(indicator_values_[i][j]) > c_){ c_ = abs(indicator_values_[i][j]); } diff --git a/src/ibea/population.h b/src/ibea/population.h index 5af0b0a..051dcd4 100644 --- a/src/ibea/population.h +++ b/src/ibea/population.h @@ -43,6 +43,8 @@ private: double ** values_; double ** indicator_values_; double * fitnesses_; + double * bmin_; + double * bmax_; int ind_min_; double c_; -- GitLab