Skip to content

Instantly share code, notes, and snippets.

@mirrornerror
Created January 28, 2019 15:30
Show Gist options
  • Save mirrornerror/067134e7bc84c61d393d03533fba6f03 to your computer and use it in GitHub Desktop.
Save mirrornerror/067134e7bc84c61d393d03533fba6f03 to your computer and use it in GitHub Desktop.
# 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