200 likes | 381 Views
Section 3.4. The Traveling Salesperson Problem. By Aaron Desrochers and Ben Epstein. Tucker Applied Combinatorics. To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4. 4 1. 3 2.
E N D
Section 3.4 The Traveling Salesperson Problem By Aaron Desrochers and Ben Epstein Tucker Applied Combinatorics
To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 4 1 3 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. 7 9 3
The Traveling Salesperson Problemapproaches • 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.
To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 4 1 3 2 The Traveling Salesperson Problemapproach #1 Consider a small traveling salesperson problem with 4 vertices X1, X2, X3, X4. Here is the cost matrix for this problem (fig3.14). Entry Cij is the cost of going from vertex (city) i to vertex j. (Note that we do not require Cij = Cji). 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 C23 we cannot also use C32 for these 2 entries form a subcircuit of length 2. Similarly if entries C23 & C31 are used, then we can’t use C12. C
To 1 2 3 4 From 1 2 3 4 To 1 2 3 4 From 1 2 3 4 3 9 7 0 6 4 3 0 6 5 3 2 5 6 6 0 1 1 9 7 4 5 3 0 The Traveling Salesperson Problemapproach #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. -3 -3 -5 -4
To 1 2 3 4 From 1 2 3 4 0 6 4 0 3 2 0 1 1 5 3 0 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 To 1 2 3 4 From 1 2 3 4 0 3 2 0 1 1 0 6 3 5 3 0 0 3 1 0 1 0 5 3 0 The Traveling Salesperson Problemapproach #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. -1
To 1 2 3 4 From 1 2 3 4 0 6 3 0 3 1 0 1 0 5 3 0 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 To 1 2 3 4 From 1 2 3 4 -3 3 0 0 6 3 0 3 1 0 3 1 0 0 0 0 1 0 5 2 0 5 3 0 Hence the new lower bound is 16+(3+1)= 20 The Traveling Salesperson Problemapproach #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 C12. Either we use it or not. We “branch” on this choice. In the case that we do not use C12, we represent the no-C12 choice by setting C12 = . The smallest value in row 1 of the altered matrix is now C14=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 C12, we obtain this new cost matrix. -1
To 1 2 3 4 From 1 2 3 4 To 1 3 4 From 2 3 4 3 0 0 3 1 2 0 0 0 5 0 0 0 0 5 2 0 The Traveling Salesperson Problemapproach #1 cont. If we use C12 to build a tour, then the rest of the tour cannot use another entry in row 1 or column 2, also entry C12 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. 0 The lower bound for a tour using C12 is now 16+1=17.
All Solutions l.b.=16 Solutions w/ c12 Solutions w/o c12 l.b.=17 l.b.=20 Since our lower bound of 17 is less than the lower bound of 20, when we do not use C12 , we continue our consideration of tours using C12 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 C12 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 C12. 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. 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.
To 1 3 4 From 2 3 4 2 0 0 0 5 0 To 1 3 From 3 4 4 1 3 2 0 0 Sub circuit l.b= 17 We extend a tour using C12 by considering another entry with value zero. This next zero entry need not connect with C12, that is, need not be of the form Cj1 or C2j, But for simplicity we shall pick an entry in row 2. The only zero entry in row 2 of the matrix is C24. Again we have the choice of using C24 or not using C24. Not using C24 will increase the lower bound by 2, (the smallest entry in row after we set C24= ; column 4 still has a 0.) using C24 will not increase the lower bound, and so we further extend the partial tour using C24 and C12. Again we delete row 2 and column 4 and set C14= (to block the subcircuit x1-x2-x4-x1)
1 2 All Solutions l.b.=16 To 1 3 From 3 4 Solutions w/ c12 Solutions w/o c12 3 4 5 l.b.=17 l.b.=20 0 0 Solutions w/ c24 3 5 Solutions w/o C24 l.b=17 Solutions w/ c43 4 Solutions w/o c43 l.b.=19 Solutions w/ c31 l.b.=17 l.b= 17 No solution l.b.=17 Now the way to finish the tour is clear: use entries C43 and C31 for a complete tour x1-x2-x4-x3-x1. We actually have no choice since not using either of C43 or C31 forces us to use an (which represents a forbidden edge) Since C43 = C31 = 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 C12 + C24 + C43 + C31 = 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 2 3 4 From 1 2 3 4 0 6 3 0 3 1 0 1 0 5 3 0 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 C43 will raise the lower bound by 3+3=6 (3 is the new smallest value in row 4 and in column 3). So C43 would theoretically have been a better entry than C12 to use for the first branching, since the greater lower bound for the subtree of tours not using C43 makes it less likely that we would ever have to check possible tours in that sub tree.
Approach 2: Quick Traveling Salesperson Construction • 1- Pick any vertex as a starting circuit C1 consisting of 1 vertex. • 2- Given the k-vertex circuit Ck, k 1, find the vertex Zk not on Ck that is closest to a vertex, call it Yk, on Ck. • 3- Let Ck+1 be the k+1 vertex circuit obtained by inserting Zk immediately in front of Yk in Ck. • 4- Repeat steps 2 and 3 until a Hamilton circuit (containing all vertices) is done.
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= C1 x1 x1 2 2 C3 C2 x4 x4 1 x3 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 C1. Vertex x4 is the closest to x1, and so C2 is x1-x4-x1. Vertex x3 is the vertex not in C2 closest to a Vertex in C2, namely closest to x4; thus C3 = x1-x3-x4-x1.
There are now two vertices, x2 and x6, 3 units from vertices in C3. Suppose we pick x2. It is inserted before x3 to obtain C4 = x1-x2-x3-x4-x1. Vertex x6 is still 3 units from x1, and so we insert x6 before x1, obtaining C5 = 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 C6= 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 x1 2 x4 1 3 x2 x3 x3 x1 2 C6 C5 C4 x6 x4 1 x1 3 x6 4 x5 x1 3 x3 3 5 3 3 x4 1 x4 x2 1 3 x3 x2
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. Theorem: The cost of the tour generated by the quick construction is less than twice the cost of the minimal traveling salesperson tour.
To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 To 1 2 3 4 From 1 0 6 4 2 0 3 2 3 0 1 1 4 5 3 0 To 1 2 3 4 From 1 3 9 7 2 3 6 5 3 5 6 6 4 9 7 4 -3 -3 -5 -4 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. l.b= 3+3+5+4+1= 16 -1
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.