tsp algorithm (computational thinking) dropbox

12
Writing an algorithm for the Travelling Salesman Problem (TSP) Appendix A: Brute Force (Exhaustive Enumeration) # code adapted from: http://www.psychicorigami.com/2007/04/17/tackling-the-travelling-salesman-problem-part-one/ # importing 'math' so that we can use the 'sqrt' function at a later point # import 'itertools' so that we can use 'permutations' function at a later point import math import itertools # creating the function that allows coordinates to be read in from a plain text file def read_coords(coord_file): coords = [] for line in coord_file: x,y = line.strip().split(',') coords.append((float(x), float(y))) return coords # setting up the distance matrix (which stores all the calculated straight line distances between any two given coordinates) def cartesian_matrix(coords): matrix={} for i,(x1,y1) in enumerate(coords): for j,(x2,y2) in enumerate(coords): dx,dy=x1-x2,y1-y2 dist=math.sqrt(dx*dx + dy*dy) matrix[i,j]=dist return matrix # setting up a function to determine distance travelled in a tour (route through all points) def tour_length(matrix,tour): total=0 num_cities=len(tour) for i in range(num_cities): j=(i+1)%num_cities city_i=tour[i] city_j=tour[j] total+=matrix[city_i,city_j] return total # own code # setting up a function to determine which route has the minimum length def min_route(coord_file): coords=read_coords(coord_file) tours=list(range(len(coords))) z=[] matrix=cartesian_matrix(coords) for x in itertools.permutations(tours): z.append(tour_length(matrix,x))

Upload: sebastian-sear

Post on 16-Apr-2017

56 views

Category:

Documents


3 download

TRANSCRIPT

Page 1: TSP algorithm (Computational Thinking) Dropbox

Writing an algorithm for the Travelling Salesman Problem (TSP) Appendix A: Brute Force (Exhaustive Enumeration) # code adapted from: http://www.psychicorigami.com/2007/04/17/tackling-the-travelling-salesman-problem-part-one/ # importing 'math' so that we can use the 'sqrt' function at a later point # import 'itertools' so that we can use 'permutations' function at a later point import math import itertools # creating the function that allows coordinates to be read in from a plain text file def read_coords(coord_file): coords = [] for line in coord_file: x,y = line.strip().split(',') coords.append((float(x), float(y))) return coords # setting up the distance matrix (which stores all the calculated straight line distances between any two given coordinates) def cartesian_matrix(coords): matrix={} for i,(x1,y1) in enumerate(coords): for j,(x2,y2) in enumerate(coords): dx,dy=x1-x2,y1-y2 dist=math.sqrt(dx*dx + dy*dy) matrix[i,j]=dist return matrix # setting up a function to determine distance travelled in a tour (route through all points) def tour_length(matrix,tour): total=0 num_cities=len(tour) for i in range(num_cities): j=(i+1)%num_cities city_i=tour[i] city_j=tour[j] total+=matrix[city_i,city_j] return total # own code # setting up a function to determine which route has the minimum length def min_route(coord_file): coords=read_coords(coord_file) tours=list(range(len(coords))) z=[] matrix=cartesian_matrix(coords) for x in itertools.permutations(tours): z.append(tour_length(matrix,x))

Page 2: TSP algorithm (Computational Thinking) Dropbox

print(min(z)) return min(z) # selecting which file to read in coordinates from coord_file = open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt") # finding the minimum route length min_route(coord_file) Appendix B: Stochastic Optimisation (1 pair swap) #code adapted from: http://www.psychicorigami.com/2007/04/17/tackling-the-travelling-salesman-problem-part-one/ #importing 'math' so that we can use the 'sqrt' function at a later point import math #creating the function that allows coordinates to be read in from a plain text file def read_coords(coord_file): coords = [] for line in coord_file: x,y = line.strip().split(',') coords.append((float(x), float(y))) return coords #setting up the distance matrix (calculating the distance between any two coordinates) #uses straight line distances def cartesian_matrix(coords): matrix={} for i,(x1,y1) in enumerate(coords): for j,(x2,y2) in enumerate(coords): dx,dy=x1-x2,y1-y2 dist=math.sqrt(dx*dx + dy*dy) matrix[i,j]=dist return matrix #setting up a function to determine distance travelled in a tour (route through points) def tour_length(matrix,tour): total=0 num_cities=len(tour) for i in range(num_cities): j=(i+1)%num_cities city_i=tour[i] city_j=tour[j] total+=matrix[city_i,city_j] return total #produces all pair combinations for a list of length 'size'

Page 3: TSP algorithm (Computational Thinking) Dropbox

def all_pairs(size): r1=range(size) r2=range(size) for i in r1: for j in r2: yield (i,j) #setting up generator function to create all possible variations where two cities have been swapped def swapped_cities(tour): for i,j in all_pairs(len(tour)): if i < j: copy=tour[:] copy[i],copy[j]=tour[j],tour[i] yield copy #setting up generator function to return all possible variations where the section between two cities are swapped def reversed_sections(tour): for i,j in all_pairs(len(tour)): if i != j: copy=tour[:] if i < j: copy[i:j+1]=reversed(tour[i:j+1]) else: copy[i+1:]=reversed(tour[:j]) copy[:j]=reversed(tour[i+1:]) if copy != tour: # no point returning the same tour yield copy #own code #setting up a function to determine which route has the minimum length def min_route(coord_file): coords = read_coords(coord_file) tour=list(range(len(coords))) z=[] matrix=cartesian_matrix(coords) z.append(tour_length(matrix,tour)) for x in swapped_cities(tour): z.append(tour_length(matrix,x)) for y in reversed_sections(tour): z.append(tour_length(matrix,y)) print(min(z)) return(min(z)) #selecting which file to read in coordinates from coord_file = open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt") #finding the minimum route length min_route(coord_file)

Page 4: TSP algorithm (Computational Thinking) Dropbox

Appendix C: Main Code – Stochastic Optimisation (n pair swaps) # imports math function so that we can use 'sqrt' function later on and itertools for the brute force method import math import itertools # creating the function that allows coordinates to be read in from a plain text file def read_coords(coord_file): coords = [] # creating an empty set to be filled coordinates for line in coord_file: # for each line in the coordinate file we are taking the value to the left x,y = line.strip().split(',') # of the comma as our x value and the value to the right as our y value coords.append((float(x), float(y))) # here we are adding the coordinate pairs to our empty set return coords # setting up the distance matrix (calculating the distance between any two coordinates) # uses straight line distances def cartesian_matrix(coords): matrix={} # creating an empty set for i,(x1,y1) in enumerate(coords): # taking one lot of coordinates from the list of coordinates for j,(x2,y2) in enumerate(coords): # taking a second lot of coordinates from the list of coordinates dx,dy=x1-x2,y1-y2 # finding a distance between the two sets of coordinates dist=math.sqrt(dx*dx + dy*dy) matrix[i,j]=dist # putting each distance into a position in the distance matrix where rows return matrix # and columns correspond to the different "cities" # setting up a function to determine distance travelled in a tour (route through points) def tour_length(matrix,tour): total=0 # start with a total of 0 seeing as we haven't travelled any distance when at starting point num_cities=len(tour) # gives the number of movements between cities on any tour for i in range(num_cities): # i represents a city, j represents next city in a tour j=(i+1)%num_cities city_i=tour[i] city_j=tour[j] total+=matrix[city_i,city_j] # summing up all the distances between consecutive cities in a tour return total # this function allows us to generate pairs of cities so that we may apply operators later on def all_pairs(size): # size represents the number of cities visited (length of a tour) r1=range(size) # gives a range of numbers (0:number of cities in a tour) r2=range(size) for i in r1: for j in r2: yield (i,j) # creates all pairings of cities within a tour # operator as generator function to create all possible variations where two cities have been swapped def swapped_cities(tour): for i,j in all_pairs(len(tour)): # taking pairs of cities from the tuples generated in all pairs if i < j: # maximises efficiency by getting rid of trivial and repeated swaps

Page 5: TSP algorithm (Computational Thinking) Dropbox

copy=tour[:] copy[i],copy[j]=tour[j],tour[i] # swaps the cities corresponding to i and j in a tour yield copy # function gives a list of possible tours when our operator is applied n times to the starting tour def route_list(n,coords): tour=list(range(len(coords))) # gives us our starting tour z=[] # creating an empty set for us to add tours into z.append(tour) for k in range(n): # represents applying the operator n times for x in range(len(z)): # applies the operator to all the tours we've created from previous applications of the operator for y in swapped_cities(z[x]): # selects potential new tours to add to list via the swapped_cities operator if y not in z: # prevents repeated tours being added to list z.append(y) # adds new tours to our set of created tours return z # this function identifies the minimum distance of any tour we have added to our 'z' list def min_route(n,coords): z=route_list(n,coords) # our created list of tours matrix=cartesian_matrix(coords) # our distance matrix m=[] # empty set for us to put total distances into for n in range(len(z)): # means that we look at all tours in our current list m.append(tour_length(matrix,z[n])) # adding the total lengths to our empty set return min(m) # select the minimum distance # creates a list telling us the minimum distance and potential tours which give us this distance using the swap operator n times def min_dist_route(n,coords): m=min_route(n,coords) # gives us our minimum distance for tours we have created z=route_list(n,coords) # our list of created tours h=[] # empty set for us to put optimal tours into matrix=cartesian_matrix(coords) # distance matrix for x in range(len(z)): # tests all tours generated so far if m==tour_length(matrix,z[x]): # selects the tours corresponding to the minimum distances h.append(z[x]) # adds selected tours to our set h.append(m) # adds the minimum distance return h # returns a list that gives optimal tours; the final entry is the distance # represented by these tours for n uses of our operator # selecting coordinates coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) # selecting n and finding minimum route length and associated route(s) min_dist_route(1,coords) # note: the more you increase n, the more likely you are to find your minimal optimal tour and tour distance # note: the more you increase n, the greater level of computation required and the greater the run time # note: float errors can result in us not getting a complete list of all tours corresponding to our theoretical minimal distance

Page 6: TSP algorithm (Computational Thinking) Dropbox

# note: increasing n results in runtime increasing severely ------------------------------------------------------------------------------------------------------------------------ # brute force method that will ALWAYS give a best solution def min_route_brute(coords): tours=list(range(len(coords))) # creating an initial tour z=[] # creating an empty set matrix=cartesian_matrix(coords) # using our distance matrix for x in itertools.permutations(tours): # finds all possible tours by find all permutations of a tour z.append(x) # adds tours to our empty set h=[] # creating another empty set for i in range(len(z)): # looks at all possible tours h.append(tour_length(matrix,z[i])) # adds distances of all possible tours to the empty set m=min(h) # takes the minimum distance k=[] # creates a new empty set for j in range(len(z)): # looks at all possible tours if m==tour_length(matrix,z[j]): # selects tours corresponding to minimal distance k.append(z[j]) # adds these tours to our set k k.append(m) # adds minimal distance the end of the set return k # returns set of optimal tour(s) and minimum distance # note: again, room for float error # not ideally suited to coordinate files containing more than 11 coordinates coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) min_route_brute(coords) Appendix D: Testing Main Code # imports math function so that we can use 'sqrt' function later on and itertools for the brute force method import math import itertools # creating the function that allows coordinates to be read in from a plain text file def read_coords(coord_file): coords = [] # creating an empty set to be filled coordinates for line in coord_file: # for each line in the coordinate file we are taking the value to the left x,y = line.strip().split(',') # of the comma as our x value and the value to the right as our y value coords.append((float(x), float(y))) # here we are adding the coordinate pairs to our empty set return coords # selecting coordinates coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) # testing read_coords function

Page 7: TSP algorithm (Computational Thinking) Dropbox

coords # setting up the distance matrix (calculating the distance between any two coordinates) # uses straight line distances def cartesian_matrix(coords): matrix={} # creating an empty set for i,(x1,y1) in enumerate(coords): # taking one lot of coordinates from the list of coordinates for j,(x2,y2) in enumerate(coords): # taking a second lot of coordinates from the list of coordinates dx,dy=x1-x2,y1-y2 # finding a distance between the two sets of coordinates dist=math.sqrt(dx*dx + dy*dy) matrix[i,j]=dist # putting each distance into a position in the distance matrix where rows return matrix # and columns correspond to the different "cities" # testing cartesian_matrix function cartesian_matrix(coords) # setting up a function to determine distance travelled in a tour (route through points) def tour_length(matrix,tour): total=0 # start with a total of 0 seeing as we haven't travelled any distance when at starting point num_cities=len(tour) # gives the number of movements between cities on any tour for i in range(num_cities): # i represents a city, j represents next city in a tour j=(i+1)%num_cities city_i=tour[i] city_j=tour[j] total+=matrix[city_i,city_j] # summing up all the distances between consecutive cities in a tour return total # testing the tour_length function tour = list(range(len(coords))) matrix = cartesian_matrix(coords) tour_length(matrix, tour) # this function allows us to generate pairs of cities so that we may apply operators later on def all_pairs(size): # size represents the number of cities visited (length of a tour) r1=range(size) # gives a range of numbers (0:number of cities in a tour) r2=range(size) for i in r1: for j in r2: yield (i,j) # creates all pairings of cities within a tour # operator as generator function to create all possible variations where two cities have been swapped def swapped_cities(tour): for i,j in all_pairs(len(tour)): # taking pairs of cities from the tuples generated in all pairs if i < j: # maximises efficiency by getting rid of trivial and repeated swaps copy=tour[:] copy[i],copy[j]=tour[j],tour[i] # swaps the cities corresponding to i and j in a tour yield copy

Page 8: TSP algorithm (Computational Thinking) Dropbox

# function gives a list of possible tours when our operator is applied n times to the starting tour def route_list(n,coords): tour=list(range(len(coords))) # gives us our starting tour z=[] # creating an empty set for us to add tours into z.append(tour) for k in range(n): # represents applying the operator n times for x in range(len(z)): # applies the operator to all the tours we've created from previous applications of the operator for y in swapped_cities(z[x]): # selects potential new tours to add to list via the swapped_cities operator if y not in z: # prevents repeated tours being added to list z.append(y) # adds new tours to our set of created tours return z # testing that the route_list function is using the all_pairs function and the swapped_cities generator route_list(2,coords) # this function identifies the minimum distance of any tour we have added to our 'z' list def min_route(n,coords): z=route_list(n,coords) # our created list of tours matrix=cartesian_matrix(coords) # our distance matrix m=[] # empty set for us to put total distances into for n in range(len(z)): # means that we look at all tours in our current list m.append(tour_length(matrix,z[n])) # adding the total lengths to our empty set return min(m) # select the minimum distance # testing the min_route function min_route(2,coords) # creates a list telling us the minimum distance and potential tours which give us this distance using the swap operator n times def min_dist_route(n,coords): m=min_route(n,coords) # gives us our minimum distance for tours we have created z=route_list(n,coords) # our list of created tours h=[] # empty set for us to put optimal tours into matrix=cartesian_matrix(coords) # distance matrix for x in range(len(z)): # tests all tours generated so far if m==tour_length(matrix,z[x]): # selects the tours corresponding to the minimum distances h.append(z[x]) # adds selected tours to our set h.append(m) # adds the minimum distance return h # returns a list that gives optimal tours; the final entry is the distance # represented by these tours for n uses of our operator # testing the min_route_dist function min_dist_route(1,coords) # note: the more you increase n, the more likely you are to find your minimal optimal tour and tour distance # note: the more you increase n, the greater level of computation required and the greater the run time # note: float errors can result in us not getting a complete list of all tours corresponding to our theoretical minimal distance # note: increasing n results in runtime increasing severely ------------------------------------------------------------------------------------------------

Page 9: TSP algorithm (Computational Thinking) Dropbox

###### Testing import time # Testing runtime for function using 5 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.00024199485778808594 min_dist_route(1,coords) # Testing runtime for function using 5 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.0008559226989746094 min_dist_route(2,coords) # Testing runtime for function using 5 coordinates and 3 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(3,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.0037910938262939453 min_dist_route(3,coords) # Testing runtime for function using 5 coordinates and 4 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(4,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.009132862091064453 min_dist_route(4,coords) # Testing runtime for function using 5 coordinates and 10 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (5 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(10,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.057394981384277344 min_dist_route(10,coords) # Testing runtime for function using 10 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (10 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program

Page 10: TSP algorithm (Computational Thinking) Dropbox

print(time.time()-t1) # print the time taken # time taken: 0.0007631778717041016 min_dist_route(1,coords) # Testing runtime for function using 10 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (10 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.0800020694732666 min_dist_route(2,coords) # Testing runtime for function using 10 coordinates and 3 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (10 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(3,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 14.427962064743042 min_dist_route(3,coords) # Testing runtime for function using 10 coordinates and 4 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (10 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(4,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: excessively long (not completed within 5 minutes) min_dist_route(4,coords) # Testing runtime for function using 15 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (15 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.0022640228271484375 min_dist_route(1,coords) # Testing runtime for function using 15 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (15 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 1.9704020023345947 min_dist_route(2,coords) # Testing runtime for function using 15 coordinates and 3 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (15 co-ordinates).txt")) t1 = time.time() # start time

Page 11: TSP algorithm (Computational Thinking) Dropbox

min_dist_route(3,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: excessively long (not completed within 5 minutes) min_dist_route(3,coords) # Testing runtime for function using 20 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (20 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.0048389434814453125 min_dist_route(1,coords) # Testing runtime for function using 20 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (20 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 21.319644927978516 min_dist_route(2,coords) # Testing runtime for function using 20 coordinates and 3 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (20 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: excessively long (not completed within 5 minutes) min_dist_route(2,coords) # Testing runtime for function using 21 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (21 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.005461931228637695 min_dist_route(1,coords) # Testing runtime for function using 21 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (21 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 32.582332134246826 min_dist_route(2,coords)

Page 12: TSP algorithm (Computational Thinking) Dropbox

# Testing runtime for function using 25 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (25 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 0.01108407974243164 min_dist_route(1,coords) # Testing runtime for function using 25 coordinates and 2 runs through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (25 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(2,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 168.34624695777893 min_dist_route(2,coords) # Testing runtime for function using 100 coordinates and 1 run through of swapping operator coords = read_coords(open("/Users/sebsear/PycharmProjects/CT Project (Travelling Sales Person)/coords_file (100 co-ordinates).txt")) t1 = time.time() # start time min_dist_route(1,coords) # run the TSP program print(time.time()-t1) # print the time taken # time taken: 2.6197609901428223 min_dist_route(1,coords) Bibliography Computational Thinking Lecture 5. n.p.: Andrew Whiter, 2013. https://moodle.ucl.ac.uk/pluginfile.php/3159573/mod_resource/content/1/Computational%20Thinking%20Lecture%205.pdf. Montgomery, John. ‘Tackling the Travelling Salesman Problem Hill Climbing’. May 12, 2007. Accessed April 15, 2016. http://www.psychicorigami.com/2007/05/12/tackling-the-travelling-salesman-problem-hill-climbing/. Montgomery, John. ‘Tackling the Travelling Salesman Problem Part One’. April 17, 2007. Accessed April 15, 2016. http://www.psychicorigami.com/2007/04/17/tackling-the-travelling-salesman-problem-part-one/. ‘Prove That Factorial Grows Faster than Exponential Function Using Limits’. 2016. Accessed April 15, 2016. http://math.stackexchange.com/questions/1137730/prove-that-factorial-grows-faster-than-exponential-function-using-limits. ‘Travelling Salesman Problem’. Accessed April 15, 2016. http://mathworld.wolfram.com/TravelingSalesmanProblem.html