subject

In this assignment you will implement one or more algorithms for the traveling salesman problem, such as the dynamic programming algorithm covered in the video lectures. Here is a data file describing a TSP instance. The first line indicates the number of cities. Each city is a point in the plane, and each subsequent line indicates the x- and y-coordinates of a single city.
The distance between two cities is defined as the Euclidean distance --- that is, two cities at locations (x, y)(x, y) and (z, w)(z, w) have distance \sqrt{(x-z)^2 + (y-w)^2} (x−z) 2 +(y−w) 2 between them.
In the box below, type in the minimum cost of a traveling salesman tour for this instance, rounded down to the nearest integer.
OPTIONAL: If you want bigger data sets to play with, check out the TSP instances from around the world here. The smallest data set (Western Sahara) has 29 cities, and most of the data sets are much bigger than that. What's the largest of these data sets that you're able to solve --- using dynamic programming or, if you like, a completely different method?
In [2]:import numpy as npfile = "tsp. txt"# file = "test2.txt"data = open(file, 'r').readlines()n = int(data[0])graph = {}for i, v in enumerate(data[1:]): graph[i] = tuple(map(float, v. strip().split(" ")))
dist_val = np. zeros([n, n])for i in range(n): for k in range(n): dist_val[i, k] = dist_val[k, i] = np. sqrt((graph[k][0]-graph[i][0])**2 + (graph[k][1]-graph[i][1])**2)print (graph)

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:00
The isometric projection camera technique provides an illusion of perspective by using things like parallax scrolling to create the illusion of 3d in a 2d game
Answers: 3
question
Computers and Technology, 23.06.2019 14:30
Open this link after reading about ana's situation. complete each sentence using the drop-downs. ana would need a minimum of ato work as a translator. according to job outlook information, the number of jobs for translators willin the future.
Answers: 3
question
Computers and Technology, 23.06.2019 22:50
What is an rss reader used for? for creating a user account on a social new site
Answers: 2
question
Computers and Technology, 24.06.2019 07:20
Ingrid started speaking about her slide presentation. when she clicked to th"third slide, which had just a picture of an elephant, she forgot what she wassupposed to talk about. what could ingrid do to avoid this situation in thefuture? oa. print handouts for her audience.ob. add presenter's notes to each slide.oc. add a video to each slide.od. save her slide presentation to a flash drive
Answers: 2
You know the right answer?
In this assignment you will implement one or more algorithms for the traveling salesman problem, suc...
Questions
question
Mathematics, 07.10.2020 14:01
question
Mathematics, 07.10.2020 14:01
question
Mathematics, 07.10.2020 14:01
question
Chemistry, 07.10.2020 14:01
question
Mathematics, 07.10.2020 14:01
question
Mathematics, 07.10.2020 14:01
Questions on the website: 13722359