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

Merge branch 'Combination' into 'master'

Combination

MAIDAY

See merge request !4
parents cbfae85c 4c90cbb8
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 "combination.h"
#include <utility>
#include <cstdlib>
#include "../coco/coco.h"
Population SBX20(Population pop){
std::pair <double,double> simple_combination(double parent1,double parent2, const double eta, coco_random_state_t *random_generator){
double child1;
double child2;
double u = coco_random_uniform(random_generator);
double beta;
std::pair <double,double> result;
if (u <= 0.5){
beta = pow(2*u,1/(1+eta));
}
else {
beta = pow(1/(2*(1-u)),1/(1+eta));
}
child1 = 0.5*((1+beta)*parent1 + (1-beta)*parent2);
child2 = 0.5*((1+beta)*parent1 + (1-beta)*parent2);
result= std::make_pair(child1,child2);
return result;
}
/* Recombinaison prédéfini */
void combine(Population new_pop, Population & pop, coco_random_state_t *random_generator){
double eta=20;
double u;
double size = new_pop.getSize();
double dimension = new_pop.getDim();
std::pair <double,double> childs;
return pop;
u = coco_random_uniform(random_generator);
for (int i; i<floor(size/2); i++){
for (int j; j<floor(dimension/2); j++){
if (u <= 1){
childs = simple_combination(new_pop.getIndiv(i,j), new_pop.getIndiv(size-i-1,dimension-j-1), eta, random_generator);
pop.setIndiv(i,j,childs.first);
pop.setIndiv(size-i-1,dimension-j-1,childs.second);
}
}
}
}
#ifndef COMBINATION_H
#define COMBINATION_H
Population SBX20(Population pop);
#include "../coco/coco.h"
#include "population.h"
double simple_combination(double parent, const double eta, coco_random_state_t *random_generator);
void combinate(Population population, Population & pop, 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.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter