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 20:00
How is the number 372 written when expanded out to place values in the base 8 (octal) number system? a. 2 x 4 + 3 x 2 + 4 x 1 b. 3 x 64 + 7 x 8 + 2 x 1 c. 3 x 8 + 7 x 7 + 2 x 6 d. 3 x 100 + 7 x 10 + 2 x 1
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
After you present a proposal, the committee starts asking you questions, some beyond the strict focus of your proposal. they ask questions about implications in other fields and knowledge about other fields. you are asked to redo your proposal. what is most likely missing? breadth of material depth of material clarity of material details of material
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
What is the item which could be matched with a statement below? software installed on a computer that produces pop-up ads using your browser an example of social engineering malware loads itself before the os boot is complete type of spyware that tracks your keystrokes, including passwords windows key + l the practice of tricking people into giving out private information or allowing unsafe programs into the network or computer when someone who is unauthorized follows the employee through a secured entrance to a room or building a type of malware that tricks you into opening it by substituting itself for a legitimate program a computer that has been hacked, and the hacker is using the computer to run repetitive software in the background without the user's knowledge an infestation designed to copy itself repeatedly to memory, on drive space, or on a network
Answers: 1
question
Computers and Technology, 25.06.2019 08:10
What is the relation between information and data?
Answers: 3
You know the right answer?
In this assignment you will implement one or more algorithms for the traveling salesman problem, suc...
Questions
question
Biology, 07.03.2020 00:09
Questions on the website: 13722362