Skip to content

Fraccaman/AntColonySystem

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

 COMPILE AND RUN

In order to compile the program we need to execute a command with maven:

- mvn clean compile assembly:single

with the terminal pointing to the code folder.
This will create a "target" folder inside the code folder with a jar file called TSP-1.0-SNAPSHOT-jar-with-dependencies.jar.
Now to run the program use the following command:

- java -jar (path/to/file.jar path/to/file.tsp) (seed)

I have also submitted a already ready jar file in the right folder.
example: java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar /Users/FraccaMan/Desktop/cup/ACS_TSP/src/main/resources/Problems/pr439.tsp 107315

Here below I list the commands to execute all the problems:

- ch130.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/ch130.tsp 1337
- d198.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/d198.tsp 959747
- eil76.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/eil76.tsp 1337
- fl1577.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/fl1577.tsp 266940
- kroA100.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/kroA100.tsp 930815
- lin318.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/lin318.tsp 985396
- pcb442.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/pcb442.tsp 312650
- pr439.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/pr439.tsp 107315
- rat783.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/rat738.tsp 485787
- u1060.tsp
    java -jar target/TSP-1.0-SNAPSHOT-jar-with-dependencies.jar src/main/resources/Problems/u1060.tsp 561906


Some file are bad formatted so, please use the .tsp files in my folder[src/main/resources/Problems] otherwise the program could crash (just run the above commands).
The seeds can be found as the second argument on the above commands.
All the parameters are set by the program.
The output will be saved on the /code/ACS_TSP folder as ‘problem_name.tsp.txt’.
Inside that report you can find BestKnown cost (the best cost listed inside the file), the seed used and the total cost found by my program. Below there are information such as the error, parameters used and all the cities visited in order (the edge that links the last to the first is computed in the total cost, but i omit in the total tour written in the report to append to the end the first city visited since it is trivial).

SYSTEM INFORMATION

OS: System Version: OS X 10.11.6 (15G1004)
Kernel Version: Darwin 15.6.0
Compiler: javac 1.8.0_60

MY IMPLEMENTATION

My approach to solve the TSP problem was to use the Ant Colony System as described in class optimized with 2opt
local search on every tour generated by each ant every iteration. In order to build
an initial solution I've used Nearest Neighbour algorithm.
My implementation diverge a little bit from what we have learned; in fact instead of appling global update only
cities on the tour, I decided to apply a general evaporation on all the existing edges and then I apply a
reinforcement on the cities of the best tour so far.