ga_initpopu.m

来自「书籍代码:遗传演算法原理与应用_活用MATLAB(Source Code)」· M 代码 · 共 16 行

M
16
字号
function popu=GA_initpopu(popuSize, bit_n, var_n, PRINT)
% popuSize is the size of population, an even positive
%  integer is prefered. i.e. popuSize=36.
% bit_n is the bit length.
% var_n is the number of parameters(Genes)
% PRINT=1 then print out Binary Population Chromosomes
% For example:
% GA_initpopu(36, 8, 2)

% PenChen Chou, 6-30-2001
if nargin==3
   popu = rand(popuSize, bit_n*var_n) > 0.5;   
else
   popu = rand(popuSize, bit_n*var_n) > 0.5   
end;    

⌨️ 快捷键说明

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