860 likes | 874 Views
Semi-Matchings for Bipartite Graphs and Load Balancing. Nick Harvey , Richard Ladner, Laszlo Lovasz, Tami Tamir. Talk Outline. “Swiss Bank” Problem Formal Definitions Optimal Semi-Matchings Algorithms Experiments. “Swiss Bank” Problem. 5 bank tellers each speaks a different language
E N D
Semi-Matchingsfor Bipartite Graphsand Load Balancing Nick Harvey, Richard Ladner, Laszlo Lovasz, Tami Tamir
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Algorithms • Experiments
“Swiss Bank” Problem • 5 bank tellers • each speaks a different language • 10 bank customers • each speaks one or more languages • Assume servicing a customer takes1 time unit • Problem: Assign each customer to a teller
Problem Model: Bipartite Graph Customers Tellers German Customer speaks German and Italian Italian French Romansh English
Customer Assignment Customers Tellers German Italian French Romansh English
Optimization Objectives Minimize: • Flow time: • Total time customers wait(or average time) • Makespan: • Maximum time a customer waits • Variance: • Load balance of tellers’ queue lengths
Customer Queues Tellers German Italian French Romansh English Customer Wait Time (Flow Time) Wait Time 1 1 4+3+2+1=10 2+1=3 2+1=3 Total Wait Time: 1+1+10+3+3 = 18 units
Customer Queues Tellers German Italian French Romansh English Square of difference from mean Teller Load and Variance Load Variance (1-2)2=1 1 (1-2)2=1 1 (4-2)2=4 4 (2-2)2=0 2 (2-2)2=0 2 Mean Load 10/5 = 2 Variance: (1+1+4+0+0)/5 = 6/5
Optimal Assignment Customers Tellers German Italian French Romansh English Variance: 0 Total Wait Time: (2+1)*5 = 15 units
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Algorithms • Experiments
Formal Definitions • Let G = (UV, E) be a bipartite graph U V
Matchings • M Eis a matching if each vertex is incident with at most one edge in M U V The blue edges are a matching, M
Philip Hall (1904-1982) Matchings • First studied by Philip Hall of Cambridge University • “Marriage Theorem” characterizes the existence of perfect matchings P. Hall, On representatives of subsets, J. London Math. Soc. 10 (1935), 26-30.
Harold W. Kuhn Princeton University Matchings • “Hungarian Algorithm” used to find matchings of maximum cardinality H. W. Kuhn, The Hungarian method for the assignment problem, Naval Res. Logist. Quart. 2:83-97, 1955.
Semi-Matchings • M Eis a semi-matching if each U-vertex is incident with exactly one edge in M U V The blue edges are a semi-matching, M
Max-Weight Semi-Matchings • Let w: E R be an edge-weight function • Problem (Lawler ‘76): Find semi-matching M maximizing • Solvable by simple greedy algorithm Eugene Lawler, Combinatorial Optimization: Networks and Matroids. Holt, Rinehart & Winston, 1976.
Optimal Semi-Matching, M • Edges are unweighted • Let degM(v) denote number of M-edges incident with vV • Define cost of M at a vertex vV: • Define c(M) = • M is an optimal semi-matching if c(M) is minimal
Optimal Semi-Matchings • c(M) gives the total weighting time of the “customers” in U U V cM(v) 1 1 4+3+2+1=10 2+1=3 2+1=3 c(M)=1+1+10+3+3 = 18
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Cost Reducing Paths • Optimality Criterion • Lp-norm • Algorithms • Experiments
Optimality Properties • Optimal Semi-Matchings have useful load balancing properties: • Minimize variance of { degM(v) } • Minimize max { degM(v) } • Minimize Lp-norm of { degM(v) } • Optimal Semi-Matchings contain a maximum matching as a subset • And a max matching is easy to find
Alternating Paths • Let P = (v1, u1, …, uk-1, vk) be a path in G • If {vi, ui} M and {ui, vi+1} E \ M for all i,then P is called an alternating path U V v3 u2 White edges are in E \ M v2 u1 P is an alternating path v1 Blue edges are in M
Cost-Reducing Paths (CRPs) • Let P be an alternating path in G • If degM(vk) < degM(v1)-1 then P is called a cost-reducing path U V v3 degM(v3)= 1 u2 v2 u1 P is not a cost-reducing path v1 degM(v1)= 2
Cost-Reducing Paths (CRPs) • Let P be an alternating path in G • If degM(vk) < degM(v1)-1 then P is called a cost-reducing path U V v2 degM(v2)= 1 u1 v1 degM(v1)= 4 P is a cost-reducing path
Improvement with CRPs • Let P = (v1, u1, …, uk-1, vk) be a CRP • Remove {vi, ui} from M for all i • Add {ui, vi+1}to M for all i U V v2 degM(v2)= 2 degM(v2)= 1 u1 v1 degM(v1)= 4 degM(v1)= 3 P is a cost-reducing path
Improvement with CRPs • cM(v1) decreases by degM(v1) • cM(vk) increases by degM(vk)+1 • Total decrease is (degM(v1)-degM(vk)-1) > 0 U V v2 cM(v2)= 3 cM(v2)= 1 u1 v1 cM(v1)= 10 cM(v1)= 6 c(M)Decrease of 4+ Increase of 2 = Decrease of 2
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Cost Reducing Paths • Optimality Criterion • Lp-norm • Algorithms • Experiments
Optimality Criterion • Theorem: A semi-matching is optimal if and only if no cost-reducing path exists • Proof: • Any CRP can reduce the cost of a semi-matching – this was just shown • If a semi-matching is not optimal then a cost-reducing path exists – this requires some proof
Proof of Optimality Criterion • Let M be a suboptimal semi-matching • Let O be an optimal semi-matching with smallest symmetric difference withM • In color the edges of Mred and the edges in Ogreen • Let G be G restricted to edge-set = (M \ O)(O \ M)
Construction of G • Direct red edges VU and green edges UV Suboptimal M Optimal O G M \ O O \ M
Properties of G • Acyclicity • G contains no alternating red/green cycle • Monotonicity • If there is an alternating red/greenpath in G from v1 to v2 in V thendegO(v1) degO(v2) • Both properties hold by choice of O
degO(v) 2 2 2 2 2 Properties of G G O • Acyclic • Monotone
degM(v) 3 2 3 2 0 G yields CRP for M G M There is acost-reducing red/green path for M
Existence of CRP Proof • Choose V-vertex v1 such thatdegM(v1) > degO(v1) • Build red/green path in G untilwe find V-vertex v2 with degM\O(v2) = 0 • Path from v1 to v2 is a cost-reducing path for M! degM(v2) ≤ degO(v2) - 1 ≤ degO(v1) - 1 < degM(v1) - 1 arrived at v2 on O\M edge monotonicity choice of v1
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Cost Reducing Paths • Optimality Criterion • Lp-norm • Algorithms • Experiments
Lp-norm of load vector • Let xi = degM(vi) • The Lp-norm of the vector X=(x1,x2,…,xm) is • ||X||1 is always |U| • For any p>1, ||X||p is a measure ofthe balance of the load on V-vertices • ||X||2 is the sum of squares • ||X|| is the load of the most loaded V-vertex • ||X||p is everything in between ||X||p = (i xip)1/p
Optimality of Lp-norm • Theorem: Let p>1. A semi-matching is optimal iff the Lp-norm of its load vector is optimal • Proof outline: Based on following claims • A cost-reducing path can reduce the Lp-norm of the load vector Proof: Simple calculation • A semi-matching M has optimal Lp-norm iff no cost-reducing path relative to M exists Proof: Similar to the proof for optimal total cost
Optimality of L-norm • Theorem: An optimal semi-matching is optimal with respect to L (load on most loaded teller) • Proof: more complicated • The converse does not hold: xi xi 2 2 1 0 2 1 Optimal L Optimal semi-matching Total cost: 6 Total cost: 5
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Algorithms • Network Flow Algorithms • Algorithm SM1 • Algorithm SM2 • Experiments
Network Flow Algorithms • Can reduce semi-matching problem to known network-flow problems • Assignment ProblemRequires O(n0.5 m . log(n)) time(Gabow and Tarjan, 1989) • Min-cost Max-flow ProblemRequires O(n .m . log2(n)) time(Goldberg and Tarjan, 1987) where n=num vertices andm=num edges
Assignment Problem Assignment Problem G
Min-cost Max-flow Problem Cost Centers U V Source Sink
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Algorithms • Network Flow Algorithms • Algorithm SM1 • Algorithm SM2 • Experiments
Algorithm SM1 • Simple modification of “Hungarian Algorithm” for Bipartite Matching • Runtime: O(n .m) (n=|U|+|V| and m=|E|) • Same as Hungarian Algorithm • Actual performance is not good
Algorithm SM1 Pseudocode • Initially M is empty • For each uU • Build tree T of alternating paths rooted at u • Let v be a V-vertex in T such that degM(v) is minimum • Switch matching and non-matching edges on path from v to u • Note: u is matched and |M| increased by one
Algorithm SM1 Example U V 1 Initially: no one is assigned. 1 Step 1: assign u1 to a least loaded V-vertex 2 3 4 5
Algorithm SM1 Example U V 1 1 Step 2: assign u2 2 2 3 4 5
Algorithm SM1 Example U V 1 Step 3: assign u3 1 2 3 Can increase the load on v2 2 or v1 or v3 3 v3 is the least loaded 4 5
Algorithm SM1 Example U V 1 1 2 3 2 3 4 5
Talk Outline • “Swiss Bank” Problem • Formal Definitions • Optimal Semi-Matchings • Algorithms • Network Flow Algorithms • Algorithm SM1 • Algorithm SM2 • Experiments
Algorithm SM2 • General idea: Find and remove cost-reducing paths • Runtime: O(|U|3/2 . |E|) • Worse bound than Algorithm SM1 • Actual performance is very good!