Question: In C: Write a program to implement heuristics for Traveling Salesman Problem using circular linked lists. Given N points in the plane, the goal of

In C:

In C: Write a program to implement heuristics for Traveling Salesman Problem

Write a program to implement heuristics for Traveling Salesman Problem using circular linked lists. Given N points in the plane, the goal of a traveling salesperson is to visit all of them (and arrive back home) while keeping the total distance traveled as short as possible. An example traveling salesman tour is given below. Figure 1: Example Traveling Salesman Tour For large N, there is no efficient method to find the shortest possible tour for any given set of points. However, many efficient methods have been studied that seem to work well in practice, even though they are not guaranteed to produce the best possible tour. Such methods are called heuristics. Implement the following heuristics for this problem Nearest Neighbor Heuristic: Read in the next point and add it to the current tour after the point to which it is closest (shortest distance). You need to find the closest point and insert it after that point. !S Smallest Increase Heuristic: Read in the next point and add it to the tour after the point where it results in the least possible increase in tour length. For two points Pi and Pj with distance d(Pi, Pj), insertion of Pk between Pi and Pj increases the tour length between P i and Pj to d(Pi, Pk) + d(Pk, Pj) To implement these heuristics, you need to store the current tour. Implement a circular linked list and store your current tour as a circular linked list. Initially your list will be empty. You need to insert the points one by one into the appropriate place in the circular linked list based on the heuristic. Given points Pi = (xi, yi) and Pj = (xj, yj) the distance between Pi and Pj is given as d(Pi, Pj) = V (xi - xj) 2 + (yi - yj) 2 Read the input from a file and output the tour to a file. Input format is as follows n x_0 y_0 x_l y_l x_n-l y_n-l First line of the input file is the number of points n and the lines after this entry are the x and y coordinates of the points. Output format is as follows lengtn t0_x t0_y tl_x tl_y tn-l_x tn-l_y length is the total length of the tour and subsequent lines are the coordinates of the points on the tour. Implement your program to work in the following format. It reads the input from the file specified and saves the output of nearest neighbor and smallest increases heuristics to the output files specified. elk05> tsp inputl.txt outputnearestneighbor.txt outputsmallestincrease.txt Write a program to implement heuristics for Traveling Salesman Problem using circular linked lists. Given N points in the plane, the goal of a traveling salesperson is to visit all of them (and arrive back home) while keeping the total distance traveled as short as possible. An example traveling salesman tour is given below. Figure 1: Example Traveling Salesman Tour For large N, there is no efficient method to find the shortest possible tour for any given set of points. However, many efficient methods have been studied that seem to work well in practice, even though they are not guaranteed to produce the best possible tour. Such methods are called heuristics. Implement the following heuristics for this problem Nearest Neighbor Heuristic: Read in the next point and add it to the current tour after the point to which it is closest (shortest distance). You need to find the closest point and insert it after that point. !S Smallest Increase Heuristic: Read in the next point and add it to the tour after the point where it results in the least possible increase in tour length. For two points Pi and Pj with distance d(Pi, Pj), insertion of Pk between Pi and Pj increases the tour length between P i and Pj to d(Pi, Pk) + d(Pk, Pj) To implement these heuristics, you need to store the current tour. Implement a circular linked list and store your current tour as a circular linked list. Initially your list will be empty. You need to insert the points one by one into the appropriate place in the circular linked list based on the heuristic. Given points Pi = (xi, yi) and Pj = (xj, yj) the distance between Pi and Pj is given as d(Pi, Pj) = V (xi - xj) 2 + (yi - yj) 2 Read the input from a file and output the tour to a file. Input format is as follows n x_0 y_0 x_l y_l x_n-l y_n-l First line of the input file is the number of points n and the lines after this entry are the x and y coordinates of the points. Output format is as follows lengtn t0_x t0_y tl_x tl_y tn-l_x tn-l_y length is the total length of the tour and subsequent lines are the coordinates of the points on the tour. Implement your program to work in the following format. It reads the input from the file specified and saves the output of nearest neighbor and smallest increases heuristics to the output files specified. elk05> tsp inputl.txt outputnearestneighbor.txt outputsmallestincrease.txt

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!