www.pudn.com > anttsp.rar > immune_operator.m, change:2008-04-20,size:1133b


function new_antitrope=immune_operator(city_num,antitrope_tour,pc,uc,ps,us,pi,ui) 
%利用不同的免疫算子对抗体进行免疫操作 
%字符换位算子 
r=unidrnd(uc-1)+1; 
for k=1:r 
    i=unidrnd(city_num-1)+1; 
    j=unidrnd(city_num-1)+1; 
    while j==i 
        j=unidrnd(city_num-1)+1; 
    end 
    %以概率Pc进行换位 
    if rand>pc 
        temp=antitrope_tour(i); 
        antitrop_tour(i)=antitrope_tour(j); 
        antitrop_tour(j)=temp; 
    end 
end 
%字符串移位算子 
r=unidrnd(us-1)+1; 
for k=1:r 
    i=unidrnd(city_num-1)+1; 
    j=unidrnd(city_num-1)+1; 
    while j==i 
        j=unidrnd(city_num-1)+1; 
    end 
    if i>j 
        temp=i;i=j;j=i; 
    end 
    %以概率Ps进行移位 
    if rand>ps 
    antitrope_tour(i:j)=shift_cycle(2,antitrope_tour(i:j),1); 
    end 
end 
%字符串逆转算子 
r=unidrnd(ui-1)+1; 
for k=1:r 
    i=unidrnd(city_num-1)+1; 
    j=unidrnd(city_num-1)+1; 
    while j==i 
        j=unidrnd(city_num-1)+1; 
    end 
    if i>j 
        temp=i;i=j;j=i; 
    end 
    %以概率Pi进行逆转 
    if rand>pi 
        antitrope_tour(i:j)=rot90(antitrope_tour(i:j),2); 
    end 
end 
new_antitrope=antitrope_tour;