Min Cost Max Flow S05 capacity: maximum number of trucks that can go - - PowerPoint PPT Presentation
Min Cost Max Flow S05 capacity: maximum number of trucks that can go - - PowerPoint PPT Presentation
Min Cost Max Flow S05 capacity: maximum number of trucks that can go through this road at a time. cost: money should be paid for each truck on this road. $4 10 $5 $5 $3 15 15 5 20 $6 10 $2 25 $3 5 $6 Task : Find a maximum flow from
capacity: maximum number of trucks that can go through this road at a time. cost: money should be paid for each truck on this road. $5 $3 $6 $3 $4 $5 $6 $2 15 25 10 5 5 20 10 15
Task: Find a maximum flow from s to t with minimum cost
s v u t 10 30 5 20 10 15 s v u t $5 $3 $4 $2 $6 $1
Shortest Path Problem Maximum Flow Problem
Only consider the cost Only consider the capacity and flow
What we have learn…
s v u t 10/10 25/30 0/5 20/20 5/10 15/15
Minimum Cost Maximum Flow
- Definition. The cost of a flow f is defined as:
- Definition. A minimum cost maximum flow of a network G = (V, E)
is a maximum flow with the smallest possible cost.
s v u t 10 $5 30 $6 5 $3 20 $4 10 $1 15 $-2 (a)A flow graph with cost s v u t ?/10 $5 ?/30 $6 ?/5 $3 ?/20 $4 ?/10 $1 ?/15 $-2 (b)How to find a min-cost maximum flow?
Optimal Criteria
- Question. Given A maximum flow f, is it optimal?
- Claim. The cost of a maximum flow f is minimum iff there’s no negative
cycle in the residual network of f.
s v u t 10/10 25/30 0/5 20/20 5/10 15/15 $5 $3 $4 $-2 $6 $1 Is it’s cost minimum?
val(f) = 30 cost(f) = 255
s v u t 10/10 25/30 0/5 20/20 5/10 15/15 $5 $3 $4 $-2 $6 $1 (a)Maximum Flow f s v u t 10 5 5 20 5 15 $-5 $3 $-4 $2 $6 $1 $-6 5$-1 25 (b)Residual Network Flow Gf 25 s v u t 15 5 $1 $-6 (c)a negative cycle C in Gf $2 $2 5 s v u t 5 5 $1 $-6 (c)a negative cycle C in Gf
- Claim. The cost of a maximum flow f is minimum iff there’s no negative
cycle in the residual network of f.
Proof
Part 1: min cost max flow f no negative cycle in Gf Suppose there is a negative cycle C in Gf. Then construct a flow 𝑔′ = 𝑔 + 𝐷 For 𝑔′: 𝑤𝑏𝑚 𝑔′ = 𝑤𝑏𝑚 𝑔 + 𝑤𝑏𝑚 𝐷 = 𝑤𝑏𝑚 𝑔 + 0 = 𝑤𝑏𝑚 𝑔 𝑑𝑝𝑡𝑢 𝑔′ = 𝑑𝑝𝑡𝑢 𝑔 + 𝑑𝑝𝑡𝑢 𝐷 < 𝑑𝑝𝑡𝑢 𝑔 Contradiction.
$2 5 s v u t 5 5 $1 $-6 (c)a negative cycle C in Gf s v u t 10/10 25/30 0/5 20/20 5/10 15/15 $5 $3 $4 $-2 $6 $1 (a)Maximum Flow f s v u t 10 5 5 20 5 15 $-5 $3 $-4 $2 $6 $1 $-6 5$-1 25 (b)Residual Network Flow Gf s v u t 10/10 20/30 0/5 20/20 10/10 10/15 $5 $3 $4 $-2 $6 $1 (d)f+C with a lower cost cost(f) = 255 cost(f) = 240
- Define: A circulation is a flow which is balanced at every
node(including s and t) in the network.
s v u t 10/10 5/30 15/15 10/30 5/10 w 10/15
lemma: Any circulation f can be decomposed entirely into cycles and 𝑑𝑝𝑡𝑢 𝑔 = 𝑗 𝑑𝑝𝑡𝑢(𝐷𝑗).
s v u t 10/10 5/30 15/15 10/30 5/10 w 10/15 s v u 10/10 10/15 10/30 w 10/15 v u t 5/30 5/15 5/10
Observation: the difference of two flows f1 and f2 with the same value is a circulation in the residual network Gf2 (where the capacities are C-f2).
s v u t 10/10 20/30 0/5 15/20 5/10 10/15 $5 $3 $4 $-2 $6 $1 s v u t 5/10 17/30 0/5 20/20 8/10 12/15 $5 $3 $4 $-2 $6 $1 s v u t 5/10 3/30 0/5 5/20 3/10 2/15 $5 $3 $-4 $2 $6 $-1 f1 f2 f1-f2
- Suppose there is a maximum flow f’ with a lower cost than f.
- f’ – f is a circulation f’’. Cost(f’’) = cost(f’) – cost (f) < 0.
- 𝑑𝑝𝑡𝑢 𝑔′′ = 𝑗 𝑑𝑝𝑡𝑢(𝐷𝑗) => ∃𝐷𝑗: 𝑑𝑝𝑡𝑢(𝐷𝑗) < 0.
- So 𝐷𝑗 is a negative cycle and it is also feasible in the residual net work of f.
Proof
Part 2: no negative cycle in Gf min cost max flow f
s v u t 10/10 25/30 0/5 20/20 5/10 15/15 $5 $3 $4 $-2 $6 $1 (a)Maximum Flow f s v u t 10/10 20/30 0/5 20/20 10/10 10/15 $5 $3 $4 $-2 $6 $1 (b)a maximum flow f’ with a lower cost s v u t 10 5 5 20 5 15 $-5 $3 $-4 $2 $6 $1 $-6 5$-1 25 (b)Residual Network Flow G(f) (c)f’-f s v u t 0/10 5/30 0/5 0/20 5/10 5/15 $5 $3 $4 $2 $-6 $1
Cycle canceling algorithm:
begin establish a feasible maximum flow f in the network; while G(f) contains a negative cycle : use some algorithm to identify a negative cycle W; 𝛽 is the minimum residual capacity along the cycle; augment 𝛽 units of flow in the cycle W and update G(f); end;
s v u t 10/10 25/30 0/5 20/20 5/10 15/15 $5 $3 $4 $-2 $6 $1 (a)Maximum Flow f s v u t 10 5 5 20 5 15 $-5 $3 $-4 $-2 $6 $1 $-6 5$-1 25 (b)Residual Network Flow Gf 25 s v u t 5 5 $3 $1 $-6 (c)a negative cycle in Gf(not optimal) s v u t 10 10 20 15 $-5 $-4 $-2 $6 $-6 10 $-1 20 (d)Residual Network Flow Gf 5 $-3 5 s v u t 5 5 $3 $1 $-6 (c)negative cycle(to remove) s v u t 10/10 30/30 5/5 20/20 10/10 15/15 $5 $3 $4 $-2 $6 $1 (c)Maximum flow f’(f+negative cycle)
val(f) = 30 cost(f) = 245
Continue to do this until there is no negative cycle in the residual network………
val(f) = 30 cost(f) = 255
Time complexity
- The total time = time (maximum flow) + time(find a negative cycle) *
iteration times
- Use Edmonds–Karp algorithm to find a maximum flow and time is
𝑃(𝑊𝐹2)
- Use Bellman-Ford algorithm to find a negative cycle and the time is
𝑃(𝑊𝐹)
- In the integer capacity and weight case, every negative cycle
decreases the cost by 1.
- So the iteration times <= 𝑓 |𝑑𝑝𝑡𝑢 𝑓 ∗ 𝑑𝑏𝑞𝑏𝑑𝑗𝑢𝑧(𝑓)|.
- So the total time complexity is O(VE ∗ ( 𝑓 𝑑𝑝𝑡𝑢 𝑓 ∗ 𝑑𝑏𝑞𝑏𝑑𝑗𝑢𝑧 𝑓 ))