www.pudn.com > TWVRP.rar > gjselect.m, change:2016-04-20,size:394b


function [chrom,fits]=gjselect(chrom,fit) 
totalfit=sum(fit); %求适应值之和 
fit1=fit/totalfit; %单个个体被选择的概率 
[px,py]=size(chrom); 
chrom1=zeros(px,py); 
for i=1:px 
   while chrom1(i,1)==0 
    r=ceil(rand*px); 
    if rand<fit1(r) 
        chrom1(i,:)=chrom(r,:); 
        fits(i)=fit(r); 
    end 
   end 
end 
[a,b]=max(fits);% 精英策略 
d=b(1); 
chrom1(d)=chrom(d); 
chrom=chrom1;