www.pudn.com > gatree.zip > gabirth.m, change:2011-11-21,size:417b


%繁育新个体函数,gene 
function newgene=gabirth(gene) 
n=size(gene,2); 
newgene=gene; 
select=find(gene==1); 
unselect=find(gene==0); 
 
ss=min(size(select,2),size(unselect,2)); 
 
a=randperm(size(select,2)); 
b=randperm(size(unselect,2)); 
 
%将time个01进行交换 
time=round(1+(ss-1)*rand); 
 
for i=1:time 
newgene(select(a(1,i)))=~newgene(select(a(1,i))); 
newgene(unselect(b(1,i)))=~newgene(unselect(b(1,i))); 
end