Created
January 28, 2019 15:30
-
-
Save mirrornerror/067134e7bc84c61d393d03533fba6f03 to your computer and use it in GitHub Desktop.
TSP: pyconcorde: https://github.com/jvkersch/pyconcorde
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# pyconcorde: https://github.com/jvkersch/pyconcorde | |
from concorde.tsp import TSPSolver | |
num=30 | |
X = np.random.random(num)*10**6 | |
Y = np.random.random(num)*10**6 | |
solver = TSPSolver.from_data(X, Y, norm='EUC_2D') | |
solution = solver.solve() | |
print(solution.found_tour) | |
print(solution.optimal_value/(10**6)) | |
path = np.concatenate([solution.tour, [0]]) | |
print(path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment