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 07:30
An endless cycle of creation and response on the internet is called
Answers: 1
question
Computers and Technology, 22.06.2019 13:00
Which option should u select to ignore all tracked changes in a document
Answers: 1
question
Computers and Technology, 22.06.2019 19:30
When creating a presentation in libre office impress, where does the editing of slides take place? a. the slides panel b. the center panel c. the tasks panel, under the masters pages tab d. the tasks panel, under the layouts tab
Answers: 1
question
Computers and Technology, 23.06.2019 06:20
What is a point-in-time measurement of system performance?
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
Mathematics, 20.01.2021 07:10
question
Mathematics, 20.01.2021 07:10
question
Mathematics, 20.01.2021 07:10
question
Mathematics, 20.01.2021 07:10
Questions on the website: 13722360