Browse Source

Create mutation

master
TianZhendong 6 years ago
committed by GitHub
parent
commit
12e19ee371
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 12
      GA_PID/mutation

12
GA_PID/mutation

@ -0,0 +1,12 @@
function y= mutation(n,MutateRate,x)
%n为染色体长度
%MutataRate为变异概率
%x为待变异染色体
rate=rand; %随机概率判断是否变异
if rate<=MutateRate
mutate_pos=floor(rand*n+1); %产生一个变异位置
x(mutate_pos)=floor(rand+1); %bianyi
end
y=x;
end
Loading…
Cancel
Save