What are the best algorithms for solving a TSP with 6 points?

  • MHB
  • Thread starter mathmari
  • Start date
In summary, the conversation discusses finding an approximation for the Travelling Salesman Problem (TSP) using the algorithms of NEAREST NEIGHBOR and NEAREST INSERTION. The NEAREST NEIGHBOR algorithm starts at vertex 1 and visits non-visited vertices with minimum distance. The result is either a tour of 1-6-4-3-2-5-1 with a total distance of 48, or a tour of 1-6-4-5-2-3-1 with a total distance of 49. The NEAREST INSERTION algorithm starts with vertex 1 and inserts vertices with minimal cost between existing vertices in T. The result is either a tour of 1-6-2-
  • #1
mathmari
Gold Member
MHB
5,049
7
Hey! :eek:

We are given the input for TSP with $6$ points with the following distances:
View attachment 5849
I want to find the approximation for a TSP-Tour using the NEAREST NEIGHBOR and the NEAREST INSERTION by starting by the vertex $1$.

Do we have the following graph from the above table?
View attachment 5851
Or do we get a directed graph? (Wondering)

Using the NEAREST NEIGHBOR we start by the vertex $1$ and then we visit at each step a non-visited vertex with the minimum distance, right? (Wondering)
So using this algorithm we get the following Tour:
$$1\rightarrow 6\rightarrow 4\rightarrow 3\rightarrow 2\rightarrow 5\rightarrow 1$$ with total distance $48$

or

$$1\rightarrow 6\rightarrow 4\rightarrow 5\rightarrow 2\rightarrow 3\rightarrow 1$$ with total distance $49$

right? (Wondering) The NEAREST INSERTION is the following:
Code:
T <- {1} 
while |T|<n do 
   j <- vertex with minimal d(T,j), j notin T 
   insert j with minimal cost into T 
return T
where $d(T,j)=\min_{i\in T}d(i,j)$ and the costs, to add $j$ between $i$ and $k$ are $\text{cost}(j)=\min_{(i,k)\in T} d(i,j)+d(j,k)-d(i,k)$

So using this algorithm we get the following:
T = {1}
j = 6 , d(1,6)=2
T = {1,6}
j = 2 , d(1,2)=3
T = {1,6,2}
j = 4 , d(1,4)=d(6,4)=4
T={1,6,2,4}
j = 3 , d(2,3)=d(4,3)=10 or j = 5 , d(4,5)=d(6,5)=10
T = {1,6,2,4,3} T = {1,6,2,4,5}
j = 5 , d(4,5)=d(6,5)=10 j = 3 , d(4,3)=d(2,3)=10
T = {1,6,2,4,3,5} T = {1,6,2,4,5,3}
with total distance $2+3+4+10+10=29$.

Is this correct? (Wondering)
 

Attachments

  • distances.PNG
    distances.PNG
    2.3 KB · Views: 79
  • travelling_salesman_problem.png
    travelling_salesman_problem.png
    7.4 KB · Views: 73
Physics news on Phys.org
  • #2
Hmmm... Looks fine to me.
 
  • #3
phymat said:
Hmmm... Looks fine to me.

Thank you! (Smile)
 

FAQ: What are the best algorithms for solving a TSP with 6 points?

What is the Travelling Salesman Problem?

The Travelling Salesman Problem (TSP) is a classic optimization problem in computer science where the goal is to find the shortest possible route that visits every given city exactly once and returns to the starting city. It is named after the hypothetical scenario of a salesman trying to minimize the distance traveled while visiting multiple cities to make sales.

What makes the Travelling Salesman Problem difficult to solve?

The TSP is considered to be a difficult problem because it falls under the category of NP-hard problems, meaning that there is no known efficient algorithm that can solve it in polynomial time. This means that as the number of cities increases, the time and resources required to find the optimal solution also increases exponentially.

What are the real-world applications of the Travelling Salesman Problem?

The TSP has many real-world applications, such as optimizing delivery routes for shipping companies, planning travel itineraries, and designing computer chips. It can also be used to solve other routing problems, such as the Vehicle Routing Problem and the Job Shop Scheduling Problem.

What are some popular algorithms used to solve the Travelling Salesman Problem?

Some popular algorithms used to solve the TSP include the brute force method, which involves trying every possible route and selecting the shortest one, and the nearest neighbor algorithm, which starts at a random city and repeatedly chooses the nearest unvisited city until all cities have been visited. Other algorithms include genetic algorithms, simulated annealing, and ant colony optimization.

Can the Travelling Salesman Problem be solved exactly?

Yes, the TSP can be solved exactly by using dynamic programming algorithms, which can find the optimal solution for smaller instances of the problem. However, as the number of cities increases, the time and resources required to solve it exactly become too large to be practical. As a result, approximate algorithms are often used to find a good solution within a reasonable amount of time.

Similar threads

Replies
4
Views
2K
Replies
4
Views
865
Replies
1
Views
1K
Replies
1
Views
2K
Replies
2
Views
1K
Replies
20
Views
4K
Back
Top