Rudy’s OBTF Rudolf Adamkovič

Home / Computer science / Traveling salesman problem (TSP) / Computation: Python, SAT + NN, permutation


Solution

Find a solution in the given time.

solver = cp.CpSolver()
solver.parameters.max_time_in_seconds = 60 * 1
result = solver.solve(model)
y = solver.objective_value
tour = [solver.value(x_i) for x_i in x]
print(f"Result: {result}")
print(f"Distance: {y}")
print(f"Tour: {tour}")
Result: 2
Distance: 148816.0
Tour: [22, 21, 20, 24, 23, 45, 44, 43, 47, 46, 68, 67, 66, 49, 48, 51, 52, 53, 41, 42, 27, 28, 29, 30, 18, 19, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 36, 35, 34, 33, 39, 40, 59, 58, 57, 56, 62, 63, 61, 60, 54, 55, 50, 65, 64, 70, 71, 72, 38, 37, 31, 32, 26, 25, 3, 2, 1, 0, 74, 75, 73, 69]

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