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


function next_city=as_next_tour(city_num,choice_info,pres_city,tempant) 
%利用随机比例规则构建路径 
sum_prob=0; 
for j=1:city_num 
    if tempant.visited(j)==1 
        selc_prob(j)=0; 
    else 
        selc_prob(j)=choice_info(pres_city,j); 
        sum_prob=sum_prob+selc_prob(j); 
    end 
end 
k=rand*sum_prob;                                          %轮盘赌 
next_city=1; 
p=selc_prob(next_city); 
while(p<k) 
    next_city = next_city +1; 
    p=p+selc_prob(next_city); 
end