?? mutation.m
字號:
function [newpop,newquanzhi]=mutation(pop,pm,quanzhi)
%變異
[px,py]=size(pop);
newpop=ones(size(pop));
newquanzhi=zeros(px,py);
newquanzhi=quanzhi;
for i=1:px
if rand<pm
newpop(i,:)=pop(i,:);
mpoint=round(rand*py); % 隨機產生變異點
if mpoint<=0
mpoint=1;
end
mpointx=round(rand*32285042);% 隨機產生變異的因子,其中是規則的最大編碼值,及的那個規則為[6 6 6 6 6 6 6 8]對應的編碼
newpop(i,mpoint)=mpointx;
newquanzhi(i,mpoint)=rand;
else
newpop(i,:)=pop(i,:);
newquanzhi(i,:)=quanzhi(i,:);
end
end
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -