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

Implemented a polynomiale mutation for a Population

parent d852f7fd
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
#include "population.h"
#include "coco/coco.h"
#include "mutation.h"
Population polynomiale_mutation(Population pop){
double polynomiale_mutation(double parent, const double eta,
const double lower_bound, const double upper_bound, coco_random_state_t *random_generator){
double child;
double u = coco_random_uniform(random_generator);
double delta = min((parent - lower_bound)/(upper_bound - lower_bound),
(upper_bound - parent)/(upper_bound - lower_bound));
double delta_q;
if (u <= 0.5){
delta_q = ((2*u) + (1-2*u)*(1-delta)**(eta+1))**(1/(1+eta)) - 1;
}
else {
delta_q = 1 - (2*(1-u) + 2*(u-0.5)*(1-delta)**(eta+1))**(1/(1+eta));
}
child = parent + delta_q*(upper_bounds - lower_bounds);
return child;
}
void mutate(Population population, const double *lower_bounds, const double *upper_bounds,
const double eta, coco_random_state_t *random_generator){
double lb, up, u;
double size = population.getSizeMax();
double dimension = population.getDim();
for (int i; i<size; i++){
for (int j; j<dimension; j++){
lb = lower_bounds[j];
ub = upper_bounds[j];
u = coco_random_uniform(random_generator);
if (u <= 0.01){
population.setIndiv(i,j,polynomiale_mutation(population.get(i,j), eta, lb, up, random_generator))
}
}
}
return pop;
}
#ifndef MUTATION_H
#define MUTATION_H
Population polynomiale_mutation(Population pop);
double polynomiale_mutation(double parent, const double eta,
const double lower_bound, const double upper_bound, coco_random_state_t *random_generator);
void mutate(Population population, const double *lower_bounds, const double *upper_bounds,
const double eta, coco_random_state_t *random_generator);
#endif
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