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

Merge branch 'normalmized_indicator' into 'master'

Fixed Normalized Indicators

Yey !

See merge request !6
parents ef6a002b 430c769b
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -6,12 +6,15 @@ ...@@ -6,12 +6,15 @@
* sets of vectors. Furthermore, instead of calling in every * sets of vectors. Furthermore, instead of calling in every
* epsilon_indicator the method coco_evaluate, we better save every f(x) and * 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 * enter as parameters of the function the two vectors f(x1) and f(x2) we want
* to compare. * to compare. Each indicator uses normalized terms :
* @param fa: image of the first vector to compare by f * f_i'(x)=(f_i(x)-bmin[i])/(bmax[i]-bmin[i])
* @param fb: image of the second vector to compare by f * @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 * @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; int k;
double eps_k=0.0, eps_temp; double eps_k=0.0, eps_temp;
...@@ -23,7 +26,7 @@ double epsilon_indicator(double * a, double * b, int dim_obj) { ...@@ -23,7 +26,7 @@ double epsilon_indicator(double * a, double * b, int dim_obj) {
*/ */
for (k = 0; k < dim_obj; k++) { 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) if (k == 0)
eps_k = eps_temp; eps_k = eps_temp;
else if (eps_k < eps_temp) else if (eps_k < eps_temp)
......
#ifndef INDICATOR_H #ifndef INDICATOR_H
#define 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 #endif
...@@ -25,6 +25,10 @@ Population::Population(int size, int dimension, int n_objectives) : ...@@ -25,6 +25,10 @@ Population::Population(int size, int dimension, int n_objectives) :
} }
fitnesses_ = (double *) coco_allocate_memory(size_*sizeof(double)); 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(){ Population::~Population(){
...@@ -115,10 +119,32 @@ void Population::evaluate(evaluate_function_t evaluate_function){ ...@@ -115,10 +119,32 @@ void Population::evaluate(evaluate_function_t evaluate_function){
} }
void Population::compute_indicators(){ 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; c_ = 0;
for (int i=0; i<current_size_; i++){ for (int i=0; i<current_size_; i++){
for (int j=0; j<current_size_; j++){ 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_){ if (abs(indicator_values_[i][j]) > c_){
c_ = abs(indicator_values_[i][j]); c_ = abs(indicator_values_[i][j]);
} }
......
...@@ -43,6 +43,8 @@ private: ...@@ -43,6 +43,8 @@ private:
double ** values_; double ** values_;
double ** indicator_values_; double ** indicator_values_;
double * fitnesses_; double * fitnesses_;
double * bmin_;
double * bmax_;
int ind_min_; int ind_min_;
double c_; double c_;
......
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