You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ant colony system for the traveling salesman problem
Reference: Dorigo M, Gambardella L M.: Ant Colony System: A cooperative learning approach to the Traveling Salesman Problem. IEEE Tr. Evol. Comp. 1, 53-66[J]. 1997, 1(1): 53-66.
Reference: Dorigo M, Birattari M, Stutzle T. Ant colony optimization[J]. IEEE computational intelligence magazine, 2006, 1(4): 28-39.
Variables
Meaning
coord_x
List, the x coordination of cities
coord_y
List, the y coordination of cities
pop
The number of ants
iter
The maximum number of iterations
alpha
The pheromone decay parameter
beta
The parameter which determines the relative importance of pheromone versus distance
rho
The parameter for pheromone local updating rule
q0
The probability of exploitation versus exploration
city_num
The number of city
dis
List, dis[i][j] denotes the distance between city i and city j
tau
List, tau[i][j] denotes the pheromone between city i and city j
start_city
List, start_city[i] denotes the start city of ant i
iter_best
List, the best so-far value of each iteration
Example
if__name__=='__main__':
# Set the parameterspop=20beta=2q0=0.9alpha=0.1rho=0.1iter=50city_num=30min_coord=0max_coord=10coord_x= [random.uniform(min_coord, max_coord) for_inrange(city_num)]
coord_y= [random.uniform(min_coord, max_coord) for_inrange(city_num)]
print(main(coord_x, coord_y, pop, iter, alpha, beta, rho, q0))