Why is traveling salesman np




















The differences between decision, search, and optimization, are precisely what the exercises 8. Those exercises are probably meant to get you interested in the relationship between these different types of problems, and how they relate to one another.

The Bottleneck traveling salesman problem bottleneck TSP is a problem in discrete or combinatorial optimization. The problem is to find the Hamiltonian cycle in a weighted graph which minimizes the weight of the most weighty edge of the cycle. The problem is known to be NP-hard. The decision problem version of this, "for a given length x is there a Hamiltonian cycle in a graph G with no edge longer than x? NP-completeness follows immediately by a reduction from the problem of finding a Hamiltonian cycle.

This problem can be solved by performing a binary search or sequential search for the smallest x such that the subgraph of edges of weight at most x has a Hamiltonian cycle. This method leads to solutions whose running time is only a logarithmic factor larger than the time to find a Hamiltonian cycle.

Let me explain a bit:. The TSP is a problem defined by a set of cities and the distances between each city pair. The problem is to find a circuit that goes through each city once and that ends where it starts.

This in itself isn't difficult. What makes the problem interesting is to find the shortest circuit among all those that are possible. Solving this problem is quite simple. One merely need to compute the length of all possible circuits, then keep the shortest one. Issue is that the number of such circuits grows very quickly with the number of cities.

A problem is NP if one can easily in polynomial time check that a proposed solution is indeed a solution. In order to check that a proposed tour is a solution of the TSP we need to check two things, namely. We didn't check the second condition! The second condition is what makes the problem difficult to solve.

As of today, no one has found a way to check condition 2 in polynomial time. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams? As an interview question, for many years I'd ask candidates to write a brute-force solution for the traveling salesman problem TSP. This isn't nearly as hard as it sounds: you just need to try every possible path, which can be done using a basic depth first search.

A lot of the time candidates who would get stuck would mention something about how the problem is NP-complete usually to indicate that they thought the problem was impossible. The complexity class of TSP is in not something I asked as part of the interview, and not something I would use to judge a candidate.

This surprises a lot of people, but it's true. The term "NP-complete" has a very specific technical meaning, so it's not surprising that people misuse the term. Therefore before continuing, I'm going to define various complexity classes.

NP is the set of all problems whose solutions can be verified in polynomial time. NP-hard problems are informally defined as those that can't be solved in polynomial time. In other words, the problems that are harder than P.

With 15 destinations, the number of possible routes could exceed 87 billion. The Brute Force approach, also known as the Naive Approach, calculates and compares all possible permutations of routes or paths to determine the shortest unique solution. To solve the TSP using the Brute-Force approach, you must calculate the total number of routes and then draw and list all the possible routes.

Calculate the distance of each route and then choose the shortest one—this is the optimal solution. This method breaks a problem to be solved into several sub-problems.

Select the cheapest arch between the unvisited and current node and then add the distance to the current distance. Repeat the process while the current distance is less then the bound. You may now add up the distance so that the bound will be equal to the current distance. Repeat this process until all the arcs have been covered. This is perhaps the simplest TSP heuristic. The key to this method is to always visit the nearest destination and then go back to the first city when all other cities are visited.

To solve the TSP using this method, choose a random city and then look for the closest unvisited city and go there. Applegate, D. Mathematical Programming B 97 , 91— Google Scholar. Arora, S. Berman, P. Boyd, S. Burkard, R. Carr, R. Chalasani, P. Chandra, B.

Christofides, N. Crowder, H. Dantzig, G. Englert, M. Frank, A. Report No. Frieze, A. Garey, M. Held, M.



0コメント

  • 1000 / 1000