Live tours
Each iteration draws the current ant tours and keeps the best route visible on top.
Java Swing + Ant Colony Optimization
A desktop project with a browser demo for exploring how ant colony search builds and improves tours for the Traveling Salesman Problem.
Browser demo
This canvas demo mirrors the Java solver logic so the project can be shown directly on GitHub Pages.
Ready
What it shows
Each iteration draws the current ant tours and keeps the best route visible on top.
Use random generated cities or the built-in NYC landmark set with a map background.
Change ants, iterations, alpha, beta, evaporation, pheromone deposit, and animation delay.
Toggle a blocked NYC edge and compare how the solver adapts its possible tours.
Code layout
The app is split so the Swing UI, solver, city data, and model code can be read and tested independently.
JFR profile
Java Flight Recorder showed the main cost in ACO.pickNext(...), which is expected because each ant scans candidate cities while constructing a tour.
sampled method time in candidate selection
young GC collections in the profiling run
longest observed GC pause
Try it
mvn compile
java -cp target/classes tsp_aco_gui.AntColonyTSP
Requires Java 21+ and Maven 3.9+.