www.pudn.com > DE(rand1).rar > crossover.m, change:2011-11-20,size:422b


function CR_pop=crossover(pop,M_pop,Pc) 
% CR_pop is the population after crossover; 
 
[Popsize,Dim]=size(pop); 
CR_pop=zeros(Popsize,Dim); 
for i=1:Popsize 
    for j=1:Dim 
        I=ceil(rand*Dim); 
        probability=rand; 
        if (probability<=Pc||I==j) 
            CR_pop(i,j)=M_pop(i,j); 
        else            %if (probability>Pc&&I~=j) 
            CR_pop(i,j)=pop(i,j); 
        end 
 
    end    
end