⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mutation.m

📁 ga三中操作算子的改进
💻 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 + -