This project is an implementation and visualization of the Ant Colony Optimization (ACO) algorithm for solving the Traveling Salesman Problem (TSP). The application allows users to interactively place points (cities) on a canvas, run the ACO algorithm, and visualize the pheromone-based pathfinding process.
- Interactive GUI: Built using Tkinter and ttkbootstrap.
- Graph Representation: Uses NetworkX to manage the graph structure.
- Algorithm Visualization: Displays pheromone trails and optimal paths dynamically.
- Image Support: Allows adding background images for visualization.
- Auto Iteration: Supports continuous execution of the ACO algorithm.
- Customizable Settings: Users can change colors, toggle number labels, and adjust parameters.
- Multilingual Support: English and Ukrainian languages available.
Create and activate a Python virtual environment:
python3 -m venv venv
source venv/bin/activate # For Linux and macOS
# or
venv\Scripts\activate # For Windows
Install the required dependencies from requirements.txt
:
pip install -r requirements.txt
Run the application using:
python main.py
- Left Click: Add a city (point) to the graph.
- Right Click: Remove a city.
- Start Algorithm: Initializes the graph and pheromone levels.
- Run Iteration: Executes one step of the ACO algorithm.
- Auto Run: Continuously runs iterations.
- Choose Image: Adds a background image.
- Clear Points: Resets the graph.
- Change Color: Switches between black and white nodes.
- Show/Hide Numbers: Toggles numbering on points.
The Ant Colony Optimization (ACO) algorithm is inspired by the foraging behavior of ants. Key steps include:
- Initialization: Cities are defined as nodes in a graph.
- Ant Movement: Each ant probabilistically chooses the next city based on pheromone levels and distance.
- Pheromone Update: Trails are reinforced based on the quality of the path taken.
- Evaporation: Pheromone levels decay over time to avoid stagnation.
- Iteration: Steps 2-4 repeat to find an optimal path.
- Alpha (α): Controls the influence of pheromones.
- Beta (β): Controls the influence of distance.
- Evaporation Rate: Defines pheromone decay over iterations.
- Pheromone Constant (Q): Determines pheromone reinforcement.
Developed as a course project in the discipline “Algorithmization and Programming” in the first year of study of the specialty 122 “Computer Science” at VNTU. 2024 1cs-23b Max Patyk.