Network Flow and Linear Programming in Optimization Problems

 
 
Network Flow &
Linear Programming
 
Jeff Edmonds
York University
 
 
 
COSC 6111
 
Lecture
Lecture
 
 
3
3
 
Network Flow
 
 
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
 
 
Instance:
A 
Network is a directed graph 
G
Edges represent pipes that carry flow
Each edge <
u
,
v
> has a maximum capacity 
c
<
u
,
v
>
A source node
 s
 out of which flow leaves
A sink node 
t
 into which flow arrives
 
Goal:
   Max Flow
Network Flow
 
 
Instance:
A 
Network is a directed graph 
G
Edges represent pipes that carry flow
Each edge <
u
,
v
> has a maximum capacity 
c
<
u
,
v
>
A source node 
s 
out of which flow leaves
A sink node 
t
 into which flow arrives
 
Network Flow
 
Network Flow
 
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.
 
 
Solution:
The amount of flow 
F
<u,v>
 through each edge.
Flow 
F
<u,v>
 can't exceed capacity 
c
<u,v>
.
No leaks, no extra flow.
  For each node v: flow in = flow out

u
 F
<u,v>
 = 
w
 F
<v,w>
 
Network Flow
 
 
Value of Solution:
Flow from 
s
 into the network
        minus flow from the network back into 
s
.
         rate(F) = 
u
 F
<s,u>
 
- 
v
 F
<v,s>
 
Goal:
   Max Flow
 
Network Flow
 
 
Value Solution 
C=<U,V>
:
cap(C) = 
how much can flow from
 U 
to
 V
            = 
u
U,v
V
 
c
<u,v>
 
Min Cut
 
s
 
t
 
Goal:
   Min Cut
 
 
Theorem:
For all Networks
   
Max
F
 rate(F) = Min
C
 cap(C)
Prove: 
 
F,C    rate(F) 
 
cap(C)
Max Flow = Min Cut
 
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.
 
u
v
f
<u,v>
/c
<u,v>
0/c
<v,u>
Flow Graph
u
v
Augmentation Graph
 
c
<u,v>
-F
<u,v>
 
F
<u,v>
+c
<v,u>
c
<u,v>
F
<u,v>
c
<v,u>
Network Flow
 
u
v
F
<u,v>
/c
<u,v>
0/c
<v.u>
Flow Graph
u
v
Augmentation Graph
c
<u,v>
-F
<u,v>
F
<u,v>
+c
<v,u>
c
<u,v>
F
<u,v>
c
<u,v>
Network Flow
 
 
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
Max Flow = Min Cut
 
 
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
Max Flow = Min Cut
 
 
Given Flow 
F
Construct Augmenting Graph 
G
F
Find path 
P
 using BFS, DFS,
  or generic search algorithm
No path
Max Flow = Min Cut
 
 
Let 
F
alg
 be this final flow.
Let cut 
C
alg
=<U,V>
,
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
 
An Application: Matching
 
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
 
An Application: Matching
s
t
 
c
<
s
,
u
>
 = 1
Total flow out of 
u
 
 flow into 
u
 
 1
Boy 
u
 matched to at most one girl.
 
1
 
c
<
v
,
t
>
 = 1
Total flow into 
v
 
=
 flow out of 
v
 
 1
Girl 
v 
matched to at most one boy.
 
1
u
v
 
An Application: Matching
s
t
Flow
 
Alternates
adding edge
removing edge
adding edge
removing edge
adding edge
Extra edge added
 
An Application: Matching
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
 
Hill Climbing
 
Problems:
 
Can our Network Flow
Algorithm get stuck
in a local maximum?
 
No!
 
Hill Climbing
Problems:
 
Running time?
 
If you take small step,
could be exponential time.
 
 
Network Flow
 
 
 
Network Flow
 
 
Add flow 1
 
 
Network Flow
 
 
Add flow 1
 
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
 
 
Taking the biggest step possible
 
 
m = # edges
l  
= # bits to specify capacities.
The flow F
t
 must increase from 0 to up to
To be poly time, we could have F
t
 double each iteration.
But it does not 
Taking the biggest step possible
 
F
0 
= 0
 
F
T 
= m
2
l
 
m
2
l
 
T
 
= log(m) + 
l
 
 
R
t
 = How much the flow can increase by
     = MaxFlow - F
t
To be poly time, we could have R
t
 half each iteration.
Or decrease by a (1-1/m) factor
Taking the biggest step possible
 
R
0 
= m
2
l
= 0
 
R
T 
= 0
 
 
R
t
 = How much the flow can increase by
     = MaxFlow - F
t
Choose any cut C = 
U,V
.
R
t
  
e
C 
augment
e
Taking the biggest step possible
 
 
Let w
t
 = amount F
t
 increases
          = the min augment in augmenting path
Let Cut = 
U,V
       where nodes u
U are reachable from s
       with edges with augment amount > 
w
t
,
        i.e. the last graph in previous algorithm
        for which s is not reachable from t.
e
C 
augment
e  
e
C 
w
t
  
m
 
w
t
              
(where m = # edges in graph)
Taking the biggest step possible
 
 
R
t
 = MaxFlow – F
t
e
C 
augment
e
Taking the biggest step possible
 
m
 
w
t
  
m 
 
amount F
t
 increases
 
m 
 
amount R
t
 decreases
 
R
t+1
  
= 
 R
t 
- amount R
t
 decreases
 
 R
t 
1
/
m
 R
t
 
= 
 (1– 
1
/
m
) R
t
 
Decreasing by an m
th
!
Does this stop after m iterations?
No because as decreases,
   the decrease decreases.
 
 
R
t
 = How much the flow can increase by
     = MaxFlow - F
t
To be poly time, we could have R
t
    decrease by a (1-1/m) factor each iteration
Taking the biggest step possible
R
0 
= m
2
l
= 0
R
T 
= 0
R
t+1
 
 (1– 
1
/
m
) R
t
 
End game:  
1
/
2
, 
1
/
4
, 
1
/
8
, 
1
/
16
, …. ?
All flows are integers.
Hence, decreasing R
T 
 
<
 1 is good enough.
 
Taking the biggest step possible
R
t+1
 
 (1– 
1
/
m
) R
t
 
R
T  
 
< 1
 
(1– 
1
/
m
)
T
  R
0
 
Taking the biggest step possible
< 1
(1– 
1
/
m
)
T
  R
0
 
(e
-1/m
)
T   
R
0
 
Taking the biggest step possible
< 1
(1– 
1
/
m
)
T
  R
0
(e
-1/m
)
T   
R
0
 
(e
-T/m
)
     
R
0
 
-
T
/
m
 + ln(R
0
)  =  ln(1) = 0
 
T =  m ln(R
0
)
    = m ln(m
2
l
)
    = m (
l
 + ln m)
 
m = # edges
l  
= # bits to specify capacities.
 
 
Linear Programming
 
 
A Hotdog
 
A combination of pork,
A combination of pork,
grain, and sawdust, …
grain, and sawdust, …
 
Constraints:
Constraints:
Amount of moisture
Amount of moisture
Amount of protein,
Amount of protein,
 
 
The Hotdog Problem
 
Given today’s prices,
what is a fast algorithm
to find the cheapest
hotdog?
 
 
There are deep ideas within the simplicity.
=
 
Abstraction
Abstraction
 
Goal: Understand and think about complex
things in simple ways.
 
There are deep ideas within the simplicity.
 
 
Rudich www.discretemath.com
 
Abstract Out Essential Details
 
Cost: 29, 8, 1, 2
 
 
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:
Subject to:
 
Minimize:
Minimize:
 
Abstract Out Essential Details
 
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.
 
 
 
Primal
 
Dual
 
 
End
Slide Note
Embed
Share

Optimization problems involve instances with large solution sets and compute costs. Network flow optimization focuses on directed graphs, maximizing flow from source to sink through edges with capacities. The goal is to find the maximum flow while considering the Min Cut theorem. Algorithms are used to determine optimal flows and cuts within networks.

  • Optimization
  • Network Flow
  • Linear Programming
  • Algorithms
  • Graph Theory

Uploaded on Sep 16, 2024 | 0 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author. Download presentation by click this link. If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

E N D

Presentation Transcript


  1. Grad Algorithms Network Flow & Linear Programming Network Flow Linear Programming Jeff Edmonds York University Lecture3 COSC 6111

  2. Optimization Problems 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)

  3. Network Flow Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge <u,v> has a maximum capacity c<u,v> A source node s out of which flow leaves A sink node t into which flow arrives Goal: Max Flow

  4. Network Flow Instance: A Network is a directed graph G Edges represent pipes that carry flow Each edge <u,v> has a maximum capacity c<u,v> A source node s out of which flow leaves A sink node t into which flow arrives

  5. Network Flow 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.

  6. Network Flow Solution: The amount of flow F<u,v> through each edge. Flow F<u,v> can't exceed capacity c<u,v>. No leaks, no extra flow. For each node v: flow in = flow out u F<u,v> = w F<v,w>

  7. Network Flow Value of Solution: Flow from s into the network minus flow from the network back into s. rate(F) = u F<s,u>- v F<v,s> Goal: Max Flow

  8. Min Cut Value Solution C=<U,V>: cap(C) = how much can flow from U to V = u U,v V c<u,v> Goal: Min Cut U V s u v t

  9. Max Flow = Min Cut Theorem: For all Networks MaxF rate(F) = MinC cap(C) Prove: F,C rate(F) cap(C) 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. U V u v

  10. Network Flow Walking F<u,v> c<v,u> c<u,v> Flow Graph Augmentation Graph c<u,v>-F<u,v> f<u,v>+w f<u,v>/c<u,v> u v u v w F<u,v>+c<v,u> 0/c<v,u>

  11. Network Flow Walking c<u,v> F<u,v> c<u,v> Flow Graph Augmentation Graph c<u,v>-F<u,v> F<u,v>-w F<u,v>/c<u,v> u v u v w F<u,v>+c<v,u> 0/c<v.u>

  12. Max Flow = Min Cut +w +w -w +w Given Flow F Construct Augmenting Graph GF 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

  13. Max Flow = Min Cut +w +w -w +w Given Flow F Construct Augmenting Graph GF 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

  14. Max Flow = Min Cut Given Flow F Construct Augmenting Graph GF Find path P using BFS, DFS, or generic search algorithm No path

  15. Max Flow = Min Cut Let Falg be this final flow. Let cut Calg=<U,V>, where U are the nodes reachable from s in the augmented graph and V not. Claim: rate(Falg) = cap(Calg)

  16. An Application: Matching Sam Mary 3 matches Can we do better? 4 matches Bob Beth John Sue Fred Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice? Ann

  17. An Application: Matching s t 1 1 u v c<s,u> = 1 Total flow out of u= flow into u 1 Boy u matched to at most one girl. c<v,t> = 1 Total flow into v = flow out of v 1 Girl v matched to at most one boy.

  18. An Application: Matching New Flow Flow s t s t Augmentation Path Augmentation Graph Alternates adding edge removing edge adding edge removing edge adding edge Extra edge added s t

  19. An Application: Matching Sam Mary 3 matches Can we do better? 4 matches Bob Beth John Sue Fred Who loves whom. Who should be matched with whom so as many as possible matched and nobody matched twice? Ann

  20. Hill Climbing Problems: Can our Network Flow Algorithm get stuck in a local maximum? Global Max No! Local Max

  21. Hill Climbing Problems: Running time? If you take small step, could be exponential time.

  22. Network Flow

  23. Network Flow Add flow 1

  24. Network Flow Add flow 1

  25. 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

  26. Taking the biggest step possible

  27. Taking the biggest step possible m = # edges l = # bits to specify capacities. The flow Ft must increase from 0 to up to To be poly time, we could have Ft double each iteration. But it does not FT = m 2l m 2l T= log(m) + l F0 = 0

  28. Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft To be poly time, we could have Rt half each iteration. Or decrease by a (1-1/m) factor RT = 0 R0 = m 2l

  29. Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft Choose any cut C = U,V . Rt e C augmente U s u v t

  30. Taking the biggest step possible Let wt = amount Ft increases = the min augment in augmenting path Let Cut = U,V where nodes u U are reachable from s with edges with augment amount > wt, i.e. the last graph in previous algorithm for which s is not reachable from t. U e C augmente e C wt mwt (where m = # edges in graph) s u v t

  31. Taking the biggest step possible Rt = MaxFlow Ft e C augmente mwt m amount Ft increases m amount Rt decreases Rt+1 = Rt - amount Rt decreases Rt 1/m Rt= (1 1/m) Rt Decreasing by an mth! Does this stop after m iterations? No because as decreases, the decrease decreases.

  32. Taking the biggest step possible Rt = How much the flow can increase by = MaxFlow - Ft To be poly time, we could have Rt decrease by a (1-1/m) factor each iteration Rt+1 (1 1/m) Rt RT = 0 End game: 1/2, 1/4, 1/8, 1/16, . ? All flows are integers. Hence, decreasing RT < 1 is good enough. R0 = m 2l

  33. Taking the biggest step possible Rt+1 (1 1/m) Rt RT < 1 (1 1/m)T R0

  34. Taking the biggest step possible (1 1/m)T R0 (e-1/m)T R0 < 1

  35. Taking the biggest step possible (1 1/m)T R0 (e-1/m)T R0 (e-T/m)R0 -T/m + ln(R0) = ln(1) = 0 T = m ln(R0) = m ln(m 2l) = m (l + ln m) m = # edges l = # bits to specify capacities. < 1

  36. Linear Programming

  37. A Hotdog A combination of pork, grain, and sawdust, Constraints: Amount of moisture Amount of protein,

  38. The Hotdog Problem Given today s prices, what is a fast algorithm to find the cheapest hotdog?

  39. Abstraction There are deep ideas within the simplicity. = = Goal: Understand and think about complex things in simple ways. There are deep ideas within the simplicity. Rudich www.discretemath.com

  40. Abstract Out Essential Details Amount to add: x1, x2, x3, x4 Cost: 29, 8, 1, 2 Cost of Hotdog: 29x1 + 8x2 + 1x3 + 2x4 3x1 + 4x2 7x3 + 8x4 12 2x1 - 8x2 + 4x3 - 3x4 24 -8x1 + 2x2 3x3 - 9x4 8 x1 + 2x2 + 9x3 - 3x4 31 Constraints: moisture protean,

  41. Abstract Out Essential Details Minimize: 29x1 + 8x2 + 1x3 + 2x4 Subject to: 3x1 + 4x2 7x3 + 8x4 12 2x1 - 8x2 + 4x3 - 3x4 24 -8x1 + 2x2 3x3 - 9x4 8 x1 + 2x2 + 9x3 - 3x4 31

  42. A Fast Algorithm For decades people thought that there was no fast algorithm. Minimize: Then one was found! 29x1 + 8x2 + 1x3 + 2x4 Theoretical Computer Science finds new algorithms every day. 3x1 + 4x2 7x3 + 8x4 12 2x1 - 8x2 + 4x3 - 3x4 24 -8x1 + 2x2 3x3 - 9x4 8 x1 + 2x2 + 9x3 - 3x4 31 Subject to:

  43. Dual Primal

  44. End

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#