COMP360 Problem Set 4 Solution 1 Backtracking: Vertex Coloring(10pts) The following is the search process: 1. A: assign color 1. 2. B: B is connected with A, so assign color 2. 3. C: C is connected with B, so assign color 1. 4. D: D is connected with C, so assign color 2. 5. E: E is connected with C,D, so assign color 3. 6. F, F is connected with A,E, so assign color 2. 7. G, G is connected with A,B,F, so assign color 3. 8. H, H is connected with C,G, so assign color 2. So it is three colorable. 2 2.1 Local Search: Load Balancing(20pts) (a) Consider a progress measure Φ defined as the sum of the squares of the loads on all machines. We claim that after an improving swap move, this quantity must strictly decrease. Indeed, suppose we execute an improving swap move on machines Mi and Mj ; suppose the loads on Mi and Mj before the swap are Ti and Tj respectively, and the loads after the swap are Ti ′ and Tj ′ . Then the change of Φ is −Ti2 − Tj2 + (Ti ′ )2 + (Ti ′ )2 ; since Ti + Tj = Ti ′ + Tj ′ , and max(Ti ′ , Tj ′ ) < max(Ti , Tj ), the change is always negative: in other words, Φ strictly decreases. Since there are only a finite number of ways to partition jobs across machines, Φ can only decrease a finite number of times. That implies that the algorithm terminates. 1 2.2 (b) Consider the machine Mi with the maximum load at the end of the algorithm. If Mi contains a single job, then since this job has to go somewhere in any solution, the makespan of our solution is the same as the optimal makespan. Otherwise, Mi has at least two jobs on it. We now claim that the load on Mi is at most twice the load on any other machine Mj . Since this applies to the machine Mj of minimum load, it implies that Mi is at most twice the average. 1 t . But the optimal makespan is at least the average, therefore this gives m ∑r r a factor 2 approximation. Now let’s prove the claim. Suppose Ti > 2Tj . Since Mi has at least two jobs, the lightest job r on Mi has size tr ≤ 21 Ti . So consider the swap move in which job r simply moves to Mi . If Ti ′ and Tj ′ are the loads after this move, we have Ti ′ < Ti and Tj ′ = Tj + tr < 21 Ti + 12 Ti = Ti . Thus max(Ti ′ , Tj ′ ) < max(Ti , Tj ), so this is an improving swap move, contradicting the termination of the algorithm. 3 Circle radius Assume y is furthest point of x ∈ P . Since the distance between any other point to x is no greater than r, our solution is feasible. On the other hand since r is the distance between x and y, any circle that contains both x and y should have diameter at least r, which means the radius is at least r/2. Thus, this is a 2-approximation algorithm. 4 Knapsack(15pts) If we can fit all items into the knapsack, we clearly have obtained an optimal solution. So let’s assume we can fit in only k < n items. If there is no space left in the knapsack, since we have been packing only the items with the highest value per unit space, this is again an optimal solution. WLOG, let’s assume that we have some leftover space W − V in the end. If our algorithm can take a −V fraction of an item, then by adding W v to our knapsack value, we would wk+1 k+1 either match or exceed OPT(unable to take fractional items). Therefore, either k−1 −V v ≥ 21 OPT. So this is a 2-approximation ∑i=1 vi ≥ 21 OPT or vk+1 ≥ W wk+1 k+1 algorithm. 5 TSP(20pts) Let ∆-TSP-R be the metric TSP problem such that the tour can visit a city for more than one time. In class, we have argued that the optimal solution for ∆-TSP-R is the same as ∆-TSP. So if you have a c-approximation algorithm for TSP-R, it is also a c-approximation algorithm for ∆-TSP-R. Remember that we show in class that one can take any feasible solution of ∆-TSP-R and turn 2 it into a feasible solution of ∆-TSP without increasing the cost of the tour by shortcutting. So this is also a c-approximation algorithm for ∆-TSP. For the other direction, let’s consider the following algorithm: on input an instance (X, d) of TSP-R, we compute the new distance function d′ (x, y) as the length of a shortest path from x to y in a weighted graph that has vertex set X and weights d(x, y). Note that d′ (x, y) is a distance function that satisfies the triangle inequality. We also compute the shortest path between any pair x and y. We then pass the input (X, d′ ) to our c-approximation algorithm for ∆-TSP, and find a cycle C ′ such that costd′ (C ′ ) ≤ c ⋅ OPT∆−T SP (X, d′ ) Note that, for every pair of points (x, y), we have d′ (x, y) ≤ d(x, y) and so OPT∆−T SP (X, d′ ) = OPT∆−T SP −R (X, d′ ) ≤ OPTT SP −R (X, d). Finally, we construct a cycle C by replacing each transition x → y in C ′ by the shortest path from x to y according to d(x,y). Because of the definition of d′ (x,y), we have costd (C) = costd′ (C ′ ) and, combining the inequalities we have proved so far, costd (C) ≤ c ⋅ OPTT SP −R (X, d) Therefore, we have argued that given a c-approximation algorithm for ∆-TSP, we can construct a c-approximation algorithm for TSP-R. 3
© Copyright 2024