This project is a C++ program that solves the Traveling Salesman Problem (TSP) using the Simulated Annealing algorithm. Given a set of cities with specific coordinates, the program attempts to find the shortest possible tour that visits each city exactly once and returns to the starting point.
This program reads city coordinates from a .tsp
file, optimizes the route using Simulated Annealing, and outputs the best tour and its distance. Simulated Annealing is a probabilistic technique that searches for an approximate global optimum in a large solution space, making it well-suited for TSP, an NP-hard problem.
- C++ Compiler: A compiler that supports C++11 or later.
- Input File: A
.tsp
file containing city coordinates in the TSPLIB format.
-
Clone the Repository
git clone <repository_url> cd <repository_name>
-
Compile the Program
g++ -o tsp_solver tsp_solver.cpp -std=c++11
-
Run the Program
./tsp_solver
-
Input the Filename When prompted, enter the name of the
.tsp
file (e.g.,xqf131.tsp
).