This is a simple project that uses various methods to find the (pseudo-)optimal solution for the TSP. Between having the right path and a path with a reduced complexity.
The Traveling Salesman Problem (TSP) is a classic combinatorial optimization problem. The goal is to find the shortest possible route that visits each point exactly once and returns to the starting point. It’s classified as an NP-hard problem in the field of combinatorial optimization.
- Given the point to start, a set of cities and the distances between them, find the optimal tour that minimizes the total distance traveled.
- Constraints: Each point must be visited exactly once, and the tour must return to the starting point.
- Exact algorithms:
-
Exhaustive search: Test all possibilties,
$complexity = O((n+1)!)$
-
Exhaustive search: Test all possibilties,
- Approximate algorithms:
-
Greedy distance remaining: Choose the point closest to the remaining cities,
$complexity = O(n²)$ -
Greedy proximity: Choose the point closest to your current one,
$complexity = O(n²)$ -
Random: Shuffle the list of cities and return it as a probable solution,
$complexity = O(n)$ -
Static sorting: Sort cities by distance from starting point, using merge sort,
$complexity = O(nlog(n))$
-
Greedy distance remaining: Choose the point closest to the remaining cities,
n := number of cities to travel (number total of cities - 1)
Clone this repository and compile it using make command
git clone https://codeberg.org/Angel-Karasu/traveling-salesman-problem.git;
cd traveling-salesman-problem;
make all;
- Run the executable file :
path
- Choose the starting point
- Optimized exhaustive search
- Add more algorithms
- Stylish the marp slides
This project is licensed under the GNU GPLv3.
See the LICENSE
file for details.