440 likes | 626 Views
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 マトロイド.
E N D
Class Plan 1-1.Graph グラフ 1-2.GraphSearch グラフ探索 + some graph properties 1-3.Network Flow ネットワーク・フロー 1-4.Algorithms&Complexity アルゴリズムと計算量 • 2-1.Minimum SpanningTree 最小木 • ( + data structures and sorting データ構造,整列) • 2-2.Matroid マトロイド 3-0. Shortest path 最短路 • 3-1.Maximum Flow 最大流 • 3-2. Minimum Cost Flow 最小費用流 • ?4-1.Approximation algorithm 近似解法 • ?4-2. Heuristics ヒューリスティック
Network Flows Variants in flows classical , traditional (?) • generalized flow • multicommodity flow • dynamic flow • maximum flow • minimum cost flow • Problem Formulation • Optimality condition • (Algorithm)
Maximum Flow Problem(最大流問題) Given : directed graph G=(V,A) total out flow from s 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
3 2) 4 3 3 3 2 1 1 s t 4 4 4 1 3 3 0 2 1 1 1 2 2 s s t t 1 3 4 3 2 2 Example capacity instance 3 4 5 2 4 3 s t 出口 入口 3 4 2 Are the following flows feasible/maximum ? 3) 1) 5) 4) 3 3 4 4 3 4 2 2 1 1 2 1 s t s t 3 4 4 4 2 3
For evaluate a bottleneck of flow value … • s-t cut : • capacity of an s-t cut 3 3 4 4 5 5 2 2 4 4 3 3 s t s t 3 3 4 4 2 2 total out flow from s : v≠s
Feasible flow and s-t cut total out flow from s :
Total out flow ∂φ(s)≦capacity of δ+(X) Maximum-flow Minimum-cut Theorem (Corollary 4.2) (s-t cut with minimum capacity) Ford-Fulkerson(1956)
Augmenting path method(偽) step0: Augmenting path step1: instance capacity ε step2: s 2 4 1 2 3 2 3 ε t 1 3 flow: s 2 s 2 s 0 0 0 0 0 0 0 0 1 0 0 2 2 0 0 0 0 0 0 t t t 0 2 0 3 0 0 s 2 0 1 2 2 0 ? There is no s-t directed path. 1 t 0 3
s 2 4 cap s 2 1 +1 s 2 0 1 2 2 3 3 1 2 0 1 2 0 1 t 2 -1 1 3 2 1 +1 t t 0 2 0 3 -1 s 2 1 1 2 1 1 ☆ residual network 2 t 1 3 :reverse arc of a arcs represent the possibility of pushing flow back on arcs s 2 4 2 2 1 2 1 2 1 t 3 1
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. ←augmenting path s 2 4 ε cap 1 2 2 3 3 t 1 3 s 2 1 s 2 0 1 2 1 2 1 1 0 2 2 1 t t 1 3 0 3 s 4 s 3 2 2 1 no augmenting path 2 2 1 2 1 2 1 2 1 1 1 2 2 1 1 t 1 3 t 1 3
When no augmenting path exists … : feasible flow There is no s-t directed path (augmenting path ) in s s t t X X : set of vertices reachable from s →s-t cut total out flow from s “Maximum “
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)
Max … min… duality Max flow problem Min cut problem 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 ≦ 4x1+2x2+4x3≦26 2nd constraint ×2 Obj func. = 4x1+x2+3x3 ≦ 5x1+x2+3x3≦27 2nd constraint ×2 + 1st constraint
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 ≦ y1+13y2 We need y2 ≧0 y1+2y2 ≧ 4 -y1+y2 ≧1 -y1+2y2 ≧3 If coefficient of each xi is at least as big as the corresponding coefficient in obj. function. then obj. function ≦ y1+13y2
Review of LP (dual problem) dual primal The dual of the dual problem is always the primal problem
Review of LP (duality theorem) : primal opt. sol ⇒ There exists : dual opt. sol s.t.
Review of LP (complementary slackness) : primal feasible sol : dual feasible sol : opt. solutions (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. ε
Instance 1 capacity M M 1 s t M-1 M M M-1 1 1 1 s t 1 1 residual network M-1 M-1 M M-1 M M 1 1 1 s s t t 1 M M-1 M M Number of iterations : ?
Instance 2 M 1 3 1 M M r t 1 s M M 2 4 P1=(s,2,1,3,4,t) P2=(s,1,2,4,3,t) P3=(s,3,1,2,4,t) M • Find maximum flow • If the algorithm chooses augmenting path as P1, P2, P1, P3, P1, P2, P1, P3, ,,, how many iterations the algorithm performs?
Rules for selecting augmenting paths Maximum capacity augmenting path … Find an augmenting path maximizing α ε • Max capacity augmenting path algo. • Capacity scaling algo. • MA ordering algo. Minimum length augmenting path … Find an augmenting path with least edges • Min length augmenting path algo. • Dinitz’s blocking flow algo.
Max capacity augmenting pathalgo. 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. An s-t directed path maximize min{uφ(a)|a∈A(P)} ε
Max capacity augmenting path algo.(complexity) ※integer capacity 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 U=max{u(a)|a∈A}
Capacity scaling algorithm ※integer capacity Bit scaling Capacity of kth scaling phase φ ←2φ 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 s 5 5 101 s 101 3 1 011 001 2 101 2 010 3 5 010 011 t t 4 3 100 011 K=3 (log25=2.32…)
Capacity scaling algorithm 101 s 101 uk(a)=2uk-1(a) or 2uk-1(a)+1 011 001 101 010 010 011 t 100 011 u1 u2 u3 1 s 1 10 101 s 10 s 101 0 01 011 0 1 00 001 10 101 0 01 010 0 01 010 0 01 011 t t t 1 0 10 01 100 011 2 2 Max flow ×2 0 0 1 1 2 0 0 0 0 0 1 0 t 0 0 0 0 Max flow t 0 0
Capacity scaling algorithm(complexity) Step0: φ:=0, k:=1 Step1: [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. uk(a)=2uk-1(a) or 2uk-1(a)+1 2 2 Max flow ×2 0 0 1 1 2 0 0 Min cut value in the auxiliary network: ≦m (the number of cut edges) 0 0 0 1 0 t 0 0 0 0 Max flow t 0 0
Other algorithms Push-relabel algorithm Network simplex algorithm preflow flow bound constraints No augmenting path mass balance constraints
capacity s 2 4 1 2 3 2 3 t 1 3 Max flow on planar graph 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.GraphSearch グラフ探索 + some graph properties 1-3.Network Flow ネットワーク・フロー 1-4.Algorithms&Complexity アルゴリズムと計算量 • 2-1.Minimum SpanningTree 最小木 • ( + 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 → R Find : flow :A →R+ minimizing total cost which satisfies ・flow bound constraints and ・mass balance constraints • feasible flow • minimum cost flow
Example (cap,cost) instance (3,-1) (4,3) (3,0) (2,2) (1,-1) (1,-3) (2,2) (2,1) (4,2) 0 3 1 0 2 0 0 1 1 0 1 1 0 0 0 0 2 0 0 2 0 0 1 1 0 2 0 total cost = 0 total cost = -2 total cost = 12
residual network w.r.t. a flow ☆ residual network :reverse arc of a arcs represent the possibility of pushing flow back on arcs
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 optimality condition (negative cycle…) 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 : = 0 step1 : 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 (cap,cost) (3,-1) (4,3) (3,0) (2,2) (1,-1) (1,-3) 0 1 (2,2) (2,1) 0 0 0 0 (4,2) 0 1 0 0 0 1 0 0 0 0 0 0 residual network optimal (2,-1) (3,-1) (1,1) (4,3) (3,0) (3,0) (4,3) (2,2) (1,2) (1,-2) (1,-1) (1,-1) (1,-3) (1,3) (2,2) (2,2) (2,1) (2,1) (4,2) (4,2)
LP form Minimize Subject to • Show the dual problem • Show the complementary slackness condition Compare to optimality conditions
Optimality condition (reduced cost) potential Kilter diagram u(a)
Modified network w.r.t. p G=(V, A) Modified capacity
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 Positive cut : a cut with
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 (cap,cost) (3,-1) (4,3) (3,0) (2,2) (1,-1) (1,-3) 1 (2,2) (2,1) (4,2) 0 1 (0, 3)0 (0, 3)0 0 0 (3, 3)-1 (0, 0)3 0 1 (0, 3)0 (0, 0)3 (0, 3)0 (0, 0)2 (0, 1)0 1 (0, 3)0 0 (0, 0)3 (1, 1)-4 (0, 0)2 (1, 1)-1 0 0 (0, 2)0 (1, 1)-3 (0, 0)2 (0, 2)0 (0, 1)0 1 0 0 (0, 0)1 0 (1, 1)-2 (0, 0)2 (0, 0)2 0 (0, 2)0 0 (0, 2)0 (0, 0)2 0 2 modified network (Ip,up)cp (0, 0)4
Other algorithms Primal dual algorithm Network simplex algorithm +Scaling technique