Package: satsp
Travelling Salesman Problem Using Simulated AnnealingThis package solves the Travelling Salesman Problem (TSP) using Simulated Annealing (SA).Required LibrariesNumpyPandasMatplotlibMathInstallationThesatsppackage can be installed usingpip:pip install satspUsageBasic usage:from satsp import solver

cities = [[1, 6.0, 7.0],
          [2, 4.0, 9.0],
	  [3, 7.0, 1.0]]

solver.Solve(cities)
solver.PrintSolution()The three columns in cities represent id, x coordinate and y coordinate.Advanced Usage:solver.Solve(city_list = None, dist_matrix = None, start_temp = None, \
          stop_temp = None, alpha = None, epochs = None, epoch_length = None, \
          epoch_length_factor = 1.00, stopping_count = 100, screen_output = True)Arguments ofsolver.Solve()function:city_list: a N*3 matrix containing three columns representing id, x coordinate and y coordinate of the N cities. Can beNone.dist_matrix: a N*N matrix containing the distances between the N cities. IfNoneis passed and aNonecity_listis passed, the program will calculate the Eclidean distances between the cities. If bothcity_listanddist_matrixareNone, a test instance with 48 cities will be solved.start_temp: initial temperature for SA. If None is passed, the program will estimate the initial temperature using a small sample from the data.stop_temp: stopping temperature for SA. Can beNone.alpha: cooling rate for SA. IfNoneis passed, the program will calculate alpha ifstop_tempandepochsare given. Otherwisealphais set at 0.99.epochs: number of epochs for SA. A decisive factor for the running time of the algorithm. The program will terminate after this number of epochs. IfNoneis passed, andstop_tempandalphaare given, the program will calculate number of epochs. Otherwise, the stopping condition will be switched to no improvement after a certain number of epochs, where the number is decided bystopping_count.epoch_length: number of iterations in each epoch. The default is min(100, N*(N-1) / 2).epoch_length_factor: the rate at which epoch length increases at each epoch. Should be greater than or equal to 1. Default is 1.00. A small value is recommended for large instances.stopping_count: the number of epochs after which the program will stop if no improvement is made. This stopping condition is only activated if the number of total epochs is neither specified by the user nor can be calculated by the program. Default is 100.screen_output: Parameters of SA, progress of the algorithm and the results will be displayed if set toTrue. Default isTrue.Other functions provided bysolver:solver.GetBestDist(): return the total distance of the best TSP toursolver.GetBestTour(): return a list of cities of the best TSP toursolver.PrintBestTour(): Output a picture drawing the best TSP toursolver.PrintConvergence(): Plot the convergence of the distances at the end of each epochAlgorithmThis package implements the simulated annealing (SA) metaheuristic to solve TSP. A sketch of the algorithm is as follows:Generate a random initial tour, and set an initial temperature.Set a number for the iterations to be performed, determined by epoch length.Randomly pick two cities in the tour and perform a "2-opt" operation, i.e., reverse the tour between the two cities.If a tour with shorter distance is obtained, accept the new tour. Otherwise, accept the new tour with a certain probability determined by the difference between old and new distances and the current temperature.Repeat 3-4 for the number of iterations determined in 2.If a stopping condition is met, terminate. Otherwise go to 7.Decrease the temperature and repeat 2-5.ReferencesKirkpatrick, Scott, C. Daniel Gelatt, and Mario P. Vecchi. "Optimization by simulated annealing." Science 220.4598 (1983): 671-680.Park, Moon-Won, and Yeong-Dae Kim. "A systematic procedure for setting parameters in simulated annealing algorithms." Computers & Operations Research 25.3 (1998): 207-217.