Upload
taryn
View
36
Download
0
Embed Size (px)
DESCRIPTION
Finding Minimum-Cost Circulation By Successive Approximation. Goldberg and Tarjan 1990. Advanced Algorithms Seminar Instructor: Prof. Haim Kaplan Presented by: Michal Segalov & Lior Litwak. Motivation. What is the minimum cost circulation problem? - PowerPoint PPT Presentation
Citation preview
Finding Minimum-Cost Circulation By Successive
Approximation
Goldberg and Tarjan 1990
Advanced Algorithms Seminar
Instructor: Prof. Haim Kaplan
Presented by: Michal Segalov & Lior Litwak
Motivation
What is the minimum cost circulation problem?
What is this problem equivalent to in the real world?
The Min-Cost Circulation Problem
In the flow problems we have the “source” and “sink” special vertices, such that flow passes between them.
The Min-Cost Circulation Problem
In the flow problems we have the “source” and “sink” special vertices, such that flow passes between them.
The circulation problems take these vertices out of the game.
The Min-Cost Circulation Problem
In the flow problems we have the “source” and “sink” special vertices, such that flow passes between them.
The circulation problems take these vertices out of the game.
We push flow through edges in cycles along the graph, seeking minimal cost.
The Min-Cost Circulation Problem
In the flow problems we have the “source” and “sink” special vertices, such that flow passes between them.
The circulation problems take these vertices out of the game.
We push flow through edges in cycles along the graph, seeking minimal cost.
Notice – we are not interested in pushing maximal flow anymore.
Max-Flow, Min-Cost & What’s Between
Consider the familiar Max-Flow problem. In that problem we want to achieve maximal flow on the edges.
Max-Flow, Min-Cost & What’s Between
Consider the familiar Max-Flow problem. In that problem we want to achieve maximal flow on the edges.
Now think of giving a cost to flow units going through each edge (positive or negative).
Max-Flow, Min-Cost & What’s Between
Consider the familiar Max-Flow problem. In that problem we want to achieve maximal flow on the edges.
Now think of giving a cost to flow units going through each edge (positive or negative).
We now wish to find, amongst all possible maximal flows, the one with minimal cost.
Min-Cost Max-Flow Equivalenceto Min-Cost Circulation
Given a graph G, construct G’ by adding two vertices s and t, not connected to any of the other vertices. Any min cost flow in G’ is a min-cost circulation in G.
s t
G G’
Min-Cost Max-Flow Equivalenceto Min-Cost Circulation
Given a graph G, construct G’ by connecting t and s with a new edge s.t.
, , 1u t s mU c t s C n
ts
ts
G G’
Previous Work
Some other Algorithms out there:
This paper introduced an efficient general scheme, rather than a specific one, for solving the problem
The BIG Picture
In this lecture we will see a general approach for solving this problem.
The BIG Picture
In this lecture we will see a general approach for solving this problem.
It works by finding an initial approximate solution and then iteratively refining it until reaching an optimal one.
The BIG Picture
In this lecture we will see a general approach for solving this problem.
It works by finding an initial approximate solution and then iteratively refining it until reaching an optimal one.
The error parameter, ε, is halved in each iteration until the integrality of the arc costs guarantees an optimal solution.
The BIG Picture
We will see two methods for refinement: The Generic method – Uses a sequence of
transformation on the current circulation to produce a finer one. Achieves a runtime of
Blocking Flow method – a generalization of Dinic used for refinement. Complexity is the same for a simple implementation.
Complexity even better with dynamic trees…
3 min log , logO n nC m n
Definitions – The Basics
A circulation network is a symmetric graph G=(V,E) with a real value capacity u(v,w) function and a cost c(v,w) function for each arc s.t.
c(v,w) = -c(w,v) (cost antisymmetry constraint)
Definitions – The Basics
A pseudoflow is a function s.t. for each : 1. f(w,v) ≤ u(w,v) (capacity constraint)2. f(w,v) = –f(v,w) (flow antisymmetry constraint)
The cost of a pseudoflow is
,
1cost( ) , ,2 v w E
f c v w f v w
:f E R ,v w E
Definitions – The Basics
For a pseudoflow f and a vertex v, the excess flow into v , is defined by
A vertex v is called active if Observe that
(because G is symmetric)
fe v
,
,fu v E
e v f u v
0fe v 0fv V
e v
Definitions – The Basics
Pseudoflow example:
4,1,3
6,3,-2
u=5,f=2,c=-1
4,3,1
Total cost = -2
0,-1,-3
0,-3,2
2,-3,-1
0,-2,1
ef = -1
ef = -4
ef = -1
ef = 6
Definitions – The Basics
A circulation is a pseudoflow s.t. for each vertex v, 0fe v
Definitions – The Basics
A circulation is a pseudoflow s.t. for each vertex v,
This means that there is no excess flow in v, and that flow is not “created” in v(i.e. no “sources” and “sinks” in G)
0fe v
Definitions – The Basics
A circulation is a pseudoflow s.t. for each vertex v,
This means that there is no excess flow in v, and that flow is not “created” in v(i.e. no “sources” and “sinks” in G)
A pseudoflow is a circulation iff there are no active vertices (by definition)
0fe v
Definitions – The Residual System
The residual capacity of and edge (v,w) is
An arc is saturated if The residual graph is defined as
Note that all the residual arcs are non-saturated…
, , ,fu v w u v w f v w , 0fu v w
, , | 0f f f fG V E E e u e
Definitions – Prices & Costs
A price function is a function We use the price function to define the
reduced cost of an arc:
:p V R
, ,pc v w c v w p v p w
Definitions – Prices & Costs
A price function is a function We use the price function to define the
reduced cost of an arc:
Note that the cost of a circulation is the same whether the original costs or the reduced costs with respect to some price function are used!
:p V R
, ,pc v w c v w p v p w
Optimality of Circulations
We say the a circulation is optimal if its cost is minimal
Optimality of Circulations
We say the a circulation is optimal if its cost is minimal
Theorem 2.1 A circulation f is minimum cost iff the
residual graph contains no cycles of negative cost
Optimality of Circulations
Proof ( ): If there are negative cycles in Gf we can obtain
a “cheaper” circulation by increasing flow on them.
4,0,3
6,3,-2
u=5,f=3,c=-1
4,3,1
4,3
3,-2
uf=2,c=-1
1,1
cost = -6We have a negative cycle
GfG
Optimality of Circulations
Proof ( ): If the circulation f is not optimal, we show there
exists a negative cycle in Gf
Let f* be an optimal circulation.We will look at the decomposition of the circulation f*-f into cycles.
Since it is of negative cost and feasible in Gf, it contains a negative cycle!
Optimality of Circulations
Theorem 2.2 A circulation f is minimum cost iff there is a
price function p s.t. for each arc (v,w)
, 0 , ,pc v w f v w u v w
Optimality of Circulations
Proof ( ): Given such p, there are no negative reduced
cost cycles in Gf. Hence, no negative cost cycles in Gf. Use the previous theorem.
Optimality of Circulations
Proof ( ): Given an optimal circulation, such a function
can be calculated using the shortest paths from an external vertex s in Gf.
can you think how?
Optimality of Circulations
4,3
2,-2
uf=1,c=-1
Gf
4,1
4,2
4,-1
Optimality of Circulations
3
-2
c=-1
Gaux
1
2
-1
S
0
00
0
Optimality of Circulations
3
-2
c=-1
Gaux
1
2
-1
S
0
00
0
Optimality of Circulations
3
-2
c=-1
Gaux
1
2
-1
S
0
00
Optimality of Circulations
3
-2
c=-1
Gaux
1
2
-1
S
0
0
Optimality of Circulations
-2
c=-1
Gaux
1
2
-1
S
0
0
Optimality of Circulations
-2
c=-1
Gaux
2
-1
S
0
0
Optimality of Circulations
-2
c=-1
Gaux
2
S
0
0
Optimality of Circulations
-2
c=-1
T
S
0
0
Optimality of Circulations
-2
c=-1
T
S
0
0
d = 0
d = 0
d = -1
d = -3
,c v w d v d w
Optimality of Circulations
4,3
2,-2
uf=1,c=-1
Gf
4,1
4,2
4,-1
p = 0
p = 0
p = -1
p = -3
Define p = d:
Optimality of Circulations
c=-1, cp=0
Gf
p = 0
p = 0
p = -1
p = -3
c=1, cp=0
c=-2, cp=0
c=2, cp=0
c=-1, cp=2
c=3, cp=3
, 0 ,p fc v w v w G
So What Have We Seen So Far?
Definitions – The Basics
A circulation network is a symmetric graph G=(V,E) with a real value capacity u(v,w) function and a cost c(v,w) function for each arc s.t.
c(v,w) = -c(w,v) (cost antisymmetry constraint)
Definitions – The Basics
A pseudoflow is a function s.t. for each : 1. f(w,v) ≤ u(w,v) (capacity constraint)2. f(w,v) = –f(v,w) (flow antisymmetry constraint)
The cost of a pseudoflow is
,
1cost( ) , ,2 v w E
f c v w f v w
:f E R ,v w E
Definitions – The Basics
For a pseudoflow f and a vertex v, the excess flow into v , is defined by
A vertex v is called active if Observe that
(because G is symmetric)
fe v
,
,fu v E
e v f u v
0fe v 0fv V
e v
Definitions – The Basics
A circulation is a pseudoflow s.t. for each vertex v, 0fe v
Definitions – Prices & Costs
A price function is a function We use the price function to define the
reduced cost of an arc:
:p V R
, ,pc v w c v w p v p w
Definitions – Prices & Costs
A price function is a function We use the price function to define the
reduced cost of an arc:
Note that the cost of a circulation is the same whether the original costs or the reduced costs with respect to some price function are used!
:p V R
, ,pc v w c v w p v p w
Optimality of Circulations
We say the a circulation is optimal if its cost is minimal
Optimality of Circulations
We say the a circulation is optimal if its cost is minimal
Theorem 2.1 A circulation f is minimum cost iff the
residual graph contains no cycles of negative cost
Optimality of Circulations
Theorem 2.2 A circulation f is minimum cost iff there is a
price function p s.t. for each arc (v,w)
, 0 , ,pc v w f v w u v w
Now let’s relax the definition of circulation optimality
Optimality and Approximate Optimality
A circulation f is ε-optimal with respect to a price function p if
(we relax the optimality constraint) A pseudoflow is ε-optimal if it is ε-optimal with
respect to some price function p. Observe that a pseudoflow is ε-optimal w.r.t. p
iff for every residual arc.
, , ,pc v w f v w u v w
,pc v w
Approximate Optimality Properties
Theorem 2.3 If all costs are integers and
then an ε-optimal solution is optimal1/ n
Approximate Optimality Properties
Proof: Consider a simple cycle in Gf. The ε-optimality of f implies that the reduced
cost of the cycle is at least . The reduced cost of the cycle equals the
original cost which is non-negative (all costs are integral).
Since there are no negative cost cycles, f is minimum cost circulation.
1n
Fitting Price Functions and Tight Error Parameters
The definition of ε-optimality raises two interesting questions:
1. Given a pseudoflow f and a constant ε, find a price function p s.t. f is ε-optimal w.r.t p(or show that f is not ε-optimal).
2. Given a pseudoflow f, find an ε s.t. f is ε-tight (the smallest ε s.t. f is ε-optimal).
Finding a Fitting Price Function
Objective:
Given a pseudoflow f and a constant ε, find a price function p s.t. f is ε-optimal w.r.t p, or show that f is not ε-optimal.
Finding a Fitting Price Function
Let’s define Extend the residual graph by adding a
vertex s with arcs to all other vertices –
(Also define )
, ,c u v c u v
,aux fG V s E s V
, 0c s u
fG
Finding a Fitting Price Function
Theorem 3.3A pseudoflow is ε-optimal if and only if
contains no cycle of negative cost. If T is a shortest path tree of rooted at s w.r.t , and d is the distance function in the tree then f is ε-optimal w.r.t p = d.
auxG
auxG
c
c
Finding a Fitting Price Function
Using the previous theorem the first problem can be solved by constructing a short distance tree in (or finding a negative cost cycle in it).
O(n+m) for constructing O(nm) – Building shortest path
tree/looking for negative cost cycle (Bellman Ford)
auxG
auxG
The Last Introduction Slide!
The Minimum-Cost Framework
Now we get to business…We want to construct a general algorithm
framework to solve the Minimum-Cost Circulation problem.
The Minimum-Cost Framework
Now we get to business…We want to construct a general algorithm
framework to solve the Minimum-Cost Circulation problem.
The successive approximation framework assumes all costs are integral.
The Minimum-Cost Framework
The basic idea: Find an initial C-optimal circulation f w.r.t. p s.t.
p(v) = 0 (for all v) Refine ε by half and adjust f and p to be
ε/2-optimal Repeat until ε is small enough to guarantee
optimality.
The Minimum-Cost Framework
Procedure min-cost(V,E,u,c):[Initialization] ε ← C; ; If there exists a circulation then load it into f,
else return NULL;[Main loop] While ε ≥ 1/n do
(ε,f,p) ← refine(ε,f,p) Return f
End
, 0v V p v
The Minimum-Cost Framework
Correctness: Under the assumption that refine is correct, the
correctness of the algorithm is immediate from Theorem 2.3.
The Minimum-Cost Framework
Correctness: Under the assumption that refine is correct, the
correctness of the algorithm is immediate from Theorem 2.3.
Complexity: iterations of refine Each refine takes and can be reduced
using dynamic trees to .
logO nC 3O n
2log /O nm n m
The Generic Refinement Method
This method uses ideas similar to those presented in Goldberg & Tarjan’s Max-Flow algorithm.
We will use push and relabel operations here as well, modified to fit the ε-optimal environment.
The Generic Refinement Method
Procedure refine(ε,f,p):[Initialization] ε ← ε/2; For every (v,w) in E do:
If cp(v,w) < 0 then f(v,w) ← u(v,w);[Loop] While there exists a flow/price update operation
that applies do:Select such an operation and apply it;
Return (ε,f,p)End
The Generic Refinement Method
Refine starts by halving ε and saturating all edges with negative reduced cost.
This achieves an ε-optimal pseudoflow.Next we apply the flow & price update
operations (push & relabel respectively), to transform the pseudoflow into an ε-optimal circulation.
The Generic Refinement MethodProcedure push(v,w):
Applicability: v is active, uf(v,w) > 0 and cp(v,w) < 0 Action: send δ = min {ef(v),uf(v,w)} units of flow
from v to w
Procedure relabel(v):Applicability: v is active and :
uf(v,w) > 0 cp(v,w) ≥ 0 Action: replace p(v) with
w V
,max ,fv w E p w c v w
The Generic Refinement Method
The push operation (non-saturating):
The vertex is no longer active.
uf=5,cp=-1Gf
uf=2,cp=1
ef=2uf=3,cp=-1
Gf
uf=2,cp=1
ef=0
The Generic Refinement Method
The push operation (saturating):
The vertex remains active!
uf=1,cp=-1Gf
uf=2,cp=1
ef=2
uf=0,cp=-1Gf
uf=2,cp=1
ef=1
The Generic Refinement Method
The relabel operation:
No flow is changed, only the price of the vertex.
c=-1,cp=3Gf
c=2,cp=4
p=0
p=-4
p=-2
c=-1,cp=-εGf
c=2,cp=1-ε
p=-3-ε
p=-4
p=-2
Let’s Analyze aComprehensive Example
x1
x2x3
y1
y2
y3
9,0
10,-2 10,-2
10,1 10,1
10,1
10,-2
Example – The Initial G(Assume G = Gf)
Gf
An Iteration of Refine
ε ← ε/2 = 1
x1
x2x3
y1
y2
y3
9,0
10,-2 10,-2
10,1 10,1
10,1
10,-2
Gf
An Iteration of Refine
At first all negative cost arcs are saturated
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,1
10,1
10,2
Gf
An Iteration of RefineLet’s see how the excess flow moves from
x3 to x1, applying relabels and pushes:
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,1
10,1
10,2
Gf
An Iteration of RefineWe start by applying relabel on x3:
p(x3) = 0
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,1
10,1
10,2
Gf
An Iteration of RefineWe start by applying relabel on x3:
Relabel:
p’(x3) = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,-1
10,-1
10,0
Gf
An Iteration of RefineNow we can push – we choose (arbitrarily)
to push towards x2:
p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,-1
10,-1
10,0
Gf
An Iteration of RefineNow we can push – we choose (arbitrarily)
to push towards x2:
p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10, 1
10,-1
10,0
Gf
An Iteration of RefineNow we relabel x2:
p(x2) = 0p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10, 1
10,-1
10,0
Gf
An Iteration of RefineNow we relabel x2:
Relabel:
p’(x2) = -2p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,-1 10, -1
10,-1
10,0
Gf
An Iteration of RefineAgain, we choose (arbitrarily) to push
towards x1:
p = -2p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,-1 10, -1
10,-1
10,0
Gf
An Iteration of RefineAgain, we choose (arbitrarily) to push
towards x1:
p = -2p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10, -1
10,-1
10,0
Gf
An Iteration of RefineNow we can relabel x1:
p = -2p = -2
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10, -1
10,-1
10,0
Gf
p(x1) = 0
An Iteration of RefineNow we can relabel x1:
Relabel:
p’(x1) = -1
p = -2p = -2
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,2 10,2
10,0 10, -1
10,0
10,0
Gf
An Iteration of RefineWe push 9 flow units towards y1:
p = -2
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,2 10,2
10,0 10, -1
10,0
10,0
Gf
p = -1
p = -2
An Iteration of RefineWe push 9 flow units towards y1:
p = -2
1
-1
x1
x2x3
y1
y2
y3
9, 1
10,2 10,2
10,0 10, -1
10,0
10,0
Gf
p = -1
p = -2
An Iteration of RefineWe can relabel x1 again:
p = -2
1
-1
x1
x2x3
y1
y2
y3
9, 1
10,2 10,2
10,0 10, -1
10,0
10,0
Gf
p = -1
p = -2
An Iteration of RefineWe can relabel x1 again:
Relabel:
p’(x1) = -2
p = -2
1
-1
x1
x2x3
y1
y2
y3
9, 2
10,2 10,2
10,-1 10, -1
10,1
10,0
Gfp = -2
p = -2
1
-1
x1
x2x3
y1
y2
y3
9, 2
10,2 10,2
10,-1 10, -1
10,1
10,0
Gfp = -2
p = -2
Anybody wants to continue?!
p = -2
1
-1
x1
x2x3
y1
y2
y3
9, 2
10,2 10,2
10,-1 10, -1
10,1
10,0
Gfp = -2
p = -2
Anybody wants to continue?!We will, later on – This example is
important to prove certain bounds…
The Correctness of Refine
We need to show a few things: ε-optimality is preserved throughout the
execution of refine. Refine returns an ε-optimal circulation (rather
than just a pseudoflow). Refine terminates (and efficiently…)
The Correctness of Refine
Note that push preserves ε-optimality of any pseudoflow – no arcs with negative reduced cost are added to Gf.
Lemma 5.3:Suppose f is an ε-optimal pseudoflow w.r.t
p and relabel is applied to v, then the price of v decreases by at least ε, and f is ε-optimal w.r.t p’ (the new price function).
ε-Optimality Preservation
Proof:Let f be a ε-optimal pseudoflow w.r.t p.
Before the relabeling of v
After the relabel: , , 0 ,f pv w E c v w p v p w c v w
,' max ,fv w Ep v p w c v w p v
ε-Optimality Preservation
Proof:Let f be a ε-optimal pseudoflow w.r.t p.
Before the relabeling of v
After the relabel:
Now we will show that the new pseudoflow is ε-optimal w.r.t. p’. Show that
, , 0 ,f pv w E c v w p v p w c v w
,' max ,fv w Ep v p w c v w p v
', ,f pv w E c v w
ε-Optimality Preservation
Proof – continuedThe only residual arcs effected by the
change are (v,w) or (w,v).An arc of the form (w,v) has its reduced
cost increased by ε, preserving ε-optimal
ε-Optimality Preservation
Proof – continuedThe only residual arcs effected by the
change are (v,w) or (w,v).An arc of the form (w,v) has its reduced
cost increased by ε, preserving ε-optimalFor an arc (v,w) in Gf
since by definition.
' , , 'pc v w c v w p v p w
' ,p v p w c v w
The Correctness of Refine
Theorem 5.4If refine terminates, the pseudoflow f it
returns is an ε-optimal circulation.
We saw the ε-optimality preservation. Refine terminates only when there are no
active vertices, which means we have a circulation (by definition).
The Complexity of Refine
Suppose we implement refine naively, choosing update operations arbitrarily.
How many update operations are performed in every invocation of refine?
Bounding the Price Reduction
To limit the number of relabel operations performed, we need to bound the reduction in price for each vertex.
Bounding the Price Reduction
Lemma 5.7Let f be a pseudoflow and f’ a circulation.
For any v with ef(v) > 0 there exists a w with ef(w) < 0 and a path from v to w, such that and for
0 1, ... lv v v v w 1,i i fv v E 1 ',i i fv v E
0 i l
Bounding the Price Reduction
Proof:Suppose ef(v) > 0.
Bounding the Price Reduction
Proof:Suppose ef(v) > 0.Define G+=(V,E+),
G-=(V,E-), , | ' , ,E x y f x y f x y
, | ' , ,E x y f x y f x y
Bounding the Price Reduction
Proof:Suppose ef(v) > 0.Define G+=(V,E+),
G-=(V,E-), Notice that:
and that iff
, | ' , ,E x y f x y f x y , | ' , ,E x y f x y f x y
',f fE E E E ,x y E ,y x E
Bounding the Price Reduction
Proof:Suppose ef(v) > 0.Define G+=(V,E+),
G-=(V,E-), Notice that:
and that iffConclusion – it suffices to show the
existence of such path in G+
, | ' , ,E x y f x y f x y , | ' , ,E x y f x y f x y
',f fE E E E ,x y E ,y x E
Bounding the Price Reduction
Proof – Continued:Let S be the set of all vertices reachable
from v in G+
Bounding the Price Reduction
Proof – Continued:Let S be the set of all vertices reachable
from v in G+ Notice that for every edge ,
otherwiseNow we show a crucial inequality
,x y S S , ' ,f x y f x y
y S
Bounding the Price ReductionProof – Continued:
,
,
,,
0
,
0 ' , ' is a circulation
, by previous argument
, , by antisimetry
, by definition of
by antisimetry
x y S S E
x y S S E
x y S S Ex y S S E
x y S V E
fx S
f x y f
f x y
f x y f x y
f x y S
e x
Bounding the Price Reduction
Proof – Continued:Eventually,
But we know thatso there must exist such thatw S
0fx S
e x
0fe v
0fe w
Bounding the Price Reduction
Now we can bound the reduction in price –
Lemma 5.8The price of any vertex v decreases by at
most 3nε during an execution of refine
Bounding the Price Reduction
Proof:We start with , the refine input. 2 2, , 2f p
Bounding the Price Reduction
Proof:We start with , the refine input.
Let f and p be the pseudoflow and the price function after any relabel of v.
2 2, , 2f p
Bounding the Price Reduction
Proof:We start with , the refine input.
Let f and p be the pseudoflow and the price function after any relabel of v.
v must be active before the relabel, and it remains active afterwards.
2 2, , 2f p
Bounding the Price Reduction
Proof:We start with , the refine input.
Let f and p be the pseudoflow and the price function after any relabel of v.
v must be active before the relabel, and it remains active afterwards.
Use previous lemma with f, f’=f2ε, to show that there is a path from v to w such that
2 2, , 2f p
0fe w
Bounding the Price ReductionProof – Continued:From the ε-optimality of f:
1 1
1 10 0
, ,l l
p i i i ii i
l c v v p v p w c v v
Bounding the Price ReductionProof – Continued:From the ε-optimality of f:
From the 2ε-optimality of f’:
1 1
1 10 0
, ,l l
p i i i ii i
l c v v p v p w c v v
2
1 1
1 2 2 10 0
2 , ,l l
p i i i ii i
l c v v p w p v c v v
Bounding the Price ReductionProof – Continued:From the ε-optimality of f:
From the 2ε-optimality of f’:
Sum the above inequalities to get:
1 1
1 10 0
, ,l l
p i i i ii i
l c v v p v p w c v v
2
1 1
1 2 2 10 0
2 , ,l l
p i i i ii i
l c v v p w p v c v v
2 23 3p v p v l p v n
The Bounds: RelabelLemma 5.9The number of relabel operations during
an execution of refine is at most 3n(n-1)
Proof:Recall that after each relabel, the price of
a vertex decreases by at least εOverall it decreases by at most 3nε We get at most 3n(n-1) relabel operations!
The Bounds: Saturating PushLemma 5.10The number of saturating pushes during
an execution of refine is at most 3nm
Proof:After a saturating push on an arc (v,w),
there must be a relabel operation on v, before (any) other push can occur.
We get at most 3nm saturating pushes!
The Bounds: Non-saturating Push
Lemma 5.11The number of non-saturating pushes
during an execution of refine is at most 3n2(n+m)
The Bounds: Non-saturating Push
Some definitions:An arc (v,w) is admissible if
A push operation is applicable only to active admissible arcs.
, 0 , 0f pu v w and c v w
The admissible graph is
Its most important feature – it is acyclic(as we shall prove).
Lemma 5.5Immediately after a relabel is applied to v,
no admissible arcs enter v.
The Bounds: Non-saturating Push
, |A A AG V E E e e is admissible
Proof:Let . Before the relabeling,
by ε-optimality. , fw v G
,pc w v
The Bounds: Non-saturating Push
Proof:Let . Before the relabeling,
by ε-optimality. After the relabeling p(v) decreases by at
least ε, hence it increases by at least ε.
, fw v G
,pc w v
,pc w v
The Bounds: Non-saturating Push
Proof:Let . Before the relabeling,
by ε-optimality. After the relabeling p(v) decreases by at
least ε, hence it increases by at least ε.
Thus, after the relabeling, i.e. (w,v) is not admissible.
, fw v G
,pc w v
,pc w v
, 0pc w v
The Bounds: Non-saturating Push
The Bounds: Non-saturating Push
Corollary 5.6Throughout the running of refine,
the admissible graph remains acyclic.Proof:Initially GA contains no arcs,
hence it is acyclic.Pushes preserve acyclicity. From Lemma 5.5, so do relabels.
The Bounds: Non-saturating Push
Now to prove Lemma 5.11:The number of non-saturating pushes
during an execution of refine is at most 3n2(n+m)
The Bounds: Non-saturating Push
Let’s define a potential function for each vertex, , the number of vertices reachable from v in GA.
v
The Bounds: Non-saturating Push
Let’s define a potential function for each vertex, , the number of vertices reachable from v in GA.
The total potential will be:
v
| is activev v
The Bounds: Non-saturating Push
Let’s define a potential function for each vertex, , the number of vertices reachable from v in GA.
The total potential will be:
Let’s amortize the number of non-saturating pushes using this potential.
v
| is activev v
The Bounds: Non-saturating Push
In the beginning of refine, there are no admissible arcs, i.e. is at most n.
The Bounds: Non-saturating Push
A non-saturating push decreases by at least 1. In such a push operation over the arc (v,w), v
becomes inactive, so its potential is subtracted from the total.
If w becomes active as a result of the push, its potential is added to the total.
But since GA is acyclic. Hence the total potential decreases!
w v
The Bounds: Non-saturating Push
A saturating push increases by at most n: Such a push may activate at most one other
vertex. At most n vertices are reachable from the newly
activated vertex.
The Bounds: Non-saturating Push
A relabel increases by at most n: From Lemma 5.5, no admissible vertices enter
v after a relabel on v. Recall that no other arc are affected by relabel. Thus, for any w≠v, can only decrease! For v itself, can increase up to n.
v w
The Bounds: Non-saturating Push
Overall, the number of non-saturating pushes equals: The initial potential value Plus the number of relabels, times n Plus the number of saturating pushes, times n
That is:
23 1 3 3n n n n nm n n n m
In conclusion, we have shown that a naïve implementation of refine performs update operations.
Let’s show that such an implementation exists, and works in the above complexity.
The Complexity of Refine
2O n m
A Straight-Forward Implementation
Procedure push/relabel(v):Applicability: v is activeAction: Let {v,w} be the current edge of v If uf(v,w) > 0 && cp(v,w) < 0 then push(v,w) Else If {v,w} is not last of edge list of v then:
Make current edge of v the next edge on the list Else:
Make the first edge of v the current edgeRelabel(v)
End
This implementation of refine uses the push/relabel procedure repeatedly, until all vertices are non-active.
If a relabel is applied on v, all arcs (v,w) are saturated (v is still active).
In order for flow to be pushed back to v, there must be a relabel on w first, after which
But this means
A Straight-Forward Implementation
, 0pc w v , 0pc v w
We get a complexity of for refine.
A Straight-Forward Implementation
2O n m
By restricting the application of relabel and push we can obtain better complexity, .
We will apply the operations on a vertex until it is either relabeled or rendered inactive.
Now we should decided in which order to process the vertices.
A Faster Implementation of Refine
3O n
A Faster Implementation of Refine
Procedure discharge(v):Applicability: v is activeAction: apply push/relabel on v until it is
relabeled or becomes inactive
A Faster Implementation of Refine:First Attempt - FIFO
In the Max-Flow algorithm of Goldbreg & Tarjan, we saw that FIFO processing of the vertices improves performance.
Does it work here as well?
A Faster Implementation of Refine:First Attempt - FIFO
Unfortunately, we need passes over the queue in the worst case…
Lemma 6.3During an execution of the FIFO
implementation of refine, there arepasses over the queue.
3O n
3O n
A Faster Implementation of Refine:Second attempt: Topological Order
We use a different order of processing than in the FIFO implementation.
Here, we process the vertices in a topological order, with respect to the current admissible graph GA.
Such an order always exists because recall that GA is acyclic!
A Faster Implementation of Refine:Second attempt: Topological Order
Just a reminder:An arc (v,w) is admissible if
A push operation is applicable only to active admissible arcs.
The admissible graph is
, 0 , 0f pu v w and c v w
, |A A AG V E E e e is admissible
A Faster Implementation of Refine:Second attempt: Topological Order
We maintain a current vertex list in topological order, L.
L is initialized in any order, since GA has no edges to begin with.
In each pass over L, we scan for the first active vertex, and apply discharge on it.
If a vertex is relabeled, it is moved to the beginning of L, and we begin the scan again.
A Faster Implementation of Refine:Second attempt: Topological Order
Procedure first-active:Let L be any vertex listLet v be the first vertex in LWhile there exists an active vertex in L
do:If v is active then:
• discharge(v)• If the discharge relabeled v, move v to the front
of LElse replace v by the next vertex in L
End
A Faster Implementation of Refine:Second attempt: Topological Order
Note that push operations do not affect the topological order of L.
Recall that after a relabel operation on v: No admissible arcs enter v Only arcs connected to v are affected
Thus, moving v to the front of L retains the topological order with respect to the current GA.
A Faster Implementation of Refine:Second attempt: Topological Order
Why is the topological order important?
A Faster Implementation of Refine:Second attempt: Topological Order
Why is the topological order important?After relabel we start from the beginning,
so we never miss an active vertex.
A Faster Implementation of Refine:Second attempt: Topological Order
Why is the topological order important?After relabel we start from the beginning,
so we never miss an active vertex.The topological order guaranties that we
always push flow towards subsequent vertices in L.
A Faster Implementation of Refine:Second attempt: Topological Order
Why is the topological order important?After relabel we start from the beginning,
so we never miss an active vertex.The topological order guaranties that we
always push flow towards subsequent vertices in L.
If discharge ends with a push, the vertex becomes inactive.
A Faster Implementation of Refine:Second attempt: Topological Order
Why is the topological order important?After relabel we start from the beginning,
so we never miss an active vertex.The topological order guaranties that we
always push flow towards subsequent vertices in L.
If discharge ends with a push, the vertex becomes inactive.
It will not be active again until the next relabel operation!
A Faster Implementation of Refine:Second attempt: Topological Order
We define that a pass over L begins from the first vertex and ends on the first relabel operation.
Lemma 6.4The first-active method terminates after
passes over L.Proof:We have only relabel operations.
2O n
2O n
Theorem 6.5The first-active implementation of refine
runs in time, giving a total time complexity of the Min-Cost Circulation algorithm of
A Faster Implementation of Refine:Second attempt: Topological Order
3O n
3 logO n nC
A Faster Implementation of Refine:Second attempt: Topological Order
Proof:We can reduce the bound on the number
of nonsaturating push operations to . In a pass over L, each vertex which is not
relabeled becomes inactive. That is, a nonsaturating push is applied to it. We get nonsaturating pushes per pass.
Other bounds remain the same.Total bound for refine is now !
3O n
3O n
O n
Let’s Test the above Method on the Example Shown Earlier
x1 x2 x3 xn
y1
y2 y3yn
h-1,0
h,-2 h,-2 h,-2
h,1 h,1 h,1
h,1
h,-2
The Example Revisited(Assume G = Gf)
Gf
An Iteration of Refine
ε ← ε/2 = 1
x1 x2 x3 xn
y1
y2 y3yn
h-1,0
h,-2 h,-2 h,-2
h,1 h,1 h,1
h,1
h,-2
Gf
An Iteration of Refine
At first all negative cost arcs are saturated
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,1
h,1
Gf
h,2
An Iteration of RefineLet’s see how the excess flow moves from
xn to x1, applying n relabels and pushes:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,1
h,1
Gf
h,2
An Iteration of RefineWe start by applying relabel on xn:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,1
h,1
Gf
p(xn) = 0
h,2
An Iteration of RefineWe start by applying relabel on xn:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,-1
h,-1
GfRelabel:
p’(xn) = -2
h,0
An Iteration of Refine
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,-1
h,-1
Gf
h,0
p = -2
Now we can push – we choose (unfavorably) to push towards xn-1:
An Iteration of Refine
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,1
h,-1
Gf
h,0
p = -2hh,1
xn-1
Now we can push – we choose (unfavorably) to push towards xn-1:
An Iteration of RefineNow we relabel xn-1:
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,1
h,-1
Gf
h,0
p = -2hh,1
xn-1
p(xn-1) = 0
An Iteration of RefineNow we relabel xn-1:
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,-1
h,-1
Gf
h,0
p = -2hh,-1
xn-1
Relabel:
p’(xn-1) = -2
An Iteration of RefineAgain, we choose (unfavorably) to push
towards xn-2:
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,1 h,-1
h,-1
Gf
h,0
p = -2hh,-1
xn-1
p = -2
An Iteration of RefineWe end up in the following state (after the
last push to x1):
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,-1 h,-1
h,-1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
An Iteration of RefineNow we can relabel x1:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,0
h, 2 h, 2 h,2
h,1 h,-1 h,-1
h,-1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
p = 0
An Iteration of RefineNow we can relabel x1:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,-1h, 2 h, 2 h,2
h,0 h,-1 h,-1
h,0
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
Relabel:
p’(x1) = -1
An Iteration of RefineWe push h-1 flow units towards y1:
h
-h
x1
x2 x3 xn
y1
y2 y3yn
h-1,-1
h, 2 h, 2 h,2
h,0 h,-1 h,-1
h,0
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
p = -1
An Iteration of RefineWe push h-1 flow units towards y1:
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 1h, 2 h, 2 h,2
h,0 h,-1 h,-1
h,0
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
p = -1
An Iteration of RefineWe can relabel x1 again:
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 1
h, 2 h, 2 h,2
h,0 h,-1 h,-1
h,0
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
p = -1
An Iteration of RefineWe can relabel x1 again:
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2h, 2 h, 2 h,2
h,-1 h,-1 h,-1
h,1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
Relabel:
p’(x1) = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h,-1 h,-1 h,-1
h,1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
The single flow unit will flow back to xn :
p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h,-1 h,-1 h,-1
h,1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
Push the flow unit to x2 :
p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h-1,-1
h,-1 h,-1
h,1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
Push the flow unit to x2 :
1,1p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h-1,-1
h,-1
h,1
Gf
h,0
p = -2h,-1
xn-1
p = -2p = -2p = -2
And then push the flow unit to x3 :
1,1
h-1,-1
1,1p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h-1,-1
h,1
Gf
h,0
p = -2
xn-1
p = -2p = -2p = -2
And so on, until finally it reaches xn :
1,1
h-1,-1
1,1
h-1,-1
1,1
h-1,-1
1,1p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h-1,-1
h,0
Gf
h,-1
p = -3
xn-1
p = -2p = -2p = -2
Relabel xn :
1,1
h-1,-1
1,1
h-1,0
1,0
h-1,-1
1,1p = -2
An Iteration of Refine
1-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,2
h-1,-1
h,0
Gf
h-1,-1
p = -3
xn-1
p = -2p = -2p = -2
Push towards yn :
1,1
h-1,-1
1,1
h-1,0
1,0
h-1,-1
1,1
1,1
p = 0
p = -2
An Iteration of Refine
1-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-1,-1
h,0
Gf
h-1,1
p = -3
xn-1
p = -2p = -2p = -2
Relabel yn :
1,1
h-1,-1
1,1
h-1,0
1,0
h-1,-1
1,1
1,-1
p = -2
p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-1,-1
h,0
Gf
h,1
p = -3
xn-1
p = -2p = -2p = -2
Push back towards xn :
1,1
h-1,-1
1,1
h-1,0
1,0
h-1,-1
1,1
p = -2
p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-1,-1
h,-1
Gf
h,0
p = -4
xn-1
p = -2p = -2p = -2
Relabel xn again:
1,1
h-1,-1
1,1
h-1,1
1,-1
h-1,-1
1,1
p = -2
p = -2
An Iteration of Refine
1
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-1,-1
h-1,-1
Gf
h,0
p = -4
xn-1
p = -2p = -2p = -2
Choose (very unfavorably) to push back the flow immediately to x1 :
1,1
h-1,-1
1,1
h-1,1
1,-1
h-1,-1
1,1
p = -2
1,1
p = -2
An Iteration of Refine
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-2,-1
h-1,-1
Gf
h,0
p = -41
xn-1
p = -2p = -2p = -2
Now the flow is pushed towards xn-1 :
2,1
h-2,-1
2,1
h-1,1
1,-1
h-2,-1
2,1
p = -2
1,1
p = -2
An Iteration of Refine
-1
x1
x2 x3 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-2,-1
h-1,-1
Gf
h,0
p = -41
xn-1
p = -4p = -2p = -2
And xn-1 is relabeled:
2,1
h-2,-1
2,1
h-1,-1
1,1
h-2,1
2,-1
p = -2
1,1
p = -2
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-3,-1
h-2,-1
Gf
h,0
p = -4
xn-1
p = -4p = -2p = -2
Now we can push back to xn-2 , but we choose (unfavorably) to do it through xn :
3,1
h-3,-1
3,1
h-2,-1
2,1
h-2,1
2,-1
p = -2
2,1
p = -2
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 2
h, 2 h, 2 h,0
h-n+1,1
h-n+1,-1
Gf
h,0
p = -4
xn-1
p = -4p = -4p = -4
The process continue until, after n iterations, we return the flow to x1 :
n-1,-1
p = -2
n-1,1
p = -2h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4h, 2 h, 2 h,0
h-n+1,-1
h-n+1,1
Gf
h,0
p = -4
xn-1
p = -4p = -4p = -4
We finish by relabeling x1 :
n-1,1
p = -2
n-1,-1
p = -4h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,0
h-n+1,-1
h-n+1,1
Gf
h,0
p = -4
xn-1
p = -4p = -4p = -4
Notice that all the x nodes had their price reduced by two in this process:
n-1,1
p = -2
n-1,-1
p = -4h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,0
h-n+1,-1
h-n+1,1
Gf
h,0
p = -4
xn-1
p = -4p = -4p = -4
Also, n-1 flow units have been returned from x1 to xn and passed through this arc:
n-1,1
p = -2
n-1,-1
p = -4h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
h-n+1,-1
n-1,1
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,1
Gf
h,0
p = -4
xn-1
p = -4p = -4p = -4
Again, we can push the unit of flow all the way to xn :
n,1
p = -2
n-1,-1
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,-1
n,1
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,0
Gf
h,-1
p = -5
xn-1
p = -4p = -4p = -4
Now relabel xn :
n,1
p = -2
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
An Iteration of Refine
1-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
And push down to yn :
n,1
p = -2
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,-11,1
An Iteration of Refine
1-1
x1
x2 xn-2 xn
y1
y2 y3yn
h-1, 4
h, 2 h, 2 h,-1
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
Relabel yn :
n,1
p = -3
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,01,0
An Iteration of Refine
-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h-1,-1
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
Now we can, for the first time, push the flow unit towards yn-1 :
n,1
p = -3
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,01,0
1
yn-1
h, 2
1,1
p = 0
An Iteration of Refine
-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h-1,1
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
We then relabel yn-1 :
n,1
p = -3
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,01,0
1
yn-1
h, 0
1,-1
p = -2
An Iteration of Refine
1-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h,1
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
The flow is pushed back to yn :
n,1
p = -3
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,01,0
yn-1
h, 0
p = -2
An Iteration of Refine
1-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
Relabel yn again:
n,1
p = -4
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h-1,11,-1
yn-1
h, 0
p = -2
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,0
Gf
p = -5
xn-1
p = -4p = -4p = -4
The flow returns to xn with push:
n,1
p = -4
n-1,0
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,0
n,0
h,1
yn-1
h, 0
p = -2
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,-1
Gf
p = -6
xn-1
p = -4p = -4p = -4
And xn is relabeled again:
n,1
p = -4
n-1,1
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,1
n,-1
h,0
yn-1
h, 0
p = -2
An Iteration of Refine
1
-1
x1
x2 xn-2 xn
y1
y2yn
h-1, 4
h, 2 h, 2 h,0
h-n,-1
h-n-1,-1
Gf
p = -6
xn-1
p = -4p = -4p = -4
We will stop here, the behavior is clear…
n,1
p = -4
n-1,1
p = -4h-n,-1
n,1
h-n,-1
n,1
h-n,1
n,-1
h,0
yn-1
h, 0
p = -2
Can We Get a Better Complexity?
Yes – using dynamic tree, we geta complexity for refine of 2lognm n m
Can We Get a Better Complexity?
Yes – using dynamic tree, we geta complexity for refine of
Use finger search trees to find the first active vertex
Use dynamic trees for performing non-saturating pushes more efficiently (keep the edge list in a dynamic tree)
2lognm n m
So Much for the Generic Method…
Refine Using Dinic’s Ideas
In the Generic Method, we used ideas given by Goldberg & Tarjan in their Max-Flow Algorithm.
Our Min-Cost Circulation problem can also be solved using Dinic’s ideas for solving the Max-Flow problem, namely Blocking Flows.
We call this the Blocking-Flow Method.
Recall that Dinic solved the Max-Flow problem solving O(n) Blocking-Flow problems.
It appears that refine can also be implemented in a similar manner!
Note – this does not imply that refine can be fully implemented by a Max-Flow algorithm (this is an open problem…)
Refine Using Dinic’s Ideas
The Blocking-Flow Method
Some definitions: Let G=(V,E), with 2 distinct vertices s and t. A pseudoflow is a flow if every vertex except s,t
has zero excess. A flow is blocking if every path from s to t
contains at least one saturates arc. Note that a maximum flow is blocking, but not
conversely!
The Blocking-Flow Method
Some definitions (cont.): Define S to be all the vertices reachable in the
current GA from vertices with positive excess.
| s.t. 0
and is reachable from inf
A
v V u V e uS
v u G
The Blocking-Flow MethodGA
The Blocking-Flow MethodGA
The Blocking-Flow Method
Some definitions (cont.): Let N be the auxiliary network formed from GA
by adding:A source and a sink (s & t)An arc (s,v) of capacity ef(v), for every v with ef(v)>0An arc (v,t) of capacity -ef(v), for every v with ef(v)<0
The Blocking-Flow MethodGA
The Blocking-Flow MethodGA
S t
The Blocking-Flow MethodProcedure refine(ε,f,p):
[Initialization] ε ← ε/2; For every (v,w) in E do:
If cp(v,w) < 0 then f(v,w) ← u(v,w);[Loop] While f is not a circulation do:
Compute S, (price update)Build N, and find a blocking-flow fb on N (flow update)
Return (ε,f,p)End
,v S p v p v
, , , , ,A bv w E f v w f v w f v w
x1
x2x3
y1
y2
y3
9,0
10,-2 10,-2
10,1 10,1
10,1
10,-2
Example – The Initial G(Assume G = Gf)
Gf
An Iteration of Refine
ε ← ε/2 = 1
x1
x2x3
y1
y2
y3
9,0
10,-2 10,-2
10,1 10,1
10,1
10,-2
Gf
An Iteration of Refine
At first all negative cost arcs are saturated
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,1
10,1
10,2
Gf
An Iteration of Refine
The admissible graph
10
-10
x1
x2x3
y1
y2
y3
GA
An Iteration of Refine
S = {x3}
10
-10
x1
x2x3
y1
y2
y3
GA
An Iteration of Refine
Decrease price of vertices in S
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,0
10,0
10,1
Gfp=-1
An Iteration of Refine
Constructing N
10
-10
x1
x2x3
y1
y2
y3
GA
ts
10
10
An Iteration of Refine
A blocking flow of 0 is found
10
-10
x1
x2x3
y1
y2
y3
GA
1010t
s
10
10
An Iteration of Refine
S is still {x3}
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,0
10,0
10,1
Gfp=-1
An Iteration of Refine
Decrease price of vertices in S={x3}
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,-1
10,-1
10,0
Gfp=-2
An Iteration of Refine
The admissible graph now:
10
-10
x1
x2x3
y1
y2
y3
10,-1
10,-1
GAp=-2
An Iteration of Refine
Constructing NA blocking flow of 0 is found
10
-10
x1
x2x3
y1
y2
y3
10,-1
10,-1GAp=-2
1010t
s
10
10
An Iteration of Refine
S is now {x1,x2,x3}
10
-10
x1
x2x3
y1
y2
y3
9,0
10,2 10,2
10,1 10,-1
10,-1
10,0
Gfp=-2
An Iteration of Refine
Decrease price of vertices in S={x1,x2,x3}
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,2 10,2
10,1 10,-1
10,-1
10,-1
Gfp=-3p=-1
p=-1
An Iteration of Refine
The admissible graph now:
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,-1
10,-1
10,-1
GAp=-3
p=-1p=-1
An Iteration of RefineConstructing NA BF is found
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,-1
10,-1
10,-1
Gfp=-3
p=-1p=-1
ts
10
10
An Iteration of Refine
10
-10
x1
x2x3
y1
y2
y3
9,-1
10,-1
10,-1
10,-1
Gfp=-3
p=-1p=-1
Constructing NA BF is found (9 flow units)
ts
10
10
An Iteration of RefineAdd the BF found to the pseudo flow:
1
-1
x1
x2x3
y1
y2
y3
9, 1
10,2 10,2
10,1 10,-1
1,-1
10,-1
Gfp=-3
p=-1p=-1
9, 1
An Iteration of RefineThe admissible graph:
1
-1
x1
x2x3
y1
y2
y3
10,-1
1,-1
10,-1
GAp=-3
p=-1p=-1
An Iteration of Refine
S={x1,x2,x3,y3}
1
-1
x1
x2x3
y1
y2
y3
10,-1
1,-1
10,-1
GAp=-3
p=-1p=-1
An Iteration of RefineDecrease prices of vertices in S
1
-1
x1
x2x3
y1
y2
y3
9, 2
10,2 10,1
10,1 10,-1
10,-1
Gfp=-4p=-2
p=-2
9, 1
p=-1
1,-1
An Iteration of RefineConstruct NA 0 BF is found
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
Gfp=-4
p=-2p=-2
p=-1
1,-1
ts
1
1
An Iteration of Refine
S is still {x1,x2,x3,y3}
1
-1
x1
x2x3
y1
y2
y3
9, 2
10,2 10,1
10,1 10,-1
10,-1
Gfp=-4
p=-2p=-2
9, 1
p=-1
1,-1
An Iteration of RefineDecrease prices of vertices in S
1
-1
x1
x2x3
y1
y2
y3
9, 3
10,2 10,0
10,1 10,-1
10,-1
Gfp=-5p=-3
p=-3
9, 1
p=-2
1,-1
An Iteration of RefineConstruct NA 0 BF is found
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
Gf 1,-1p=-5
p=-3p=-3
p=-2
ts
1
1
An Iteration of Refine
S is still {x1,x2,x3,y3}
1
-1
x1
x2x3
y1
y2
y3
9, 3
10,2 10,0
10,1 10,-1
10,-1
Gfp=-5
p=-3p=-3
9, 1
p=-2
1,-1
An Iteration of RefineDecrease prices of vertices in S
1
-1
x1
x2x3
y1
y2
y3
9, 3
10,2 10,-1
10,1 10,-1
10,-1
Gfp=-6p=-4
p=-4
9, 1
p=-3
1,-1
An Iteration of RefineThe admissible graph:
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
10,-1
GAp=-6
p=-4p=-4
p=-3
1,-1
An Iteration of RefineConstruct N
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
10,-1
p=-6p=-4
p=-4
p=-3
1,-1
ts
1
1
An Iteration of Refine
S is now {x1,x2,x3,y2,y3}
1
-1
x1
x2x3
y1
y2
y3
9, 3
10,2 10,-1
10,1 10,-1
10,-1
Gfp=-6
p=-4p=-4
9, 1
p=-3
1,-1
An Iteration of RefineDecrease prices of vertices in S
1
-1
x1
x2x3
y1
y2
y3
9, 4
10,1 10,-1
10,1 10,-1
10,-1
Gfp=-7p=-5
p=-5
9, 1
p=-4p=-1
1,-1
An Iteration of RefineBuild N
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
10,-1
p=-7p=-5
p=-5
p=-4p=-1
ts
1
1
1,-1
An Iteration of Refine
S is still {x1,x2,x3,y2,y3}
1
-1
x1
x2x3
y1
y2
y3
9, 4
10,1 10,-1
10,1 10,-1
10,-1
Gfp=-7
p=-5p=-5
9, 1
p=-4p=-1
1,-1
An Iteration of RefineDecrease prices of vertices in S
1
-1
x1
x2x3
y1
y2
y3
9, 5
10,0 10,-1
10,1 10,-1
10,-1
Gfp=-8p=-6
p=-6
9, 1
p=-5p=-2
1,-1
An Iteration of RefineBuild N
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
10,-1
p=-8p=-6
p=-6
p=-5p=-2
1,-1
ts
1
1
An Iteration of Refine
S is still {x1,x2,x3,y2,y3}
1
-1
x1
x2x3
y1
y2
y3
9, 5
10,0 10,-1
10,1 10,-1
10,-1
Gfp=-8
p=-6p=-6
9, 1
p=-5p=-2
1,-1
An Iteration of Refine
1
-1
x1
x2x3
y1
y2
y3
9, 6
10,-1 10,-1
10,1 10,-1
10,-1
Gfp=-9p=-7
p=-7
9, 1
p=-7p=-3
Decrease prices of vertices in S
1,-1
An Iteration of RefineThe admissible graph:
1
-1
x1
x2x3
y1
y2
y3
10,-1
10,-1
10,-1
GA 1,-1
10,-1
p=-9p=-7
p=-7
p=-7p=-3
An Iteration of RefineBuild N and find a BF (1 flow unit)
1
-1
x1
x2x3
y1
y2
y3
10,-1 10,-1
10,-1
10,-1
Gfp=-9
p=-7p=-7
p=-7p=-3
1,-1
ts
1
1
An Iteration of RefineAdd the BF to the pseudo flow
x1
x2x3
y1
y2
y3
9, 6
9,-1 9,-1
10,1 10,-1
9,-1
Gfp=-9
p=-7p=-7
9, 1
p=-7p=-3
1,1 1,1
1,1
1,-1
p=0
An Iteration of RefineNo more active vertices – iteration over!
x1
x2x3
y1
y2
y3
9, 6
9,-1 9,-1
10,1 10,-1
9,-1
Gfp=-9
p=-7p=-7
9, 1
p=-7p=-3
1,1 1,1
1,1
1,-1
p=0
Blocking-Flow Method Correctness
The following strong lemma proves the main ideas of the Blocking-Flow Method:
Blocking-Flow Method Correctness
Lemma 8.1a. The set S computed in the inner loop
contains only vertices with ef(v)≥0.b. At the beginning of every iteration of the
inner loop, f is ε-optimal w.r.t. p; Decreasing the prices of vertices in S preserve ε-optimality.
c. GA remains acyclic throughout the algorithm (as before).
Blocking-Flow Method Correctness
Lemma 8.1a – Proof:By induction on the number of iterations of
the inner loop: Base – Initially, there are no arcs in GA, so only
ef(v)>0 vertices are contained in S. Step – We add a blocking flow on N, which, by
definition, disconnects all paths from ef(v)>0 vertices to ef(v)<0 vertices!
Blocking-Flow Method Correctness
We will look at a path from s to t
After the BF is found at least one arc is saturated on every path, hence the green vertex is not reachable from the red (active) vertex.
What happens if the first or last arc is saturated?
s t
Blocking-Flow Method Correctness
Lemma 8.1b – Proof:By the same induction:
Base – At the first iteration, f is ε-optimal. Step – The price decrease of vertices in S
preserves ε-optimality:The decrease does not affect arcs from S to S or from
S to S.Arcs from S to S have their reduced cost increased.Arcs from S to S have their reduced cost decreased
by ε, but recall that beforehand cp(v,w)≥0 !
Blocking-Flow Method Correctness
Ss t
Suppose this is the state before the price reduction in S:
S
Blocking-Flow Method Correctness
Ss t
Arcs within S are not effected
S
Blocking-Flow Method Correctness
Ss t
Same goes for arcs in S
S
Blocking-Flow Method Correctness
Ss t
Arcs going from S to S have their reduced cost increased
S
Blocking-Flow Method Correctness
Ss t
Arcs going from S to S have their reduced cost decreased, but still greater than -ε!
S
Blocking-Flow Method Correctness
Lemma 8.1c – Proof:By the same induction:
Base – Initially, there are no arcs in GA. Step – The price decrease can add arcs from S
to S, but will make all arcs from S to S non- admissible, thus GA remains acyclic.
Blocking-Flow Method Correctness
From 8.1b we conclude that f is ε-optimal at all times during the inner loop.
Therefore, if refine terminates, the returned f is an ε-optimal circulation, as needed!
Thus the correction of the Blocking-Flow Method is proven.
Blocking-Flow Method Complexity
We will bound the number of iterations of the inner loop of refine:
Lemma 8.2The number of inner loops is at most 3n
Blocking-Flow Method Complexity
Proof:Note that the inner loop never changes the
vertex excess from non-negative to negative or from non-positive to positive.
Blocking-Flow Method Complexity
Proof:Note that the inner loop never changes the
vertex excess from non-negative to negative or from non-positive to positive.
Only non-negative excess vertices have their price changed by iε after i iterations (this results from 8.1a).
Blocking-Flow Method Complexity
Proof:Note that the inner loop never changes the
vertex excess from non-negative to negative or from non-positive to positive.
Only non-negative excess vertices have their price changed by iε after i iterations.
Recall Lemma 5.8 –The price reduction is at most 3nε, and the bound is obtained!
Blocking-Flow Method Complexity
Lemma 8.3The Blocking-Flow Method takes
time, giving a total algorithm bound of
where B(n,m) is the time to find a blocking flow in an acyclic network (here we make use of 8.1c)
,O nB n m
, logO nB n m nC
And That’s That for Dinic…
ConclusionThe main ideas presented:Successive approximation – finding an
approximated (ε-optimal) solution “good enough” for optimality.
The algorithm framework achieves this concept using a refine method.
Recall that this only works for integer costs, to get log(nC) iterations.
ConclusionThe main ideas presented:We saw two ways for implementing refine:
The Generic Method – push & relabel The Blocking-Flow Method
Both methods can be implemented efficiently to achieve complexity of(or using Dynamic Trees)
3O n
2logO nm n m
Questions???