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

📄 initpopgray.m

📁 继续上次传的简单遗传算法
💻 M
字号:
function [initpop]=InitPopGray(popsize,bits) 
len=sum(bits);
initpop=zeros(popsize,len);%The whole zero encoding individual
for i=2:popsize-1
    pop=round(rand(1,len));
    pop=mod(([0 pop]+[pop 0]),2);
    %i=1时,b(1)=a(1);i>1时,b(i)=mod(a(i-1)+a(i),2)
    %其中原二进制串:a(1)a(2)...a(n),Gray串:b(1)b(2)...b(n)
    initpop(i,:)=pop(1:end-1);
end
initpop(popsize,:)=ones(1,len);%The whole one encoding individual

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -