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


function M_pop=mutation(pop,F) 
% M_pop is the population after mutation; 
[Popsize,Dim]=size(pop); 
M_pop=zeros(Popsize,Dim); 
p=zeros(3,1); 
for i=1:Popsize 
    p=ceil(rand(3,1)*Popsize); 
    while(p(1)==i) 
        p(1)=ceil(rand*Popsize); 
    end 
    while(p(2)==i||p(2)==p(1)) 
        p(2)=ceil(rand*Popsize); 
    end 
    while(p(3)==i||p(3)==p(1)||p(3)==p(2)) 
        p(3)=ceil(rand*Popsize); 
    end 
    M_pop(i,:)=pop(p(1),:)+F.*(pop(p(2),:)-pop(p(3),:));    
end