Skip to content

tommy3713/TSP-dynamic-programming-Python

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TSP-dynamic-programming-Python

Traveling salesman problem

Using Dynamic Programming

Reference: https://github.com/phvargas/TSP-python.git

Introduction

what is in the readfile.txt?

First column is the index of city

Second column is the x cooridinate

Third column is the y cooridinate

You can simply modify this txt file by changing its idex or position.

1. Run the program

python3 TSP_dp.py

2. Two files will be generated

  1. draw.txt -> used to draw the route
  2. output.txt ->include route, best distance and execution time.
Best Visit Order: 1  3  2  11  9  10  5  4  6  7  8  1  
Best Distance:  167.80695975880067
Execution Time:  0.1690812110900879  (s)

3. gnuplot mode

gnuplot

4. draw path

load "draw.plt"

5. Result

output.svg will be generated.

Use Chrome or safari to open it

截圖 2021-04-13 下午3 22 30

About

Traveling Salesman Problem. Dynamic Programming.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published