1.21k likes | 1.32k Views
Global Price Updates Help A.V Goldberg and R. Kennedy. Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing. Motivation. Solving two “new” problems: Bipartite matching problem Assigment problem Using Push & Relabel methods
E N D
Global Price Updates HelpA.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing
Motivation • Solving two “new” problems: • Bipartite matching problem • Assigment problem • Using Push & Relabel methods • Improve complexity using “Global Updates”
Some definitions… • Bipartite Graph G = (X U Y, E) • Undirected graph • The sets of vertices V can be divided into two disjoint sets (X, Y) where there is no edge e Є E such that both endpoint of e are in the same set.
Bipartite Matching problem • Matching in G is a subset of edges M that have no node in common. • Cardinality of matching is |M|. • Bipartite matching problem is to find the matching with the maximum cardinality. • Usage: matching tasks to processors.
Bipartite matching to Max Flow • Given Ĝ = (X U Y,Ê) • Build G for the maximum flow problem by: • Adding nodes s and t. • V = X U Y U {s,t} • For each v X , placing (s,v) in E with capacity 1. • For each v Y, placing (v,t) in E with capacity 1. • For each edge {v,w} Ê, placing (v,w) in E with capacity 1. • Reverse arcs will have zero capacity. • G is called a matching network
Building a matching network 1 1 1 t S
Any integral flow in G can be “converted” into a matching in Ĝ. • The matching are the arcs (x,y) with f = 1. • Maximum flow in G corresponds to a maximum matching in Ĝ.
Pseudoflow – one more time • pseudoflow satisfies the following : • f(u,v) = - f(v,u) • f(u,v) ≤ u(u,v) • Excess flow ef(v) • ef(v) = ∑ (u,v) Є E f(u,v) • A flow is a pseudoflow such that there is no excess at any node.
Some more definitions • Distance labeling d is valid w.r.t f if: • d(t) = 0 • d(s) = n • For every arc (v,w) Ef : d(v) ≤ d(w) + 1 • Admissible arc (v,w) : d(v) = d(w) + 1. • GAis acyclic for any valid distance labeling
Basic algorithm • Init: • d(s) = n, d(t) = 0 • for every v V d(v) = 0; • saturate all arcs out of s. • Apply sequence of Push and Relabels until f is a flow.
Push and Relabel operations • Push : • Send a unit of flow from v to w. • Relabel: • d(v) ← min(v,w) Ef { d(w) +1 } • Limitation on invocation as we know already…
Analysis of the basic algorithm • All arcs have unit capacity , therefore each push is a saturating push • 2n ≥ d(v) ≥ 0 for all nodes v. • Relabel increases d(v). • Number of Relabel operations per node is O(n). • The work done in Relabel operations is O(nm).
Analysis - Cont • If v is relabeled k times then the number of Pushes from v is at most (k+1)*degree (v). • The number of Push operation are O(nm). • Selecting an arc to push flow on will be done using the “current arc method”. Current arc
dw(v) definition • For any node v and w: • dw(v) = bfs distance from v to w in Gf of the current preflow f. • If w is unreachable from v then dw(v) =∞.
Global Update definition • Global Update: for every node v setting d(v) = min { dt(v), n+ds(v)}. • The global update also sets the “current arc” of every node to be the first arc. • Can be done in O(m). • d(v) can not be decreased...
Global update – When? • At Init. • After each Push and Relabel operation if : • Since the last update, at least one unit of excess has reached s or t. • And • Since the last update, the algorithm has done at least m work in Push and Relabel operations.
Minimum Distance Discharge – The idea • Selecting a unit of excess at active node with minimum d(v). • Process this unit of excess until: • Relabel occurs. • The excess reached t or s. • If after the Relabel the node still has the minimum d(v) continue with this node.
Minimum Distance Discharge algorithm with Global Update • Init: • saturate all arcs out of s. • Global update. • Apply sequence of Push, Relabels and Global updates by the MDD order until f is a flow.
Minimum distance discharge – how is it implemented? • Building buckets B0,….., B2n. • Bucket Bi holds the active nodes with d(v) = i. • μ - index of the bucket from which we selected the recent active node (unit of excess).
Minimum distance discharge – how is it implemented? - Cont • After each Global Update: • Current arc is set to the nodes first arc. • The buckets are built again - O(n). • μ is reset to 0.
Some definitions for the analysis • Γ(f,d) – the minimum distance label of an active node w.r.t pseudoflow f and distance label d. • Γmax– The maximum Γ value reached by the algorithm so far.
Minimum Distance Discharge - Analysis • Lemma 4.1: Between two consecutive Global Updates, the algorithm does O(n) work in examining empty buckets.
Minimum Distance Discharge - Analysis • Proof: • μ decreases only when it is set to zero after an update.
Minimum Distance Discharge - Analysis • Proof: • μ decreases only when it is set to zero after an update. μ = 3 d=3 d=2 d=1 Active node T d = 1
Minimum Distance Discharge - Analysis • Proof: • μ decreases only when it is set to zero after an update. • There are 2n+1 buckets.
Minimum Distance Discharge - Analysis • We will divide the analysis into 4 stages: • Γmax Є[0,k] • Γmax Є[k,n] • ΓmaxЄ[n,n+k] • ΓmaxЄ [n+k,2n] • K will be chosen later.
Stage 1 and 3 • Lemma 4.2: The Minimum Distance Discharge Algorithm expends O(km) work during the periods when ΓmaxЄ [0,k] and ΓmaxЄ [n,n+k]
Stage 1 and 3 – Proof • If Γmax Є[0,k] then ΓЄ[0,k] . • If Γmax Є[n,n+k] then ΓЄ [n,n+k], since no excess can reached t anymore. • Each node can be relabeled at most k+1 times • Relabels and Pushes require O(km). • During O(km) work, at most k Global Updates can be done. • Global Updates require O(km) work during each stage. => Stage 1 and 3 require O(km) work.
Flow Decomposition • Lemma 4.3: (Without a proof) Any Integral pseudoflow f in the augmented residual graph of an integral flow g in a matching network can be decomposed into cycles and simple paths that are pairwise node disjoint except at the endpoints of the paths, such that each element in the decomposition carries one unit of flow. Each Path is from a node v with ef(v) < 0 to ef(w) > 0
Example for 4.3 0 -2 2 t s Augmented residual graph for flow f (f=2). All Arcs have unit capacity on both sides
Stage 2 • Definition: residual flow value total excess that can reach t in Gf. • Lemma 4.4 If Γmax ≥ K (>2), the residual flow value is at most n/(k-1) if G is a matching network.
Stage 2 • Proof: • Let’s look at the first time Γ(f,d) ≥ K. • Assume f* is the maximum flow in G. • f’ = f* - f. • -f’ is a pseudoflow in the augmented residual graph of f* => can be decomposed into cycles and paths as in Lemma 4.3
Stage 2 - cont • From –f’ decomposition we can find f’ decomposition. • Γ≥ k therefore any path in Gf from an active node to t must contain at least k+1 nodes. • Since each such path is node disjoint => there are at most (n-2)/(k-1) such paths. • The amount of excess that can reach t is at most n/(k-1).
Stage 4 • Same idea as in Stage 2. • For Γmax ≥ n+ k (>n+2) the residual flow value is at most n/(k-1) if G is a matching network.
Stage 2 and Stage 4 • Lemma 4.6 Between any two consecutive global update operations, the algorithm does Θ(m) work.
Stage 2 and Stage 4 - Cont • Proof: • It’s sufficient to show that the work done in moving a unit of excess to s or t after global update is O(m). • For each node v, at least one of dt(v), ds(v) is finite. • After global update there is at least one admissible arc leaving each node. • So the first unit of excess being processed after global update can reach t or s without any Relabel.
Stage 2 and Stage 4 - Cont • Choosing a unit of excess to process is done in O(n). • The path to s or t can be at most n. • The work of pushing the excess to its destination is O(n) + the work in finding the admissible arc leaving the node. • O(n + m ) = O(m).
Complexity of Minimum Distance Discharge Algorithm • Lemma 4.7: • The Minimum Distance Discharge algorithm with Global Updates computed maximum flow in a matching network (and hence a maximum cardinality bipartite matching) in O(m√n).
Complexity of Minimum Distance Discharge Algorithm • Proof: • The amount of work during stage 1 and 3 is O(km). • The amount of excess processed during stage 2 and 4 is at most 2n/(k-1) • Moving this excess takes O(mn/k). • O(km + mn/k) = O(m√n) when k = √n.
Bad family relabel 0 0 1 d(v) = 7 0 0 -3 1 0 0 1
Bad family 1 0 1 relabel 7 0 0 -3 1 0 0 1
Bad family 1 0 1 7 0 1 -3 1 0 0 1 relabel
Bad family relabel 1 0 0 1 7 0 1 -3 1 0 1 1
Bad family 1 1 0 0 7 0 1 1 -3 1 0 0 1 1
Bad family 1 1 0 0 7 0 1 1 -3 0 0 1 1 relabel 1
Bad family 1 1 0 0 7 0 1 2 -3 0 1 0 1 1
Bad family 1 1 0 0 7 0 1 2 -3 0 1 0 2 1 relabel
Bad family 1 relabel 1 0 1 7 0 1 2 -3 0 1 0 2 0
Bad family relabel 1 2 1 0 7 0 1 2 -3 0 1 0 2 0