# Polynomial Time Approximation Scheme for Euclidian Traveling Salesman

## Presentation on theme: "Polynomial Time Approximation Scheme for Euclidian Traveling Salesman"— Presentation transcript:

Polynomial Time Approximation Scheme for Euclidian Traveling Salesman
(PTAS) for Euclidian Traveling Salesman Problem (TSP) Presented By: Dahan Yakir Sepetnitsky Vitali

Introduction The 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

Introduction Euclidian 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 Scheme is a polynomial-time algorithm which finds an (1 + ε)-approximation to the optimal solution for ε > 0 The run-time is polynomial by n

Introduction The algorithm we will present
We will show that Euclidian TSP has a PTAS The algorithm was given by Sanjeev Arora at 1996 and improved several times through 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

The main idea A general description
The main idea of the PTAS is that the plane (and thus the instance) can be recursively partitioned such that some (1 + ε)-approximation tour crosses each line of the partition a bounded number of times For each line in the partition the algorithm “guesses” where the tour crosses this line and the crossings number , then it recurses on the two sides of the line There is no way to define a deterministic solution to the approximation tour, so it is specified probabilistically

This lesson Structure Basic definitions
A deterministic version of the algorithm Counterexamples A randomized version of the algorithm which guarantees an (1 + ε)-approximation to the optimal solution with probability ≥ 1∕2

Step 1 Bounding Box of 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 L the size of the box We can scale all distances such that L = 4n2 and thus: k = 2+2∙log2n = O(log n)

Step 2 Perturbation 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 2 Error 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 √2 – go to the closest grid point, and then come back  (√2 / 2) * 2 = √2

Step 2 Error 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 2 Error 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 Let’s define the optimal cost of the TSP problem solution as OPT. Assume we have (1 + ε)-approximation to I’ (denote its cost as SOL’)  SOL’ ≤ (1 + ε)OPT Now, let’s take the solution SOL’ and move all the points, back to their original position, let’s denote the new tour cost as SOL According to the stated in the previous slide we have: (SOL – SOL’)∕SOL’ ≤ n√2∕2L = n√2∕8n2 = 1∕4√2n  SOL ≤ (1 + 1∕4√2n)SOL’ Thus we have: SOL ≤ (1 + 1∕4√2n)SOL’ ≤ (1 + 1∕4√2n) (1 + ε)OPT = (1 + 1∕4√2nε + ε + 1∕4√2n) OPT Therefore, the corresponding solution for the I instance of the TSP problem is (1 + ε + 1∕4√2n)-approximation (the 1∕4√2nε part is negligible)

Step 3 Dissection of the Bounding Box
L A recursive partitioning into four smaller squares An L × L square is divided into four L∕2 × L∕2 squares and so on We view the partitioning as a 4-ary tree T , whose root is the bounding box, the four L∕2 × L∕2 squares are its children and so on L∕2

Step 3 Dissection of 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 3 Dissection of 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 3 Dissection of 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 i there are 4i squares (i = 0 to k) The number of the nodes in the tree is therefore: … + 4k = (4k ) / (4 - 1) = = O(4k) = O( log n) = O(n4) At last level there are L2 unit squares, which can be represented as a power of 4 (since the tree is 4-ary). Therefore we get L2 = 4x, but, according to the previous assumption L = 2k. Thus, we get 22x = 2k ∙ 2k = 22k  2x = 2k  x = k We got that at the last level of the tree there are 4k squares  the depth of the tree is k The bounding box Level 1 squares Level 2 squares

Step 3 Dissection of the Bounding Box (Cont.)
Now we assign levels for the lines from which the dissection is constructed Level i lines create 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 4 Portals 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 i line Each useful square has at most 4m portals on its sides and corners . portal L∕(2im)

Step 4 Portals (Cont.) m is a power of 2 and belongs to [k∕ε , 2 ∙ k∕ε] Therefore m = O(log n∕ε) A portal in a level i square 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 – Proof Stage 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 l only 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 l only twice: c' c' a a d d p p b a' b a' 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

Conclusion The 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 In fact there is no guarantee that it is close enough to optimum – just the opposite, we will show a counterexample Instead we will construct a larger family of dissections and prove that at least half of them have optimal WBLC tour which is close enough to the optimum

Definition valid 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' c 1 1 1 b c‘, d 2 1 a' The optimal WBLC tour can be computed in time 2O(m) = nO(1∕ε) 2 a, e’ d‘, e 2

Stage 5 Computing 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 5 Computing 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 The third bullet can be derived from the fact that there are at most 4m portals on each useful square

Stage 5 Computing the optimal WBLC (Cont.)
The total number of possible assignments is m = 24m∙log23 m in the range [O(log n)∕ε , 2 ∙ O(log n) ∕ε] Therefore 24 ∙ O(log n)∕ε ∙ (log 3) ≤ 34m ≤ 28 ∙ O(log n)∕ε ∙ (log 3) Thus we have n(4 log 3) ∕ε ≤ 34m ≤ n(8 log 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 5 Computing the optimal WBLC (Cont.)
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: A useful square S rth Catalan number is the number of expressions constructed from r balanced pairs of parentheses.

Stage 5 Computing 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 5 Computing 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: m = 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 programming Computing 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∕ε) Minimum Costs Level 0 Level 1 Square 1 Square 2 Square 3 Square 4 valid visit 1 valid visit 2 valid visit 3

Definition Computing the optimal WBLC: consistency
We say that a valid visit of square S1 at level i is consistent with a valid visit of its parent square S, if all common portals get the same portal usages and internal pairings How to check if the external and internal pairings are consistent: We can represent the pairing as a sequence of parentheses when entering to big and small square is considered as two lparen-s “((“ and, similarly, existing from a small square and the big square will be considered as two rparen-s “))”. In addition, each move between two child squares will be considered as an lparen and rparen “)(“ The resulted sequence of parentheses of the path above will be: “(()()())(()())”

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 – 1 downto 0 2.1. For each square S at level i For each valid visit V in S For each possibility of portal usages on the two lines which divide S (to 4 squares) For each valid pairing of all the portals consistent with the visit V portals usage

Dynamic programming (Cont
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) Sum the optimal lengths of the appropriate visits in the children squares Compute the minimum cost among the costs for this internal portal usage 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∕ε)

#entries ∙ nO(1∕ε) = 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: We compute all the available WBLCs costs, since each WBLC tour of a square S at level i can be divided to 4 squares at level i + 1, whose minimal WBLCs costs were calculated for each valid visit

WB tour vs. Optimal tour How 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

An edge of the changed tour An edge of the optimal tour
WB tour vs. Optimal tour How 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

Counterexample How 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 8x L 8x 4x 2x x y

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 8x L 8x 4x 2x x y

Counterexample (Cont.) How an optimal WB tour differs from OPT (Cont.)
Since y ≤ L∕2 we obtain |SOL| ∕|OPT| ≥ Hence, the described algorithm fails for a selection of an error parameter ε < To bypass this problem we will randomize the algorithm and generalize the concept of the dissection 4x 8x 8x L 8x 4x 2x x y

Definition (a,b)-Shifted Dissection of 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 ≤ 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 Dissection of the Bounding Box (Cont).
Here we a shifting of the level-1 lines is illustrated b a

Randomization (Cont.) (a,b)-Shifted Dissection analysis
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 lines at random level i) Thus, we have 2k 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 i is 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

Randomization (Cont.) Proving N(τ) ≤ √2 ∙ OPT (Cont.)
C crosses vertical grid lines Dx - 1 times C crosses horizontal grid lines Dy - 1 times D2 = Dx2+ Dy2 Dx2+ Dy2 ≥ (Dx+ Dy)2 / 2 Thus we have: 2D2 ≥ (Dx+ Dy)2  √2D ≥ Dx+ Dy ≥ N(C) Adding up we obtain the desired result: N(τ) ≤ √2 OPT (x2,y2) D Dy=4 C [(x+y)^2 ] / 2 = (x^2 + y^2 +2xy) / 2 <= (x^2 + y^2 +2xy) <= x^2 + y^2 (x1,y1) Dx=3

Summary PTAS for Euclidian TSP (in R2)
Given a TSP instance, perform: Find the bounding box Perturbation of the instance Create an (a,b)-shifted dissection of the bounding box for some randomly chosen integers 0 ≤ a, b < L Calculate an optimal WBLC tour τ, using dynamic programming With probability of at least 1∕2 , τ is an (1 + ε)-approximation to the optimal solution Repeat 3-5 until the required probability is obtained

References V. V. Vazirani, Approximation Algorithms, Springer, 2001.
Sanjeev Arora, Polynomial-time Approximation Schemes for Euclidean TSP and other Geometric Problems, Journal of the ACM 45(5) 753–782, 1998.