Download presentation
Presentation is loading. Please wait.
Published byLogan Patterson Modified over 8 years ago
2
Network Flow & Linear Programming Jeff Edmonds York University COSC 6111 Lecture 3 Network Flow Linear Programming
3
Ingredients: Instances: The possible inputs to the problem. Solutions for Instance: Each instance has an exponentially large set of solutions. Cost of Solution: Each solution has an easy to compute cost or value. Specification Preconditions: The input is one instance. Postconditions: An valid solution with optimal cost. (minimum or maximum) Optimization Problems
4
Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge has a maximum capacity c A source node s out of which flow leaves A sink node t into which flow arrives Goal: Max Flow Network Flow
5
Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge has a maximum capacity c A source node s out of which flow leaves A sink node t into which flow arrives Network Flow
6
For some edges/pipes, it is not clear which direction the flow should go in order to maximize the flow from s to t. Hence we allow flow in both directions.
7
Solution: The amount of flow F through each edge. Flow F can't exceed capacity c. No leaks, no extra flow. For each node v: flow in = flow out u F = w F Network Flow
8
Value of Solution: Flow from s into the network minus flow from the network back into s. rate(F) = u F - v F Goal: Max Flow Network Flow
9
Value Solution C= : cap(C) = how much can flow from U to V = u U,v V c Min Cut s t U V u v Goal: Min Cut
10
Theorem: For all Networks Max F rate(F) = Min C cap(C) Prove: F,C rate(F) cap(C) Max Flow = Min Cut U V u v Prove: flow F, alg either finds a better flow F or finds cut C such that rate(F) = cap(C) Alg stops with an F and C for which rate(F) = cap(C) F witnesses that the optimal flow can't be less C witnesses that it can't be more.
11
u v f /c 0/c Flow Graph u v Augmentation Graph f +w w Walking c -F F +c c F c Network Flow
12
u v F /c 0/c Flow Graph u v Augmentation Graph F -w c -F F +c c F c w Walking Network Flow
13
Given Flow F Construct Augmenting Graph G F Find path P Let w be the max amount flow can increase along path P. Increase flow along path P by w. i.e newF = oldF + w × P +w -w Max Flow = Min Cut
14
Given Flow F Construct Augmenting Graph G F Find path P Let w be the max amount flow can increase along path P. Increase flow along path P by w. i.e newF = oldF + w × P +w -w Max Flow = Min Cut
15
Given Flow F Construct Augmenting Graph G F Find path P using BFS, DFS, or generic search algorithm No path Max Flow = Min Cut
16
Let F alg be this final flow. Let cut C alg =, where U are the nodes reachable from s in the augmented graph and V not. Claim: rate(F alg ) = cap(C alg ) Max Flow = Min Cut
17
An Application: Matching SamMary BobBeth JohnSue FredAnn Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice? 3 matches Can we do better? 4 matches
18
An Application: Matching st c = 1 Total flow out of u flow into u 1 Boy u matched to at most one girl. 1 c = 1 Total flow into v = flow out of v 1 Girl v matched to at most one boy. 1 u v
19
An Application: Matching st Flow st Augmentation Graph Augmentation Path Alternates adding edge removing edge adding edge removing edge adding edge Extra edge added st New Flow
20
An Application: Matching SamMary BobBeth JohnSue FredAnn Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice? 3 matches Can we do better? 4 matches
21
Hill Climbing Problems: Can our Network Flow Algorithm get stuck in a local maximum? Local Max Global Max No!
22
Hill Climbing Problems: Running time? If you take small step, could be exponential time.
23
Network Flow
24
Add flow 1
25
Network Flow Add flow 1
26
Hill Climbing Problems: Running time? If each iteration you take the biggest step possible, Alg is poly time in number of nodes and number of bits in capacities. If each iteration you take path with the fewest edges Alg is poly time in number of nodes
27
Taking the biggest step possible
28
R_t = MaxFlow - F_t m * increase > sum_cut augment = sum_{e \in cut} C_e - F_e = value(cut_t) - F_t > min cut - F_t > M_t F_{t+1} = F_t + increase R_{t+1} = R_t – increase < R_t - [R_t / m] < (1-1/m)^t R_t < (1-1/m)^t F_0 < (1-1/m)^t MaxFlow < (1-1/m)^t sum_e C_e
29
Linear Programming
30
A Hotdog A combination of pork, grain, and sawdust, … Constraints: Amount of moistureAmount of moisture Amount of protein,Amount of protein, …
31
The Hotdog Problem Given today’s prices, what is a fast algorithm to find the cheapest hotdog?
32
There are deep ideas within the simplicity. =Abstraction Goal: Understand and think about complex things in simple ways. There are deep ideas within the simplicity. Rudich www.discretemath.com
33
Abstract Out Essential Details Cost: 29, 8, 1, 2 Amount to add: x 1, x 2, x 3, x 4 pork grainwater sawdust 3x 1 + 4x 2 – 7x 3 + 8x 4 12 2x 1 - 8x 2 + 4x 3 - 3x 4 24 -8x 1 + 2x 2 – 3x 3 - 9x 4 8 x 1 + 2x 2 + 9x 3 - 3x 4 31 Constraints: moisturemoisture protean,protean, … 29x 1 + 8x 2 + 1x 3 + 2x 4 Cost of Hotdog:
34
3x 1 + 4x 2 – 7x 3 + 8x 4 12 2x 1 - 8x 2 + 4x 3 - 3x 4 24 -8x 1 + 2x 2 – 3x 3 - 9x 4 8 x 1 + 2x 2 + 9x 3 - 3x 4 31 29x 1 + 8x 2 + 1x 3 + 2x 4 Subject to: Minimize: Abstract Out Essential Details
35
A Fast Algorithm For decades people thought that there was no fast algorithm. Then one was found! Theoretical Computer Science finds new algorithms every day. 3x 1 + 4x 2 – 7x 3 + 8x 4 12 2x 1 - 8x 2 + 4x 3 - 3x 4 24 -8x 1 + 2x 2 – 3x 3 - 9x 4 8 x 1 + 2x 2 + 9x 3 - 3x 4 31 29x 1 + 8x 2 + 1x 3 + 2x 4 Subject to: Minimize:
37
Primal Dual
38
End
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.