www.pudn.com > LBG_GA.rar > mutation.m, change:2011-06-15,size:694b


%变异操作,单点变异,变异概率为0.1 
 
function  mut_pop=mutation(pop,adapt,pm)   
 
global gen 
% pop=rand(10); 
mut_pop=zeros(size(pop)); 
m=size(pop,1); 
n=size(pop,2); 
% k1=0.001; 
% k2=0.002; 
for i=1:m-1 
%     if adapt(i)<=mean(adapt) 
%         pm=k1*(min(adapt)-adapt(i))/(min(adapt)-mean(adapt)); 
%     else 
%         pm=k2; 
%     end 
    if rand(1)<pm %变异概率自适应线性调整,由0.001上升至0.01 
%       if rand(1)<pm 
        M_pos=round(n*rand); 
        if M_pos~=0 %若变异位为0则无意义 
            mut_pop(i,M_pos)=round(rand*255);%生成1~255之间的正整数 
        end 
      else  
          mut_pop(i,:)=pop(i,:); 
      end 
       
end 
mut_pop(m,:)=pop(m,:); 
end