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


function chrom=crossover(chrom) 
pc=0.6; 
[nx,ny]=size(chrom); 
for i=1:nx/2 
    if pc>=rand 
        a=randperm(nx); 
        b=[chrom(a(1),:);chrom(a(2),:)]; 
        c=randperm(ny); 
        d=[c(1),c(2)]; 
        e=sort(d); 
        f=chrom(a(1),e(1):e(2)); 
        g=chrom(a(2),e(1):e(2)); 
        chrom(a(1),e(1):e(2))=g; 
        chrom(a(2),e(1):e(2))=f; 
    end 
end 
chrom;