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


function new=preproccess(city_num,dist,A) 
%对抗体A进行预处理,以减少人工免疫过程的迭代次数 
for i=1:city_num 
    dist(i,i)=inf; 
end 
rand_int=unidrnd(city_num); 
if rand_int~=1 
    shift_num=find(A==rand_int)-1; 
    B=shift_cycle(1,A,shift_num); 
else 
    B=A; 
end 
temp1=B(1); 
new=[temp1]; 
temp2=dist(temp1,:); 
for i=1:city_num-1 
    index=min(find(temp2==min(temp2))); 
    new=cat(2,new,index); 
    dist(:,temp1)=inf; 
    temp1=index; 
    temp2=dist(temp1,:); 
end 
while new(1)~=1 
   new=shift_cycle(2,new,1); 
end