Rudy’s OBTF Rudolf Adamkovič

Home / Computer science / Traveling salesman problem (TSP) / Sample instance (pr76)


Optimal tour for pr76 (108159):

import numpy as np
import traveling_salesman as ts

solution = np.array([1, 76, 75, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
                     74, 15, 16, 17, 18, 37, 36, 38, 39, 40, 34, 35, 33, 32,
                     29, 30, 31, 19, 20, 26, 27, 28, 43, 42, 54, 53, 52, 55,
                     56, 57, 58, 59, 60, 41, 61, 62, 63, 64, 73, 72, 71, 65,
                     66, 51, 49, 50, 67, 70, 68, 69, 47, 48, 44, 45, 46, 24,
                     25, 21, 22, 23])

# tour = ???

# TODO Convert solution to tour.

instance = ts.read_instance('bib/pr76.tsp')
distances = ts.distances(instance)
distance = ts.distance(tour, distances)

return f"Tour: \n {tour}" "\n\n" f"Distance: {distance}"

© 2025 Rudolf Adamkovič under GNU General Public License version 3.
Made with Emacs and secret alien technologies of yesteryear.