🎉 从330转为WashU帮助手册啦!

CSE347
模块
Cse347 L5

Lecture 5

Takeaway from Bipartite Matching

  • We saw how to solve a problem (bi-partite matching and others) by reducing it to another problem (maximum flow).
  • In general, we can design an algorithm to map instances of a new problem to instances of known solvable problem (e.g., max-flow) to solve this new problem!
  • Mapping from one problem to another which preserves solutions is called reduction.

Reduction: Basic Idea

Convert solutions to the known problem to the solutions to the new problem

  • Instance of new problem
  • Instance of known problem
  • Solution of known problem
  • Solution of new problem

Reduction: Formal Definition

Problems L,KL,K.

LL reduces to KK (LKL\leq K) if there is a mapping ϕ\phi from any instance lLl\in L to some instance ϕ(l)KK\phi(l)\in K'\subset K, such that the solution for ϕ(l)\phi(l) yields a solution for ll.

This means that L is no harder than K

Using reduction to design algorithms

In the example of reduction to solve Bipartite Matching:

L:L: Bipartite Matching

K:K: Max-flow Problem

Efficiency:

  1. Reduction: ϕ:lϕ(l)\phi:l\to\phi(l) (Polynomial time reduction ϕ(l)\phi(l))
  2. Solve prom ϕ(l)\phi(l) (Polynomial time to solve poly(g)poly(g))
  3. Convert the solution for ϕ(l)\phi(l) to a solution to ll (Polynomial time to solve poly(g)poly(g))

Efficient Reduction

A reduction ϕ:lϕ(l)\phi:l\to\phi(l) is efficient (Lp(k)L\leq p(k)) if for any lLl\in L:

  1. ϕ(l)\phi(l) is computable from ll in polynomial (l|l|) time.
  2. Solution to ll is computable from solution of ϕ(l)\phi(l) in polynomial (l|l|) time.

We call LL is poly-time reducible to KK, or LL poly-time reduces to KK.

Which problem is harder?

Theorem: If Lp(k)L\leq p(k) and there is a polynomial time algorithm to solve KK, then there is a polynomial time algorithm to solve LL.

Proof: Given an instance of lLl\in L If we can convert the problem in polynomial time with respect to the original problem ll.

  1. Compute ϕ(l)\phi(l): p(l)p(l)
  2. Solve ϕ(l)\phi(l): p(ϕ(l))p(\phi(l))
  3. Convert solution: p(ϕ(l))p(\phi(l))

Total time: p(l)+p(ϕ(l))+p(ϕ(l))=p(l)+p(ϕ(l))p(l)+p(\phi(l))+p(\phi(l))=p(l)+p(\phi(l)) Need to show: ϕ(l)=poly(l)|\phi(l)|=poly(|l|)

Proof:

Since we can convert ϕ(l)\phi(l) in p(l)p(l) time, and on every time step, (constant step) we can only write constant amount of data.

So ϕ(l)=poly(l)|\phi(l)|=poly(|l|)

Hardness Problems

Reductions show the relationship between problem hardness!

Question: Could you solve a problem in polynomial time?

Easy: polynomial time solution Hard: No polynomial time solution (as far as we know)

Types of Problems

Decision Problem: Yes/No answer

Examples: Subset sums

  1. Is the there a flow of size FF
  2. Is there a shortest path of length LL from vertex uu to vertex vv.
  3. Given a set of intercal, can you schedule kk of them.

Optimization Problem: What is the value of an optimal feasible solution of a problem?

  • Minimization: Minimize cost
    • min cut
    • minimal spanning tree
    • shortest path
  • Maximization: Maximize profit
    • interval scheduling
    • maximum flow
    • maximum matching

Canonical Decision Problem

Does the instance lLl\in L (an optimization problem) have a feasible solution with objective value kk:

Objective value k\geq k (maximization) k\leq k (minimization)

DLDL is the reduced Canonical Decision problem LL

Hardness of Canonical Decision Problems

Lemma 1: DLp(L)DL\leq p(L) (DLDL is no harder than LL)

Proof: Assume LL maximization problem DL(l)DL(l): does have a solution k\geq k.

Example: Does graph GG have flow k\geq k.

Let vv^∗ be the maximum objective on ll by solving ll.

Let the instance of DL:(l,k)DL:(l,k) and ll be the problem and kk be the objective

  1. lϕ(l)Ll\to \phi(l)\in L (optimization problem) ϕ(l,k)=l\phi(l,k)=l
  2. Is v(l)kv^*(l)\geq k? If so, return true, else return false.

Lemma 2: If v=O(cl)v^* =O(c^{|l|}) for any constant cc, then Lp(DL)L\leq p(DL).

Proof: First we could show LDLL\leq DL. Suppose maximization problem, canonical decision problem is is there a solution k\geq k.

Naïve Linear Search: Ask DL(l,k)DL(l,k), if returns false, ask DL(l,k+1)DL(l,k+1) until returns true

Runtime: At most kk search to iterate all possibilities.

This is exponential! How to reduce it?

Our old friend Binary (exponential) Search is back!

You gets a no at some value: try power of 2 until you get a no, then do binary search

# questions: =log2(v(l))=poly(l)=log_2(v^*(l))=poly(l)

Binary search in area: from last yes to first no.

Runtime: Binary search (O(n)=log(v(l))O(n)=\log(v^*(l)))

Reduction for Algorithm Design vs Hardness

For problems L,KL,K

If KK is “easy” (exists a poly-time solution), then LL is also easy.

If LL is “hard” (no poly-time solution), then kk is also hard.

Every problem that we worked on so far, KK is “easy”, so we reduce from new problem to known problem (e.g., max-flow).

Reduction for Hardness: Independent Set (ISET)

Input: Given an undirected graph G=(V,E)G = (V,E),

A subset of vertices SVS\subset V is called an independent set if no two vertices of are connected by an edge.

Problem: Does GG contain an independent set of size k\geq k?

ISET(G,k)ISET(G,k) returns true if GG contains an independent set of size k\geq k, and false otherwise.

Algorithm? NO! We think that this is a hard problem.

A lot of people have tried and could not find a poly-time solution

Example: Vertex Cover (VC)

Input: Given an undirected graph G=(V,E)G = (V,E)

A subset of vertices CVC\subset V is called a vertex cover if contains at least one end point of every edge.

Formally, for all edges (u,v)E(u,v)\in E, either uCu\in C, or vCv\in C.

Problem: VC(G,j)VC(G,j) returns true if has a vertex cover of size j\leq j, and false otherwise (minimization problem)

Example:

How hard is Vertex Cover?

Claim: ISETp(VC)ISET\leq p(VC) Side Note: when we prove VCVC is hard, we prove it is no easier than ISETISET.

DO NOT: VCp(ISET)VC\leq p(ISET)

Proof: Show that G=(V,E)G=(V,E) has an independent set of kk if and only if the same graph (not always!) has a vertex cover of size Vk|V|-k.

Map:

ISET(G,k)VC(g,vk)ISET(G,k)\to VC(g,|v|-k)

G=GG'=G

Proof of reduction: Direction 1

Claim 1: ISETISET of size kk\to VCVC of size Vk|V|-k

Proof: Assume GG has an ISETISET of size k:Sk:S, consider C=VS,C=VkC = V-S,|C|=|V|-k

Claim: CC is a vertex cover

Proof of reduction: Direction 2

Claim 2: VCVC of size VkISET|V|-k\to ISET of size kk

Proof: Assume GG has an VCVC of size Vk:C|V| −k:C, consider S=VC,S=kS = V − C, |S| =k

Claim: SS is an independent set

What does poly-time mean?

Algorithm runs in time polynomial to input size.

  • If the input has items, algorithm runs in Θ(nc)\Theta(n^c) for any constant is poly-time.
    • Examples: intervals to schedule, number of integers to sort, # vertices + # edges in a graph
  • Numerical Value (Integer nn), what is the input size?
    • Examples: weights, capacity, total time, flow constraints
    • It is not straightforward!

Real time complexity of F-F?

In class: O(F(V+E))O(F( |V| + |E|))

  • V+E|V| + |E| = this much space to represent the graph
  • FF : size of the maximum flow.

If every edge has capacity , then F=O(CE)F = O(CE) Running time:O(CE(V+E)))O(C|E|(|V| + |E| )))

What is the actual input size?

Each edge (E|E| edges):

  • 2 vertices: V|V| distinct symbol, logV\log |V| bits per symbol
  • 1 capacity: logC\log C

Size of graph:

  • O(E(V+logC))O(|E|(|V| + \log C))
    • p(E,V,logC)p( |E| , |V| , \log C)

Running time:

  • P(E,V,C)P( |E| , |V| , |C| )
    • Exponential if is exponential in V+E|V|+|E|

Pseudo-polynomial

Naïve Ford-Fulkerson is bad!

Problem ’s inputs contain some numerical values, say W|W|. We need only log bits to store . If algorithms runs in p(W)p(W), then it is exponential, or pseudopolynomial.

In homework, you improved F-F to make it work in p(V,E,logC)p( |V| ,|E| , \log C), to make it a real polynomial algorithm.

Conclusion: Reductions

  • Reduction
    • Construction of mapping with runtime
    • Bidirectional proof
  • Efficient Reduction Lp(K)L\leq p(K)
    • Which problem is harder?
    • If LL is hard, then KK is hard. \to Used to show hardness
    • If KK is easy, then LL is easy. \to Used for design algorithms
  • Canonical Decision Problem
    • Reduction to and from the optimization problem
  • Reduction for hardness
    • Independent Setleqpleq p Vertex Cover

On class

Reduction: V=O(ck)V^* = O(c^k)

OPT: Find max flow of at least one instance (G,s,t)(G,s,t)

DEC: Is there a flow of size pKpK, given G,s,t    G,s,t \implies the instance is defined by the tuple (G,s,t,k)(G,s,t,k)

Yes, if there exists one No, otherwise

Forget about F-F and assume that you have an oracle that solves the decision problem.

First solution (the naive solution): iterate over k=1,2,k = 1, 2, \dots until the oracle returns false and the last one returns true would be the max flow.

Time complexity: KXK\cdot X, where XX is the time complexity of the oracle Input size: poly(V,E,Elog(maxcapacity))poly(||V|,|E|, |E|log(max-capacity)), and VV^* \leq \sum capacities

A better solution: do a binary search. If there is no upper bound, we use exponential binary search instead. Then,

log(V)Xlog(capacities)Xlog(EmaxCapacity)X(log(E+log(maxCapacity)))\begin{aligned} log(V^*) &\leq X\cdot log(\sum capacities)\\ &\leq X\cdot log(|E|\cdot maxCapacity)\\ &\leq X\cdot (log(|E| + log(maxCapacity))) \end{aligned}

As log(maxCapacity)\log(maxCapacity) is linear in the size of the input, the running time is polynomial to the solution of the original problem.

Assume that ISET is a hard problem, i.e. we don't know of any polynomial time solution. We want to show that vertex cover is also a hard problem here:

ISETpVCISET \leq_{p} VC

  1. Given an instance of ISET, construct an instance of VC
  2. Show that the construction can be done in polynomial time
  3. Show that if the ISET instance is true than the CV instance is true
  4. Show that if the VC instance is true then the ISET instance is true.

ISET: given (G,K)(G,K), is there a set of vertices that do not share edges of size KK
VC: given (G,K)(G,K), is there a set of vertices that cover all edges of size KK

  1. Given l:(G,K)l: (G,K) being an instance of ISET, we construct ϕ(l):(G,K)\phi(l): (G',K') as an instance of VC. ϕ(l):(G,VK),i.e., G=GK=VK\phi(l): (G, |V|-K), \textup{i.e., } G' = G \cup K' = |V| - K
  2. It is obvious that it is a polynomial time construction since copying the graph is linear, in the size of the graph and the subtraction of integers is constant time.

Direction 1: ISET of size k     \implies VC of size VK|V| - K Assume that ISET(G,K) returns true, show that VC(G,VK)VC(G, |V|-K) returns true

Let SS be an independent set of size KK and C=VSC = V-S

We claim that CC is a vertex cover of size VK|V|-K

Proof:

We proceed by contradiction. Assume that CC is NOT a vertex cover, and it means that there is an edge (u,v)(u,v) such that uc,vCu\notin c , v\notin C. And it implies that uS,vSu\in S , v\in S, which contradicts with the assumption that S is an independent set. Therefore, cc is an vertex cover

Direction 2: VC of size VK    |V|-K \implies ISET of size KK

Let CC be a vertex cover of size VK|V|-K , let s=vcs = |v| - c

We claim that SS is an independent set of size KK.

Again, assume, for the sake of contradiction, that SS is not an independent set. And we get

(u,v)such that uS,vS\exists (u,v) \textup{such that } u\in S, v \in S

u,v\notinCu,v \notinC

C is not a vertex coverC \textup{ is not a vertex cover}

And this is a contradiction with our assumption.