Advanced Algorithms (VII) Shanghai Jiao Tong University Chihao - - PowerPoint PPT Presentation

advanced algorithms vii
SMART_READER_LITE
LIVE PREVIEW

Advanced Algorithms (VII) Shanghai Jiao Tong University Chihao - - PowerPoint PPT Presentation

Advanced Algorithms (VII) Shanghai Jiao Tong University Chihao Zhang April 20, 2020 The Probabilistic Method The Probabilistic Method In the class of Combinatorics, you already learnt the probabilistic method The Probabilistic Method In the


slide-1
SLIDE 1

Advanced Algorithms (VII)

Shanghai Jiao Tong University

Chihao Zhang

April 20, 2020

slide-2
SLIDE 2

The Probabilistic Method

slide-3
SLIDE 3

The Probabilistic Method

In the class of Combinatorics, you already learnt the probabilistic method

slide-4
SLIDE 4

The Probabilistic Method

In the class of Combinatorics, you already learnt the probabilistic method

slide-5
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

  • f some object.
slide-6
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

  • f some object.

Sometimes, it is also useful to “find the object”

slide-7
SLIDE 7

Max Cut

slide-8
SLIDE 8

Max Cut

Given an undirected graph , the max cut

  • f

is the partition such that is maximized

G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|

slide-9
SLIDE 9

Max Cut

Given an undirected graph , the max cut

  • f

is the partition such that is maximized

G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|

slide-10
SLIDE 10

Max Cut

Given an undirected graph , the max cut

  • f

is the partition such that is maximized

G = (V, E) G V = S ∪ ¯ S |E(S, ¯ S)|

edge between and

S ¯ S

slide-11
SLIDE 11

Max Cut

Given an undirected graph , the max cut

  • f

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
SLIDE 12

Max Cut

Given an undirected graph , the max cut

  • f

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 13
slide-14
SLIDE 14

We find a partition by tossing a fair coin at each vertex

(S, ¯ S) v

slide-15
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

  • therwise,

put in

v S, v ¯ S

slide-16
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

  • therwise,

put in

v S, v ¯ S

We can compute

slide-17
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

  • therwise,

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
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

  • therwise,

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 19
slide-20
SLIDE 20

Can we turn the existence proof into an algorithm?

slide-21
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
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
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 24
slide-25
SLIDE 25

Let be the probability that our algorithm terminates in one round

p

slide-26
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
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
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 29
slide-30
SLIDE 30

So we obtained a polynomial-time randomized approximation algorithm with approximation ratio 1

2

slide-31
SLIDE 31

So we obtained a polynomial-time randomized approximation algorithm with approximation ratio 1

2

Approximation Ratio of an algorithm A

slide-32
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
SLIDE 33

Derandomization

slide-34
SLIDE 34

Derandomization

Our algorithm can be de-randomized using the method of conditional expectation

slide-35
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
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
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 38
slide-39
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
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
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
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 43
slide-44
SLIDE 44

We can set

  • r

according to which of and is bigger

X1 = 0 X1 = 1 E0 E1

slide-45
SLIDE 45

We can set

  • r

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
SLIDE 46

We can set

  • r

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
SLIDE 47

We can set

  • r

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
SLIDE 48

Max SAT

slide-49
SLIDE 49

Max SAT

The simple “Tossing Coins” strategy can also be applied to the MAXimum SATisfiability problem.

slide-50
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
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 52
slide-53
SLIDE 53

Let us analyze the “tossing fair coins” algorithm

slide-54
SLIDE 54

Let us analyze the “tossing fair coins” algorithm Let be the number of satisfied clauses

X

slide-55
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
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
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 58
slide-59
SLIDE 59

A trivial upper bound is OPT(ϕ) ≤ m

slide-60
SLIDE 60

A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5

slide-61
SLIDE 61

A trivial upper bound is OPT(ϕ) ≤ m So the approximation ratio is 0.5 Can we improve it?

slide-62
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
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
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 65
slide-66
SLIDE 66

If for some , only one of and is in

x ∈ V x ¯ x ϕ

slide-67
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
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
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
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 71
slide-72
SLIDE 72

Assume there are more positive singletons than negative singletons in ϕ

slide-73
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
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
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
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
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
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 79
slide-80
SLIDE 80

E[X] = t + ∑

C∈𝒟′

Pr[C is satisfied] ≥ t + (m − 2t) min{p,1 − p2}

slide-81
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
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
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
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

  • approximation

algorithm

p = 1 − p2 0.618

slide-85
SLIDE 85

Non-identical Coins via LP

slide-86
SLIDE 86

Non-identical Coins via LP

The drawback of previous algorithms is that we toss the same coin for each variable

slide-87
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
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 89
slide-90
SLIDE 90

The Integer Program

slide-91
SLIDE 91

The Integer Program

slide-92
SLIDE 92
  • for each clause

zj Cj

The Integer Program

slide-93
SLIDE 93
  • for each clause

zj Cj

  • for each variable

yi xi

The Integer Program

slide-94
SLIDE 94
  • for each clause

zj Cj

  • for each variable

yi xi

The Integer Program It is NP-hard to solve the IP

slide-95
SLIDE 95

The Linear Program

slide-96
SLIDE 96

The Linear Program

slide-97
SLIDE 97

The Linear Program

  • the optimal

solution of the LP

z* = {z*

j }j∈[m], y* = {y* i }i∈[n]

slide-98
SLIDE 98

The Linear Program

  • the optimal

solution of the LP

z* = {z*

j }j∈[m], y* = {y* i }i∈[n]

We toss

  • coin for the variable !

y*

i

xi

slide-99
SLIDE 99

The Linear Program OPT(ϕ) ≤ OPT(LP) =

m

j=1

z*

j

  • the optimal

solution of the LP

z* = {z*

j }j∈[m], y* = {y* i }i∈[n]

We toss

  • coin for the variable !

y*

i

xi

slide-100
SLIDE 100
slide-101
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
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 103
slide-104
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
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
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