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:40
Pthreads programming: create and terminate a thread write a c++ program that creates a thread. the main will display a message “hello world from the main”. the main will create a thread that will display a message “hello world from the thread” and then terminates with a call to pthread_exit()
Answers: 3
question
Computers and Technology, 22.06.2019 23:30
The next button in the review section shows the next available comment. next slide with no comment. previous comment. edited comment.
Answers: 1
question
Computers and Technology, 23.06.2019 02:00
Arecipients list has been loaded into a document. which commands should be clicked in order to filter the list so that letters will not be printed for recipients who live in a certain state? mailings tab, start mail merge, select recipients, type new list, then insert only contacts from the desired states mailings tab, rules, select recipients, use existing list, then choose a recipients list that includes only contacts in certain states mailings tab, select recipients, use existing list, rules, fill in, then type in certain states mailings tab, rules, skip record select “state” under field name, then type in the state name under “equal to”
Answers: 2
question
Computers and Technology, 23.06.2019 10:00
Hey i just logged on and one of the moderators deleted a bunch of my answers to questions, even though the answers were right and the people it doesn't make sense but if anyone wants to talk about anything just message me lol (this is super random lol)
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, 13.07.2019 14:30
question
Mathematics, 13.07.2019 14:30
question
Mathematics, 13.07.2019 14:30
question
Mathematics, 13.07.2019 14:30
Questions on the website: 13722361