A Python/Tkinter tool for visualizing and comparing ACO, PSO, and ABC swarm algorithms on an intermodal TSP. Features automated experiments and CSV data export for analysis.
An advanced pathfinding visualization and analysis tool developed in Python. This application serves as an experimental testbed for comparing three metaheuristic algorithms—Ant Colony Optimization (ACO), Particle Swarm Optimization (PSO), and Artificial Bee Colony (ABC)—for solving the Traveling Salesperson Problem (TSP) on a complex, intermodal grid.
The tool was designed to facilitate undergraduate-level research into the performance characteristics and trade-offs of different swarm intelligence algorithms in a realistic logistics scenario.
Interactive Grid Designer: Visually design complex delivery networks with standard roads, highways, walls, and intermodal hubs (airports, rail terminals).
Intermodal A* Pathfinding: A high-performance, cached A* implementation calculates the true cost between any two points, accounting for different travel costs and fixed transfer penalties at hubs.
Three Swarm Algorithms: Textbook-accurate implementations of:
Ant Colony Optimization (ACO)
Discrete Particle Swarm Optimization (DPSO)
Artificial Bee Colony (ABC)
Granular Parameter Control: Adjust key algorithm parameters (e.g., population size, iterations, alpha/beta for ACO, inertia/cognitive/social weights for PSO) via sliders with helpful tooltips.
Live Visualization: Watch the algorithms work in real-time, with live updates for the current iteration, best path cost, and a progress bar.
Automated Experiment Mode: Run algorithms for a specified number of trials automatically. The results, including initial cost, final cost, and execution time, are exported to a single CSV file for easy analysis.
This tool allows for a deep, empirical analysis of core trade-offs in metaheuristic design:
Exploration vs. Exploitation: Compare the methodical, exploitation-focused search of ACO against the highly explorative nature of ABC and PSO.
Convergence Behavior: Observe how PSO and ABC rapidly converge from poor random states, while ACO starts with a strong initial solution and makes smaller, incremental improvements.
Reliability vs. Speed: Quantitatively measure which algorithms are fastest versus which are most likely to find the globally optimal solution.
Design Your Network:
-Use the Drawing Mode radio buttons on the right to select an element (e.g., Walls, Highways, Airports).
-Left-click on the grid to place the selected element.
-Use the "Set Start Point," "Set End Point," and "Add Delivery Points" modes to define the TSP problem.
-Right-click to erase any element and return it to an empty cell.
Configure Costs and Parameters:
-Use the Intermodal Cost Settings sliders to define transfer penalties and the relative cost (speed) of different transport modes.
-Select an algorithm (ACO, PSO, or ABC). The specific parameters for that algorithm will appear below.
-Adjust the parameters as needed. Hover over a parameter's label to see a tooltip explaining what it does.
Run a Simulation or Experiment:
Run Simulation: Runs the selected algorithm one time with full visual feedback. This is great for understanding how an algorithm works.
Run Experiment: Opens a dialog asking for the number of runs per algorithm. It will then automatically run all three algorithms for the specified number of trials and prompt you to save the results as a .csv file. This is the primary tool for data collection.
Stop Algorithm: Gracefully stops any currently running simulation or experiment.
The project is written in standard Python and has minimal dependencies.
Install the required library (NumPy):
The application requires the numpy library. You can install it using pip.
pip install numpy
The primary purpose of this tool is to generate data for analysis. After running a 270-trial experiment, the exported CSV can be used to generate insights like the following:
Metric Ant Colony Optimization (ACO) Particle Swarm Optimization (PSO) Artificial Bee Colony (ABC)
Avg. Initial Cost 167.31 197.88 203.20
Avg. Final Cost 162.24 163.66 159.37
Success Rate 32.2% 43.3% 88.9%
Avg. Execution Time 0.2599 s 0.0132 s 0.0199 s
From this data, we can conclude: ACO is best for initial stability, providing a good solution almost instantly. PSO is the fastest algorithm. ABC is the most reliable for finding the best possible solution. This allows for a nuanced discussion about which algorithm is "best" depending on the specific problem constraints.
If you use any part of this code in your project, please include the following attribution:
Created by Jitanshu Singh — ( https://github.com/Jitanshu-commits )