linear programming – max flow – min cut orgad keller

27
Linear Programming – Max Flow – Min Cut Orgad Keller

Upload: arthur-price

Post on 22-Dec-2015

222 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Linear Programming – Max Flow – Min Cut Orgad Keller

Linear Programming –

Max Flow – Min Cut

Orgad Keller

Page 2: 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

Page 3: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 4: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 5: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 6: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 7: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 8: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 9: Linear Programming – Max Flow – Min Cut Orgad Keller

Orgad Keller - Algorithms 2 - 9

We’ll show by a simple example:

Max Flow with Linear Programming

s t

a

b32

13

1

Page 10: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 11: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 12: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 13: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 14: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 15: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 16: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 17: Linear Programming – Max Flow – Min Cut Orgad Keller

Orgad Keller - Algorithms 2 - 17

Going back to the example:

Min Cut with Linear Programming

s t

a

b32

13

1

Page 18: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 19: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 20: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 21: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 22: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 23: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 24: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 25: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 26: Linear Programming – Max Flow – Min Cut Orgad Keller

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

Page 27: Linear Programming – Max Flow – Min Cut Orgad Keller

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