crossover.m
来自「遗传算法matlab实现」· M 代码 · 共 27 行
M
27 行
function res=crossover(grp,parent,p_cross,numSVM)
%GA crossover function
%The return value refers to postcrossover the group
%The mother refers to the original group
res=zeros(99,numSVM);
for i=1:99
first=parent(i,1);
second=parent(i,2);
if Bernoulli(p_cross)
pos=round(numSVM*rand(1));
while pos==0
pos=round(numSVM*rand(1));
end
res(i,:)=exchange(grp(first,:),grp(second,:),pos);
else
res(i,:)=grp(first,:);
end
end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?