Rudy’s OBTF Rudolf Adamkovič

Home / Computer science / Traveling salesman problem (TSP) / Computation in Python / Implement


traveling_salesman.tour_random

def tour_random(instance, distances, random):
    """Return indices for a random tour, and its distance"""

    tour = np.arange(len(instance))

    random.shuffle(tour)

    distance1 = distance(tour, distances)

    return tour, distance1

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