class plan
DESCRIPTION
Class Plan. 1-1 . Graph グラフ 1-2 . Graph Search グラフ探索 + some graph properties 1-3 . Network Flow ネットワーク・フロー 1-4 . Algorithms & Complexity アルゴリズムと計算量 . 2-1 . Minimum Spanning Tree 最小木 ( + data structures and sorting データ構造,整列) 2-2 . Matroid マトロイド. - PowerPoint PPT PresentationTRANSCRIPT
Class Plan
• 1-1 . Graph グラフ• 1-2 . Graph Search グラフ探索• + some graph properties • 1-3 . Network Flow ネットワーク・フロー• 1-4 . Algorithms & Complexity アルゴリズムと計算量
• 2-1 . Minimum Spanning Tree 最小木 ( + data structures and sorting データ構造,整列)• 2-2 . Matroid マトロイド• 3-1. Maximum Flow 最大流• 3-2 . Minimum Cost Flow 最小費用流 • ?4-1. Approximation algorithm 近似解法• ?4-2 . Heuristics ヒューリスティック
3-0. Shortest path 最短路
Network Flows
classical , traditional (?)
• maximum flow
• minimum cost flow
Variants in flows
• generalized flow
• multicommodity flow
• dynamic flow
• Problem Formulation
• Optimality condition
• (Algorithm)
Maximum Flow Problem ( 最大流問題 )
Given : directed graph G=(V,A)
Find :which satisfies• flow bound constraints : ( 容量制約 )
and• mass balance constraints : ( 流量保存制約 )
=
v
• feasible flow( 可能流 ) : a flow satisfying the above two constraints
• maximum flow( 最大流 ) : a feasible flow maximizing
total out flow from s
3
5
3
4
4
23 4
2
s t
capacity
入口 出口
Are the following flows feasible/maximum ?
Exampleinstance
3
1
1
4
4
02 1
2
s t
3
4
3
4
3
21 1
2
s t
1) 3
3
3
4
3
21 1
2
s t
2) 3)
3
4
4
4
4
21 1
3
s t
4) 3
3
3
4
4
22 1
2
s t
5)
For evaluate a bottleneck of flow value …
• s-t cut :
• capacity of an s-t cut
3
5
3
4
4
23 4
2
s t
3
5
3
4
4
23 4
2
s t
total out flow from s :
v≠s
Feasible flow and s-t cut
total out flow from s :
Maximum-flow Minimum-cut Theorem
(Corollary 4.2)
(s-t cut with minimum capacity)
Ford-Fulkerson(1956)
Total out flow ∂φ (s) ≦ capacity of δ+(X)
Augmenting path method(偽 )
2
2
1
3
4
13
3
s
t
instance capacity
0
0
0
0
0
0 0
0
s
t
flow:
2
0
2
0
0
2
0
0 0
2
s
t
0
2
1
0
2
0
0 0
3
s
t
0
2
2
0
2
0
11
3
s
t
0 ? There is no s-t directed path.
step0:step1:
step2:
Augmenting path
ε
ε
2
2
0
2
0
11
3
s
t
+1
+1-1
-1
0
2
2
0
1
1
12
2
s
t
2
2
1
1
1
12
3
s
t
1
2
2
1
3
4
13
3
s
t
2
☆ residual network
arcs represent the possibility of pushing flow back on arcs
s
t
0
cap
2
1 3
2
2 21
4
121€
Aϕ = AϕF ∪AϕB
AϕF = {a∈ A |ϕ (a) < u(a)}, Aϕ
B = {ar |ϕ (a) > 0} ar :reverse arc of a
€
uϕ (a) =u(a) −ϕ (a) (a∈ AϕF )ϕ (ar) (a∈ AϕB )
⎧ ⎨ ⎩
€
Gϕ = (V ,Aϕ ),uϕ
Augmenting path method (本物 )
step0: step1: construct a residual network step2: Find an s-t directed path P in
If there is no such a path …step3: compute and update flow along P Go to step1.
0
2
2
0
2
0
11
3
s
t
2
2
1
1
1
12
3
s
t
1
s
t
2
1
2
2
2 21 1 1
3
4 s
t
1
1
2
2
1 12 1 2
3
3
1
1no augmenting path
← augmenting path
€
Gϕ = (V ,Aϕ )
ε 2
2
1
3
4
13
3
s
t
2
cap
When no augmenting path exists …
: feasible flowThere is no s-t directed path (augmenting path ) in
t t
ss
X
X : set of vertices reachable from s→ s-t cut
total out flow from s
“Maximum “
€
Gϕ = (V ,Aϕ )
Optimality condition
Theorem4.1 (Augmenting path theorem)
A feasible flow φ is maximum ⇔ there is no augmenting path in
⇒) If there is an augmenting path in …..
) proved⇒
Maximum-flow Minimum-cut Theorem
(s-t cut with minimum capacity)
Ford-Fulkerson(1956)
€
Gϕ = (V ,Aϕ )
€
Gϕ = (V ,Aϕ )
Max … min…
Max flow problem Min cut problemduality
Subject to
◆Show the dual problem ◆Show the complementary slackness condition
Review of LP (dual problem)Example:
Maximize 4x1+x2+3x3
Subject to x1- x2- x3 = 1 2x1+x2+2x3 13≦ x1, x2, x3≧0
A (quick) estimate of the optimal value (upper bound)
Since x1, x2, x3 are nonnegative,
Obj func. = 4x1+x2+3x3 4x≦ 1+2x2+4x3 26≦
2nd constraint ×2 + 1st constraint
Obj func. = 4x1+x2+3x3 5x≦ 1+x2+3x3 27≦
2nd constraint ×2
Review of LP (dual problem)Example:
Maximize 4x1+x2+3x3
Subject to x1- x2- x3 = 1 2x1+x2+2x3 13≦ x1, x2, x3≧0
Linear combination 1st constraint ×y1 + 2nd constraint ×y2
(y1+2y2)x1+ (-y1+y2)x2 +(-y1+2y2)x3 y≦ 1+13y2
We need y2 ≧0
If
y1+2y2 4≧-y1+y2 1≧-y1+2y2 3≧
coefficient of each xi is at least as big as the corresponding coefficient in obj. function.
then obj. function y≦ 1+13y2
Review of LP (dual problem)
primal
€
maximize c jx jj=1
n
∑
subject to aijx jj=1
n
∑ = bi (i =1,...,l )
aijx jj=1
n
∑ ≤ bi (i = l +1,...,m)
x j ≥ 0 ( j =1,...,n)
€
minimize biyii=1
m
∑
subject to aijyii=1
m
∑ ≥ c j ( j =1,...,n)
yi ≥ 0 (i = l +1,...,m)
dual
€
c jx j ≤ aijyii=1
m
∑ ⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
j=1
n
∑j=1
n
∑ x j ≤ aijx jj=1
n
∑ ⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
i=1
m
∑ yi ≤ biyii=1
m
∑
The dual of the dual problem is always the primal problem
Review of LP (duality theorem)
€
x * : primal opt. sol
⇒ There exists
€
y * : dual opt. sol
s.t.
€
c jx * jj=1
n
∑ = biy *ii=1
m
∑
Review of LP (complementary slackness)
€
x * : primal feasible sol
€
y * : dual feasible sol
€
x *
€
y * : opt. solutions
€
⇔
aijy *i = c j or x * j = 0 ( j =1,...n)i=1
m
∑
aijx * j = bi or y *i = 0 (i =1,...m)j=1
n
∑
⎧
⎨ ⎪ ⎪
⎩ ⎪ ⎪
€
c jx j ≤ aijyii=1
m
∑ ⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
j=1
n
∑j=1
n
∑ x j ≤ aijx jj=1
n
∑ ⎛
⎝ ⎜ ⎜
⎞
⎠ ⎟ ⎟
i=1
m
∑ yi ≤ biyii=1
m
∑
(proof)
Form
Augmenting path method (complexity)
Analyze the worst case time complexity for the augmenting path method
step0: step1: construct a residual network step2: Find an augmenting path P in
If there is no such a path, stop.step3: compute and update flow along P Go to step1.
€
Gϕ = (V ,Aϕ )
ε
Instance 1
s t
M
M
M
M
1
capacity
s t
M
M
M
M
1
residual network
s t
M-1
M
M
M-1
11
1
s t
M-1
M-1
M-1
M-1
11
11
1
Number of iterations : ?
Instance 2
st
1
2
3
4
M
M
M1
1
M
M
M
r€
r = 5 −12
(<1), M > 4
€
rk < rk−1
rk−1 − rk = rk+1
◆Find maximum flow◆If the algorithm chooses augmenting path as P1, P2, P1, P3, P1, P2, P1, P3, ,,, how many iterations the algorithm performs?
P1=(s,2,1,3,4,t)P2=(s,1,2,4,3,t)P3=(s,3,1,2,4,t)
Rules for selecting augmenting paths
Maximum capacity augmenting path
Minimum length augmenting path
… Find an augmenting path maximizing α
… Find an augmenting path with least edges
ε
•Max capacity augmenting path algo.•Capacity scaling algo.•MA ordering algo.
•Min length augmenting path algo.•Dinitz’s blocking flow algo.
Max capacity augmenting path algo.
step0: step1: construct a residual network step2: Find an augmenting path P in
If there is no such a path, stop.step3: compute and update flow along P Go to step1.
€
Gϕ = (V ,Aϕ )
ε An s-t directed path maximize
min{uφ(a)|a A(P)}∈
Max capacity augmenting path algo.(complexity)
€
ϕ* :ϕ :ϕ ':
(1− 1m
)(∂ϕ *(s) −∂ϕ (s)) ≥ (∂ϕ *(s) −∂ϕ '(s))
Opt. flow
A flow
Flow obtained by updating along a max cap. aug. path
The number of iteration O(m log(nU)) × maxmin type shortest path€
1− 1m
⎛ ⎝ ⎜
⎞ ⎠ ⎟m
≤ 12
U=max{u(a)|a A}∈
※ integer capacity
Capacity scaling algorithm
※ integer capacity
Capacity of kth scaling phase
€
uk (a) = u(a)2K−k
⎢ ⎣ ⎢
⎥ ⎦ ⎥
K = logU +1⎣ ⎦
kth scaling phase find a maximum fow φw.r.t uk
(k+1)th scaling phase find a maximum fow φw.r.t uk+1
φ ← 2 φ
Bit scaling
2
5
1
4
2
5
3
5
3
s
t
3 010
101
001
100
010
101
011
s
t
101011
011
K=3 (log25=2.32…)
Capacity scaling algorithm
010
101
001
100
010
101
011
s
t
101011
011
0
1
0
1
0
1
0
s
t
10
001
10
00
10
01
10
01
s
t
1001
01010
101
001
100
010
101
011
s
t
101011
011
u1 u2 u3
uk(a)=2uk-1(a) or 2uk-1(a)+1
Max flow
0 0
0
0
0 t
0
0
1 1
1
0 0
0
0
0 t
0
0
2 2
2× 2
Max flow
Capacity scaling algorithm(complexity)
uk(a)=2uk-1(a) or 2uk-1(a)+1
Max flow
0 0
0
0
0 t
0
0
1 1
1
0 0
0
0
0 t
0
0
2 2
2× 2
Max flow
Min cut value in the auxiliary network:
≦m(the number of cut edges)
Step0: φ:=0, k:=1Step1: [k scaling phase] find a maximum flow φ with respect to uk
Step2: If k=K, then stop. Else k:=k+1, φ:=2φ, and go to step 1.
€
K = logU +1⎣ ⎦
€
uk (a) = u(a)2K−k
⎢ ⎣ ⎢
⎥ ⎦ ⎥
Minimum length augmenting path
Other algorithms
Push-relabel algorithm
Network simplex algorithm
flow bound constraints
No augmenting pathmass balance constraints
preflow
Max flow on planar graph
2
2
1
3
4
1
3
3
s
t
capacity
2
s-t planar graph … the graph added the arc (t, s) is still planar
s-t cut = s*-t* path
min cut = shortest path
Class Plan
• 1-1 . Graph グラフ• 1-2 . Graph Search グラフ探索• + some graph properties • 1-3 . Network Flow ネットワーク・フロー• 1-4 . Algorithms & Complexity アルゴリズムと計算量
• 2-1 . Minimum Spanning Tree 最小木 ( + data structures and sorting データ構造,整列)• 2-2 . Matroid マトロイド• 3-1. Maximum Flow 最大流• 3-2 . Minimum Cost Flow 最小費用流 • ?4-1. Approximation algorithm 近似解法• ?4-2 . Heuristics ヒューリスティック
minimum circulation problem ( 最小費用循環流問題 )
Given : directed graph G=(V,A) capacity u: A → R+
cost c: A → RFind : flow :A → R+ minimizing total cost which satisfies ・ flow bound constraints and ・ mass balance constraints
• feasible flow
• minimum cost flow
(3,-1)
(3,0)
(cap,cost)instance
Example
(4,3)
(2,1)
(1,-1)(1,-3)
(2,2)
(4,2)
(2,2)
0
0
0
0
0
00
0
0
3
1
2
2
1
12
2
0
1
1
0
0
1
10
0
0
total cost = 0 total cost = 12 total cost = -2
residual network w.r.t. a flow
☆ residual network
arcs represent the possibility of pushing flow back on arcs
€
Aϕ = AϕF ∪AϕB
AϕF = {a∈ A |ϕ (a) < u(a)}, Aϕ
B = {ar |ϕ (a) > 0} ar :reverse arc of a€
Gϕ = (V ,Aϕ ),uϕ
€
uϕ (a) =u(a) −ϕ (a) (a∈ AϕF )ϕ (ar) (a∈ AϕB )
⎧ ⎨ ⎩
€
c(a) =c(a) (a∈ AϕF )
−c(ar ) (a∈ AϕB )
⎧ ⎨ ⎩
optimality condition (negative cycle…)
The following statements are equivalent :
MCF-(a) : is minimum cost flow
MCF-(b) : the residual network does not have any
negative-cost cycles
MCF-(c) : There exists π : V → R such that
holds for every
Let be a feasible flow
directed cycle C with
(a) (b)⇒
If the residual network has a negative cost cycle, …
(b) (a)⇒: a flow satisfying (b)
: optimal flow
: feasible flow in
can be decomposed into cycles in
⇒ is optimal
negative cycle canceling algorithm
step0 : = 0step1 : construct the residual network
step2 : Find a negative-cost cycle C in
If there is no such a cycle, stop.
step3 : compute
and update flow along C.
Go to step1.
Shortest path algorithm
0
0
0
0
0
00
0
0
(3,-1)
(3,0) (4,3)
(2,1)
(1,-1)(1,-3)
(2,2)
(4,2)
(2,2)
(cap,cost)
1
0
0
0
0
11
0
0
(3,-1)
(3,0) (4,3)
(2,1)
(1,-1)(1,-3)
(2,2)
(4,2)
(2,2)
(2,-1)
(3,0) (4,3)
(2,1)
(1,-1)(1,3)
(1,2)
(4,2)
(2,2)
(1,-2)
(1,1)
residual network optimal
LP form
◆Show the dual problem ◆Show the complementary slackness condition
Minimize
Subject to
Compare to optimality conditions
Optimality condition (reduced cost)
€
c p (a) = c(a) − p(∂+a) + p(∂−a)
€
p = −π
€
c p (a) > 0⇒ ϕ (a) = 0
c p (a) < 0⇒ ϕ (a) = u(a)
c p (a) = 0⇒ 0 ≤ ϕ (a) ≤ u(a)
Kilter diagram
€
ϕ (a)
€
p(∂+a) − p(∂−a)
u(a)
potential
Modified network w.r.t. p
G=(V, A)
Modified capacity
€
u p (a) =0u(a)u(a)
⎧ ⎨ ⎪
⎩ ⎪
(c p (a) > 0)(c p (a) = 0)(c p (a) < 0)
l p (a) =00u(a)
⎧ ⎨ ⎪
⎩ ⎪
(c p (a) > 0)(c p (a) = 0)(c p (a) < 0)
Optimality condition (positive cut)
A potential p is dual optimal if and only if in the modified network w.r.t. p any cut δ(X) satisfies
€
u p (a)a∈δ + (X )
∑ ≥ l p (a)a∈δ − (X )
∑
Positive cut : a cut with
€
u p (a)a∈δ + (X )
∑ < l p (a)a∈δ − (X )
∑
Positive cut canceling algorithm
step0 : p: any potential
step1 : construct the modified network
step2 : Find a positive cut in modified network
If there is no such a cut, stop.
step3 : compute
and update potential
Go to step1.
Max flow algorithm
0
0 0
0
0 0
(3,-1)
(3,0) (4,3)
(2,1)
(1,-1)(1,-3)
(2,2)
(4,2)
(2,2)
(cap,cost)
1
modified network
(Ip,up)cp
€
α =minmin c p (a) | a∈ δ+(a),c p (a) > 0{ },
min −c p (a) | a∈ δ−(a),c p (a) < 0{ }
⎧ ⎨ ⎪
⎩ ⎪
⎫ ⎬ ⎪
⎭ ⎪
€
p(v) =p(v) +αp(v)
⎧ ⎨ ⎩
(v ∈ X)(v ∉ X)
(0, 3)0(3, 3)-1
(0, 0)2
(0, 0)3
(0, 0)1
(0, 0)2
(0, 0)2(1, 1)-3
(1, 1)-1
0
0 1
1
0 0
(0, 3)0(0, 3)0
(0, 0)2
(0, 0)3
(0, 2)0
(0, 0)2
(0, 0)2(1, 1)-4
(0, 1)00
0 1
1
2 0
(0, 3)0(0, 3)0
(0, 2)0
(0, 0)3
(0, 2)0
(0, 0)4
(0, 2)0(1, 1)-2
(0, 1)0
Other algorithms
Primal dual algorithmNetwork simplex algorithm
+Scaling technique