This implementation of the Ant System (a variation of Ant Colony Optimization) [1] aims to solve the Traveling Salesman Problem. The problem is to find the shortest tour distance given a list of cities represented by its x and y coordinates where each city is visited only once. This was tested using the berlin52
dataset found [here] (http://elib.zib.de/pub/mp-testdata/tsp/tsplib/tsp/berlin52.tsp).
- ant_colony.m
This is the main file for the algorithm implementation. This calls other functions (written in separate files) in order to achieve the optimization objective. - ant_tour_construction.m
For each ant in the colony, we make them traverse the whole map (tour
). They first start at a randomly generated starting area (start_places), and jump to each node. The jumps are controlled by the attractiveness of the node raised to beta, and the pheromone effect raised to alpha. - compute_cost.m
For each ant, we look at the path it took (also known as itstour
), and then we base the distance from the distance matrix and add it to the link. - update_tau.m
Here, we're using Ant-Quantity AS variation. In this case, only local information,d_{ij}
, is used to update pheromone concentrations. Lower cost links are made more desirable. Ifd_{ij}
represents the distance between links, then ant-quantity AS prefers selection of the shortest links.
First, make sure that you have MATLAB installed. Compatibility to open-source software, such as Octave, has not yet been tested. If you're set, then just clone this repository:
$ git clone https://github.com/ljvmiranda921/tsp-ant-system.git`
Import the berlin52.csv
file from your local path:
cd('your\local\path\to\file')
Change your Ant System parameters:
Parameter | Description |
---|---|
iterations |
Number of iterations that the algorithm will run. |
colony_size |
Number of ants that will explore the search space. |
evap_coeff |
Rate of pheromone degradation. |
alpha |
Exploitation parameter, sets how the ants are attracted to pheromone concentration. |
beta |
Exploration parameter, sets how the ants are more attracted to try out shorter paths. |
tau |
Initial pheromone concentration. |
el |
Parameter for eliminating common costs. |
Q |
Positive constant for the Ant-Quantity System |
Run ant_colony.m
Experiment on different values of alpha
and beta
in order to balance the exploitation-exploration tradeoff.
- Parameter Tuning
This implementation, albeit simple, was able to generate a tour distance of7548.9927
, a little bit shy of the most optimal solution for theberlin52
dataset (7542
) [2]. In this case, I used the following parameters:
iterations = 100;
colony_size = 30;
evap_coeff = 0.15;
alpha = 9;
beta = 12;
tau = 0.0001 * ones(52);
el=0.97;
Q = 0.2;
This project is licensed under the MIT License - see the LICENSE.txt file for details
[1] A.P. Engelbrecht, "Ant System" in Computational Intelligence: An Introduction, 2nd Edition, John Wiley & Sons, Ltd., pp. 368-372, 2007.
[2] "Optimal Solutions for Symmetric TSPs", Available: http://comopt.ifi.uni-heidelberg.de/software/TSPLIB95/STSP.html [Accessed: November 28, 2016].
[3] I. Sustrino, "Ant Colony Optimization to solve traveling salesman problem (TSP)," Available: https://www.mathworks.com/matlabcentral/fileexchange/51113-ant-colony-optimization--aco--to-solve-traveling-salesman-problem--tsp-, 2015. [Accessed: November 27, 2016]. Note: The partitioning of different ant-colony functions into stand-alone MATLAB m-files was adopted from Sustrino's work for this project.