Other Flow Net
Other Flow Net
> Problem: Given a set of points (x1, y1), ..., (xn, ym) on an n x n grid,
determine whether there exists a set of paths along grid lines
from each of the points to the boundary that do not intersect
Escape Problem Example
from http://jeffe.cs.illinois.edu/teaching/algorithms/notes/24-maxflowapps.pdf
Robber Problem
> Here’s what it might like look like if the streets are a grid:
1 1
1 1 1
1 1
1 1 1
1 1
Robber Problem
1 1
1 1 1
1 1
1 1
1
1 1 1
s 1
Robber Problem
1 1 1
1 1
1 1
1
1 1 1 1
s 1 t
1
Robber Problem
> Has a solution iff the max flow equals the number of robbers
1 1
1 1 1
1 1
1 1
1
1 1 1 1
s 1 t
1
1 1
1 1 1
Robber Problem
1
1 1
1
1 1 1 1
> Has a solution iff the max flow equals the number of robbers:
– can assume flow is {0, 1} on each edge — (by F-F)
– flow on each edge (s,u) gives a path from u to the boundary...
> flow into u on (s,u) leaves on some edge (u,v)
> flow into v on (u,v) leaves on some edge (v,w)
> can only stop with an edge (z,t), and z is a boundary node by construction
– two paths using the same edge would violate edge capacity
1 1 1
Robber Problem
1
1 1
1
1 1 1 1
. .
. .
. .
Node Capacity Constraints
. .
. .
. .
Node Capacity Constraints
cn
. .
. .
. .
Node Capacity Constraints
> All flow through the node now goes through this internal edge
> That allows us to limit the total flow using the node
– node balance constraint is preserved...
– flow balance constraint on the two nodes tell us:
flow into the first node = flow along internal edge = flow out of the second node
1 1
1 1 1
Robber Problem
1
1 1
1
1 1 1 1
> Has a solution iff the max flow equals the number of robbers
– already proved that paths must be edge-disjoint
– node capacity means paths must be node-disjoint as well
1 1
1 1 1
Robber Problem
1
1 1
1
1 1 1 1
> Has a solution iff the max flow equals the number of robbers
– we have shown that this properly models the robber problem:
> every solution to the robber problem corresponds to a flow of value #robbers
> every 0/1 flow of value #robbers encodes escape paths for all robbers
from http://jeffe.cs.illinois.edu/teaching/algorithms/notes/24-maxflowapps.pdf
Covering with Dominos
> Could try putting every square on both the left & right side
– allow matching squares on left and right only to adjacent ones (not selves)
from http://jeffe.cs.illinois.edu/teaching/algorithms/notes/24-maxflowapps.pdf
Token Placing: False Start
> Second thought: turn row / col restrictions into flow constraints?
1
s t
1
squares rows
Token Placing: False Start
> Second thought: turn row / col restrictions into flow constraints?
– can use that to ensure only one in each row OR in each column
> (a useful idea we can use elsewhere)
– BUT how can we do both at once?
> lose track of what column it came from when we flow into the row nodes
> could put 2 units of flow into a square, one for row & one for col,
but there is no guarantee that the solution uses 2 units
– doesn’t seem to work...
Token Placing
> Note that programs can be stopped, restarted, and moved between
processors with no penalty.
Processor Scheduling: Example
1 2 3 4 5 6 7 8 9
Processor Scheduling
> If the program can be started at time s and must finish by time e
and requires total processing time p, we need to find an
assignment of the program to p 1-second intervals in [s, e].
– i.e, this is essentially a matching problem
– units of processing for programs need to be matched to
intervals of available time on the processors
– in this case, p units of time matched to intervals in [s, e]
Processor Scheduling
> Can have only one node for each program and 1-second interval
– allow a program requiring p units of time to be assigned to p intervals
– allow each interval to be assigned m different programs (for m processors)
Processor Scheduling: Example
1 number of processors
1
1 2
processing time 3 program start end req time
1 1
3 1 1 5 3
3 1
2 3 5 2
4
2 2 t 3 3 7 4
5 4 5 9 4
s 4
3 6
4
3
7
4 1
1 8
programs intervals
Processor Scheduling
> Can have only one node for each program and 1-second interval
– allow a program requiring p units of time to be assigned to p intervals
– allow each interval to be assigned m different programs (for m processors)
crew flights
Airline Scheduling: False Start