Title: Semi-Matchings for Bipartite Graphs and Load Balancing
1Semi-Matchingsfor Bipartite Graphsand Load
Balancing
- Nick Harvey, Richard Ladner, Laszlo Lovasz, Tami
Tamir
2Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Experiments
3Swiss 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
4Problem Model Bipartite Graph
Tellers
Customers
German
Customer speaks German and Italian
Italian
French
Romansh
English
5Customer Assignment
Tellers
Customers
German
Italian
French
Romansh
English
6Optimization Objectives
- Minimize
- Flow time
- Total time customers wait(or average time)
- Makespan
- Maximum time a customer waits
- Variance
- Load balance of tellers queue lengths
7Customer Wait Time (Flow Time)
Wait Time
1
1
432110
213
213
Total Wait Time 111033 18 units
8Square of difference from mean
Teller Load and Variance
Load
Variance
(1-2)21
1
(1-2)21
1
(4-2)24
4
(2-2)20
2
(2-2)20
2
Variance (11400)/5 6/5
Mean Load 10/5 2
9Optimal Assignment
Tellers
Customers
German
Italian
French
Romansh
English
Variance 0
Total Wait Time (21)5 15 units
10Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Experiments
11Formal Definitions
- Let G (U ?V, E) be a bipartite graph
U
V
12Matchings
- M ? E is a matching if each vertex is incident
with at most one edge in M
U
V
The blue edges are a matching, M
13Matchings
- 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.
14Matchings
- Hungarian Algorithm used to find matchings of
maximum cardinality
H. W. Kuhn, The Hungarian method for the
assignment problem, Naval Res. Logist. Quart.
283-97, 1955.
15Semi-Matchings
- M ? E is 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
16Max-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.
17Optimal Semi-Matching, M
- Edges are unweighted
- Let degM(v) denote number of M-edges incident
with v?V - Define cost of M at a vertex v?V
- Define c(M)
- M is an optimal semi-matching if c(M) is minimal
18Optimal Semi-Matchings
- c(M) gives the total weighting time of the
customers in U
U
V
cM(v)
1
1
432110
213
213
c(M) 111033 18
19Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Cost Reducing Paths
- Optimality Criterion
- Lp-norm
- Algorithms
- Experiments
20Optimality 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
21Alternating Paths
- Let P (v1, u1, , uk-1, vk) be a path in G
- If vi, ui? M and ui, vi1? 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
22Cost-Reducing Paths (CRPs)
- Let P be an alternating path in G
- If degM(vk) lt 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
23Cost-Reducing Paths (CRPs)
- Let P be an alternating path in G
- If degM(vk) lt 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
24Improvement with CRPs
- Let P (v1, u1, , uk-1, vk) be a CRP
- Remove vi, ui from M for all i
- Add ui, vi1 to M for all i
U
V
v2
degM(v2) 1
degM(v2) 2
u1
v1
degM(v1) 4
degM(v1) 3
P is a cost-reducing path
25Improvement with CRPs
- cM(v1) decreases by degM(v1)
- cM(vk) increases by degM(vk)1
- Total decrease is (degM(v1)-degM(vk)-1) gt 0
U
V
v2
cM(v2) 1
cM(v2) 3
u1
v1
cM(v1) 10
cM(v1) 6
c(M) Decrease of 4 Increase of 2 Decrease of
2
26Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Cost Reducing Paths
- Optimality Criterion
- Lp-norm
- Algorithms
- Experiments
27Optimality 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
28Proof of Optimality Criterion
- Let M be a suboptimal semi-matching
- Let O be an optimal semi-matching with smallest
symmetric difference ? with M - In ? color the edges of M red and the edges in O
green - Let G? be G restricted to edge-set ?
? (M \ O) ? (O \ M)
29Construction of G?
- Direct red edges V?U and green edges U?V
Suboptimal M
Optimal O
G?
?
M \ O
O \ M
30Properties 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
31Properties of G?
G?
O
32G? yields CRP for M
G?
M
There is acost-reducing red/green path for M
33Existence of CRP Proof
- Choose V-vertex v1 such thatdegM(v1) gt 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 lt degM(v1) - 1
- arrived at v2 on O\M edge
- monotonicity
- choice of v1
34Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Cost Reducing Paths
- Optimality Criterion
- Lp-norm
- Algorithms
- Experiments
35Lp-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 pgt1, 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
36Optimality of Lp-norm
- Theorem Let pgt1. 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
37Optimality 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
1
2
Optimal L?
Optimal semi-matching
Total cost 5
Total cost 6
38Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Network Flow Algorithms
- Algorithm SM1
- Algorithm SM2
- Experiments
39Network 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 nnum vertices andmnum edges
40Assignment Problem
Assignment Problem
G
41Min-cost Max-flow Problem
Cost Centers
U
V
Source
Sink
42Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Network Flow Algorithms
- Algorithm SM1
- Algorithm SM2
- Experiments
43Algorithm SM1
- Simple modification of Hungarian Algorithm for
Bipartite Matching - Runtime O(n .m) (nU V and mE )
- Same as Hungarian Algorithm
- Actual performance is not good
44Algorithm SM1 Pseudocode
- Initially M is empty
- For each u?U
- 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
45Algorithm 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
46Algorithm SM1 Example
U
V
1
Step 2 assign u2
1
2
2
3
4
5
47Algorithm 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
48Algorithm SM1 Example
U
V
1
1
2
3
2
3
4
5
49Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Network Flow Algorithms
- Algorithm SM1
- Algorithm SM2
- Experiments
50Algorithm 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!
51Algorithm SM2 Pseudocode
- Quickly find an initial semi-matching M
- While M contains a cost-reducing path P
- Improve M by switching edges along P
- Stop M is optimal
52Step 1 Initial Semi-Matching
- Any semi-matching will work but a near-optimal
one is better - Easy approach
- Match each u?U with its least-loaded V-neighbor
- Better approach
- Sort vertices in U by increasing degree
- Match each u?U with its least-loaded
V-neighbor.In case of a tie, choose V-neighbor
with least degree.
53Step 1 Greedy Example
U
V
54Step 2 Find CRP
- Easy approach
- For each v?V
- Build tree T of alternating paths rooted at v
- If T contains a cost-reducing path, return it
- Return false
- Runtime O(V . E )
55Step 2 Find CRP
- Better approach
- Build forest F of alternating paths where each
tree root is a least-loaded V-vertex that is not
in F - If F contains a cost-reducing path, return it
- Return false
- Runtime O(E )
56Step 2 Find CRP Example
U
V
57Algorithm SM2 Analysis
- Step 1 Find Greedy Matching O(E )
- Step 2 Find CRP O(E )
- Step 3 Eliminate CRP O(U V )
- How many CRPs must be eliminated to achieve
optimality? - Depends on cost of Greedy Assignment
58Algorithm SM2 Num Iterations
- Worst-possible Greedy Assignment has Total Cost
U . (U 1)/2 - Each iteration reduces Total Cost by at least 1
- Therefore at most O(U 2) iterations
- Total Runtime O(U 2 . E )
- Can prove tighter bound O(U 3/2 . E )
59Coin Towers Problem
- Start Tower of coins C stories tall
- Goal C towers of coins each 1 story tall
- Coins can only move down and right
- Minimum number of moves is obviously C-1
- Problem What is maximum number of moves?
60Coin Towers Example
Tower 1
Tower 2
Tower 3
Tower 4
Tower 5
Tower 6
Total 8 Moves
61Coin Towers Analysis
- Assume tower heights non-increasing from left to
right - For any K, each coin moves at most K times before
passing beyond Tower K - Because each move goes right
- Tower K has maximum height C/K. Thus, each coin
moves at most C/K times after passing Tower K - Because each move goes down
- For arbitrary K, can prove thateach coins moves
at most KC/K times - Fix Ksqrt(C). Then maximum possible moves is O(C
. sqrt(C)) O(C1.5)
62Talk Outline
- Swiss Bank Problem
- Formal Definitions
- Optimal Semi-Matchings
- Algorithms
- Experiments
63Semi-Matching Experiments
- Compute Optimal Semi-Matchings
- Compare SM1 SM2 to reduction to assignment
problem - CSA Goldberg Kennedy, 1993
- LEDA www.algorithmic-solutions.com
- Use input graph generators from Cherkassky et
al., 1998
64(No Transcript)
65(No Transcript)
66(No Transcript)
67(No Transcript)
68(No Transcript)
69(No Transcript)
70Maximum Matching Experiments
- Compute Maximum Matchings
- Compare SM1 SM2 to existing matching algorithms
- BFS Breadth-First Search based alternating-path
algorithm - LO Push-relabel algorithm with Lo heuristic
- Both from Cherkassky et al., 1998
- Use input graph generators from Cherkassky et
al., 1998
71(No Transcript)
72(No Transcript)
73(No Transcript)
74(No Transcript)
75(No Transcript)
76(No Transcript)
77(No Transcript)
78Conclusions
- Optimal Semi-Matchings solve simple load
balancing problems - Minimize maximum load and variance
- Optimal Semi-Matchings contain Maximum Bipartite
Matchings - Algorithm SM1 has an efficient theoretical bound
- Algorithm SM2 is efficient in practice at
computing Optimal Semi-Matchings and Maximum
Matchings
79Questions?
80Algorithm SM1 Example
1
- Build an alternating tree rooted at u. Edges
(ui,vj) are in E\M and edges (vj,ui) are M. - Select v, the least loaded V-vertex in the tree.
- Re-assign matching edges on path from u to v
1
2
u
3
2
v
3
4
5
81Algorithm SM1 Example
U
V
1
Step 4 assign u4
1
2
Can increase the load on v1 or v3
3
2
4
or v1 or v2
or v2
3
All have the same load.
4
5
82Algorithm SM1 Example
U
V
1
Assign u4 to v3
1
2
3
2
4
3
4
5
83Algorithm SM1 Example
U
V
1
Step 5 assign u5 Step 6 assign u6
1
2
3
2
4
5
3
6
4
5
84Algorithm SM1 Example
U
V
1
Step 7 assign u7
1
2
Can increase the load on v3
3
2
or v1 or v2
4
or v1
5
3
or v2
6
v1 is the least loaded
4
7
5
85Algorithm SM1 Example
U
V
1
1
2
3
2
4
5
3
6
4
7
5
86(No Transcript)