Download presentation
Presentation is loading. Please wait.
Published byChana Herst Modified over 9 years ago
1
Section 3.4 The Traveling Salesperson Problem Tucker Applied Combinatorics By Aaron Desrochers and Ben Epstein
2
The Traveling Salesperson Problem In this section we illustrate the use of trees in optimization problems of operations research. The traveling salesperson problems seeks to minimize the cost of the route for a salesperson to visit a set of cities and return home. One seeks a minimal-cost Hamilton circuit in a complete graph having associated cost matrix C. Entry Cij in C is the cost of using the edge from the ith vertex to the jth vertex. To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 4 1 3232 7 9 3
3
The Traveling Salesperson Problem approaches There are 2 approaches to this problem, both use trees, but in very different ways. The first approach is to systematically consider all the possible ways to build Hamilton circuits in search of the cheapest one, using a “branch and bound” method to limit the number of different vertices in the search tree that must be inspected in search of a minimal solution. Each vertex in the tree will represent a partial Hamilton circuit, and each leaf a complete Hamilton circuit. Note that a complete graph on n vertices has (n-1)! different Hamilton circuits, for example, a 50-city (vertex) problem has 49! 6 x 10^(62) possible circuits…..so this first approach would be rather time consuming for large problems, even though some circuits can be eliminated with the “branch and bound” method. Large traveling salesperson problems lead to a faster, more efficient approach, which is to construct a near-minimal solution using an algorithm that is quite fast. We will deal with the first approach to lay the foundation for the quicker algorithm.
4
The Traveling Salesperson Problem approach #1 Consider a small traveling salesperson problem with 4 vertices X 1, X 2, X 3, X 4. Here is the cost matrix for this problem (fig3.14). Entry C ij is the cost of going from vertex (city) i to vertex j. (Note that we do not require C ij = C ji). The infinite costs on the main diagonal indicate that we cannot use these entries. A Hamilton circuit will use 4 entries in the cost matrix C, one in each row and in each column, such that no proper subset of the entries (edges) forms a subcircuit. This means if we choose entry C 23 we cannot also use C 32 for these 2 entries form a subcircuit of length 2. Similarly if entries C 23 & C 31 are used, then we can’t use C 12. C To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 4 1 3232
5
The Traveling Salesperson Problem approach #1 cont. We first show how to obtain a lower bound for the cost of this traveling salesperson problem. Since every solution must contain an entry in the first row, the edges of a minimal tour will not change if we subtract a constant value from the first row of the cost matrix. (Of course, the cost of a minimal tour will change by this constant.) We subtract the value of the smallest entry in row 1, in this case 3. Do this for the other 3 rows and we now have an altered cost matrix. To 1 2 3 4 From 1 2 3 4 3 9 7 6 53 5 6 6 9 7 4 To 1 2 3 4 From 1 2 3 4 0 6 4 3 20 0 1 1 5 3 0 -3 -5 -4
6
All rows have a 0 entry. After subtracting a total of 3+3+5+4=15 from the different rows, a minimal tour using this new cost data will cost 15 less than a minimal tour using original cost C. Still the edges of a minimal tour for the altered problem are the same edges that form a minimal a tour for the original problem. To 1 2 3 4 From 1 2 3 4 0 6 4 3 20 0 1 1 5 3 0
7
The Traveling Salesperson Problem approach #1 cont. In a similar fashion, we can subtract a constant from any column without changing the set of edges on a minimal tour. Since we will want to avoid making any entries negative, we consider subtracting a constant only from columns with all current entries positive. The only such column in the altered matrix is column 4, whose smallest value is 1. So we subtract 1 from the last column to get a new matrix. To 1 2 3 4 From 1 2 3 4 0 6 4 3 20 0 1 1 5 3 0 To 1 2 3 4 From 1 2 3 4 0 6 3 3 10 0 1 0 5 3 0
8
The cost of a minimal tour using this new matrix has been reduced by a total of 15+1=16 from the original cost matrix C. We can use this reduction of cost to obtain a lower bound on the cost of a minimal tour: A minimal tour using the costs in our new matrix must trivially cost at least zero, and hence a minimal tour using the original matrix C must cost at least 16. In general, the lower bound for the traveling salesman problems equals the sum of the constants subtracted from the rows and columns of the original cost matrix to obtain a new cost matrix with a 0 entry in each row and column. To 1 2 3 4 From 1 2 3 4 0 6 3 3 10 0 1 0 5 3 0
9
The Traveling Salesperson Problem approach #1 cont. Now its time for the branching part of the “branch and bound” method. we look at an entry in our new matrix that is equal to 0. Say C 12. Either we use it or not. We “branch” on this choice. In the case that we do not use C 12, we represent the no-C 12 choice by setting C 12 =. The smallest value in row 1 of the altered matrix is now C 14 =3, and we can now subtract this amount from row 1. Similarly we can subtract 1 from column 2. So, if we do not use C 12, we obtain this new cost matrix. To 1 2 3 4 From 1 2 3 4 0 6 3 3 10 0 1 0 5 3 0 Hence the new lower bound is 16+(3+1)= 20 To 1 2 3 4 From 1 2 3 4 3 0 3 10 0 0 0 5 2 0 -3
10
The Traveling Salesperson Problem approach #1 cont. If we use C 12 to build a tour, then the rest of the tour cannot use another entry in row 1 or column 2, also entry C 12 must be set equal to (to avoid a subcircuit of length 2). The new smallest value of the reduced matrix in row 2 is 1, and so we subtract 1 from row 2 to obtain a new cost matrix. The lower bound for a tour using C 12 is now 16+1=17. To 1 2 3 4 From 1 2 3 4 3 0 3 10 0 0 0 5 2 0 To 1 3 4 From 2 3 4 2 0 0 5 0 0
11
Since our lower bound of 17 is less than the lower bound of 20, when we do not use C 12, we continue our consideration of tours using C 12 by determining bounds associated with whether or not to use a second entry with value 0. We will continue to use these partial tours using C 12 as long as the lower bound is less than or equal to 20. If the lower bound were to exceed 20, then we would have to go back and consider partial tours not using C 12. Our tree of choices for this problem will be a binary tree whose interval vertices represent choices of the form: use entry Cij or do not use Cij. All Solutions l.b.=16 Solutions w/ c12 Solutions w/o c12 l.b.=17l.b.=20 At any stage, as long as the lower bounds for partial tours using Cij are less than the lower bound for tours not using Cij, we do not need to look at the sub tree of possible tours using Cij.
12
We extend a tour using C 12 by considering another entry with value zero. This next zero entry need not connect with C 12, that is, need not be of the form C j1 or C 2j, But for simplicity we shall pick an entry in row 2. The only zero entry in row 2 of the matrix is C 24. Again we have the choice of using C 24 or not using C 24. Not using C 24 will increase the lower bound by 2, (the smallest entry in row after we set C 24 = ; column 4 still has a 0.) using C 24 will not increase the lower bound, and so we further extend the partial tour using C 24 and C 12. Again we delete row 2 and column 4 and set C 14 = (to block the subcircuit x1-x2-x4-x1) To 1 3 4 From 2 3 4 2 0 0 5 0 4 1 3232 Sub circuit To 1 3 From 3 4 0 l.b= 17
13
Now the way to finish the tour is clear: use entries C 43 and C 31 for a complete tour x1-x2-x4-x3-x1. We actually have no choice since not using either of C 43 or C 31 forces us to use an (which represents a forbidden edge) Since C 43 = C 31 = 0, this tour has cost equal to the lower Further, this tour must be minimal since its cost equals our lower bound. Rechecking the tour’s cost with the original cost matrix C, we have C 12 + C 24 + C 43 + C 31 = 3 + 5 + 4 + 5 = 17. We summarize the preceding reasoning with the decision tree, summarizing the choices we have made and their lower bounds. To 1 3 From 3 4 0 l.b= 17 All Solutions l.b.=16 Solutions w/ c12 Solutions w/o c12 Solutions w/o C24 Solutions w/ c24 Solutions w/o c43 Solutions w/ c43 Solutions w/ c31 l.b.=17 l.b=17 l.b.=17l.b.=20 l.b.=19 No solution l.b.=17 1 2 3 4 3 5 4 5
14
One last general point should be made about how to take advantage of the “Branch and bound” technique. At each stage, we should pick as the next entry on which to branch (use or not use) the 0 entry whose removal maximizes the increase in the lower bound. In the matrix below a check of all 0 entries reveals that not using entry C 43 will raise the lower bound by 3+3=6 (3 is the new smallest value in row 4 and in column 3). So C 43 would theoretically have been a better entry than C 12 to use for the first branching, since the greater lower bound for the subtree of tours not using C 43 makes it less likely that we would ever have to check possible tours in that sub tree. To 1 2 3 4 From 1 2 3 4 0 6 3 3 10 0 1 0 5 3 0
15
Approach 2 : Quick Traveling Salesperson Construction 1- Pick any vertex as a starting circuit C 1 consisting of 1 vertex. 2- Given the k-vertex circuit C k, k 1, find the vertex Z k not on C k that is closest to a vertex, call it Y k, on C k. 3- Let C k+1 be the k+1 vertex circuit obtained by inserting Z k immediately in front of Y k in C k. 4- Repeat steps 2 and 3 until a Hamilton circuit (containing all vertices) is done.
16
Worked example We’ll apply the preceding algorithm to a 6 vertex traveling salesman problem whose cost matrix is to the left. Name the vertices x1,x2,x3,x4,x5,x6. We will start with x1 as C 1. Vertex x4 is the closest to x1, and so C 2 is x1-x4-x1. Vertex x3 is the vertex not in C 2 closest to a Vertex in C 2, namely closest to x4; thus C 3 = x1-x3-x4-x1. To 1 2 3 4 5 6 From 1 3 3 2 7 3 2 3 3 4 5 5 3 3 3 1 4 4 4 2 4 1 5 5 5 7 5 4 5 4 6 3 5 4 5 4 x1= C 1 C3C3 C2C2 x1 x4 2 x1 x4 x3 2 1
17
There are now two vertices, x2 and x6, 3 units from vertices in C 3. Suppose we pick x2. It is inserted before x3 to obtain C 4 = x1-x2-x3-x4-x1. Vertex x6 is still 3 units from x1, and so we insert x6 before x1, obtaining C 5 = x1-x2-x3-x4-x6-x1. Finally, x5 is within 4 units of x3 and x6. Inserting x5 before x6, we obtain our near minimal tour C 6 = x1-x2-x3-x4-x5-x6-x1, whose cost we compute to be 19. To 1 2 3 4 5 6 From 1 3 3 2 7 3 2 3 3 4 5 5 3 3 3 1 4 4 4 2 4 1 5 5 5 7 5 4 5 4 6 3 5 4 5 4 C4C4 C5C5 C6C6 x1 x4 x3 2 1 x1 x4 x3 x2 2 1 3 x1 x4 x3 x2 x6 x5 3 4 3 3 5 1 x1 x4 x3 x6 3 1 3 3
18
In this case, the length of the tour obtained with the Quick Tour Construction algorithm is quite close to the minimum ( which happens to be 18). The length of the tour generally depends on the starting vertex. If we suspected that our approximate tour was not that close to an optimal length, then by trying other vertices as the starting vertices as the starting vertex (that comprises C1) and applying the algorithm, we will get other near minimum tours. Taking the shortest of this set of tours generated by the Quick Tour Construction would give us an improved estimate for the true minimum tour. The cost of the tour generated by the quick construction is less than twice the cost of the minimal traveling salesperson tour. Theorem:
19
For the class to try Use approach # 1 to get a zero in all rows and columns, and obtain a lower bound for the augmented matrix. To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 -3 -5 -4 To 1 2 3 4 From 1 0 6 4 2 0 3 2 3 0 1 1 4 5 3 0 l.b= 3+3+5+4+1= 16 To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4
20
To 1 2 3 4 From 1 0 6 3 2 0 3 1 3 0 1 0 4 5 3 0 Perform the branch and bound method, find the minimal cost circuit. See approach 1 and the steps taken in the branch and bound portion.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.