• Nem Talált Eredményt

Minicourse on parameterized algorithms and complexity Part 3: Randomized techniques

N/A
N/A
Protected

Academic year: 2022

Ossza meg "Minicourse on parameterized algorithms and complexity Part 3: Randomized techniques"

Copied!
40
0
0

Teljes szövegt

(1)

Minicourse on parameterized algorithms and complexity Part 3: Randomized techniques

Dániel Marx

November 3, 2016

(2)

Why randomized?

A guaranteed error probability of10−100 is as good as a deterministic algorithm.

(Probability of hardware failure is larger!)

Randomized algorithms can be more efficient and/or conceptually simpler.

Can be the first step towards a deterministic algorithm.

(3)

Polynomial-time vs. FPT randomization

Polynomial-time randomized algorithms

Randomized selection to pick a typical,unproblematic, average element/subset.

Success probability is constant or at most polynomially small.

Randomized FPT algorithms

Randomized selection to satisfy a bounded numberof (unknown) constraints.

Success probability might be exponentially small.

(4)

Randomization

There are two main ways randomization appears:

Algebraic techniques Schwartz-Zippel Lemma Linear matroids

This lecture: combinatorial techniques.

(5)

Randomization as reduction

Problem A

(what we want to solve)

Randomized magic

Problem B

(what we can solve)

(6)

Color Coding

k-Path

Input: A graphG, integer k.

Find: A simple path of lengthk.

Note: The problem is clearly NP-hard, as it contains the Hamiltonian Pathproblem.

Theorem[Alon, Yuster, Zwick 1994]

k-Path can be solved in time2O(k)·nO(1).

(7)

Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

Check if there is a path colored 1−2− · · · −k; output “YES” or “NO”.

If there is nok-path: no path colored12− · · · −k exists

“NO”.

If there is ak-path: the probability that such a path is colored 12− · · · −k isk−k thus the algorithm outputs “YES” with at least that probability.

(8)

Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

2 4 5 4 4

3 3 2

2 1

Check if there is a path colored 1−2− · · · −k; output “YES” or “NO”.

If there is nok-path: no path colored12− · · · −k exists

“NO”.

If there is ak-path: the probability that such a path is colored 12− · · · −k isk−k thus the algorithm outputs “YES” with at least that probability.

(9)

Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

2 4 4

3

5 4

3 2

2 1

Check if there is a path colored 1−2− · · · −k; output “YES”

or “NO”.

If there is nok-path: no path colored12− · · · −k exists

“NO”.

If there is ak-path: the probability that such a path is colored 12− · · · −k isk−k thus the algorithm outputs “YES” with at least that probability.

(10)

Error probability

Useful fact

If the probability of success is at leastp, then the probability that the algorithmdoes notsay “YES” after1/p repetitions is at most

(1−p)1/p < e−p1/p

=1/e≈0.38

Thus if p >k−k, then error probability is at most 1/e afterkk repetitions.

Repeating the whole algorithm a constant number of times can make the error probability an arbitrary small constant. For example, by trying 100·kk random colorings, the probability of a wrong answer is at most 1/e100.

(11)

Error probability

Useful fact

If the probability of success is at leastp, then the probability that the algorithmdoes notsay “YES” after1/p repetitions is at most

(1−p)1/p < e−p1/p

=1/e≈0.38

Thus if p>k−k, then error probability is at most 1/e afterkk repetitions.

Repeating the whole algorithm a constant number of times can make the error probability an arbitrary small constant.

For example, by trying 100·kk random colorings, the probability of a wrong answer is at most 1/e100.

(12)

Finding a path colored 1 − 2 − · · · − k

2 2

5 5 5 5 4 3 3 3 3 2 22 1 1 1 1

4 4

4

Edges connecting nonadjacent color classes are removed.

The remaining edges are directed towards the larger class.

All we need to check if there is a directed path from class 1to class k.

(13)

Finding a path colored 1 − 2 − · · · − k

2 2

5 5 5 5 4 3 3 3 3 2 22 1 1 1 1

4 4

4

Edges connecting nonadjacent color classes are removed.

The remaining edges are directed towards the larger class.

All we need to check if there is a directed path from class 1to class k.

(14)

Finding a path colored 1 − 2 − · · · − k

2 2

5 5 5 5 4 3 3 3 3 2 22 1 1 1 1

4 4

4

Edges connecting nonadjacent color classes are removed.

The remaining edges are directed towards the larger class.

All we need to check if there is a directed path from class 1to class k.

(15)

Finding a path colored 1 − 2 − · · · − k

2 2

5 5 5 5 4 3 3 3 3 2 22 1 1 1 1

4 4

4

Edges connecting nonadjacent color classes are removed.

The remaining edges are directed towards the larger class.

All we need to check if there is a directed path from class 1to class k.

(16)

Finding a path colored 1 − 2 − · · · − k

2 2

5 5 5 5 4 3 3 3 3 2 22 1 1 1 1

4 4

4

Edges connecting nonadjacent color classes are removed.

The remaining edges are directed towards the larger class.

All we need to check if there is a directed path from class 1to class k.

(17)

Color Coding

k-PATH

Color Coding success probability:

k−k Finding a 1−2− · · · −k

colored path

polynomial-time solvable

(18)

Improved Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

2 4 5 4 4

3 3 2

2 1

Check if there is acolorful path where each color appears exactly once on the vertices; output “YES” or “NO”.

(19)

Improved Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

2 4 5 4 4

3 3 2

2 1

Check if there is acolorful path where each color appears exactly once on the vertices; output “YES” or “NO”.

If there is nok-path: nocolorfulpath exists“NO”.

If there is ak-path: the probability that it is colorfulis

k!

kk >(ke)k

kk =e−k,

thus the algorithm outputs “YES” with at least that probability.

(20)

Improved Color Coding

Assign colors from[k]to vertices V(G)uniformly and independently at random.

2 4 5 4 4

3 3 2

2 1

Repeating the algorithm 100ek times decreases the error probability to e−100.

How to find a colorful path?

Try all permutations (k!·nO(1) time) Dynamic programming (2k·nO(1) time)

(21)

Finding a colorful path

Subproblems:

We introduce2k· |V(G)|Boolean variables:

x(v,C) =TRUE for some v ∈V(G) andC ⊆[k] m

There is a pathP ending at v such that each color in C appears on P exactly once and no other color

appears.

Answer:

There is a colorful path ⇐⇒ x(v,[k]) =TRUE for some vertex v.

Initialization & Recurrence:

Exercise.

(22)

Improved Color Coding

k-PATH

Color Coding success probability:

e−k

Finding a colorful path

Solvable in time 2k·nO(1)

(23)

Derandomization

Definition

A familyHof functions [n]→[k]is a k-perfectfamily of hash functions if for everyS ⊆[n]with |S|=k, there is anh ∈ H such thath(x)6=h(y)for any x,y ∈S,x 6=y.

Theorem[Alon, Yuster, Zwick 1994]

There is ak-perfect family of functions [n]→[k]having size 2O(k)logn (and can be constructed in time polynomial in the size of the family).

Instead of trying O(ek) random colorings,we go through a k-perfect family H of functionsV(G)→[k].

If there is a solutionS

⇒The vertices of S are colorful for at least one h∈ H

⇒Algorithm outputs “YES”.

⇒k-Pathcan be solved in deterministictime 2O(k)·nO(1).

(24)

Derandomization

Definition

A familyHof functions [n]→[k]is a k-perfectfamily of hash functions if for everyS ⊆[n]with |S|=k, there is anh ∈ H such thath(x)6=h(y)for any x,y ∈S,x 6=y.

Theorem[Alon, Yuster, Zwick 1994]

There is ak-perfect family of functions [n]→[k]having size 2O(k)logn (and can be constructed in time polynomial in the size of the family).

Instead of trying O(ek) random colorings,we go through a k-perfect family H of functionsV(G)→[k].

If there is a solutionS

⇒The vertices of S are colorful for at least one h∈ H

⇒Algorithm outputs “YES”.

⇒k-Pathcan be solved in deterministictime 2O(k)·nO(1).

(25)

Derandomized Color Coding

k-PATH

k-perfect family 2O(k)logn functions

Finding a colorful path

Solvable in time 2k·nO(1)

(26)

Bounded-degree graphs

Meta theorems exist for bounded-degree graphs, but randomization is usually simpler.

Dense k-vertex Subgraph Input: A graphG, integers k,m.

Find: A set ofk vertices inducing ≥m edges.

Note: on general graphs, the problem is W[1]-hard parameterized byk, as it containsk-Clique.

Theorem

Densek-vertex Subgraphcan be solved in randomized time 2k(d+1)·nO(1) on graphs with maximum degreed.

(27)

Dense k -vertex Subgraph

Remove each vertex with probability 1/2 independently.

(28)

Dense k -vertex Subgraph

Remove each vertex with probability 1/2 independently.

With probability 2−k no vertex of the solution is removed.

With probability 2−kd every neighbor of the solution is removed.

⇒ We have to find a solution that is the union of connected components!

(29)

Dense k -vertex Subgraph

Remove each vertex with probability 1/2 independently.

With probability 2−k no vertex of the solution is removed.

With probability 2−kd every neighbor of the solution is removed.

⇒ We have to find a solution that is the union of connected components!

(30)

Dense k -vertex Subgraph

Remove each vertex with probability 1/2 independently.

k1vertices

m1edges k2 vertices

. . .

m2 edges

k3vertices m3edges

ki vertices mi edges

Select connected components with at most k verticesand at least medges.

What problem is this?

(31)

Dense k -vertex Subgraph

Remove each vertex with probability 1/2 independently.

k1vertices

m1edges k2 vertices

. . .

m2 edges

k3vertices m3edges

ki vertices mi edges

Select connected components with at most k verticesand at least medges.

What problem is this?

KNAPSACK!

(32)

Dense k -vertex Subgraph

Select connected components with at most k verticesand at least medges.

This is exactly KNAPSACK!

(I.e., pick objects of totalweight at mostS andvalue at least V.) We can interpret

number ofvertices= weight of the items number ofedges = value of the items

If the weights are integers, then DP solves the problem in time polynomial in the number of objects and the maximum weight.

(33)

Dense k -vertex Subgraph

DENSE k-VERTEX SUBGRAPH

Random deletions success probability:

2−k(d+1)

KNAPSACK

Polynomial time

(34)

Balanced Separation

Useful problem for recursion:

Balanced Separation

Input: A graphG, integers k,q. Find:

A setS of at mostk vertices such thatG \S has at least two components of size at leastq each.

Theorem

Balanced Separationcan be solved in randomized time 2O(q+k)·nO(1).

(35)

Balanced Separation

C1 S C2

Remove each vertex with probability 1/2 independently.

With probability 2−k every vertex of the solution is removed. With probability 2−q no vertex of T1 is removed.

With probability 2−q no vertex of T2 is removed.

⇒ The reduced graphG0 has two components of size≥q that can be separated in the original graphG byk vertices.

For any pair of large components of G0, we find a minimum s−t cut in G.

(36)

Balanced Separation

C1 S C2

T1 T2

Remove each vertex with probability 1/2 independently.

With probability 2−k every vertex of the solution is removed. With probability 2−q no vertex of T1 is removed.

With probability 2−q no vertex of T2 is removed.

⇒ The reduced graphG0 has two components of size≥q that can be separated in the original graphG byk vertices.

For any pair of large components of G0, we find a minimum s−t cut in G.

(37)

Balanced Separation

C1 S C2

T1 T2

Remove each vertex with probability 1/2 independently.

With probability 2−k every vertex of the solution is removed.

With probability 2−q no vertex of T1 is removed.

With probability 2−q no vertex of T2 is removed.

⇒ The reduced graphG0 has two components of size≥q that can be separated in the original graphG byk vertices.

For any pair of large components of G0, we find a minimum s−t cut in G.

(38)

Balanced Separation

C1 S C2

T1 T2

Remove each vertex with probability 1/2 independently.

With probability 2−k every vertex of the solution is removed.

With probability 2−q no vertex of T1 is removed.

With probability 2−q no vertex of T2 is removed.

⇒ The reduced graphG0 has two components of size≥q that can be separated in the original graphG byk vertices.

For any pair of large components of G0, we find a minimum s−t cut in G.

(39)

Balanced Separation

BALANCED SEPARATION

Random deletions success probability:

2−(k+2q)

MINIMUM s−t CUT

Polynomial time

(40)

Conclusions

Randomization gives elegant solution to many problems.

Derandomization is sometimes possible (but less elegant).

Small (butf(k)) success probability is good for us.

Reducing the problem we want to solve to a problem that is easier to solve.

Hivatkozások

KAPCSOLÓDÓ DOKUMENTUMOK

If exists optimal LP solution that sets x v to 1, then exists optimal vertex cover that selects v..  Remove v from G and decrease k

Theorem: [Grohe, Grüber 2007] There is a polynomial-time algorithm that finds a solution of D ISJOINT DIRECTED CYCLES with OPT/̺(OPT) cycles for some nontrivial function ̺....

By default iterative compression adds n factor to the running time.. Ex: show that for VC and FVST this factor can be reduced to O(k) (hint:

The undirected approach does not work: the pushing lemma is not true.. Pushing Lemma (for

Proof: Find a collection of good clusters covering every vertex and having minimum total size... A sufficient and

Proof: Find a collection of good clusters covering every vertex and having minimum total size... A sufficient and

bounds for polynomial time solvable problems, and for running time of

Mean square error In of distance measurement by microwave telemeters is much affected by the determination error of instrument constant Ak enhancing the care to