Upload
others
View
32
Download
0
Embed Size (px)
Citation preview
CHAPTER 1 An introduction to approximation algorithms
Approximation algorithms
To show that an algorithm Alg is an α-approximation
algorithm we need to show three things:
① The algorithm runs in polynomial time.
② The algorithm always produces a feasible solution.
③ The value is within a factor α of the optimal value
α – approximation algorithm
Minimization problem
For all instances:
ALG ≤ αOpt (α ≥ 1)
Maximization problem
For all instances:
ALG ≥ αOpt (α ≤ 1)
Vertex Cover
Instance: Graph G = (V, E)
Solution: I ⊆ V such that each edge has at least one endpoint in I
Cost: The number of vertices in I
Goal: Minimize cost.
2
1
3
4 5
I = {1,3,4}
Cost = 3
Vertex Cover (weighted)
Instance: Graph G = (V, E), and weight wj for all j∈ V
Solution: I ⊆ V such that each edge has at least one endpoint in I
Cost: The total weight of the vertices in I
Goal: Minimize cost.
w2=10
w1=1
w3=1
w4=2 w5=8
I = {1,3,4}
Cost = 1+1+2=4
Algorithm A (for unweighted VC)
Step 1 Find a maximal matching M in G
Step 2 Add all endpoints of M to I.
2
1
3
4 5
I = {1,3,4,5}
Cost = 4
Algorithm A (for unweighted VC)
Theorem Algorithm A is a 2-approximation algorithm
Proof
1. Polynomial running time ✓
2. Feasible.
Assume e is not covered. Then adding e to M increases
the matching. Not possible since M is maximal.
3. Ratio: |I| = 2|M| , |M| ≤ Opt |I| ≤ 2Opt.
Algorithm B: LP-rounding
Algorithm B: LP-rounding
Step 1 Solve LP x*, ZLP*
Step 2 If xj* ≥ 0.5 then take vertex j in solution I.
x1*=1/
2
x3*=1/2 x2*=1/2
x5*=1/2 x4*=1/2
Algorithm B: LP-rounding
Theorem Algorithm B is a 2-approximation algorithm
Proof
1. Polynomial time ✓ (LP’s in poly. time)
2. Feasible ✓
xi*+xj*≥ 1
3. Ratio ✓ x-value’s are at most doubled
i
j
Set Cover
e1
e2
e3 e4
e5
S1,
w1=2
S2,
w2=4
S3,
w3=3
Instance: Elements E={e1,…,en}, subsets Sj ⊆ E, weights wj ≥ 0, j=1..m.
Solution: I ⊆ {1,..,m} such that the subsets Sj (j∈ I) cover all elements
Cost: The weight of solution I
Goal: Minimize cost.
Solution:
I = {1,3}
Cost= 2+3=5
Set Cover
Vertex Cover is the special case of Set Cover in which
each element appears in exactly two sets.
element e3
subset S4
2
1
3
4 5
e1
e2
e3 e6
e4
e5
Set Cover
Thereom Vertex Cover is NP-complete (NP-hard)
Corollary Set Cover is NP-complete (since VC is a special case of SC)
Algorithm 1: LP-rounding
Assume: each element in at most f sets.
Step 1 Solve LP x*, ZLP*
Step 2 If xj* ≥ 1/f then take j (set Sj) in solution I.
Algorithm 1: LP-rounding
Theorem LP-rounding gives an f -approximation
Proof
1. Polynomial time ✓ (LP’s in poly. time)
2. Feasible ✓
xj*+xk*+ xl*≥ 1
3. Ratio ✓
x-value’s are increased by at most a factor f.
ei
Sj Sk
Sl
Algorithm 2: Dual approach
Assume: each element in at most f sets.
Step 1 Solve D y*, ZD*
Step 2 If constraint for Sj is tight (‘=’) then add j to I.
Algorithm 2: Dual approach
Theorem Dual approach gives gives an f -approximation
Proof
1. Polynomial time ✓ (LP’s in poly. time)
2. Feasible ✓
Assume ei not covered. Then: • None of the constraints containing ei is tight
• Dual solution can be improved. Not possible since dual y* is optimal.
3. Ratio ✓
ei
tight in ≤ f sets optimal strong duality
Alg 1 is not worse than Alg 2
Theorem:
Let I1,I2 be solutions by Alg 1 and Alg 2 for some instance.
Then I1⊆ I2.
Proof
Complemantary
slackness
Algorithm 2: Dual approach
Remark: In the proof, optimality of y* is not really needed.
We argued:
1. In an optimal solution y*, each element is in a tight set.
2.
Note that for any feasible solution y,
Enough to find y such that each element is in a tight set. (Alg. 3)
Algorithm 3: Primal-Dual approach
• Start with I = { } and y=0
• For i=1,..,n
Increase yi until some set becomes tight.
• Take all tight sets in the solution.
Theorem Algorithm 3 gives an f-approximation
Proof
1. Time : O(fn)✓
2. Feasible ✓ Each element in a tight set
3. Ratio ✓
Algorithm 4: Greedy
Idea:
Add sets one by one. Each time take the `cheapest’ option.
Algorithm: (Unweighted version: wj=1)
At each step, choose a set with the maximum number of yet
uncovered elements.
Algorithm 4: Greedy
S1
S2 S3
S5
S4
Algorithm 4: Greedy
Theorem
Greedy is an Hn-approximation algorithm. (Hn=1/1+1/2+…+1/n ≈ ln n is n-th Harmonic number)
Note: Ratio depends on n, not on f.
• If f < Hn then Alg. 1,2,3 `better’ than Alg 4
• If f > Hn then Alg. 1,2,3 `worse’ than Alg 4
Algorithm 4: Greedy
Proof
1. Divide total cost over the items:
Cost is |I| = y1+y2+…+yn, where yi is cost for item ei
2. Relabel such that items are covered in order en,en-1..,e1.
Show that yi ≤ Opt/i, for i=1…n.
1+2 Cost ≤ (1/1+1/2+..+1/n)Opt = HnOpt.
Algorithm 4: Greedy
1. Divide total cost over the items:
Algorithm 4: Greedy
1. Divide total cost over the items:
Algorithm 4: Greedy
1. Divide total cost over the items:
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6 1/3
1/3
1/3
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6 1/3
1/3
1/3
1/2 1/2
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6 1/3
1/3
1/3
1/2 1/2
1
Algorithm 4: Greedy
1. Divide total cost over the items:
1/6
1/6
1/6
1/6
1/6
1/6 1/3
1/3
1/3
1/2 1/2
1
Let yi be cost for ei
Algorithm 4: Greedy
Proof
1. Divide total cost over the items:
Cost is |I| = y1+y2+…+yn, where yi is cost for item ei
1. Relabel such that items are covered in order en,en-1..,e1.
Show that yi ≤ Opt/i.
1+2 Cost ≤ (1/1+1/2+..+1/n)Opt = HnOpt.
✓
7
8
9
10
11
Algorithm 4: Greedy
2. Relabel such that items are covered in order en,en-1..,e1.
Show that yi ≤ Opt/i.
12 6
i=5
4
2 3
1
• Let ki be number of uncovered
items just before ei is covered
ki ≥ i
ei
7
8
9
10
11
Algorithm 4: Greedy
2. Relabel such that items are covered in order en,en-1..,e1.
Show that yi ≤ Opt/i.
12
6
5
4
2 3
1
• Let ki be number of uncovered
items just before ei is covered
ki ≥ i
• The ki items can be covered by
at most OPT sets
One of these has at least
ki /OPT uncovered items.
Algorithm 4: Greedy
2. Relabel such that items are covered in order en,en-1..,e1.
Show that yi ≤ Opt/i.
• Let ki be number of uncovered
items just before ei is covered
ki ≥ i
• The ki items can be covered by
at most OPT sets
One of these has at least
ki /OPT uncovered items.
• Greedy picks a set with at least
ki /OPT uncovered items.
yi ≤ OPT/ki ≤ OPT/i
7
8
9
10
11
12
6
5
4
2 3
1
Algorithm 4: Greedy
Idea:
Add sets one by one. Each time take the `cheapest’ option.
Algorithm for weighted Set Cover
At each step, choose a set Sj that has minimum value
Theorem Greedy is an Hn-approximation algorithm
Proof Similar to unweighted version.
w j
# uncovered in S j
Algorithm 5: Randomized LP-rounding
Idea:
Step 1 Solve LP x*, ZLP*
Step 2 Take as rounded solution Xj∈{0,1} where
Pr(Xj=1) = xj* and Pr(Xj=0) = 1-xj*.
The expected value of the solution is
E[Σj wjXj] = Σj E[wjXj] = Σj wjxj* = ZLP*.
But, might be feasible with very small probability
Algorithm 5: Randomized LP-rounding
Would like an algorithm that returns a feasible solution with
high probability:
Pr(feasible) ≥ 1-1/n
Idea: Multiply by large number K.
Step 1 Solve LP x*, ZLP*
Step 2 Take as rounded solution Xj∈{0,1} where
Pr(Xj=1) = min{1,Kxj*}
Algorithm 5: Randomized LP-rounding
Theorem If K=2ln(n) then
1. Pr(feasible) ≥ 1-1/n
2. If solution is feasible, then expected value ≤ 4ln(n)OPT.
Proof
1. Pr(ei not covered) ≤ …. ≤ … ≤ e-K
Pr(at least one ei not covered) ≤ ne-K
Take K=2ln(n) ne-K = nn-2=1/n
Algorithm 5: Randomized LP-rounding
Proof
2. Expected cost
4