?? 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;
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -