This Jupyter Notebook contains Python code implementing Ant Colony Optimization (ACO) for the Traveling Salesman Problem (TSP). The ACO algorithm is designed to find an optimal or near-optimal solution for the TSP by simulating the foraging behavior of ants.
The following ACO approaches are used:
- Standard ACO
- MMAS
- Elitist
Before running the code, make sure you have the following dependencies installed:
- Python 3
- Jupyter Notebook
You can install Jupyter Notebook using the following command: pip install notebook
The following libraries will need to be installed:
- numpy
- xml.etree.ElementTree
- matplotlib.pyplot
- pandas
Getting Started
- Clone or download the repository to your local machine:
git clone [repository_url]
- Navigate to the project directory:
cd [project_directory]
- Open Jupyter Notebook:
jupyter notebook
In Jupyter Notebook, open the ipynb file you want to run. There are 2, brazil.ipynb and burma.ipynb
Running the Code
-
Inside the notebook, execute the code cells by selecting each cell and pressing Shift + Enter.
-
Customize the parameters: input_data: Path to the XML file containing TSP data. num_iterations: Number of iterations for the ACO algorithm. max_evaluations: Maximum number of evaluations before terminating the algorithm. Other ACO parameters such as num_ants, alpha, beta, rho, Q, and elitist_percentage can be adjusted as needed.
-
Monitor the output: The algorithm will print progress information, including the best path and distance, at regular intervals.
-
View Results: The final results, including the best path and distance, will be displayed after the algorithm completes.
License This code is provided under the MIT license.