linear programming – max flow – min cut orgad keller
TRANSCRIPT
Linear Programming –
Max Flow – Min Cut
Orgad Keller
Orgad Keller - Algorithms 2 2
We have an objective function:
Subject to constraints:
Linear Programming
1 1max ... n nc x c x
1,1 1 1, 1
,1 1 ,
...
...
, 0
n n
m m n n m
i
a x a x b
a x a x b
i x
Orgad Keller - Algorithms 2 - 3
Given all parameters
we want to find the optimal
Linear Programming
1,..., nx x, , , 1 ,1j i i ja c b i n j m
Orgad Keller - Algorithms 2 - 4
It is easier to present the problem with a matrix and vectors:
Linear Programming
max
. .
, 0i
c x
s t
Ax b
i x
1 1 1
1,1 1,
,1 ,
: ( ,..., ), ( ,..., ), ( ,..., )n n m
n
m m n
where x x x c c c b b b
a a
A
a a
Orgad Keller - Algorithms 2 - 5
Given the Primal Problem:
It’s Dual Problem is defined as:
The Dual Problem
max
. .
, 0i
c x
s t
Ax b
i x
1
min
. .: ( ,..., )
, 0
mT
i
b y
s twhere y y y
A y c
i y
1 1 1
1,1 1,
,1 ,
: ( ,..., ), ( ,..., ), ( ,..., )n n m
n
m m n
where x x x c c c b b b
a a
A
a a
Orgad Keller - Algorithms 2 - 6
Given a problem and it’s dual problem, then:
In other words, the optimal objective function’s value for the primal problem, is equal to the optimal objective function’s value for the dual problem.
Strong Duality Theorem
1 1
max minn m
i i j ji j
c x b y
Orgad Keller - Algorithms 2 - 7
As you remember from Algorithms I Given a directed graph , two
vertices and a capacity for each edge
We want to find a flow function
so that the flow value is maximal
Maximum Flow
:c E N
( , )G V E,s t V
( , )
v V s
f s v
Orgad Keller - Algorithms 2 - 8
But, we are subject to some rules: What goes in must come out:
Capacity restrictions:
Maximum Flow
( , ) , ( , ) ( , )u v E f u v f v u
, , ( , ) ( , )u V u V
v V s t f u v f v u
( , ) , ( , ) ( , )u v E f u v c u v
Orgad Keller - Algorithms 2 - 9
We’ll show by a simple example:
Max Flow with Linear Programming
s t
a
b32
13
1
Orgad Keller - Algorithms 2 - 10
We want to present the example in the form:
Subject to:
Max Flow with Linear Programming
max c f
A f b
Orgad Keller - Algorithms 2 - 11
Formally:
Max Flow with Linear Programming
saf
s t
a
b 32
13
1
sbf
abf
atf
btf
atfabfsaf
abfsbf
3211300
But we don’tpermit
equalities
saf sbfmax
btf
Orgad Keller - Algorithms 2 - 12
So we’ll add another edge, and change the problem’s representation a little.
Max Flow with Linear Programming
s t
a
b 32
13
1
∞
saf
sbf
abf
atf
btf
atfabfsaf
abfsbf
3211300
saftsf 0
0sbf
tsfatf btf
btf
tsfmax
Orgad Keller - Algorithms 2 - 13
max
max 0 0 0 0 0 1
ts
sa
sb
ab
at
bt
ts
f
ff
fc f
f
f
f
Orgad Keller - Algorithms 2 - 14
1 0 0 0 0 0 3
0 1 0 0 0 0 2
0 0 1 0 0 0 1
0 0 0 1 0 0 1
0 0 0 0 1 0 3
1 0 1 1 0 0 0
0 1 1 0 1 0 0
1 1 0 0 0 1 0
0 0 0 1 1 1 0
sa
sb
ab
at
bt
ts
A b
ff
f
f
f
f
f
Orgad Keller - Algorithms 2 - 15
As you remember from Algorithms I Given a directed graph , two
vertices and a weight for each edge
We want to find a minimal-weight subset of edges such that if we’ll remove them, we won’t be able to travel from to .
Minimum Cut
:c E N
( , )G V E,s t V
s t
Orgad Keller - Algorithms 2 - 16
In other words:We’ll choose ,
where: , ,
such that the cut value,
is minimal.
Minimum Cut
,s tV V V
ss V tt V s tV V V
,
( , )s
t
u Vv V
c u v
Orgad Keller - Algorithms 2 - 17
Going back to the example:
Min Cut with Linear Programming
s t
a
b32
13
1
Orgad Keller - Algorithms 2 - 18
Min Cut with Linear Programming
s t
a
b 32
13
1 What about:
Is that enough?We haven’t ensured paths from to are cut.
( , )
min ( , )
. .
( , ) , 0,1
uvu v E
uv
c u v y
s t
u v E y
This look like
And we know thatIP
IP NPhard
s t
Orgad Keller - Algorithms 2 - 19
Min Cut with Linear Programming
s t
a
b 32
13
1 Beside a variable for every edge , we’ll want a variable for every vertex , such that:
uvy( , )u v
uz u V
1
0u s
u t
z u V
z u V
Orgad Keller - Algorithms 2 - 20
Min Cut with Linear Programming
s t
a
b 32
13
1 Let’s take for instance: If is in the cut , that means
that If is not in the cut , that means
that either or or
So it is the same to constrain:
( , )a b( , )a b ( 1)aby
,s ta V b V ( 1, 0)a bz z ( , )a b ( 0)aby
1, 1a bz z
0ab a by z z
0, 0a bz z 0, 1a bz z
Orgad Keller - Algorithms 2 - 21
Formally:
Max Flow with Linear Programming
0sa s ay z z
s t
a
b 32
13
1min3 2 3sa sb ab at bty y y y y
0sb s by z z
0ab a by z z
0at a ty z z
0bt b ty z z
1s tz z In order to ensure
ss V tt V
Orgad Keller - Algorithms 2 - 22
min3 2 3
min 3 2 1 1 3 0 0 0 0
sa sb ab at bt
sa
sb
ab
at
bt
a
b
s
t
y y y y y
y
y
y
yby
z
z
z
z
Orgad Keller - Algorithms 2 - 23
min3 2 3
min 3 2 1 1 3 0 0 0 0
sa sb ab at bt
sa
sb
ab
at
bt
a
b
s
t
y y y y y
y
y
y
yby
z
z
z
z
Orgad Keller - Algorithms 2 - 24
1 0 0 0 0 1 0 1 0 0
0 1 0 0 0 0 1 1 0 0
0 0 1 0 0 1 1 0 0 0
0 0 0 1 0 1 0 0 1 0
0 0 0 0 1 0 1 0 1 0
0 0 0 0 0 0 0 1 1 1
saT
sb
ab
at
bt
a
b
s
t
yA cy
y
y
y
z
z
z
z
Orgad Keller - Algorithms 2 - 25
We now see that the problems are dual So also according to the Strong Duality
Theorem, Max Flow = Min Cut
Max Flow – Min Cut Theorem
Orgad Keller - Algorithms 2 - 26
We want integer values for the variables, but this is LP, not IP!
So how do we know that the solution will yield integer values for the variables?
Theroem: If the constraints matrix is totally unimodular and the right hand side is comprised of integers, then it’s easy to find an integer solution.
Integer Values
Orgad Keller - Algorithms 2 - 27
Definition: A Unimodular matrix is a square matrix whose determinant is 0, 1 or -1.
Definition: A Totally Unimodular matrix is a matrix whose every non-singular square submatrix is unimodular.
Unimodular / Totally Unimodular