This program approximates solutions to the Travelling Salesman Problem (TSP) using the Ant Colony Optimization (ACO) with some additional features.
The random number
The value of
The initial pheromone guess
When all the ants have completed a tour (at the end of each iteration), one of them is picked so that their current tour is improved with a local search. The "lucky ant" is alternating every iteration between being the ant with the best tour length in the current iteration and a randomly chosen ant. This is because we can not exclude that an ant that has a current longer path is located in the area of the global minimum (just not reached yet), while the best ant is just located in a local minimum area.
The local search is also alternating between a 2OPT and a 2.5OPT.
With some trials, I found out that it is a good idea to reduce the number of swaps that the 2opt performs, allowing to get more iterations done. For this reason, each step of the 2opt only swaps the couple i,j that has the best gain.
To run all instances run make compile
and make runall
.
To run individual instances I advise to compile the program with -O3
flag as follows: c++ -std=c++11 -O3 aco.cpp -o aco
. Then run the executable as ./aco {PATH_TO_PROBLEM}/{PROBLEM}.tsp {SEED}
. The given seed allows the results to be replicable, since the sequence of random numbers will be the same each time.
The program stops either when the best known solution is found or 3 minutes have passed.
With a time limit of 3 minutes and without farming a lucky seed, the following result could be achieved:
Problem: | Best Known: | Result: | Error: |
---|---|---|---|
ch130 | 6110 | 6110 | 0% |
d198 | 15780 | 15780 | 0% |
eil76 | 538 | 538 | 0% |
fl1577 | 22249 | 22368 | 0.53% |
kroa100 | 21282 | 21282 | 0% |
lin318 | 42029 | 42143 | 0.27% |
pcb442 | 50778 | 51094 | 0.62% |
pr439 | 107217 | 107294 | 0.07% |
rat783 | 8806 | 8888 | 0.93% |
u1060 | 224094 | 227814 | 1.66% |
The mean error is
Note that the parameters were fixed and some problems work better with certain set of parameters. This was a try to get an overall good result.
Following are some examples of results:
- PR439
- RAT783
- U1060