matlab - nonuniform mutation and blend alpha crossover in genetic algorithm -
i used blend alpha cross on , non uniform mutation in genetic algorithm.the chromosomes have form : [parent1 parent2 parent3 parent4 parent5 parent6 parent7]. value allow each chromosome should in range[0,1] , sum of them should equal 1. have code cross on , mutation constraint.but dose not work.the chromosomes in result not in [0,1] , not have sum equal 1. code cross on :
if (rnd < pc) = 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 code 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 fix if ? thank taking time.
Comments
Post a Comment