530 likes | 543 Views
This paper presents a polynomial time approximation scheme for the Euclidian Traveling Salesman Problem (TSP) using dynamic programming and dissection of the bounding box.
E N D
Polynomial Time Approximation Scheme (PTAS) for Euclidian Traveling Salesman Problem (TSP) Presented By: Dahan Yakir Sepetnitsky Vitali
IntroductionThe Traveling Salesman (TSP) problem • Given n points • For each pair {i, j} of distinct points, a cost ci,j • A shortest path is desired • Shortest path = a closed path that • Visits each point exactly once, denote a path like that, as salesman tour • The sum of all distances along the path is minimal (the path have a minimal cost) • This problem is NP-hard
IntroductionEuclidian TSP + PTAS • In Euclidian TSP the points are in (i.e. in 2D the input is a set of n points in the plane) and the costs are Euclidian distances: • The distances satisfy triangle inequality • Even 2D Euclidian TSP is NP-hard • PTAS or Polynomial Time-approximation Schemeis a polynomial-time algorithm which finds an (1 + ε)-approximation to the optimal solution for ε > 0 • The run-time is polynomial by n
IntroductionThe algorithm we will present • We will show that Euclidian TSP has a PTAS • The algorithm was given by SanjeevAroraat 1996 and improved several times through 1996-1998 • A randomized algorithm will be presented • The PTAS, we will describe, is for points on the plane (d = 2)but there is an extension to an arbitrary d • The algorithm computes an (1 + ε)-approximation to the optimal solution in no(1∕ε)time • The algorithm is based on dynamic programming • The algorithm can be de-randomized, but then the run-time should be increased by a factor of n4
Step 1Bounding Boxof a TSP instance • The smallest axis parallel square containing the instance • Let L be the side length of the square and assume w.l.o.g. that L is power of 2, i.e. L = 2k • We will call Lthe size of the box • We can scale all distances such that L = 4n2and thus: k = 2+2∙log2n = O(log n)
Step 2Perturbation of a TSP instance • First, we perform a simple “perturbation” of the given TSP instance, I, and create a new instance I’ • Define a unit grid on the bounding box and relocate each point to the nearest grid point • The maximum distance from a point to a nearest grid point is at most √2/2 L
Step 2Error analysis of the Perturbation • Approximate the error we get by the described perturbation • At least two points are on opposite edges of the square, therefore each solution cost is ≥ 2L • For a given solution cost SOL, the perturbation of the instance increases the solution length by √2 for each point L
Step 2Error analysis of the Perturbation (Cont.) • The perturbation of the instance increases the solution length by n√2 for all the points • Therefore if we denote the cost of the solution after a perturbation was made on it, as SOL’ , we have: • (SOL’ – SOL)∕SOL ≤ n√2∕2L = n√2∕8n2 = • = 1∕4√2n L
Step 2Error analysis of the Perturbation (Cont.) • Assume we are given an (1 + ε)-approximation of OPT to the perturbed instance I’ of the TSP problem • The corresponding solution to the instance I (the points are shifted to the original place) is an (1 + ε + 1∕4√2n)-approximation of OPT • For sufficiently large n, we can adjust ε to reach the desired error L
Step 3Dissectionof the Bounding Box L • A recursive partitioning into four smaller squares • An L × L square is divided into four L∕2×L∕2squares and so on • We view the partitioning as a 4-ary tree T , whose root is the bounding box, the four L∕2×L∕2squares are its children and so on L∕2
Step 3Dissectionof the Bounding Box (Cont.) • A useful square is a square represented by a node in T • The dissection is continued until we obtain squares with size ≤ 1 (therefore each one has at most one point in its interior) • The tree depth is O(log L)
Step 3Dissectionof the Bounding Box (Cont.) Level 0 square • Assign levels to the nodes of T • The root is at level 0, its children at level 1 and so on • The squares represented by nodes of T get levels accordingly • Squares at level i have dimensions L∕2i×L∕2i Level 1 square
Step 3Dissectionof the Bounding Box (Cont.) • The basic dissection of the bounding box can be seen as a 4-ary tree with depth O(k) = O(log L) • At each level ithere are 4i squares (i = 0 to k) • The number of the nodes in the tree is therefore: 1 + 4 + 42 + … + 4k = (4k + 1 - 1) / (4 - 1) = = O(4k) = O(42 + 2 log n) = O(n4) The bounding box Level 1 squares … Level 2 squares … …
Step 3Dissectionof the Bounding Box (Cont.) • Now we assign levels for the lines from which the dissection is constructed • Level ilinescreate the level i squares • Line at level i forms an edge for useful squares at levels i, i + 1, … Level 1 square Level 2 square Level 3 square
Step 4Portals • A special set of points defined for each line • The solution is allowed to cross a grid line only at a portal • The portals are equidistant points - L∕(2im) apart at level iline • Each useful square has at most 4m portals on its sides and corners portal L∕(2im)
Step 4Portals (Cont.) • m is a power of 2 and belongs to [k∕ε , 2 ∙ k∕ε] • Therefore m =O(log n∕ε) • A portal in a level isquare is a portal of a contained level i + 1 square as well portal L∕(2im)
Definitions Well behaved tours • A tour τ is well behaved with respect to the basic dissection (WB)if it is a tour through all the n points and any subset of the portals • The tour is allowed to visit portals multiple times • The tour must be non-self-intersecting • A tour τis well behaved with respect to the basic dissection with limited crossings(WBLC) if it is a well behaved tour (as defined above) and, in addition, it visits each portal at most twice
Lemma Well behaved tours (Cont.) Any well behaved tour τ can be transformed to a WBLC tour, whose length is at most the length of τ Points of the proof: • Given a well behaved tour τ, we will transform it to a WBLC tour τ’ • For each portal in τ, located on line l, which is used more than twice, we will perform a “short-cutting” on the two sides of τ • Then, self intersections (if created) will also be removed from τ’ by short-cutting
Lemma – ProofStage 1: Making each portal’s crossings # to be ≤ 2 • Let τ be a well defined tour which crosses a portal p, located on line l, α times (α > 2) • There are two cases: • αis odd • α is even • A “short-cutting” will be performed for each case and make τ cross p at most twice, without increasing its length • The correctness will be guaranteed by triangle inequality
Lemma – Proof (Cont.)Stage 1, Case 1: Crossings # is odd In this case we transform the tour to cross lonly once: c' c' a l a l b b a' a' p p c c b' b'
Lemma – Proof (Cont.)Stage 1, Case 2: Crossings # is even In this case we transform the tour to cross lonly twice: c' c' a a d d p p b a' a' b l l b' b' c c d' d'
Lemma – Proof (Cont.)Stage 2: Eliminating intersections • If the previous stage introduced self-intersections, they can be removed by the following way: c' c' a a a’ a’ c c
ConclusionThe remaining parts of the algorithm • After lemma 1 was proved we know that each WB tour τ can be transformed to a WBLC tour τ’, such that |τ’|≤ |τ| • We can show that there is a WB tour τ that is short enough, i.e. |τ| ≤ (1 + ε) ∙ OPT • From lemma 1 we know that there exists a WBLC tour τ’that is short enough too |τ’| ≤ (1 + ε) ∙ OPT • We will obtain all the WBLC tours and take the shortest one τ’’(the one with minimal sum of distances), therefore |τ’’| ≤ |τ’| |τ’’| ≤ (1 + ε) ∙ OPT
Definitionvalid visit For each useful square S, we define a valid visit as an assignment of crosses for each portal on S, such that the sum of all portal crosses is even. In addition S’s portals are divided to pairs, that are connected by some valid WBLC tour b' 1 1 1 c 0 b 2 1 c‘, d a' 0 2 a, e’ 0 0 0 2 d‘, e
Stage 5Computing the optimal WBLC The following steps: • We will build a table, that for each square in the dissection, contains the cost of each valid visit. The table will be built up the 4-ary dissection tree • The calculation uses dynamic programming
Stage 5Computing the optimal WBLC (Cont.) • We look only on WBLC tours which means that each portal can be used (= crossed) 0, 1 or 2 times • Denote some WBLC tour by τ • The total number of times, τcan enter or exit a useful square S is at most 8m • The part of τinside S, can be viewed as at most 4m paths, covering all the points inside S • First, we calculate the total number of possibilities to define the number of crossings for each portal on S sides
Stage 5Computing the optimal WBLC (Cont.) • The total number of possible assignments is 34m= 24m∙log23 • m in the range [O(log n)∕ε , 2 ∙ O(logn)∕ε] • Therefore 24 ∙O(logn)∕ε ∙ (log3)≤ 34m ≤ 28 ∙O(log n)∕ε∙ (log3) • Thus we have n(4log3) ∕ε≤ 34m ≤ n(8log 3)∕ε 34m = nO(1∕ε) • Among all the possibilities of portals crossings, we retain only those that involve an even sum of crossings (allowing to enter and exit S) • Once we defined the number of crossings for each portal on S sides, not every possible pairing is allowed because of the restriction of the self-intersection
Stage 5Computing the optimal WBLC (Cont.) A useful square S • Count the number of valid pairings, for a given assignment of portal crossings • Let’s assume that the sum of portal usages is 2r (should be even) • We will prove that the number of valid pairings is the rth Catalan number • Let’s look on a valid pairing:
Stage 5Computing the optimal WBLC (Cont.) Now, if we view the sides of S as a straight line, we can see that a valid pairing can be transformed to a sequence of balanced parentheses (a bijection can be created): A valid pairing An invalid pairing
Stage 5Computing the optimal WBLC (Cont.) • The number of balanced arrangements of 2r parentheses is the rth Catalan number, Cr=(1/r+1)∙ () • It is known for Catalan numbers that Cr < 4r = 22r • Since each visit on the portals of S crosses the portals at most 8m times, we get that the number of valid pairings for a given assignment of portal usages is bounded by: 28m= 28 ∙ O(k/ε) = 28 ∙ (O(log n)/ε) = nO(1∕ε) • Thus we get: • nO(1∕ε) possibilities for portal usages • nO(1∕ε) valid pairings for each portal usage Total number of valid visits in S is nO(1∕ε) ∙ nO(1∕ε) = nO(1∕ε) 2r r
Dynamic programmingComputing the optimal WBLC: definition of the table • Let’s build the following table in order to compute optimal WBLC cost (for each useful square): • # of columns = # of squares in the 4-ary tree = O(n4) • # of rows = # of valid visits for a square = nO(1∕ε) • Total # of entries in the table =n4∙ nO(1∕ε) = nO(4 + 1∕ε)
DefinitionComputing the optimal WBLC:consistency We say that a valid visit of square S1 at level iis consistent with a valid visit of its parent square S, if all common portals get the same portal usages and internal pairings
Dynamic programming (Cont.)Computing the optimal WBLC: the algorithm The table is filled up the dissection tree T: ] 1. The level k is computed by calculating the minimal cost for each valid visit in the squares at this level 2. For each level i, i = k – 1downto0 2.1. For each square S at level i 2.1.1. For each valid visit V in S 2.1.1.1. For each possibility of portal usages on the two lines which divide S (to 4 squares) 2.1.1.1.1. For each valid pairing of all the portals consistent with the visit V portals usage
Dynamic programming (Cont.)Computing the optimal WBLC:the algorithm (Cont.) • If the pairing is consistent, it gives rise to valid visits in the four squares internal to S(whose minimal WBLC costs were calculated) 2.1.1.1.1.1. Sum the optimal lengths of the appropriate visits in the children squares 2.1.1.1.2 Compute the minimum cost among the costs for this internal portal usage 2.1.1.2. Compute the minimum cost among the costs for all internal portal usages and store the returned cost in an appropriate entry 3. Finally, take the minimum cost of the level 0 column
Dynamic programming (Cont.)Computing the optimal WBLC: runtime • We have seen before that the table has nO(1∕ε) entries • In order to calculate each entry, which represents a valid visit V on a square S we need to consider at most all the possibilities for internal portal usages • The number of internal portals of S is at most 4m + 1 • Therefore the number of possibilities for internal portal usages is at most 34m + 1 = nO(1∕ε) (since we have seen that 34m=nO(1∕ε)) • The total number of the internal portals along with the external portals is 8m – 3 at most and therefore the total number of pairings is also bounded by nO(1∕ε)
Dynamic programming (Cont.)Computing the optimal WBLC: runtime (Cont.) • Therefore, in total we should consider nO(1∕ε) ∙ nO(1∕ε) = nO(1∕ε) valid pairings for each square. That is because we have nO(1∕ε) valid pairings for the internal portals, for a single usage assignment of them, and nO(1∕ε) usage assignments. • Finally, the total cost for a single entry calculation is nO(1∕ε) • The total runtime of the algorithm is: #entries ∙ nO(1∕ε) = nO(1∕ε) Correctness: Wecompute all the available WBLCs costs, since each WBLC tour of a square S at level i can be divided to 4 squaresat level i + 1, whose minimal WBLCs costs were calculated for each valid visit
WB tour vs. Optimal tourHow an optimal WB tour differs from OPT • First, consider an optimal WB tour and let’s calculate how much it can differ from OPT’s cost • Convert OPT to WB and see how much its length increases by this conversion An edge of the changed tour L/2im Portal Portal An edge of the optimal tour
WB tour vs. Optimal tourHow an optimal WB tour differs from OPT (Cont.) • We can easily see that for each crossing of a dissection line, |OPT| increases by at most L/2im • We can notice that the increase depends on the line’s level. i.e. the lower the level, the greater the increase An edge of the changed tour L/2im Portal Portal An edge of the optimal tour
Is it sufficient?How an optimal WB tour differs from OPT • Is it enough? Is an optimal WB tour always an (1 + ε)-approximation for the optimal TSP solution • The answer is NO!!! • We will show an instance of the Euclidian TSP problem, for which the process of transforming an optimal tour to be WB, increases its length by a fixed constant • Therefore the algorithm will fail if ε is chosen to be below this bound
CounterexampleHow an optimal WB tour differs from OPT (Cont.) • Let’s denote L/2im as x • An Euclidian TCP instance is shown on the right, along with the optimal TCP solution • We can easily obtain: 4x 8x L 8x 8x 4x 2x y x
Counterexample (Cont.)How an optimal WB tour differs from OPT (Cont.) • Now let’s modify the tour to be WB and call the new tour SOL • Again, we can easily obtain: 4x 8x L 8x 8x 4x 2x y x
Counterexample (Cont.)How an optimal WB tour differs from OPT (Cont.) • Since y ≤ L∕2 we obtain |SOL| ∕|OPT| ≥ 1.0015 • Hence, the described algorithm fails for a selection of an error parameter ε < 0.0015 • To bypass this problem we will randomize the algorithm and generalize the concept of the dissection 4x 8x L 8x 8x 4x 2x y x
Definition(a,b)-Shifted Dissectionof the Bounding Box • Let’s define L2 different dissections of the bounding box which are shifts of the basic dissection • Choose randomly two integers a and b such that 0 ≤ a, b < L • Shift each vertical line from its original location x to (x + a) mod L • Shift each horizontal line from its original location y to (y + b) mod L • We call the result (a,b)-shifted dissection
Randomization(a,b)-Shifted Dissectionof the Bounding Box (Cont). Here we a shifting of the level-1 lines is illustrated b a
Randomization (Cont.)(a,b)-Shifted Dissectionanalysis • By performing the shifting, any specific line has a random level. For instance, the level of the middle vertical line in the counter-example is not necessarily 1, but depends on a: it is the level of the [(L∕2 + a) mod L]-line in the original dissection • There are 21 lines at the first level, 22 lines at the second, …, 2k lines at level k(2i linesat random level i) • Thus, we have 2k+1 - 2 total # of lines in a dissection • The probability to randomly choose line with level i is:
Randomization (Cont.)Distance between portals on a random line • We showed that when a line at level iis crossed by the path τ, the maximal increase in the process of making τ a WB tour is x(i) = L / 2im • Now, we can define X as a random variable which describes the possibilities of length increases by a single grid-line cross • Thus, the expected value of the increase for a randomly chosen line is:
Randomization (Cont.)Number of crossings for a random dissection • Now let’s bound the number of crossings of dissection lines • Let τ be an optimal tour and let N(τ) be the total number of dissection lines crossings of τ(intersection is counted twice). Denote: |τ| = OPT. • We claim that: N(τ) ≤ √2 ∙ OPT (will be proved later) • Therefore, if we denote by Y the total increase in the path cost, we have EY = N(τ) ∙ EX ≤ √2 ∙ OPT∙ ε • Markov’s inequality says that:
Randomization (Cont.)Finalizing the algorithm • Thus, we have: • This leads us to the following corollary: Pick a and b uniformly at random from [0, L). Then, the probability that there is a WB tour of length (1+2√2ε)-approximation is greater or equal to 0.5
Randomization (Cont.)Finalizing the algorithm (Cont.) Three remarks: • The 2√2 prefix can be removed by updating εto ε’ > 0 which can be calculated by solving the equation 2√2ε’ = ε • We can reduce the probability that the total increase in length is to high, by repeating the procedure for c different (a,b)-shifted dissections and choosing the shortest tour • We can derandomize the algorithm by trying all the possible L4= O(n4) dissection and, again, choosing the shortest tour
Randomization (Cont.)Proving N(τ) ≤ √2 ∙ OPT • Consider a segment C (of τ) from a point (x1,y1) to a point (x2,y2), remember that each one is located on a grid point • Let D be the Euclidian distance between the points (clearly D ≥ 1) • Denote: • Dx = |x1 - x2| • Dy = |y1 – y2| (x2,y2) D Dy=4 C (x1,y1) Dx=3