global price updates help a.v goldberg and r. kennedy advanced algorithms seminar instructor: prof....

119
Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Post on 19-Dec-2015

214 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Global Price Updates Help A.V Goldberg and R. Kennedy

Advanced Algorithms Seminar

Instructor: Prof. Haim Kaplan

Presented by: Orit Nissan-Messing

Page 2: 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 Improve complexity using “Global

Updates”

Page 3: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 4: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bipartite graph example:

X Y

Page 5: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 6: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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

Page 7: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Building a matching network

S t

1

11

Page 8: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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 Ĝ.

Page 9: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 10: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Some more definitions

Distance labeling d is valid w.r.t f if: d(t) = 0d(s) = nFor every arc (v,w) Ef : d(v) ≤ d(w) + 1

Admissible arc (v,w) : d(v) = d(w) + 1. GA is acyclic for any valid distance labeling

Page 11: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 12: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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…

Page 13: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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).

Page 14: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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

Page 15: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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) = ∞.

Page 16: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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...

Page 17: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

AndSince the last update, the algorithm has done

at least m work in Push and Relabel operations.

Page 18: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 19: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 20: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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).

Page 21: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 22: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 23: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Distance Discharge - Analysis

Lemma 4.1:

Between two consecutive Global Updates, the algorithm does O(n) work in examining empty buckets.

Page 24: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Distance Discharge - Analysis

Proof:μ decreases only when it is set to zero

after an update.

Page 25: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Distance Discharge - Analysis

Proof:μ decreases only when it is set to zero

after an update.

d=3d=2

d=1

T

d = 1

μ = 3

Active node

Page 26: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Distance Discharge - Analysis

Proof:μ decreases only when it is set to zero

after an update. There are 2n+1 buckets.

Page 27: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 28: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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]

Page 29: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 30: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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

Page 31: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Example for 4.3

2

0

Augmented residual graph for flow f (f=2).

All Arcs have unit capacity on both sides

-2

s t

Page 32: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 33: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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

Page 34: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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).

Page 35: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 36: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Stage 2 and Stage 4

Lemma 4.6

Between any two consecutive global update operations, the algorithm does Θ(m) work.

Page 37: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 38: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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).

Page 39: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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).

Page 40: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

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.

Page 41: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

1

1

1

-3

d(v) = 7

0

0

0

0

0

0

relabel

Page 42: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

1

1

1

-3

7

1

0

0

0

0

0relabel

Page 43: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

1

1

1

-3

7

1

1

0

0

0

0

relabel

Page 44: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

1

1

-3

7

1

1

1

0

0

0

1

relabel

Page 45: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

1

1

-3

7

1

1

1

0

0

1

0

1

0

Page 46: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

1

-3

7

1

1

1

0

0

1

0

relabel

1

1

Page 47: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

1

-3

7

1

1

1

1

0

1

0

2

0

Page 48: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

1

-3

7

1

1

2

1

0

1

0

2

0

relabel

Page 49: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

0

-3

7

1

1

2

1

0

1

1

2

0

relabel

Page 50: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

1

0

0

-3

7

1

1

2

1

0

2

0

2

0

relabel

Page 51: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

0

-3

7

2

1

2

1

0

2

0

2

1

relabel

Page 52: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

1

0

-3

7

2

1

2

2

0

2

0

2

0

relabel

Page 53: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Bad family

0

0

0

-3

7

2

3

2

2

0

2

1

2

0

relabel

Page 54: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

So what Global Update would have changed?

0

0

0

-3

7

2

3

2

2

0

3

1

2

0

After some ping pong Relabels it would set d(v) to the right values such that there is a path to s or t

Page 55: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

0

0

0

-3

7

8

8

8

9

0

9

1

2

0

Page 56: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Second problem : Assignment Problem Weight of matching M is the sum of the

weights of the edges in M. The Assignment problem is to find a

maximum cardinality matching with minimum weight.

Assumption cost are integers in the range [0,..C]

Page 57: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Assignment problem to Minimum Cost Circulation problem Given Ĝ weighted bipartite graph Build G for the Minimum Cost Circulation problem by:

Adding nodes s and t For each v X , placing (s,v) in E with capacity 1 and cost -nC

For each v Y, placing (v,t) in E with capacity 1 and cost 0

For each edge {v,w} Ê, placing (v,w) in E with capacity 1 and the cost as in Ĝ.

Reverse arcs will have zero capacity and obey the cost symmetry constraint.

Adding n/2 arcs (t,s) in E with 0 cost and capacity 1.

Page 58: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Building G for the Minimum Cost Circulation Problem

S t

2-45 0

2

5

3

4

1

0

-2 u=0

Page 59: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

As in the matching problem, Any integral circulation in G can be “converted” into a matching in Ĝ.The matching are the arcs (x,y) with f = 1.

Minimum circulation in G corresponds to a maximum matching of minimum weight in Ĝ.

Page 60: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Back to definitions

Price function P: V →R. Reduced Cost of arc (v,w)

Cp(v,w) = p(v) + c(v,w) – p(w) U = X U {t} Eu : the set of arcs whose tail node is in U.

Page 61: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Definition example

2

0

2-12

0

0

0

12

Page 62: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

ε-optimality

A pseudoflow f is ε-optimal w.r.t price function p, if for every residual arc aa Є Eu Cp (a) ≥ 0a Є Eu Cp (a) ≥ - 2ε

A pseudoflow f is ε-optimal if it’s ε-optimal with respect to some price function p.

When the arc cost are int and ε < 1/n, any ε-optimal circulation is optimal.

Page 63: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Admissibility

a Є Ef is admissible:

a Є Eu Cp (a) < εa Є Eu Cp (a) < -ε

Page 64: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Succssive Approximation Algorithm – The idea

Starting with ε = C Running in iterations until ε < 1/n.Each iteration refines ε (divide by a constant

α) and saturate all arcs with Cp < 0 thus making f pseudoflow ε–optimal .

Making f an ε–optimal circulation by Pushs and Relabels.

Number of iterations = 1+ logα(nC)

Page 65: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Cost scaling Algorithm

Min-Cost(V,E,u,c) Init:

ε ← C , p(v) = 0 , f(a) = 0

While ε ≥ 1/n (ε,f,p)← Refine(ε,f,p)

Page 66: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine Procedure

Init: ε ← ε/αAll a Є E with Cp(a) < 0, f(a) =1

While f is not a circulation (ε optimal) Apply Relabel and Push operations.

Return (ε,f,p)

Page 67: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Relabel and Push

Push(v,w)Send a unit of flow from v to w

Relabel(v) If v Є U

P(v) = max (v,w) Є Ef {p(w) – c(v,w) }Else

P(v) = max (v,w) Є Ef {p(w) – c(v,w) - 2ε}

Page 68: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Relabel and Push

Relabel and Push preserve ε optimality. Every Push is a saturating push. Each Relabel decreases p(v) by at least ε. After Relabel , no admissible arc enters v. Ga is acyclic.

Page 69: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Relabel Analysis

Based on the analysis of minimum cost circulation:Every Relabel decreases a node price by at

least ε.Each iteration , p(v) decreases by O(nε).Or more accurately by at most 2αnε.

Page 70: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

2

0

2

-12

-12 0

0

0

ε = 1

admissible:a Є Eu Cp (a) < εa Є Eu Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 71: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-2

1

1

2

0

2

12

12

0

0

0

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 72: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-2

0

1 1

2

0

2

12

12

0

0

0

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Relabel : -2ReducedCost (cost)

Page 73: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-2

0

1 1

2

-2) 0(

4)2(

12

12

- 2) 0(

0

0

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

ReducedCost (cost)

P = -2

Page 74: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

1 0

2

-2) 0(

4)2(

12

12

- 2) 0(

0

0

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

P = -2

Relabel : -4

Page 75: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

1 0

2

-2) 0(

0)2(

12

12

- 2) 0(

0

0

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

P = -2P = -4

Page 76: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

0 1

2

-2) 0(

12

12

2)0(

0

0

P= -4

0-) 2(

P= -2

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 77: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

1

0 0

0)2(

0) 0(

12

12

2)0(

0

0

P= -4

0-) 2(

P= -2

Relabel : -2

admissible:a Є Eu Cp (a) < εElse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 78: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

0 1

0)2(

0) 0(

12

12

2)0(

0

0

P= -4

0-) 2(

P= -2

P = -2

Relabel : -4

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 79: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

0 1

0)2(

-2) 0(

12

12

4)0(

0

0

P= -4

-2-) 2(

P= -4

P = -2

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 80: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

1 0

0)2(

-2) 0(

12

12

4)0(

0

0

P= -4

2) 2(

P= -4

P = -2

Relabel : -6

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 81: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

1 0

0)2(

-2) 0(

12

12

4)0(

0

0

P= -6

0) 2(

P= -4

P = -2

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 82: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

0 1

0)2(

-2) 0(

12

12

4)0(

0

0

P= -6

0-) 2(

P= -4

P = -2

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

Page 83: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

1

0 0

0)2(

2) 0(

12

12

4)0(

0

0

P= -6

0-) 2(

P= -4

P = -2

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

admissible:a Є Eu Cp (a) < εelse Cp (a) < -ε

Page 84: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

-1

0

0

1

0

0-)2(

2) 0(

12

12

)4)0

0

0

P= -6

0-) 2(

P= -4

P = -2

Relabel(v) v Є U P(v) = max {p(w) – c(v,w) }

Else P(v) = max {p(w) – c(v,w) - 2ε}

admissible:a Є Eu Cp (a) < εelse Cp (a) < -εRelabel : -2

Page 85: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

This is our matching with minimum cost.

0

0

0

0

0

0-) 2(

2) 0(

12

12

4)0(

2)0(

0

P= -6

0-) 2(

P= -4

P = -2

Page 86: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Global Updates

The goal : Changing p(v) such as there is a path from every node with excess ef(v) > 0 to some node ef(w) < 0 in Ga.

Page 87: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Length function

Define length function ℓ(a) = ceil ( Cp(a)/ ε) if a Є Eu

otherwise ℓ(a) = 1 + ceil ( Cp(a)/ ε)

dℓ(v) – the distance of node v from nodes with deficit.

From CS-TR-95-1556

Page 88: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Global update intuition

Global update intuition: decreasing p(v) by dℓ(v) * ε for each node

would preserve ε optimality and Ga

acyclicity and ensuring that there is an admissible path for every node with excess to a node with deficit.

Page 89: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Example of Global Update

-1

0

0 1

0)2(

-2) 0(

12

12

4)0(

0

0

P= -6

0) 2(

P= -4

P = -2

ε = 1

dℓ = 1, p = -3

dℓ = 0, p = - 4

dℓ = 0, p = 0

dℓ = 1, p = -1

dℓ = 12, p = -18

This is our set of deficit node

Page 90: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

But ..

But it costs too much.. There is no bound on price change for every node.

We would like Global Update to take o(m) They applied a variation of Dial where the

scanned nodes are those who can be reached from an active node, active nodes has a bound on the price change.

Page 91: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Global update – When?

At Init. After each Push and Relabel operation if :

Since the last update, at least one unit of excess has canceled some deficit.

AndSince the last update, the algorithm has done

at least m work in Push and Relabel operations.

Page 92: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Price Change

δ(v) = ceil ( -p(v) / ε ) Setting at the beginning of refine iteration

p(v) = 0 for all nodes will make δ(v) to be the price change of node v during the iteration.

Page 93: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge – The idea Selecting a unit of excess at active node

with minimum δ(v). Process this unit of excess until:

Relabel occurs.A deficit is canceled.

If after the Relabel and the node still has the minimum δ(v) continue with this node.

Page 94: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum change discharge – how is it implemented?

Building buckets B0,….., B2αn.

Bucket Bi holds the active nodes with δ(v) = i.

μ - index of the bucket from which we selected the recent active node (unit of excess).

Page 95: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Definitions for Refine Analysis

Γ(f,p) – the minimum change price of an active node w.r.t pseudoflow f and p.

Γmax – The maximum value reached by Γ so far in the iteration.

Page 96: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis

Lemma 9.1: (same as Lemma 4.1)

Between two consecutive Global Updates, the algorithm does O(n) work in examining empty buckets.

Page 97: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine Analysis: small δ

Lemma 9.2:

The algorithm does O(km) work in the course of Relabel operations on nodes v obeying δ(v) ≤ k and Push operations from those nodes.

Page 98: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis Proof:

V can be relabeled at most k+1 times while δ(v) ≤ k.

The work for Relabels on those nodes O(km).

The work for Pushes is also O(km).

Page 99: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine Analysis

Define E to be total excess E = ∑ef(v) > 0 ef(v)

Lemma 9.4: (will be proved later)

At any point during the execution of refine other than the first

E* Γmax ≤ 2(( 5 + α)n -1)

Page 100: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine Analysis : Γmax ≥ K

Corollary 9.5 When Γmax ≥ K then E = O(n/k)

Can be derived from Lemma 9.4

E* Γmax ≤ 2(( 5 + α)n -1)

Page 101: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine analysis: Γmax ≤ k big δ

Lemma 9.6:

While Γmax ≤ k, the amount of work done in relabeling at nodes v with δ(v) > k and pushes from those nodes is O(n^2/k)

Page 102: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine analysis: Γmax ≤ k

Proof:Define a node with δ(v) > k when Γmax ≤ k a

“bad node”.Find a bound on Relabel operations on bad

nodes.A node v is being processed for one of 2

reasons: It was selected from a bucket δ(v) ≤ Γmax - can not

be a bad node. A unit of excess was pushed to it.

Page 103: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine analysis: Γmax ≤ k

Proof continue: A unit of excess just pushed to v :

After v is relabeled, a different node w with δ(w) = Γ will be chosen (by MCD).

The excess will remain at v until Γmax ≥ δ(v). When Γmax ≥ K then the total excess

remaining is O(n/k).

Page 104: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine analysis: Γmax ≤ k

Proof continue: Since the excess will have to remain at v

until Γmax ≥ K ,The numbers of relabeling of bad nodes is O(n/k)

The degree of each node is at most n. The work in pushes and relabeling bad

nodes is O(n^2/k)

Page 105: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis

Lemma 9.7:

Between any two consecutive global update operations, the algorithm does O(m) work.

Page 106: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Proof: It’s sufficient to show that the work done in

canceling a deficit after global update is O(m).

From Global Update “definition” – after global update there is a path from a node with excess to a node with deficit which does not require any Relabel operation.

Page 107: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

The work of pushing the excess to its destination is O(n).

The amount of work in choosing the unit of excess to process in O(n)

Page 108: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis

Theorem 9.8:

The Minimum Change Discharge algorithm with global updates computes a minimum cost circulation in a matching network in O(m√n* log (nC)) time

Page 109: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis Proof: During a refine:

Γmax ≤ k: The algorithm takes O(km+n^2/k) Γmax ≥ k:

Total excess remaining is O(n/k). The work done in pushing an excess to a

deficit is O(m) The algorithm takes O(km/n)

Page 110: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Minimum Change Discharge - Analysis Proof Continue: The work done in Refine :

O(km/n + n^2/k + km). Choosing k to be √n and α =2

Refine : O(m√n) Minimum change discharge with Global

Update takes: O(m√n* log (nC))

Page 111: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4

Lemma 9.4: At any point during the execution of

refine other than the first

E* Γmax ≤ 2(( 5 + α)n -1)

Page 112: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Flow Decomposition

Lemma 9.3: Given a matching network G and an integral

circulation g, any integral pseudoflow f in Gg can be decomposed into : Cycles and Paths, each from a node u with a deficit to a node v

with excess. Where all the elements are pairwiase node

disjoint except at s,t and the endpoints of the paths, and each element carries one unit of flow.

Page 113: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Refine Analysis

Lemma 9.4 Proof: c : the (reduced) arc cost at the

beginning of this refine. G :the augmented residual graph at

the same time. E * Γmax ≤ ∑ ef(v) > 0 δ(v)ef(v)

Page 114: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4

Prove: -∑ ef(v) > 0 p(v)ef(v) = cp(f) – c(f) Cp(f) – C(f) = ∑f(v,w)>0 (p(v)-p(w))f(v,w) Let D be the decomposition of f into paths

and cycles. Cycles do not effect the above equation. ∑f(v,w)>0 (p(v)-p(w))f(v,w) =

∑p(u)-p(v) when (u v) Є D

Page 115: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4

Nodes with deficit never relabled , thus p(u) = 0.

Cp(f) – C(f) = -∑ p(v) when (u v) Є D Cp(f) – C(f) = -∑ ef(v) > 0 p(v)ef(v)

Page 116: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4 Cp(f) – C(f):

Finding a bound Cp(f) – C(f): C(f): For a circulation g, the residual graph has

exactly n arcs a Є Eu There are at most n negative cost arcs ,

each has cost at least - 2αε C(f) ≥ - 2αεn

Page 117: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4, Cp(f):

Cp(f): f(a) >0 a reverse Є Ef From f ε-optimality:

a reverse Є Ef Cp(a reverse) ≥ -2ε.

f(a) > 0 Cp(a) ≤ 2ε.

So how many arcs with positive flow are there?

Page 118: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4, Cp(f):

Cp(f) = ∑ d Є D Cp(d)

Define V(d) : interior of a path W(d) the set containing the initial and final arcs of d. If d is a cycle then V(d) = d W(d) = Ø.

Cp(f) = ∑ d Є D Cp(V(d)) + ∑ d Є D Cp(W(d))

Page 119: Global Price Updates Help A.V Goldberg and R. Kennedy Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Orit Nissan-Messing

Lemma 9.4

Counting the number of arcs in that equation: Total number of arc not incident to s or t in path and cycles

interiors is at most n by node disjoint. Total number of arc incident to s or t are at most 2n-1 Total excess is at most n initial and final arcs of paths are

no more than 2n. Arc with positive flow has reduced cost at most 2ε.

Cp(f) ≤ (n+ 2n-1+2n) 2ε = (5n-1) 2ε Cp(f) – c(f) ≤ 2(5 + α)n -1) ε