https://github.com/ethanhe42/tsp
evaluation of various algorithms for traveling salesman problem
https://github.com/ethanhe42/tsp
algorithm animation python tsp
Last synced: 6 months ago
JSON representation
evaluation of various algorithms for traveling salesman problem
- Host: GitHub
- URL: https://github.com/ethanhe42/tsp
- Owner: ethanhe42
- License: mit
- Created: 2016-11-14T13:07:31.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2020-02-14T17:24:10.000Z (over 5 years ago)
- Last Synced: 2025-01-19T07:42:03.468Z (9 months ago)
- Topics: algorithm, animation, python, tsp
- Language: Python
- Homepage: https://arxiv.org/abs/1705.09058
- Size: 27.3 KB
- Stars: 7
- Watchers: 3
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
TSP algorithms survey
=============An animation of four algorithms trying to solve a traveling salesman problem.
### algorithms
Given a set of 200 cities four algorithms are used to find the shortest tour
of all 200 cities. The algorithms are:1. Random path, start a city and randomly select the next city from the remaining not visited cities until all cities are visited.
2. Greedy, start a city select as next city the unvisited city that is closest to the current city
3. 2-Opt, First create a random tour, and then optimize this with the 2-opt
algorithm
4. Simulated Annealing. First create a random tour, and then optimize this with 2-opt in combination
with simualted annealing.### results
lenth | greedy | 2opt | sa | optimal | random
--- | --- | --- | --- | --- | ---
p15 | 284.38 | 284.38 | 284.38 | 284.38 | 818
att48 | 40526 | 35579 | 33607 | 33523 | 157530
rand200 | 36226 | 31887 | 30944 | x | 327452time | greedy | 2opt | sa
--- | --- | --- | ---
p15 | 1ms | 5ms | 11.12
att48 | 6ms | .24s | 11s
rand200 | 10ms | 18s | 14.5s### citation
If you find the code useful in your research, please consider citing:
@article{he2017empirical,
title={An Empirical Analysis of Approximation Algorithms for the Euclidean Traveling Salesman Problem},
author={He, Yihui and Xiang, Ming},
journal={arXiv preprint arXiv:1705.09058},
year={2017}
}[Paper](https://github.com/yihui-he/TSP-paper) and [实验报告](https://github.com/yihui-he/TSP-report) latex code are also available.
### setups
To create the animation you will need python (Version 2) and ffmpeg.
For python you need one additional library (matplotlib) and its dependcies.
You can install it with:pip install matplotlib
To create the animation use:
make .anim
makeThis should create a file called sa.mp4. This should be playable with vlc.