theory of computing lecture 13 mas 714 hartmut klauck

17
Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Upload: kerry-wright

Post on 01-Jan-2016

216 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Theory of Computing

Lecture 13MAS 714

Hartmut Klauck

Page 2: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Application: Matching

• For simplicity we consider the bipartite matching problem

• G=(L[R,E) is a bipartite graph• A matching is a set Mµ E, in which no two edges

share a vertex• A perfect matching (assuming |L|=|R|) has |L| edges• Edges have weights W(u,v)• A maximum matching is a matching with the

maximum total edge weight

Page 3: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Flow network for bipartite matching

• G=(L[R,E) is a bipartite graph (unweighted)• Add two extra vertices s, t– connect s to all vertices of L, weight 1– keep the edges in E (directed from L to R), weight 1– connect all vertices in R to t, weight 1

• Then the maximum flow in the new graph is equal to the maximum matching– We will prove this later, it is obvious that a matching

leads to a flow but not the other way around

Page 4: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Computing Max Matchings

• Reduce the problem to Max Flow

Page 5: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Finding large matchings

• The Max Flow Min Cut theorem implies that the maximum flow in the graph is equal to the maximum matching:– A maximum matching of size s implies a flow of

size s– The max flow is equal to the min s,t-cut– Find a cut that is smaller than the maximum

matching

Page 6: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

The Cut

• Define– U: matched vertex pairs connected to unmatched

vertices in R (or to no unmatched vertices)– V: matched vertex pairs connected to unmatched

vertices in L– U and V are disjoint, otherwise the matching is not

maximum

Page 7: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

The Cut

Page 8: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Finding large matchings

• Problem: flows across edges are not integers• Definition: a flow is integral, if all f(u,v) are

integers• Claim:– If M is a matching in G, then there is an integral

flow f in the flow network for G, such that |f|=|M|

– Conversely, for an integral flow f there is a matching with |f|=|M|

Page 9: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Proof

1) Matching to Flow• Define flow as follows:• f(u,v)=1 if (u,v) in the matching, also f(v,u)=-1, f(s,u)=1,

f(v,t)=1 etc.• all other edges: f(u,v)=0

• This is a legal flow• Value is |M|

Page 10: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Proof

2) Flow to Matching• Let f be an integral flow• Set M={(u,v) with f(u,v)> 0}• C(s,u)=1, hence f(s,u)2{0,1}• f(u,v)2{0,1}• For u there is at most one v with f(u,v)=1• M is a matching• |M|= |f|

Page 11: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Integrality• Theorem

If all C(u,v) are integers, and a maximum flow is computed with Ford Fulkerson, then |f| and all f(u,v) are integers

• Corollary: Maximum Bipartite Matchings can be computed in time O(m2n) And even in time O(mn):Ford Fulkerson has time O(|f|m) for a max flow f, and |f|· n– Better algorithm can do it in O(m n0.5) (Hopcroft Karp)

• Proof:– Induction over the iterations– First iteration: there is an augmenting path with integral

capacity Cp(f) – Nf is also a network with integral capacities

Page 12: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Linear Programming

• Linear Programming is the most powerful optimization problem that can be solved in polynomial time– Some generalizations [semidefinite programming] can

be much more appropriate• Fast LP solvers exist– Write an LP, solve it– Fast in theory/fast in practice...

• Important theoretical tool• Duality

Page 13: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Linear Programming

• Definition– A Linear Program (LP) is an optimization problem over real

variables x1,…,xn

– Maximizes/minimizes a linear function of x:max/min C(x)=i ci xi ( ci are real coefficients)

– Constraints: feasible solutions are those that satisfy a system of linear inqualities:• A is a real m£ n matrix, b a vector• All x with Ax · b are feasible

– We are looking for a feasible x with maximum C(x)

Page 14: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Geometry

• The set of x that satisfy a linear inequality is a half-space

• The set of feasible solutions to an LP is an intersection of halfspaces

• This is a convex polytope• To solve an LP it is sufficient to be able to find

a feasible solution• I.e. find a point inside a convex polytope

Page 15: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Example: Max Flow• Graph G with capacities C(u,v)• G has m edges (u,v), use m variables f(u,v)• Inequalities:

• f(u,v)· C(u,v) for all edges (u,v)• v f(u,v)= v f(v,u) for all u except s,t• f(u,v)¸ 0 for all edges

• Maximize v f(s,v)• The program has m variables and m+n inequalities/equations• By definition the maximum is a maximum flow

Page 16: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Example: Shortest Path

• Variables: d(v) for all vertices v• Objective function:

Minimize d(t)• Constraints:

d(v)· d(u)+W(u,v) for all edges (u,v)d(s)=0

Page 17: Theory of Computing Lecture 13 MAS 714 Hartmut Klauck

Standard form

• Constraints using ¸, · and = are possible• Easy to reduce to the standard form:

max cTx Constraints: Ax· b x¸ 0