SLIDE 1 Advanced Algorithms (VII)
Shanghai Jiao Tong University
Chihao Zhang
April 20, 2020
SLIDE 2
The Probabilistic Method
SLIDE 3
The Probabilistic Method
In the class of Combinatorics, you already learnt the probabilistic method
SLIDE 4
The Probabilistic Method
In the class of Combinatorics, you already learnt the probabilistic method
SLIDE 5 The Probabilistic Method
In the class of Combinatorics, you already learnt the probabilistic method This is an important technique to prove the existence
SLIDE 6 The Probabilistic Method
In the class of Combinatorics, you already learnt the probabilistic method This is an important technique to prove the existence
Sometimes, it is also useful to “find the object”
SLIDE 7
Max Cut
SLIDE 8 Max Cut
Given an undirected graph , the max cut
is the partition such that is maximized
G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|
SLIDE 9 Max Cut
Given an undirected graph , the max cut
is the partition such that is maximized
G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|
SLIDE 10 Max Cut
Given an undirected graph , the max cut
is the partition such that is maximized
G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|
edge between and
S ¯ S
SLIDE 11 Max Cut
Given an undirected graph , the max cut
is the partition such that is maximized
G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|
edge between and
S ¯ S
It is NP-hard to determine the max cut exactly
SLIDE 12 Max Cut
Given an undirected graph , the max cut
is the partition such that is maximized
G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|
edge between and
S ¯ S
It is NP-hard to determine the max cut exactly On the other hand, each graph contains a cut of size at least |E|
2
SLIDE 13
SLIDE 14
We find a partition by tossing a fair coin at each vertex
(S, ¯ S) v
SLIDE 15 We find a partition by tossing a fair coin at each vertex
(S, ¯ S) v
If the coin gives HEAD, we put in
put in
v S, v ¯ S
SLIDE 16 We find a partition by tossing a fair coin at each vertex
(S, ¯ S) v
If the coin gives HEAD, we put in
put in
v S, v ¯ S
We can compute
SLIDE 17 We find a partition by tossing a fair coin at each vertex
(S, ¯ S) v
If the coin gives HEAD, we put in
put in
v S, v ¯ S
We can compute E[|E(S, ¯ S)|] = ∑
e∈E
Pr[e is in the cut] = |E| 2 .
SLIDE 18 We find a partition by tossing a fair coin at each vertex
(S, ¯ S) v
If the coin gives HEAD, we put in
put in
v S, v ¯ S
We can compute E[|E(S, ¯ S)|] = ∑
e∈E
Pr[e is in the cut] = |E| 2 . So there exists a cut of size at least |E|
2
SLIDE 19
SLIDE 20
Can we turn the existence proof into an algorithm?
SLIDE 21
Can we turn the existence proof into an algorithm? The following straightforward strategy turns the argument into a Las-Vegas algorithms
SLIDE 22
Can we turn the existence proof into an algorithm? The following straightforward strategy turns the argument into a Las-Vegas algorithms “Repeat tossing coins until ”
|E(S, ¯ S)| ≥ |E| 2
SLIDE 23
Can we turn the existence proof into an algorithm? The following straightforward strategy turns the argument into a Las-Vegas algorithms “Repeat tossing coins until ”
|E(S, ¯ S)| ≥ |E| 2
We know , so what is the expected running time of the algorithm?
E[|E(S, ¯ S)|] = |E| 2
SLIDE 24
SLIDE 25
Let be the probability that our algorithm terminates in one round
p
SLIDE 26
Let be the probability that our algorithm terminates in one round
p
Namely where . Then
p = Pr [|E(S, ¯ S)| ≥ m 2 ] m = |E|
SLIDE 27 Let be the probability that our algorithm terminates in one round
p
Namely where . Then
p = Pr [|E(S, ¯ S)| ≥ m 2 ] m = |E|
m 2 = E[|E(S, ¯ S)|] =
m
∑
i=0
i ⋅ Pr[|E(S, ¯ S)| = i] ≤ ( m 2 − 1)(1 − p) + pm
SLIDE 28 Let be the probability that our algorithm terminates in one round
p
Namely where . Then
p = Pr [|E(S, ¯ S)| ≥ m 2 ] m = |E|
m 2 = E[|E(S, ¯ S)|] =
m
∑
i=0
i ⋅ Pr[|E(S, ¯ S)| = i] ≤ ( m 2 − 1)(1 − p) + pm So p ≥
2 m + 2
SLIDE 29
SLIDE 30
So we obtained a polynomial-time randomized approximation algorithm with approximation ratio 1
2
SLIDE 31
So we obtained a polynomial-time randomized approximation algorithm with approximation ratio 1
2
Approximation Ratio of an algorithm A
SLIDE 32 So we obtained a polynomial-time randomized approximation algorithm with approximation ratio 1
2
Approximation Ratio of an algorithm A for maximization problem: α(A) = min
G
A(G) OPT(G) for minimization problem: α(A) = max
G
A(G) OPT(G)
SLIDE 33
Derandomization
SLIDE 34
Derandomization
Our algorithm can be de-randomized using the method of conditional expectation
SLIDE 35
Derandomization
Our algorithm can be de-randomized using the method of conditional expectation Fix an order of vertices {v1, v2, …, vn}
SLIDE 36
Derandomization
Our algorithm can be de-randomized using the method of conditional expectation Fix an order of vertices {v1, v2, …, vn} Let the coins be X1, X2, …, Xn
SLIDE 37
Derandomization
Our algorithm can be de-randomized using the method of conditional expectation Fix an order of vertices {v1, v2, …, vn} Let the coins be X1, X2, …, Xn We will decompose using conditional expectation
E[|E(S, ¯ S)|]
SLIDE 38
SLIDE 39
E[|E(S, ¯ S)|] = E[E[|E(S, ¯ S)||X1, X2, …, Xn]] = 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 0, X2, …, Xn]] + 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 1, X2, …, Xn]] = 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 0]] + 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 1]]
SLIDE 40 E[|E(S, ¯ S)|] = E[E[|E(S, ¯ S)||X1, X2, …, Xn]] = 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 0, X2, …, Xn]] + 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 1, X2, …, Xn]] = 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 0]] + 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 1]]
E0
||
E1
||
SLIDE 41 E[|E(S, ¯ S)|] = E[E[|E(S, ¯ S)||X1, X2, …, Xn]] = 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 0, X2, …, Xn]] + 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 1, X2, …, Xn]] = 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 0]] + 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 1]]
E0
||
E1
||
So we know at least one of and holds
E0 ≥ m 2 E1 ≥ m 2
SLIDE 42 E[|E(S, ¯ S)|] = E[E[|E(S, ¯ S)||X1, X2, …, Xn]] = 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 0, X2, …, Xn]] + 1 2 ⋅ E[E[|E(S, ¯ S)| ∣ X1 = 1, X2, …, Xn]] = 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 0]] + 1 2 ⋅ E[|E(S, ¯ S)| ∣ X1 = 1]]
E0
||
E1
||
So we know at least one of and holds
E0 ≥ m 2 E1 ≥ m 2
Moreover, both and can be efficiently computed
E0 E1
SLIDE 43
SLIDE 44 We can set
according to which of and is bigger
X1 = 0 X1 = 1 E0 E1
SLIDE 45 We can set
according to which of and is bigger
X1 = 0 X1 = 1 E0 E1
The argument can proceed until is revealed, deterministically!
(S, ¯ S)
SLIDE 46 We can set
according to which of and is bigger
X1 = 0 X1 = 1 E0 E1
The argument can proceed until is revealed, deterministically!
(S, ¯ S)
In fact, the “derandomized algorithm” is equivalent to a simple greedy strategy
SLIDE 47 We can set
according to which of and is bigger
X1 = 0 X1 = 1 E0 E1
The argument can proceed until is revealed, deterministically!
(S, ¯ S)
In fact, the “derandomized algorithm” is equivalent to a simple greedy strategy We obtained the approximation ratio of the greedy algorithm as a byproduct
SLIDE 48
Max SAT
SLIDE 49
Max SAT
The simple “Tossing Coins” strategy can also be applied to the MAXimum SATisfiability problem.
SLIDE 50
Max SAT
The simple “Tossing Coins” strategy can also be applied to the MAXimum SATisfiability problem. MaxSAT Input: A CNF formula Problem: Compute an assignment that satisfies maximum number of clauses
ϕ = C1 ∧ C2⋯ ∧ Cm
SLIDE 51
Max SAT
The simple “Tossing Coins” strategy can also be applied to the MAXimum SATisfiability problem. MaxSAT Input: A CNF formula Problem: Compute an assignment that satisfies maximum number of clauses
ϕ = C1 ∧ C2⋯ ∧ Cm
Formula , variables ,
ϕ V = {x1, …, xn} |Ci| = ℓi ≥ 1
SLIDE 52
SLIDE 53
Let us analyze the “tossing fair coins” algorithm
SLIDE 54
Let us analyze the “tossing fair coins” algorithm Let be the number of satisfied clauses
X
SLIDE 55 Let us analyze the “tossing fair coins” algorithm Let be the number of satisfied clauses
X
E[X] =
m
∑
i=1
Pr[Ci is satisfied] =
m
∑
i=1
(1 − 2−ℓi) ≥ m 2
SLIDE 56 Let us analyze the “tossing fair coins” algorithm Let be the number of satisfied clauses
X
E[X] =
m
∑
i=1
Pr[Ci is satisfied] =
m
∑
i=1
(1 − 2−ℓi) ≥ m 2 Recall
SLIDE 57 Let us analyze the “tossing fair coins” algorithm Let be the number of satisfied clauses
X
E[X] =
m
∑
i=1
Pr[Ci is satisfied] =
m
∑
i=1
(1 − 2−ℓi) ≥ m 2 Recall To bound the approximation ratio, we need an upper bound for OPT(ϕ)
SLIDE 58
SLIDE 59
A trivial upper bound is OPT(ϕ) ≤ m
SLIDE 60
A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5
SLIDE 61
A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5 Can we improve it?
SLIDE 62
A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5 Can we improve it? In the analysis
SLIDE 63
A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5 Can we improve it? In the analysis we use ℓi ≥ 1
SLIDE 64
A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5 Can we improve it? In the analysis we use ℓi ≥ 1 In fact, we can tweak those singleton clauses
SLIDE 65
SLIDE 66
If for some , only one of and is in
x ∈ V x ¯ x ϕ
SLIDE 67 If for some , only one of and is in
x ∈ V x ¯ x ϕ
- we can toss an unfair coin to increase its
chance to be satisfied
SLIDE 68 If for some , only one of and is in
x ∈ V x ¯ x ϕ
- we can toss an unfair coin to increase its
chance to be satisfied If both and are in ,
x ¯ x ϕ
SLIDE 69 If for some , only one of and is in
x ∈ V x ¯ x ϕ
- we can toss an unfair coin to increase its
chance to be satisfied If both and are in ,
x ¯ x ϕ
- only one of them can be satisfied in any
assignment!
SLIDE 70 If for some , only one of and is in
x ∈ V x ¯ x ϕ
- we can toss an unfair coin to increase its
chance to be satisfied If both and are in ,
x ¯ x ϕ
- only one of them can be satisfied in any
assignment! Both cases are good for us!
SLIDE 71
SLIDE 72
Assume there are more positive singletons than negative singletons in ϕ
SLIDE 73
Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
SLIDE 74
Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
Then OPT(ϕ) ≤ m − t
SLIDE 75
Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
Then OPT(ϕ) ≤ m − t Let be the set of clauses and
𝒟
SLIDE 76
Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
Then OPT(ϕ) ≤ m − t Let be the set of clauses and
𝒟
𝒟′ = 𝒟∖{singleton x and ¯ x with x ∈ S}
SLIDE 77
Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
Then OPT(ϕ) ≤ m − t Let be the set of clauses and
𝒟
𝒟′ = 𝒟∖{singleton x and ¯ x with x ∈ S} For all , change it to
¯ x ∈ 𝒟′ x
SLIDE 78 Assume there are more positive singletons than negative singletons in ϕ Let and
S = {x ∈ V : both x and ¯ x are clauses} t = |S|
Then OPT(ϕ) ≤ m − t Let be the set of clauses and
𝒟
𝒟′ = 𝒟∖{singleton x and ¯ x with x ∈ S} For all , change it to
¯ x ∈ 𝒟′ x
Switch the positive and the negative for all appearance of x
SLIDE 79
SLIDE 80 E[X] = t + ∑
C∈𝒟′
Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}
SLIDE 81 E[X] = t + ∑
C∈𝒟′
Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}
The term is because the worst case now is either a positive singleton or
min{p,1 − p2} x ¯ y ∨ ¯ z
SLIDE 82 E[X] = t + ∑
C∈𝒟′
Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}
The term is because the worst case now is either a positive singleton or
min{p,1 − p2} x ¯ y ∨ ¯ z
Therefore
SLIDE 83 E[X] = t + ∑
C∈𝒟′
Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}
The term is because the worst case now is either a positive singleton or
min{p,1 − p2} x ¯ y ∨ ¯ z
Therefore E[X] ≥ t + (OPT − t) min{p,1 − p2} ≥ min{p,1 − p2} ⋅ OPT
SLIDE 84 E[X] = t + ∑
C∈𝒟′
Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}
The term is because the worst case now is either a positive singleton or
min{p,1 − p2} x ¯ y ∨ ¯ z
Therefore E[X] ≥ t + (OPT − t) min{p,1 − p2} ≥ min{p,1 − p2} ⋅ OPT For , we have a
algorithm
p = 1 − p2 0.618
SLIDE 85
Non-identical Coins via LP
SLIDE 86
Non-identical Coins via LP
The drawback of previous algorithms is that we toss the same coin for each variable
SLIDE 87
Non-identical Coins via LP
The drawback of previous algorithms is that we toss the same coin for each variable The linear programming can helps us to choose coins!
SLIDE 88
Non-identical Coins via LP
The drawback of previous algorithms is that we toss the same coin for each variable The linear programming can helps us to choose coins! We first treat MaxSAT problem as an integer programming
SLIDE 89
SLIDE 90
The Integer Program
SLIDE 91
The Integer Program
SLIDE 92
zj Cj
The Integer Program
SLIDE 93
zj Cj
yi xi
The Integer Program
SLIDE 94
zj Cj
yi xi
The Integer Program It is NP-hard to solve the IP
SLIDE 95
The Linear Program
SLIDE 96
The Linear Program
SLIDE 97 The Linear Program
solution of the LP
z* = {z*
j }j∈[m], y* = {y* i }i∈[n]
SLIDE 98 The Linear Program
solution of the LP
z* = {z*
j }j∈[m], y* = {y* i }i∈[n]
We toss
y*
i
xi
SLIDE 99 The Linear Program OPT(ϕ) ≤ OPT(LP) =
m
∑
j=1
z*
j
solution of the LP
z* = {z*
j }j∈[m], y* = {y* i }i∈[n]
We toss
y*
i
xi
SLIDE 100
SLIDE 101 Pr[Cj is not satisfied] = ∏
i∈Pj
(1 − y*
i ) ∏ k∈Nj
y*
k
≤ 1 ℓj ∑
i∈Pj
(1 − y*
i ) + ∑ k∈Nj
y*
k ℓj
= 1 ℓj ℓj − ∑
i∈Pj
y*
i + ∑ k∈Nj
(1 − y*
k ) ℓj
≤ (1 − z*
j
ℓj )
ℓj
.
SLIDE 102 Pr[Cj is not satisfied] = ∏
i∈Pj
(1 − y*
i ) ∏ k∈Nj
y*
k
≤ 1 ℓj ∑
i∈Pj
(1 − y*
i ) + ∑ k∈Nj
y*
k ℓj
= 1 ℓj ℓj − ∑
i∈Pj
y*
i + ∑ k∈Nj
(1 − y*
k ) ℓj
≤ (1 − z*
j
ℓj )
ℓj
.
AM-GM
SLIDE 103
SLIDE 104 E[X] =
m
∑
j=1
Pr[Cj is satisfied] ≥
m
∑
j=1
1 − (1 − z*
j
ℓj )
ℓj
≥
m
∑
j=1
1 − (1 − 1 ℓj)
ℓj
z*
j
≥ (1 − e−1)
m
∑
j=1
z*
j ≥ (1 − 1
e ) OPT
SLIDE 105 E[X] =
m
∑
j=1
Pr[Cj is satisfied] ≥
m
∑
j=1
1 − (1 − z*
j
ℓj )
ℓj
≥
m
∑
j=1
1 − (1 − 1 ℓj)
ℓj
z*
j
≥ (1 − e−1)
m
∑
j=1
z*
j ≥ (1 − 1
e ) OPT
Concavity
SLIDE 106 E[X] =
m
∑
j=1
Pr[Cj is satisfied] ≥
m
∑
j=1
1 − (1 − z*
j
ℓj )
ℓj
≥
m
∑
j=1
1 − (1 − 1 ℓj)
ℓj
z*
j
≥ (1 − e−1)
m
∑
j=1
z*
j ≥ (1 − 1
e ) OPT
Concavity
≈ 0.632