Vertex Cover - Linear Progamming and Approximation...
Transcript of Vertex Cover - Linear Progamming and Approximation...
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Vertex CoverLinear Progamming and Approximation Algorithms
Joshua Wetzel
Department of Computer ScienceRutgers University–Camden
March 24, 2009
Joshua Wetzel Vertex Cover 1 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
What is Linear Programming?
Optimize a linear objective fn subject to linear constraints.
Examples:
min 7x1 + x2 + 3x3
s.t.
x1 − x2 + 3x3 ≥ 10
5x1 + 2x2 − x3 ≥ 6
x1, x2, x3 ≥ 0
max 6x1 + 2x2 − 4x3
s.t.
5x1 + x2 − 2x3 ≤ 14
2x1 − 2x2 + 4x3 ≤ 20
x1, x2, x3 ≥ 0
Joshua Wetzel Vertex Cover 2 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Feasible Solutions: Upper Bounding OPT
Linear Program:
min 7x1 + x2 + 3x3
s.t.
x1 − x2 + 3x3 ≥ 10
5x1 + 2x2 − x3 ≥ 6
x1, x2, x3 ≥ 0
Feasible Solutions:x1 = 2, x2 = 1, x3 = 4
7(2) + 1(1) + 5(4) = 35
x1 = 85 , x2 = 1
2 , x3 = 3
7(85) + 1(1
2) + 5(3) = 26.7
All constraints are satisfied.
OPT ≤ 35, OPT ≤ 26.7
Joshua Wetzel Vertex Cover 3 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Finding a Lower Bound on OPT
Linear Program:
min 7x1 + x2 + 3x3
s.t.
x1 − x2 + 3x3 ≥ 10
5x1 + 2x2 − x3 ≥ 6
x1, x2, x3 ≥ 0
OPT ≥ ?
Joshua Wetzel Vertex Cover 4 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Lower Bounding OPT: Adding the Constraints
min 7x1 + x2 + 3x3
s.t.
x1 − x2 + 3x3 ≥ 10
+ 5x1 + 2x2 − x3 ≥ 6
6x1 + x2 + 2x3 ≥ 16
OPT ≥ 16
Joshua Wetzel Vertex Cover 5 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Lower Bounding OPT
min 7x1 + x2 + 3x3
s.t. x1 − x2 + 3x3 ≥ 10 (y1)
+ 5x1 + 2x2 − x3 ≥ 6 (y2)
x1( y1 + 5y2 ) + x2( −y1 + 2y2 ) + x3( 3y1 − y2 ) ≥ 10y1 + 6y2
10y1 + 6y2 is a lower bound on OPT if:
y1 + 5y2 ≤ 7
−y1 + 2y2 ≤ 1
3y1 − y2 ≤ 3
Joshua Wetzel Vertex Cover 6 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP to Lower Bound OPT
max 10y1 + 6y2
s.t.
y1 + 5y2 ≤ 7
−y1 + 2y2 ≤ 1
3y1 − y2 ≤ 3
y1, y2 ≥ 0
Joshua Wetzel Vertex Cover 7 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Primal LP and Dual LP
Primal LP:
min 7x1 + x2 + 3x3
s.t. x1 − x2 + 3x3 ≥ 10
5x1 + 2x2 − x3 ≥ 6
x1, x2, x3 ≥ 0
Dual LP:
max 10y1 + 6y2
s.t. y1 + 5y2 ≤ 7
−y1 + 2y2 ≤ 1
3y1 − y2 ≤ 3
y1, y2 ≥ 0
Every primal LP has a corresponding dual LP.
If the primal is a min problem, the dual is a max problem.
There is a dual constraint corresponding to each primalvariable.
Joshua Wetzel Vertex Cover 8 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP Duality Theorems
DualFeasible ≤ DualOPT = PrimalOPT ≤ PrimalFeasible
The Primal LP:
min 7x1 + x2 + 3x3
s.t. x1 − x2 + 3x3 ≥ 10
5x1 + 2x2 − x3 ≥ 6
x1, x2, x3 ≥ 0
The Dual LP:
max 10y1 + 6y2
s.t. y1 + 5y2 ≤ 7
−y1 + 2y2 ≤ 1
3y1 − y2 ≤ 3
y1, y2 ≥ 0
Joshua Wetzel Vertex Cover 9 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Vertex Cover
Input:Given G = (V , E)Non-negative weights on vertices
Objective:Find a least-weight collection of vertices such that eachedge in G in incident on at least one vertex in the collection.
Joshua Wetzel Vertex Cover 10 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Vertex Cover: Example
24
15
50
30
12
10
18
6
COST = 97
24
15
50
30
10
18
6
12
COST = 108
Joshua Wetzel Vertex Cover 11 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Approximation Algorithms
NP-hard problems.No optimal poly-time algorithms are known
β-approximation alg., A, for a minimization problem Ppoly-time algorithm.for every instance I of P, A produces solution of cost atmost β ·OPT (I)OPT (I)?
Joshua Wetzel Vertex Cover 12 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Approximation Algorithms
compute a lower bound on OPT .
compare cost of our solution with the lower bound.
lowerbound
OPT upperbound
β
Joshua Wetzel Vertex Cover 13 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Vertex Cover
Input:Given G = (V , E)Non-negative weights on vertices
Objective:Find a least-weight collection of vertices such that eachedge in G in incident on at least one vertex in the collection
Joshua Wetzel Vertex Cover 14 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Algorithm
Find a maximal matching in G
Include in our cover both vertices incident on each edge ofthe matching
Joshua Wetzel Vertex Cover 15 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Example
11
1
1
1
1
1
1
Joshua Wetzel Vertex Cover 16 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Example
1
1
1
1
1
1
1
1
Joshua Wetzel Vertex Cover 17 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Example
1
1
1
1
1
1
1
1
Joshua Wetzel Vertex Cover 18 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Example
1
1
1
1
1
1
1
1
Cost = 6
Joshua Wetzel Vertex Cover 19 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Analysis: Feasibility
1
1
1
1
1
1
1
1
Every black edge shares a vertex with a green edge
Joshua Wetzel Vertex Cover 20 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Analysis: Approximation Guarantee
1
1
1
1
1
1
1
1
OPT has to choose atleast one endpoint fromeach green edge.
We choose both endpointsfor each green edge.
Hence:
Our Cost ≤ 2OPT
Joshua Wetzel Vertex Cover 21 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Unweighted Vertex Cover: Tight Example
1
1
1
1
1
1
1
1
OPT = 3
1
1
1
1
1
1
1
1
COSTAlg = 6
Joshua Wetzel Vertex Cover 22 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bad Example
200 1 200
OPT = 1
200 1 200
CostAlg = 201
Joshua Wetzel Vertex Cover 23 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Vertex Cover: IP Formulation
xv ← 1 if v is in our cover, 0 otherwise
min∑
v∈V
wvxv
s.t.
xa + xb ≥ 1, ∀ e = (a, b)
xv ∈ {0, 1}, ∀ v ∈ V
Joshua Wetzel Vertex Cover 24 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP Relaxation
Integer programs have been shown to be NP-hard
Relax the integrality constraints xv ∈ {0, 1}, ∀ v ∈ V
min∑
v∈V
wvxv
s.t.
xa + xb ≥ 1, ∀ e = (a, b)
xv ≥ 0, ∀ v ∈ V
Joshua Wetzel Vertex Cover 25 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Why Do This?
LP can be solved in polynomial time
Every solution to the IP is also a solution to the LP
Hence:
OPTLP ≤ OPTIP
We can use OPTLP as a lower bound on OPTIP
Joshua Wetzel Vertex Cover 26 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP Solution: Example
xa + xb ≥ 1, ∀ e = (a, b)
xv ≥ 0, ∀ v ∈ V
1/2 1/2
1/2
OPTLP = 1.5
xa + xb ≥ 1, ∀ e = (a, b)
xv ∈ {0, 1}, ∀ v ∈ V
1
1 0
OPTIP = 2
Joshua Wetzel Vertex Cover 27 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP-Rounding Algorithm
x∗ ← optimal LP soln.
x̂v ← 1 if x∗
v ≥12 , otherwise x̂v ← 0
Include v in our cover iff x̂v = 1
Joshua Wetzel Vertex Cover 28 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Analysis: Feasibility
min∑
v∈V
wvxv
s.t.
xa + xb ≥ 1, ∀ e = (a, b)
xv ≥ 0, ∀ v ∈ V
x∗
a ≥12
or x∗
b ≥12
x̂a = 1 or x̂b = 1
Joshua Wetzel Vertex Cover 29 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Analysis: Approximation Guarantee
Our Cost =∑
v∈C
wv =∑
v∈V
wv x̂v
≤∑
v∈V
wv (2x∗
v )
= 2∑
v∈V
wvx∗
v
= 2OPTLP
≤ 2OPTIP
Joshua Wetzel Vertex Cover 30 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
LP-Rounding: Tight Example
1/2 1/2
1/2
OPTLP = 1.5
1
1 1
Our Cost = 3
Joshua Wetzel Vertex Cover 31 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Primal-Dual Method
PrimalOPT ≤ OPTIP
Solving the LP is expensive.
DualFeasible ≤ DualOPT = PrimalOPT ≤ PrimalFeasible
Better Alternative:Construct the dual LPConstruct an algorithm that manually tightens dualconstraints to obtain a ’maximal’ dual solution
Joshua Wetzel Vertex Cover 32 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Constructing the Dual LP
Primal LP:
min∑
v∈V
wvxv
s.t.
xa + xb ≥ 1, ∀ e = (a, b) (ye)
xv ≥ 0, ∀ v ∈ V
Joshua Wetzel Vertex Cover 33 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Primal LP and Dual LP
Primal LP:
min∑
v∈V
wvxv
s.t.
xa + xb ≥ 1, ∀ e = (a, b)
xv ≥ 0, ∀ v ∈ V
Dual LP:
max∑
e∈E
ye
s.t. ∑
e : e hits v
ye ≤ wv , ∀ v ∈ V
ye ≥ 0, ∀ e ∈ E
Joshua Wetzel Vertex Cover 34 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm
Inititally all edges are uncovered.While ∃ an uncovered edge in G:
Choose an arbitrary edge, eRaise the value of ye for that edge until one of its incidentvertices , v , becomes full (i.e
∑e:e hits v
ye = wv )
C ← C ∪ {v}Any edge that touches v is considered to be covered
Return C as our vertex cover
Joshua Wetzel Vertex Cover 35 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example
24
15
50
30
12
10
18
00
0
00
0
0
0
0
0
6
Joshua Wetzel Vertex Cover 36 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
00
0
00
0
0
0
0
0
6
Arbitrarily choose e and raise ye until a vertex is fullJoshua Wetzel Vertex Cover 37 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
0
0
0
6
Joshua Wetzel Vertex Cover 38 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
0
0
0
6
Joshua Wetzel Vertex Cover 39 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
15
0
0
6
Joshua Wetzel Vertex Cover 40 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
15
0
0
6
Joshua Wetzel Vertex Cover 41 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
15
0
18
6
Joshua Wetzel Vertex Cover 42 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
12
10
18
60
0
00
0
0
15
0
18
6
Joshua Wetzel Vertex Cover 43 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
10
18
60
0
012
0
0
15
0
18
6
12
Joshua Wetzel Vertex Cover 44 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
10
18
60
0
012
0
0
15
0
18
6
12
Joshua Wetzel Vertex Cover 45 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example∑
e:e hits v
ye ≤ wv
24
15
50
30
10
18
60
0
012
0
0
15
17
18
6
12
Joshua Wetzel Vertex Cover 46 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Example
24
15
50
30
10
18
60
0
012
0
0
15
17
18
6
12
Cost = 107
Joshua Wetzel Vertex Cover 47 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Analysis
24
15
50
30
10
18
60
0
012
0
0
15
17
18
6
12
∑
e:e hits v
ye ≤ wv
Dual Obj. Fn:
max∑
e
ye
Our Cost = wt(red vertices)
≤ 2∑
e hits red
ye
≤ 2∑
e
ye
= 2DFS
≤ 2OPT
Joshua Wetzel Vertex Cover 48 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Bar-Yehuda and Even Algorithm: Tight Example
1 1
1
11
1 6
COSTOPT = 6
1 1
1
11
1 61
11
1
1 1
COSTBar-Yehuda = 12
Joshua Wetzel Vertex Cover 49 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Integrality Gap
1/2 1/2
1/2
OPTLP = 1.5
1
1 0
OPTIP = 2
For a complete graph of n vertices
OPTLP = n/2
OPTIP = n − 1
limn→∞
OPTIPOPTLP
= limn→∞
n−1(n/2) = 2
Joshua Wetzel Vertex Cover 50 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Reference
R. Bar-Yehuda and S. Even. A linear time approximationalgorithm for the weighted vertex cover problem. J. ofAlgorithms 2:198-203, 1981.
Joshua Wetzel Vertex Cover 51 / 52
Linear Programming TheoryVertex CoverLP-Rounding
Primal-Dual
Thank You.
Joshua Wetzel Vertex Cover 52 / 52