Question: Travelling Salesman Problem ( TSP ) : Given a set of cities and distance between every pair of cities, the problem is to find the
Travelling Salesman Problem TSP: Given a set of cities and distance between every pair of cities, the problem is to find the shortest possible route that visits every city exactly once and returns to the starting point.
For example, consider the graph shown below. A TSP tour in the graph is The cost of the tour is which is
The data is provided in file showing distance between all the nodes. The number of nodes can vary but make sure to attach the testFile while submitting your code.
testFile.txt
Take a number N from user and create N different threads. Each thread will find a solution of TSP by randomly generating numbers Make sure the sequence of random numbers generated by different thread is not the same Now each thread will save their output cost of the tour in a global array after displaying it on terminal alongwith their thread id When all threads will be done computing the value, they will check whether their value was the minimum cost or not. The threads whose solution was not shortest will be stuck in an infinite loop. The one with shortest solution will output the thread id and cancel all the remaining threads.
If two threads have the same value, then define a mechanism as tiebreaker and explain it in comment on the top of your code file.
provide the code for above in c language
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
