Docsity

Lecture Notes on Homework 1 - Algorithms: Approximation Algorithms | COM SCI 280AP, Assignments of Algorithms and Programming

Toggle sidebar
bg1
CS280AP, Fall 2008 – Homework One
Jeffrey Lee Hellrung, Jr.
October 14, 2008
1. Suppose we have two salesman, one starting at location Aand one starting at location B. We are
given a list of cities and asked to find a tour for each salesman such that every city is visited by one of
them. The distances between cities are also given, and form a metric. Give a Θ(1) approximation for
this problem.
Solution
For notational purposes, let Vbe the set of cities and G= (V, E ) be the complete graph on Vwith edge
weights w(e), e∈E, representing the distances between cities. Let G∗
X= (V∗
X, E∗
X), X=A, B, be an
optimum (total-length-minimizing) pair of tours for the two salesman, where V∗
X∋Xand V∗
A∪V∗
B=V.
First observe that the optimum pair of tours of the salesmen may be assumed to be disjoint, for if each
salesman visits city Y, one salesman may safely skip Yalong his or her route without increasing the
total tour length (due to the metric property of G). Thus, (V∗
A, V ∗
B) define a cut Cin G. Let ebe
any edge on the cut C. Since the combined tours with the addition of e((V∗
A⊔V∗
B, E∗
A⊔E∗
B⊔ {e}))
certainly spans Gand is connected, the cost of the combined tours with emust be at least as large
as the cost of a minimum spanning tree (MST) on G. Let Tbe a MST of G. Observe that, by the
Minimum Spanning Tree Theorem, Tmust have a minimum-weight edge e′on the cut C, and hence
w(e)≤w(e′). Now let e′′ be the minimum-weight edge in Talong the (unique) path with Tfrom Ato
B. Certainly e′lies along this path (Cis a cut dividing Aand B), hence w(e′′)≤w(e′)≤w(e), and
we conclude that T\e′′ has cost at most the combined cost of the two tours G∗
Aand G∗
B.
This suggest the following 2-approximation algorithm for the metric two-traveling salesman. Compute
a MST Tof G, remove the minimum-weight edge ealong the path in Tfrom Ato B, and then traverse
the vertices of T\ein depth-first order, starting, separately, from Aand B(the analysis from here is
identical to that for the classical metric traveling salesman approximation algorithm). Or, we can get a
3/2-approximation by computing a minimum-cost perfect matching on the odd-degree vertices of each
component of T\e, adding these matchings to T\e, then finding an Eulerian tour on each component.
We can’t hope to do better on this problem than on classical metric TSP, since an instance of classical
metric TSP can be easily reduced to an instance of metric two-traveling salesmen by adding the
additional vertex B, where the distance from Bto any other vertex is ∞(or just very large).
2. We’d like to solve a set cover instance where each set has size at most s. Prove that a Θ(log s)
approximation is possible. Hint: Prove by induction on s.
Solution
The algorithm works as before: greedily select sets one by one that each cover a maximal number of
uncovered elements. We will show that this algorithm selects at most 2 log(s)OPT sets. Suppose the
first ksets each covered at least s/2 uncovered elements when they were selected, and the remaining
selected sets covered fewer than s/2 uncovered elements when they were selected. Call U′the set of
uncovered elements after selecting the first ksets. By the induction hypothesis, this algorithm selects
at most 2 log (s/2)OPTs/2sets, where OPTs/2is the optimal number of sets needed to cover U′. But
note that OPTs/2≤OPT (certainly, the optimal selection of sets from the original problem can be
used to cover U′), so the algorithm selects at most 2 log(s/2)OPT sets to cover U′. Further, we can
1
pf3
pf4

Partial preview of the text

Download Lecture Notes on Homework 1 - Algorithms: Approximation Algorithms | COM SCI 280AP and more Assignments Algorithms and Programming in PDF only on Docsity!

CS280AP, Fall 2008 – Homework One

Jeffrey Lee Hellrung, Jr.

October 14, 2008

  1. Suppose we have two salesman, one starting at location A and one starting at location B. We are given a list of cities and asked to find a tour for each salesman such that every city is visited by one of them. The distances between cities are also given, and form a metric. Give a Θ(1) approximation for this problem. Solution For notational purposes, let V be the set of cities and G = (V, E) be the complete graph on V with edge weights w(e), e ∈ E, representing the distances between cities. Let G∗ X = (V (^) X∗ , E∗ X ), X = A, B, be an optimum (total-length-minimizing) pair of tours for the two salesman, where V (^) X∗ ∋ X and V (^) A∗ ∪V (^) B∗ = V. First observe that the optimum pair of tours of the salesmen may be assumed to be disjoint, for if each salesman visits city Y , one salesman may safely skip Y along his or her route without increasing the total tour length (due to the metric property of G). Thus, (V (^) A∗ , V (^) B∗ ) define a cut C in G. Let e be any edge on the cut C. Since the combined tours with the addition of e ((V (^) A∗ ⊔ V (^) B∗ , E A∗ ⊔ E B∗ ⊔ {e})) certainly spans G and is connected, the cost of the combined tours with e must be at least as large as the cost of a minimum spanning tree (MST) on G. Let T be a MST of G. Observe that, by the Minimum Spanning Tree Theorem, T must have a minimum-weight edge e′^ on the cut C, and hence w(e) ≤ w(e′). Now let e′′^ be the minimum-weight edge in T along the (unique) path with T from A to B. Certainly e′^ lies along this path (C is a cut dividing A and B), hence w(e′′) ≤ w(e′) ≤ w(e), and we conclude that T \e′′^ has cost at most the combined cost of the two tours G∗ A and G∗ B. This suggest the following 2-approximation algorithm for the metric two-traveling salesman. Compute a MST T of G, remove the minimum-weight edge e along the path in T from A to B, and then traverse the vertices of T \e in depth-first order, starting, separately, from A and B (the analysis from here is identical to that for the classical metric traveling salesman approximation algorithm). Or, we can get a 3 /2-approximation by computing a minimum-cost perfect matching on the odd-degree vertices of each component of T \e, adding these matchings to T \e, then finding an Eulerian tour on each component. We can’t hope to do better on this problem than on classical metric TSP, since an instance of classical metric TSP can be easily reduced to an instance of metric two-traveling salesmen by adding the additional vertex B, where the distance from B to any other vertex is ∞ (or just very large).
  2. We’d like to solve a set cover instance where each set has size at most s. Prove that a Θ(log s) approximation is possible. Hint: Prove by induction on s. Solution The algorithm works as before: greedily select sets one by one that each cover a maximal number of uncovered elements. We will show that this algorithm selects at most 2 log(s)OPT sets. Suppose the first k sets each covered at least s/2 uncovered elements when they were selected, and the remaining selected sets covered fewer than s/2 uncovered elements when they were selected. Call U ′^ the set of uncovered elements after selecting the first k sets. By the induction hypothesis, this algorithm selects at most 2 log(s/2)OPTs/ 2 sets, where OPTs/ 2 is the optimal number of sets needed to cover U ′. But note that OPTs/ 2 ≤ OPT (certainly, the optimal selection of sets from the original problem can be used to cover U ′), so the algorithm selects at most 2 log(s/2)OPT sets to cover U ′. Further, we can

bound OPT and k by, respectively, OPT ≥ n/s and k ≤ 2 n/s to obtain k ≤ 2OPT, hence the number of sets selected by the algorithm is at most

k + 2 log(s/2)OPT ≤ 2OPT + 2 log(s/2)OPT = 2 log(s)OPT,

as desired.

  1. Given a graph, we’d like to find the minimum number of edges which could be cut such that the shortest- path distance between nodes x and y increases by at least α. Prove that this is NP-Hard in general. Suppose we had a polynomial-time algorithm for the case where α = 1. Design an approximation algorithm for the general problem with approximation ratio α. Solution Denote the given problem as MCEXYSPI (Minimum Cut Edges x, y-Shortest Path Increase), which has the parameters a graph G; vertices x, y; and a positive integer α. To show that MCEXYSPI is NP-Hard, we reduce an instance of multiway cut (with, specifically, k = 3, but it will be easy to see how to reduce from an instance with k > 3 as well) to an instance of MCEXYSPI, and show how a solution to MCEXYSPI gives a solution to multiway cut. To this end, let G = (V, E) be a graph with terminals s 1 , s 2 , s 3 ∈ V , where we wish to find the minimum number of edges to cut from G that disconnects si from sj , i 6 = j. Without loss of generality, we may assume that G is connected, and hence the shortest-path distance d from s 1 to s 3 is finite (note that d can be computed in polynomial time). Let n = |V | and m = |E|. Construct the graph G′^ from G by adding “path bundles” between s 1 and s 2 and between s 2 and s 3. The “path bundle” between s 1 and s 2 consists of m + 1 simple disjoint (except at s 1 and s 2 ) paths (sequences vertices and edges), each of length n. The “path bundle” between s 2 and s 3 is constructed similarly. We thus obtain an instance of MCEXYSPI on the graph G′^ with x = s 1 , y = s 3 , and α = 2n − d. Let F be a minimum-sized set of edges which could be cut from G′^ such that the shortest-path distance from s 1 to s 3 is at least 2n. The claim is that F is also a minimum-sized multiway cut which disconnects si from sj , i 6 = j. First, we show that F ⊂ E, i.e., no edge from the new “path bundles” between s 1 and s 2 or between s 2 and s 3 need be cut. Indeed, removing an edge from one of the m + 1 new paths betweeen s 1 and s 2 could not change the shortest-path distance from s 1 to s 3 unless an edge from all m + 1 new paths were selected, in which case it would be more optimal for F = E. The same argument applies to the m + 1 new paths between s 2 and s 3. Thus, as claimed, F ⊂ E. Second, we show that F is a multiway cut of G. Indeed, any path in G\F between s 1 and s 3 must have length at most n − 1 < 2 n and is also a path in G′\F , contradicting the choice of F. Likewise, any path in G\F between s 1 and s 2 must have length at most n − 1 < n, is also a path in G′\F , and can be concatenated to one of the new paths of length n in G′^ between s 2 and s 3 , thereby giving a path in G′\F of length 2n − 1 between s 1 and s 3 , again contradicting the choice of F. A similar argument applies to the pair of vertices s 2 , s 3 , and we conclude there exist no paths among s 1 , s 2 , and s 3 within G\F , i.e., F is a multiway cut of G. Lastly, any multiway cut F ′^ of G also satisfies the property that its removal from G′^ increases the shortest-path length between s 1 and s 3 to 2n. From this we infer that F must actually be a minimum- sized multiway cut of G, as desired. This concludes the proof that MCEXYSPI is NP-Hard. Given a polynomial-time algorithm for the case with “α = 1”, it is easy to approximate the general problem to with a factor of α by just iteratively querying the “α = 1” case (and removing the resulting cut edges) until the shortest-path distance between x and y has increased overall by at least α. Let OPT be the minimum-sized set of edges that could be cut from G to increase the shortest-path distance between x and y by at least α. In each query to the case “α = 1”, we know we won’t remove any more than |OPT| edges from the graph (since we could just remove the edges in OPT at any point and achieve our goal), and we’d need at most α queries to the “α = 1” case, hence we’d remove at most α |OPT| edges overall, as desired.

for any i > i∗. For the first claim, observe that D[i] ≥ D[i∗] for i ≤ i∗, hence (for i ≤ i∗)

U [i∗] + D[i∗] ≤ 2 D[i∗] ≤ 2 D[i] ≤ 2(U [i] + D[i]),

as desired. Similarly, U [i∗^ + 1] ≤ U [i] for i∗^ < i, hence (for i > i∗)

U [i∗^ + 1] + D[i∗^ + 1] ≤ 2 U [i∗^ + 1] ≤ 2 U [i] ≤ 2(U [i] + D[i]),

again as desired. To summarize, U [i∗] + D[i∗] is within a factor of 2 of mini≤i∗^ U [i] + D[i], while U [i∗^ + 1] + D[i∗^ + 1] is within a factor of 2 of mini>i∗^ U [i] + D[i]. It suffices then to take the minimum of U [i∗] + D[i∗] and U [i∗^ + 1] + D[i∗^ + 1].

If such an i∗^ does not exist, then either U [1] > D[1] or U [n] < D[n]. The analysis above works for either case by just ignoring the “nonsensical half”, and we find that U [1] + D[1] (in the former case) or U [n] + D[n] (in the latter case) are within a factor of 2 of mini U [i] + D[i].

To improve this approximation factor to 1 + 1/x, we perform 2x − 1 binary searches to find indices i∗ k, −x < k < x, such that

U [i∗ k] ≤

x + k x

D[i∗ k], U [i∗ k + 1] ≥

x + k x

D[i∗ k + 1]

for −x < k ≤ 0, and

U [i∗ k] ≤

x x − k

D[i∗ k], U [i∗ k + 1] ≥

x x − k

D[i∗ k + 1]

for 0 ≤ k < x. Clearly this takes time O(x log n). Again, assume for the moment that all such i∗ k’s exist. Now observe that if k = −x + 1 and 1 ≤ i ≤ i∗ k, then

U [i∗ k] + D[i∗ k] ≤

x

D[i∗ k]

x

D[i]

x

(U [i] + D[i]);

while if −x + 1 < k ≤ 0 and i∗ k− 1 < i ≤ i∗ k, then

U [i∗ k] + D[i∗ k] ≤

k x

D[i∗ k]

k x

D[i]

x

D[i] +

x + (k − 1) x

D[i]

x

D[i] + U [i]

x

(U [i] + D[i]).

Thus, for −x < k ≤ 0, U [i∗ k] + D[i∗ k] is within a factor of 1 + 1/x of mini∗ k− 1 <i≤i∗ k U [i] + D[i] (where we set i∗−x = 0). By a similar analysis, we can show that for 0 ≤ k < x, U [i∗ k] + D[i∗ k] is within a factor of 1 + 1/x of mini∗ k ≤i<i∗ k+1 U [i] + D[i] (where we set i∗ x = n + 1). As before, then, it suffices to take the minimum among the sums U [i∗ k] + D[i∗ k] (which takes additional time Θ(x)).

Also, as before, if some of the i∗ k’s do not exist, the analysis above still works by just ignoring those intervals containing a “nonexistent” i∗ k.