This project implements a Genetic Algorithm to solve the Traveling Salesman Problem (TSP), a classic optimization problem.
The TSP Solver is designed for academic purposes demonstrating the application of genetic algorithms in solving complex optimization problems.
The code includes functions for loading distance matrices, creating symmetric matrices, and various genetic operations like selection, crossover, and mutation.
Modularity: The code is organized into functions for easy readability and maintainability. Efficiency: Algorithms are optimized for efficient computation of routes and distances. Readability: Consistent naming conventions and code structuring are used for clarity. Error Handling: Rrror handling to ensure reliable operation under various input scenarios. Documentation: Comprehensive comments to explain the functionality of each part of the code.
- Python 3.11.3
- Visual Studio Code
- LineProfiler
- Loading and processing triangular matrix files for distance calculations.
- Symmetric matrix generation for TSP.
- Implementation of genetic algorithm operations: Population initialization, Tournament selection, Partially Mapped Crossover (PMX), Inversion and Exchange mutations
- Elitism strategy to retain top-performing solutions.
- Calculation and display of the optimal route and distance.
- Performance measurement for algorithm execution.
- Ensure right version of Python is installed.
- Place the triangular matrix file in the same directory as the script.
- Run the script in a Python environment.
- The best route and distance will be displayed, along with the execution time.