nonuniform mutation and blend alpha crossover in genetic algorithm

246 views Asked by At

i used blend alpha cross over and non uniform mutation in genetic algorithm.the chromosomes have the form : [parent1 parent2 parent3 parent4 parent5 parent6 parent7]. value allow for each chromosome should be in the range[0,1] and the sum of them should be equal to 1. i have code cross over and mutation to do this constraint.but it dose not work.the chromosomes in result are not in [0,1] and do not have sum equal to 1. my code for cross over :

 if (rnd < pc)
  for i = 1:n
 u = rand;
 alpha = 0.5;
 gamma = (1+(2*alpha)* u) - alpha ;
 child1(i) = (((1 - gamma) * best1(i)) + (gamma * best2(i)));
end           
    end
 child1(1:n) = bsxfun(@rdivide,child1(1:n).',sum(child1(1:n).')).';

and my code for mutation:

    rnd = randi([0 100]) / 100;
    if (rnd < pm)
        mutationPoints = randperm(n-1,3);
        m1 = mutationPoints(1);
        m2 = mutationPoints(2);
        m3 = mutationPoints(3);
        mu = 0;
        sigma = 0.35;
        rnd1 = normrnd(mu,sigma);
        rnd2 = normrnd(mu,sigma);
        rnd3 = normrnd(mu,sigma);
        child1(m1) = child1(m1) + rnd1;
        child1(m2) = child1(m2) + rnd2;
        child1(m3) = child1(m3) + rnd3;
        child1(1:n) bsxfun(@rdivide,child1(1:n).',sum(child1(1:n).')).';
        end

how can i fix if ? thank for taking your time.

0

There are 0 answers