Question: Please give a PYTHON code for a-c NOT a different language Consider the travelling salesman problem, as described in class. For parts a)-c), write code

 Please give a PYTHON code for a-c NOT a different language

Please give a PYTHON code for a-c NOT a different language

Consider the travelling salesman problem, as described in class. For parts a)-c), write code to generate 100 random TSP instances involving 7 cities, where cities lie at points in the 2D plane ([0.0,1.0], [0.0,1.0]), sampled uniformly at random. Your code should be correct but will not be marked for style. Use Euclidean distance as your distance measure between cities. a) Solve each TSP exactly by brute-force search over all possible tours. Record and save these costs. In your report, simply state where in your code this is implemented, and state the mean, min, max, and standard deviation of the optimal tour lengths across the 100 instances. b) As a baseline, generate a random tour for each of the 100 instances. What is the mean, min, max, and standard deviation of the tour lengths found? Report the number of instances for which the random tour happens to be the optimal solution (may be zero). c) Implement and apply hill climbing greedy local search using the 2-change neighbourhood function described in class on the 100 instances, using the randomly sampled start state from part b). What is the mean, min, max, and standard deviation of the tour lengths found? Also report the number of instances for which the algorithm found the optimal solution. d) Scale up your experiments! Repeat parts b) and c) using 100 random TSP instances involving 100 cities. Since the number of possible tours is factorial with respect to the number of cities, it may no longer be feasible to compute the costs of the optimal solutions in a reasonable amount of time, so simply omit that part of the table. (If you have extra time, you can find libraries to help you plot and visualize the solutions found by your algorithms, but this is not necessary for the submission.) o Implementation tips: Represent a tour as an array of cities, which are (x,y) coordinates Some useful methods you should write should implement: Computing the cost of a tour Computing the cost between two cities Generating the neighbours of a state Generating a TSP instance If you're using Python, the following modules may be useful: random, itertools (in particular itertools.permutations), statistics O O O

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!