📄 mutation.m
字号:
function y=mutation(chrom,P_mutation,Popsize,ecope) %均匀变异
m=25;
% P=rand(Popsize,1);
% n=find(P<P_mutation);
% len=length(n);
% for i=1:len
% d=fix(9*rand(1))+1;
% x=4*rand(1)-2;
% chrom(n(i),d)=x; %
% end
P=rand(size(chrom));
n=find(P<P_mutation);
len=length(n);
% R=4/ecope;
for i=1:len
tem_a=chrom(n(i));
R=min(m-tem_a,tem_a-m);
tem_a=tem_a+R*2*rand-R;
if tem_a>m
tem_a=m-rand;
elseif tem_a<-m
tem_a=-m+rand;
end
chrom(n(i))=tem_a;
end
y=chrom;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -