Question: This question has 3 parts: a] loadTSPlfilenamel {4 marks}. 1Write this p5.js function that will read a TSP problem from a .tsp file. For this

This question has 3 parts: a] loadTSPlfilenamel
This question has 3 parts: a] loadTSPlfilenamel {4 marks}. 1Write this p5.js function that will read a TSP problem from a .tsp file. For this assignment, we will only consider Euclidean distance problems. The information you need to load in includes the problem name, total number of cities, the id of each city, and the co-ordinates of those cities. You could store the city information as 3 parallel arrays lids, xcords, ycoords] or an array of objects with an id, x and y 1luralue. You can find the TSPLIE documentation and the dataset with Euclidean only problems on the course website. Your function should take the name of a .tsp file to load. Hint: Reading the TSPLlB.pdf file can be a little daunting. Haye a look at some of the actual .tsp files l berlin52. tsp, a280.tsp}. it should make the problem seem a lot easier. bl showLoadedTSPl] [4 marks}. Write this function that will yisualise a loaded problem. You will need to find a way to scale the loaded problem to fit correctly on the canyas. You may choose what shapest'colours to use to yisualise the problem. You should make sure you display the problem name and number of cities somewhere on the canyas. c] showSolutionlsolutionFile} {4 marks}. Write this function that will yisualise a solution to a loaded problem from a file. You may assume that this function will only be used AFTER showLoadedTSPl} has already been run. The first line of a .sol le contains the problem file name i[you should check this matches the loaded TSP]. The second line contains the tour length, and the rest of the file contains a list of ID's {one on each line} that represents the order that the cities should be connected to form the shortest tour. You should display the solution tour distance on the canyas. Some sample .sol files haye been proyided on the course website. Challenge {3 marks}: Make the program animate the tour. The program should show the salesman starting from the first city and smoothly moying between all the cities leaving the tour as a trail behind them until they reach the last city and return back to the first one. You can loop this animation if you wish

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 Mathematics Questions!