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: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 02:10
3. (5 points) describe what would be printed by the code below or what error would occur. const char* cstr = "0123456"; const char* ptr = & cstr[4]; cout < < ptr[-1] < < ptr < < endl; 1 4. (5 points) theseus has been trapped in a maze with a minotaur, which is trying to capture him. each round, theseus and the minotaur move through the maze; theseus towards the exit, and the minotaur towards theseus. theseus can move in any of the four cardinal directions, or he can wait for a round to see how the minotaur moves. write code that creates a data type to represent the possible moves that theseus could make.
Answers: 3
question
Computers and Technology, 22.06.2019 11:00
Ihave an iphone 8plus should i get another phone like samsung note 9 or s9 ? ?
Answers: 2
question
Computers and Technology, 22.06.2019 19:20
Amedian in the road will be marked with a white sign that has a black arrow going to the left of the median. true false
Answers: 1
question
Computers and Technology, 24.06.2019 04:30
Fall protection, confined space entry procedures, controlled noise levels, and protection from chemical hazards are some of the things that contribute to a safe and
Answers: 1
You know the right answer?
In this assignment you will implement one or more algorithms for the traveling salesman problem, suc...
Questions
question
Mathematics, 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
question
French, 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
question
Advanced Placement (AP), 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
question
Mathematics, 16.04.2021 14:00
Questions on the website: 13722361