Search
Search Results
-
PYTHON ANT ALGORITHM
D.Y. Zorkin, L.V. Samofalova, N.V. Asanova2025-01-30Abstract ▼This study is devoted to the analysis and optimization of the ant colony algorithm for solving the
traveling salesman problem, a classic NP-hard combinatorial optimization problem. The primary objective
of the work is to experimentally assess the impact of the algorithm’s parameters on the quality and
efficiency of the search for approximate solutions, as well as to develop recommendations for their adaptive
tuning. The standard Berlin52 graph from the TSPLIB library—containing the coordinates of 52 cities
with a known optimal route length of 7542 units—was used as the test dataset. Experiments were conducted
in a Python environment using the ACO-Pants library, which implements the ant colony algorithm.
A series of 10 runs with fixed parameters was performed: number of ants (20), number of iterations (100),
pheromone influence coefficient (α = 1.0), distance coefficient (β = 2.0), and pheromone evaporation rate
(ρ = 0.5). The results showed an average deviation from the optimum of 1.85%, with the best found solution
being 7675.23 (a deviation of 1.67%). To enhance the algorithm’s efficiency, adaptive mechanisms
for dynamic parameter tuning were explored: a linear increase of α (up to 2.0) and a decrease of β (to
3.0), a reduction of ρ (to 0.3), as well as an increase in the number of ants (up to 30). These modifications
reduced the average deviation to 1.70% and improved the stability of the solutions. Particular attention
was paid to analyzing the balance between exploring new routes and exploiting accumulated data. It was
found that increasing the number of ants improves the quality of solutions; however, beyond 30 agents, the
efficiency gains diminish. Dynamic adjustment of the parameters prevents premature convergence to local
minima and accelerates the search for globally optimal paths. Visualization of the convergence dynamics
confirmed a rapid decrease in route length during the first 20 iterations, followed by subsequent stabilization.
The practical significance of this work lies in demonstrating the flexibility of the ant colony algorithm
for routing tasks in logistics and network planning. The results indicate that ACO outperforms generalpurpose
methods (for example, genetic algorithms) in computational efficiency for the TSP. The developed
recommendations for parameter tuning can be applied to scale the algorithm to larger graphs. Overall,
the study emphasizes the importance of adaptive approaches in metaheuristic optimization and opens up
prospects for further improvements through hybridization with other methods.








