Set Cover Problem

Let Ω={a1,…,an}\Omega = \{ a_1, \ldots, a_n \} be a set, and S1,…,SmS_1, \ldots, S_m be subsets of Ω\Omega, such that SjS_j is associated with weight wj∈R+w_j \in \mathbb{R}^+ for each j∈[m]j \in [m]. The goal is solve the following the following optimization problem

min⁡J⊆[m]∑j∈Jwj,s.t.∪j∈JSj=Ω \begin{array}{lll} &\min_{J \subseteq [m]} &\sum_{j \in J} w_j, \\ &\text{s.t.} &\cup_{j \in J} S_j = \Omega \end{array}

In case where wj=1w_j = 1 for each j∈[m]j \in [m], the problem is called the unweighted set cover problem.

Linear Programming

The linear program for the problem is

min⁡∑j∈[m]wj⋅xjs.t.∑j:ai∈Sjxj≥1∀i∈[n]xj≥0∀j∈[m] \begin{array}{llr} \min &\sum_{j \in [m]} w_j \cdot x_j \\ \text{s.t.} &\sum_{j : a_i \in S_j} x_j \ge 1 &\forall i \in [n]\\ &x_j \ge 0 &\forall j \in [m] \end{array}

The dual LP of the primal is

max⁡∑i∈[n]yis.t.∑i:ai∈Sjyi≤wj∀j∈[m]yi≥0∀i∈[n] \begin{array}{llr} \max &\sum_{i \in [n]} y_i \\ \text{s.t.} &\sum_{i: a_i \in S_j} y_i \le w_j &\forall j \in [m]\\ &y_i \ge 0 &\forall i \in [n] \end{array}

Rounding the Optimal Primal Solution

For each element i∈[n]i \in [n], let Ei≐{j∈[m]:ai∈Sj}E_i \doteq \{ j \in [m] : a_i \in S_j \}, and let C=max⁡i∈[n]∣Ei∣C = \max_{i \in [n]} |E_i|.

Suppose that xj∗,j∈[m]x_j^*, j \in [m] be the optimal solution to the primal LP.

Theorem.

J≐{j∈[m]:xj∗≥1C} J \doteq \left\{ j \in [m] : x_j^* \ge \frac{1}{C} \right\}

is a CC-approximate solution to the set cover problem.

Proof. We prove first that Sj,j∈JS_j, j \in J is a set cover, then we prove that it is a CC approximate one.

Feasibility. Since xj∗x_j^* is the optimal solution to the primal LP, for each i∈[n]i \in [n], we have

∑j:ai∈Sjxj≥1. \sum_{j : a_i \in S_j} x_j \ge 1.

Therefore, , there exists at least one j∈Eij \in E_i, s.t.,

xj∗≥1∣Ei∣≥1C. x_j^* \ge \frac{1}{|E_i|} \ge \frac{1}{C}.

Approximation Ratio. The cost of the approximate solution is given by

∑j∈Jwj≤∑j∈Jwj⋅(xj∗⋅C)≤C⋅∑j∈[m]wj⋅xj∗. \sum_{j \in J} w_j \le \sum_{j \in J} w_j \cdot \big( x_j^* \cdot C \big) \le C \cdot \sum_{j \in [m]} w_j \cdot x_j^*.

□\square

Remark. This is a 22-approximation algorithm for the vertex cover problem, a special case of the set cover problem.

Rounding the Optimal Dual Solution

Let yi∗,i∈[n]y_i^*, i \in [n] be the optimal solution to the dual.

Theorem.

J′≐{j∈[m]:∑i:ai∈Sjyi∗=wj} J' \doteq \left\{ j \in [m] : \sum_{i: a_i \in S_j} y^*_i = w_j \right\}

is a CC-approximate solution to the set cover problem.

Proof. We prove first that Sj,j∈J′S_j, j \in J' is a set cover, then we prove that it is a CC approximate one.

Feasibility. Suppose that there exits an uncovered element aka_k, which implies that for each j∈Ekj \in E_k, it holds that

∑i:ai∈Sjyi∗<wj. \sum_{i: a_i \in S_j} y^*_i < w_j.

But this implies that we can increase the value of yk∗y_k^*, and therefore increase the value of ∑i∈[n]yi∗\sum_{i \in [n]} y_i^*, without violating the dual constraints, contradicting the yi∗,i∈[n]y_i^*, i \in [n] being optimal.

Approximation Ratio. The cost of the approximate solution is given by

∑j∈J′wj=∑j∈J′(∑i:ai∈Sjyi∗)≤∑i∈[n](∑i:ai∈Sjyi∗)≤C⋅∑i∈[n]yi∗, \sum_{j \in J'} w_j = \sum_{j \in J'} \left( \sum_{i: a_i \in S_j} y^*_i \right) \le \sum_{i \in [n]} \left( \sum_{i: a_i \in S_j} y^*_i \right) \le C \cdot \sum_{i \in [n]} y^*_i,

where the last inequality holds, since each yi∗y_i^* appears in at most CC constraints.

□\square

Remark. Via complementary slackness, if xj∗>0x_j^* > 0, we always have

∑i:ai∈Sjyi∗=wj. \sum_{i : a_i \in S_j} y^*_i = w_j.

Since J≐{j∈[m]:xj∗≥1/C}J \doteq \left\{ j \in [m] : x_j^* \ge 1 / C \right\}, it holds that J⊆J′J \subseteq J'. Therefore, rounding the primal solution do no worse than rounding the dual one.

The Primal-Dual Method

Rounding the optimal dual solution requires to solve the dual LP optimally, which could be slow even though the LP can be solved in polynomial time. The following algorithm overcomes this drawback by constructing only a feasible dual solution.

Algorithm. Aprimal-dual\mathcal{A}_{primal \text{-} dual}

  1. yi←0y_i \leftarrow 0, for each i∈[n]i \in [n]
  2. J←∅J \leftarrow \emptyset
  3. while ∃ak∉∪j∈JSj\exists a_k \notin \cup_{j \in J} S_j do
  4. \qquad increase yky_k until some constraint becomes tight,
  5. \qquad i.e., ∃Sℓ\exists S_\ell with ak∈Sja_k \in S_j, s.t., ∑i:ai∈Sℓyi=wℓ\sum_{i: a_i \in S_\ell} y_i = w_\ell
  6. \qquad J←J∪{ℓ}J \leftarrow J \cup \{ \ell \}

Clearly the yi,i∈[n]y_i, i \in [n] is a feasible solution to the dual.

Theorem. Algorithm Aprimal-dual\mathcal{A}_{primal \text{-} dual} returns a CC-approximate solution JJ to the set cover problem.

Proof. We prove first that Sj,j∈JS_j, j \in J is a set cover, then we prove that it is a CC approximate one.

Feasibility. Suppose that there exits an element aka_k that is not covered by JJ, which implies that for each j∈Ekj \in E_k, it holds that

∑i:ai∈Sjyi<wj. \sum_{i: a_i \in S_j} y_i < w_j.

But this implies that we can increase the value of yky_k, and therefore increase the value of ∑i∈[n]yi\sum_{i \in [n]} y_i, without violating the dual constraints, contradicting yiy_i being optimal.

Approximation Ratio. The cost of the approximate solution is given by

∑j∈Jwj=∑j∈J(∑i:ai∈Sjyi)≤∑i∈[n](∑i:ai∈Sjyi)≤C⋅∑j∈[m]yi, \sum_{j \in J} w_j = \sum_{j \in J} \left( \sum_{i: a_i \in S_j} y_i \right) \le \sum_{i \in [n]} \left( \sum_{i: a_i \in S_j} y_i \right) \le C \cdot \sum_{j \in [m]} y_i,

where the last inequality holds, since each yiy_i appears in at most CC constraints.

□\square

Randomized Rounding

We present a randomized algorithm based on the optimal solution xj∗x_j^* for the primal LP.

Let T∈N+T \in \mathbb{N}^+ be a positive integer to be determined later.

Algorithm. Arnd\mathcal{A}_{rnd}

  1. for t∈[T]t \in [T] do
  2. \qquad Jt←∅J_t \leftarrow \emptyset
  3. \qquad for each j∈[m]j \in [m] do
  4. \qquad \qquad add jj to JtJ_t with probability xj∗x_j^*
  5. output J←∪t∈[T]JtJ \leftarrow \cup_{t \in [T]} J_t

Theorem. The expected cost of JJ is at most T⋅∑j∈[m]wj⋅xj∗T \cdot \sum_{j \in [m]} w_j \cdot x_j^*. Further, if T=2ln⁡nT = 2 \ln n, with probability at least 1−1/n1 - 1 / n, JJ is a set cover.

Proof.

Expected Cost. Since jj is included in JtJ_t with probability xj∗x_j^* for each j∈[m]j \in [m], by linearity of expectation, the expected sum of weights of sets in JtJ_t is given by

∑j∈[m]wj⋅xj∗. \sum_{j \in [m]} w_j \cdot x_j^*.

Therefore, the expected cost of JJ is at most T⋅∑j∈[m]wj⋅xj∗T \cdot \sum_{j \in [m]} w_j \cdot x_j^*.

Failure Probability. The probability that a fixed aia_i is not covered by JtJ_t is given by

∏j:ai∈Sj(1−xj∗)≤exp⁡(−∑j:ai∈Sjxj∗)≤exp⁡(−1). \begin{aligned} \prod_{j : a_i \in S_j} (1 - x_j^*) \le \exp \left( - \sum_{j : a_i \in S_j} x_j^* \right) \le \exp (- 1). \end{aligned}

By independence, the probability that none of the JtJ_t covers aia_i is at most

(exp⁡(−1))T=exp⁡(−T)=1/n2. \big( \exp(-1) \big)^T = \exp(-T) = 1 / n^2.

Applying union bound over all element ai∈Ωa_i \in \Omega finishes the proof.

□\square

Greedy Algorithm

Finally, we discuss a greedy algorithm for the set cover problem.

We follows the convention that x/0=∞x / 0 = \infty, ∀x∈R+\forall x \in \mathbb{R}^+.

Algorithm. Agreedy\mathcal{A}_{greedy}

  1. S^j←Sj\hat S_j \leftarrow S_j, for each j∈[m]j \in [m]
  2. J←∅J \leftarrow \emptyset
  3. while ∪j∈JSj≠Ω\cup_{j \in J} S_j \neq \Omega do
  4. \qquad ℓ←min⁡j∈[m](wj/∣S^j∣)\ell \leftarrow \min_{j \in [m]} \left( w_j / |\hat S_j| \right)
  5. \qquad J←J∪{ℓ}J \leftarrow J \cup \{ \ell \}
  6. \qquad S^j←S^j∖Sℓ\hat S_j \leftarrow \hat S_j \setminus S_\ell, ∀j∈[m]\forall j \in [m]

For each k∈N+k \in \mathbb{N}^+, define Hk=∑i∈[k]1/iH_k = \sum_{i \in [k]} 1 / i.

Theorem. Agreedy\mathcal{A}_{greedy} outputs a HnH_n approximate solution JJ to the set cover problem.

Proof. When an ℓ\ell is added to JJ, it is easy to see that S^ℓ≠∅\hat S_\ell \neq \emptyset, as otherwise wℓ/∣S^ℓ∣=∞w_\ell / |\hat S_\ell| = \infty. Therefore we can charge the cost of wℓw_\ell among elements in S^ℓ\hat S_\ell, with each elements ai∈S^ℓa_i \in \hat S_\ell obtaining a cost of

yi≐wℓ/∣S^ℓ∣. y_i \doteq w_\ell / |\hat S_\ell|.

Since each ai∈Ωa_i \in \Omega is charged exactly once, it holds that

∑j∈Jwj=∑i∈[n]yi. \sum_{j \in J} w_j = \sum_{i \in [n]} y_i.

Our proof is based on the following lemma.

Lemma. For each j∈[m]j \in [m], it holds that

∑i:ai∈Sjyi≤wj⋅H∣Sj∣. \sum_{i : a_i \in S_j} y_i \le w_j \cdot H_{|S_j|}.

We now finish the proof for the theorem, assuming the lemma holds. Let D≐max⁡j∈[m∣Sj∣≤nD \doteq \max_{j \in [m} |S_j| \le n. For each i∈[n]i \in [n], define new variable y^i=yi/HD\hat y_i = y_i / H_D. Then the y^i\hat y_i is a feasible solution to the dual LP, and therefore ∑i∈[n]y^i≤OPT\sum_{i \in [n]} \hat y_i \le \text{OPT}, where OPT\text{OPT} is the value of the optimal solution to the set cover problem. We conclude that

∑j∈Jwj=∑i∈[n]yi=HD⋅∑i∈[n]y^i≤HD⋅OPT. \sum_{j \in J} w_j = \sum_{i \in [n]} y_i = H_D \cdot \sum_{i \in [n]} \hat y_i \le H_D \cdot \text{OPT}.

Proof of the Lemma. Suppose that the solution JJ returned by Agreedy\mathcal{A}_{greedy} consists tt numbers ℓ1,…,ℓt\ell_1, \ldots, \ell_t, indexed according to their orders added to JJ.

For each k∈[t]k \in [t], define

rk≐∣Sj∖(Sℓ1∪Sℓ2∪…∪Sℓk−1)∣. r_k \doteq \Big| S_j \setminus \big( S_{\ell_1} \cup S_{\ell_2} \cup \ldots \cup S_{\ell_{k - 1}}) \Big|.

Note that rkr_k is the number of new elements in SjS_j that is covered by sets indexed by JJ, before ℓk\ell_k is added to JJ. For convenience, let r0=nr_0 = n. For each k∈[t]k \in [t], define ck=rk−rk−1c_k = r_k - r_{k - 1}. We claim that for each k∈[t]k \in [t], it holds that

∑i:ai∈Sj∩S^ℓkyi=ck⋅yi≤ck⋅wjrk. \sum_{i : a_i \in S_j \cap \hat S_{\ell_k}} y_i = c_k \cdot y_i \le c_k \cdot \frac{w_j}{r_k}.

If Sj∩S^ℓk=∅S_j \cap \hat S_{\ell_k} = \emptyset, then ck=0c_k = 0 and the claim holds trivially. Otherwise, the criteria for picking ℓk\ell_k by Agreedy\mathcal{A}_{greedy} ensures that for each ai∈Sj∩S^ℓka_i \in S_j \cap \hat S_{\ell_k}, it holds that

yi=wℓk∣S^ℓk∣≤wjrk. y_i = \frac{w_{\ell_k} }{|\hat S_{\ell_k}|} \le \frac{w_j}{r_k}.

Therefore,

∑i:ai∈Sjyi=∑k∈[t]∑i:ai∈Sj∩S^ℓkyi≤∑k∈[t]ck⋅wjrk≤∑k∈[t]wj(1rk+1rk−1+…+1rk−ck+1)=wj∑k∈[∣Sj∣]1k=wj⋅H∣Sj∣. \begin{aligned} \sum_{i : a_i \in S_j} y_i &= \sum_{k \in [t]} \sum_{i : a_i \in S_j \cap \hat S_{\ell_k}} y_i \\ &\le \sum_{k \in [t]} c_k \cdot \frac{w_j}{r_k} \\ &\le \sum_{k \in [t]} w_j \left( \frac{1}{r_k} + \frac{1}{r_k - 1} + \ldots + \frac{1}{r_k - c_k + 1} \right) \\ &= w_j \sum_{k \in \big[ |S_j| \big]} \frac{1}{k} \\ &= w_j \cdot H_{|S_j|}. \end{aligned}

□\square

Reference

[1] D. P. Williamson and D. B. Shmoys, The Design of Approximation Algorithms. Cambridge: Cambridge University Press, 2011.