Presentation is loading. Please wait.

Presentation is loading. Please wait.

Traveling Salesman Problem (TSP)

Similar presentations


Presentation on theme: "Traveling Salesman Problem (TSP)"— Presentation transcript:

1 Traveling Salesman Problem (TSP)

2 An Example 12 2 12 2 4 8 4 12 11 8 12 11 10 10 11 3 10 3 10 11 1 3 3 6 1 5 6 6 5 9 6 7 9 12 7 9 12 9 7 7 A truck needs to leave node 1, visit each of the other nodes one and only one time, and back to node 1 What is the best route? Difference from the shortest path problem In shortest path problems, we only care the source and destination, and leave enough freedom to intermediate nodes

3 TSP and Shortest Path 1 2 3 4 5 6 7 8 9 A B C
Finding a route like this (routing arbitrarily) is TSP Finding a route like this (forward only) can be modeled as a shortest path problem

4 The Traveling Salesman Problem
A network G=(N,A) The network may be directed or undirected, which defines two versions of TSP Symmetric or asymmetric TSP If not explicitly mentioned, our discussion applies to both versions Each arc (i,j) has a cost cij Assumption 1: cij ≥0 What can we do if some cij < 0? Assumption 2: There is an arc between any two nodes. If there is no arc (i,j), we simply let the cost cij be a very large number

5 The Traveling Salesman Problem
A tour is defined as a sequence of the nodes in N The cost of a tour is the total cost for the loop that visits all nodes along the sequence of the tour Each node is visited one and only one time The TSP problem is to find a tour with the minimum cost

6 An Example The optimal tour with total cost = 12+12+10+9+7+3+10=63
4 8 4 12 11 8 12 11 10 10 11 3 10 3 10 11 1 3 3 6 1 5 6 6 5 9 6 7 9 12 7 9 12 9 7 7 The optimal tour with total cost = =63 The tour can be represented by (1,2,4,6,7,5,3) or equivalently (2,4,6,7,5,3,1), … Starting node for the tour does not matter because it is a loop

7 Visiting a Node Multiple Times?
12 1 2 3 4 12 10 8 30 1 2 3 4 12 10 8 20 2 4 8 12 30 10 3 1 In practice, sometimes it may be more cost-effective if we allow to visit some nodes multiple times (1,2,4,3,1) with cost=64 v.s. (1,2,4,2,3,1) with cost=54 Any TSP allowing multiple-time visit can be converted into a TSP not allowing multiple-time visit Find the shortest-path cost d[i,j] for all pairs of (i,j) Use d[i,j] to replace cij for all pairs of (i,j)

8 Background Applications Time complexity In transportation
Delivery/pickup for a set of customers In production scheduling To determined the processing sequence for n jobs on a single machine There is a setup cost/delay cij if job j follows job i The goal is to minimize the total setup cost Time complexity There are up to O(n!) different tours The TSP problem is NP-hard

9 Algorithms Optimal Algorithms Heuristic algorithms
Formulating and solving an integer programming Time consuming Heuristic algorithms Nearest neighbor algorithm Cheapest insertion algorithm Others

10 Nearest Neighbor Algorithm
Choose one node as the starting node Repeatedly go to the closest unvisited node until all nodes are visited Return to the starting node Start from node 1 Along (1,5) to node 5 Along (5,2) to node 2 Along (2,4) to node 4 Along (4,3) to node 3 Along (3,1) to return to node 1 Solution found: (1,5,2,4,3) with cost=668 It happens to be the optimal tour. City 1 City 2 City 3 City 4 City 5 132 217 164 58 290 201 79 113 303 196

11 Nearest Neighbor Algorithm
The nearest neighbor algorithm may not find an optimal tour For example, if we choose node 3 as the starting node, the solution found is not optimal. Multi-start Heuristics Choose different nodes as the starting nodes, and solve the problem n times. Use the best solution. Start from node 3 Along (3,4) to node 4 Along (4,1) to node 1 Along (1,5) to node 5 Along (5,2) to node 2 Along (2,3) to return to node 3 Solution found: (3,4,1,5,2) with cost=704 It is not the optimal tour. City 1 City 2 City 3 City 4 City 5 132 217 164 58 290 201 79 113 303 196

12 Nearest Neighbor Algorithm
Choose one node as the starting node Repeatedly go to the closest unvisited node until all nodes are visited Return to the starting node Time complexity It takes n iterations, to determine one node in each iteration In each iteration, it takes O(n) comparison to find the nearest node Overall complexity is O(n2)

13 Nearest Neighbor Algorithm
The nearest neighbor algorithm may find a solution that is very bad Starting from node 1, the nearest neighbor algorithms has to use a large-cost arc (7,4) to go to node 4 For a heuristic solution, define the relative error as (Cost of heuristic solution - Cost of optimal solution) / Cost of optimal solution The relative error of the nearest neighbor tour may be very large 12 2 12 2 4 4 8 12 8 11 12 11 10 10 3 11 10 10 3 11 1 3 3 1 6 5 6 6 5 6 9 7 9 7 12 9 12 9 7 7

14 Cheapest Insertion Algorithm
12 2 7 1 2 3 12 10 8 9 1 2 3 12 10 8 From arc (1,3), only nodes 2 and 7 can be inserted If node 2 is inserted, the cost increase is =10 If node 7 is inserted, the cost increase is =11 So node 2 is to be selected 4 8 12 11 10 10 11 3 3 1 6 5 6 9 7 12 9 7 Start from a loop with two nodes For example, (1,3) and (3,1) Repeat the following steps For each arc (i,j) on the loop, try to replace it with two arcs (i,k) and (k,j) for an unvisited node k We try to insert node k to the loop Find the node k with the smallest cost increase

15 Cheapest Insertion Algorithm
12 1 2 3 7 12 10 8 9 4 11 1 2 3 7 12 8 9 2 4 8 12 11 10 10 11 3 3 1 6 5 6 9 7 12 9 7 From loop (1,2,3), nodes 4 and 7 can be inserted If node 4 is inserted, the cost increase is =15 If node 7 is inserted, the cost increase is =11 So node 7 is to be inserted, which leads to a new loop (1,2,3,7)

16 Cheapest Insertion Algorithm
12 2 1 2 3 7 12 8 9 4 11 5 1 2 3 7 12 8 5 Node 5 is inserted 4 8 12 11 10 10 11 3 3 1 6 5 6 9 7 12 9 7 1 2 3 7 12 8 4 11 5 6 9 1 2 3 7 12 8 5 6 9 Node 6 is inserted. Note that Node 4 can be inserted in two different ways.

17 Cheapest Insertion Algorithm
12 1 2 3 7 12 8 4 11 5 6 9 10 1 2 3 7 12 8 4 5 11 6 9 Final solution (not optimal) 2 4 8 12 10 11 10 10 11 3 3 1 6 5 6 9 7 12 9 7 The cheapest insertion tour has a finite error bound with the triangle inequality assumption, i.e., Cost of cheapest insertion solution ≤ 2 Cost of optimal solution (We omit the proof.)

18 How about start from loop (6,7)
12 2 4 4 8 12 11 10 10 10 11 11 3 3 3 3 1 6 6 5 5 6 6 9 9 7 7 12 9 9 7 7 4 11 10 10 11 3 3 1 6 5 To be continued… 6 9 12 9 7

19 Cheapest Insertion Algorithm
Start from a loop with two nodes Repeat the following steps For each arc (i,j) on the loop, try to replace it with two arcs (i,k) and (k,j) for an unvisited node k We try to insert node k to the loop Find the node k with the smallest cost increase Time complexity There are O(n) iterations, one node is selected in each iteration Inside each iteration, there are O(n2) possible different insertion Overall time complexity O(n3) Question: can you improve it?

20 Group Project Each group (3-5 students) will be assigned an article to read. These articles are about how vehicle routing techniques have helped in various industrial applications. Please read carefully and prepare to introduce the article to the class. A sample article has been uploaded at canvas, for your references. Deliverables Presentation: Each group is expected to report the content of the article, including, for example, the background of the application, what is the problem, what formulation and techniques have been used, any challenges, what is the impact, what can we learn, any other related stories/follow-ups beyond the article. Evaluation: Each group is required to evaluate the presentation of other groups. Details will be announced later. Actions to take Sign up project groups at canvas by Oct 15. Please send to TA, Mr. Yifu LI for you cannot find a group to join.


Download ppt "Traveling Salesman Problem (TSP)"

Similar presentations


Ads by Google