40
Topics in Combinatorial OPtimization Orlando Lee – Unicamp 19 de mar¸ co de 2014 Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Topics in Combinatorial OPtimization - ic.unicamp.brlee/mo824/circulation-slides.pdf · Topics in Combinatorial OPtimization Orlando Lee – Unicamp 19 de mar¸co de 2014 ... sua

Embed Size (px)

Citation preview

Topics in Combinatorial OPtimization

Orlando Lee – Unicamp

19 de marco de 2014

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Agradecimentos

Este conjunto de slides foram preparados originalmente para ocurso Topicos de Otimizacao Combinatoria no primeirosemestre de 2014 no Instituto de Computacao da Unicamp.

Preparei os slides em ingles simplesmente porque me deuvontade, mas as aulas serao em portugues (do Brasil)!

Agradecimentos especiais ao Prof. Mario Leston Rey. Semsua ajuda, certamente estes slides nunca ficariam prontos atempo.

Qualquer erro encontrado nestes slide e de minha inteiraresponsabilidade (Orlando Lee, 2014).

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

Given

a digraph D = (V ,A), an arc capacity function u : A → R+,

a supply function b : V → R in which

b(v) > 0 means producer, and

b(v) < 0 means consumer,

find x : A → R such that:

x(δout(v))− x(δin(v)) = b(v) for every v ∈ V , and

0 ≤ x(a) ≤ u(a) for every a ∈ A.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

0

0

0

4

2−3

−3

3

3

3

32

2

2

41

Necessary condition: b(V ) = 0.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

4

2 3

3

3

3

3

32

2

2

41

s t

Set u(s, v) := b(v) se b(v) > 0,

Set u(v , t) := −b(v) se b(v) < 0.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

4

2 3

3

3

3

3

32

2

2

41

s t

The system has a feasible solution if and only if the auxiliarynetwork has a maximum st-flow which saturates all arcs

leaving s or entering t.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

Conclusion: checking whether there exists x : A → R such that:

(a) x(δout(v))− x(δin(v)) = b(v) for every v ∈ V , and

(b) 0 ≤ x(a) ≤ u(a) for every a ∈ A

can be done in polynomial time.

For brevity, if x satisfies (a), we say that it is a b-flow.

If x satisfies both (a) and (b), we say that it is a feasible b-flow.

Later we will see a good characterization for the existence of afeasible b-flow. In other words, necessary and sufficient conditionsthat provide succinct certificates for both possible answers (yes orno).

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

Let M be a real matrix with dimensions p × q such that:

the sum of the elements in row i is αi and

the sum of the elements in column j is βj .

We can round up or down any element r to ⌈r⌉ or ⌊r⌋ anyway welike.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

A consistent rounding of M is obtained by rounding the elementsof M, the values αi (i = 1, . . . , p) and the values βj (j = 1, . . . , q)so that:

the sum of the rounded elements in row i is equal to therounding of αi and

the sum of the rounded elements in column j is equal to therounding of βj .

Matrix rounding problem. Given a matrix M, find (if exists) aconsistent rounding of M.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

3.1 6.8 7.3 17.2

9.6 2.4 0.7 12.7

3.6 1.2 6.5 11.3

16.3 10.4 14.5

Matrix rounding problem.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

3

3 77 17

10 1 13

2

2

6 11

1116 14

Consistent rounding.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

We reduce Matrix Rounding Problem to the following problem.

Given a network (D, s, t, l , u) where l , u are arc capacity functionsin which for each a ∈ A:

• l(a) is the lower capacity of a and

• u(a) is the upper capacity of a,

find an st-flow f such that l(a) 6 f (a) 6 u(a) for every a ∈ A.

In a few minutes, we will show how to solve this problem.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

Reduction. construct a network as follows:

let s be the source and t be the target,

for each row i we have a vertex i ,

for each column j ′ we have a vertex j ′,

for each pair i e j ′ we have an arc (i , j ′) with capacities(⌊mi ,j⌋, ⌈mi ,j⌉),

for each vertex i we have an arc (s, i) with capacities(⌊αi⌋, ⌈αi ⌉), and

for each vertex j ′ we have an arc (j ′, t) with capacities(⌊βj⌋, ⌈βj ⌉).

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

(l , u)i j ′

s t

1 1′

2 2′

3 3′

(0, 1)

(1, 2)

(2, 3)

(3, 4)

(3, 4)

(6, 7)

(6, 7)

(7, 8)

(9, 10) (10, 11)

(11, 12)

(12, 13)

(14, 15)

(16, 17)(17, 18)

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Example: matrix rounding

There exists a 1-1 correspondence between consistent roundings ofM and feasible flows in the network.

If M := (mi ,j), α and β is a consistent rounding, then

f (a) =

mi ,j se a = (i , j),αi se a = (s, i),

βj se a = (j ′, t)

is a feasible flow in the network.

Similarly, if f is a feasible (integral) flow in the network, thenwe can obtain a consistent rouding.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Generalized networks

A generalized network is a network (D, s, t, l , u) where each arc a

is associated to a pair of capacities (l(a), u(a)).

Some typical problems:

find a feasible flow f ,

find a feasible flow with maximum value, and

find a feasible flow with minimum value.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Generalized networks

Unlike the case in which l = 0, the problem of finding a feasibleflow is more difficult.

The resolution of an optimization problem in a generalized networkis usually divided into two steps:

finding a feasible flow, and

given a feasible flow, finding a maximum one.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

In order to prove optimality of a flow in a generalized network(D, s, t, l , u) we need the following concept.

Define the (generalized) capacity of an st-cut δout(X ) as

cap(X ) := u(δout(X ))− l(δin(X )).

Lemma. Let f be a feasible flow and δout(X ) be an st-cut. Thenval(f ) ≤ cap(X ) with equality only if f (a) = u(a) for everya ∈ δout(X ) and f (a) = 0 for every a ∈ δin(X ). Furthermore, ifequality holds, then f is a maximum flow and δout(X ) is aminimum generalized capacity st-cut.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

Assume we know a feasible flow f in (D, s, t, l , u).

Define a residual network D ′

f = (V ,A′

f ) with residual capacityr as follows:

(a) if f (a) < u(a) then a ∈ A′

f and r(a) = u(a)− f (a),

(b) if l(a) < f (a) then a−1 ∈ A′

f and r(a−1) = f (a)− l(a).

Note that the definiton of residual capacity is similar to case l = 0.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

(2,3)

(l , u)

s

s

st

t

t

(1, 2) (2, 4)

(1, 4)

(0, 3)

f

0

1

1

1

3

2

2

2

2

2

2

r

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

Solve the MaxFlow problem on the network (D ′

f , s, t, r ). Letf ′ be the maximum flow returned by the algorithm.

Intuitively, f ′ is how much we must deviate from f to reach amaximum flow in the original network.

Define a flow f ∗ of the original network as follows:

(a) if a ∈ AD ′

f ∩ A then f ∗(a) := f (a) + f ′(a), and

(b) if a−1 ∈ AD ′

f ∩ A−1 then f ∗(a) := f (a)− f ′(a).

Clearly, f ∗ is a feasible flow in the original network. (Why?)

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

We will show that f ∗ is a (feasible) maximum flow in thegeneralized network. Let δout(X ) be a minimum st-cut of(D ′

f , s, t, r). Then

f ′(e) = r(e) for every e ∈ δoutD′

f(X ) and

f ′(e) = 0 for every e ∈ δinD′

f(X ).

Recall that

(a) for each e ∈ δoutD′

f(X ) either e = a for some arc a ∈ δout(X ) or

e = a−1 for some arc a ∈ δin(X ) and

(b) for each e ∈ δinD′

f(X ) either e = a for some arc a ∈ δin(X ) or

e = a−1 for some arc a ∈ δout(X ).

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

MaxFlow in generalized networks

Analyzing these four possibilities we conclude that in D we havethat

(a) if a ∈ δout(X ) then f ∗(a) = u(a) and

(b) if a ∈ δin(X ) then f ∗(a) = l(a).

Hence, f ∗ is a maximum flow and δout(X ) is a minimumgeneralized capacity cut in the generalized network.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Generalized MaxFlow MinCut theorem

Theorem. (Generalized MaxFlow MinCut)Let (D, s, t, l , u) be a generalized network. Then the value ofa maximum flow is equal to the generalized capacity of a

minimum st-cut.

Note that any MaxFlow algorithm can be used for finding amaximum flow in a generalized network, as long as we have aninitial feasible solution.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible flows

Let (D, s, t, l , u) be a generalized network.

Two basic questions:

How does one find a feasible flow, if it exists?

If it does not exist, how does one exhibit a simple certificateof this fact?

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible circulations

(l , u) (l , u)

s st t

(1, 2) (1, 2)(2, 4) (2, 4)

(1, 3) (1, 3)

(1, 4) (1, 4)(0, 3) (0, 3)

(0,∞)

Add an arc (t, s) to the network with capacities (0,∞).

The generalized network has a feasible st-flow if and only if thenew network has a feasible circulation.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible circulation problem

So the problem consists in finding x : A → R such that:

x(δout(v))− x(δin(v)) = 0 for every v ∈ V ,

l(a) ≤ x(a) ≤ u(a) for every a ∈ A.

We say that x is a feasble circulation.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Feasible circulation problem

Replacing x(a) by x ′(a) + l(a) we obtain:

x ′(δout(v))− x ′(δin(v)) = b(v) for every v ∈ V ,

0 ≤ x ′(a) ≤ u(a)− l(a) for every a ∈ A.

whereb(v) := l(δin(v))− l(δout(v)).

Therefore it suffices to find x ′ satisfying conditions above.

We have seen how this can be solved by a reduction to a MaxFlowproblem!

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Hoffman’s condition

Given a digraph D = (V ,A) and capacities l , u : A → R withl 6 u, we want to find out if there exists a feasible circulation.

A necessary condition is the following:

l(δin(X )) ≤ u(δout(X )) for every X ⊆ V .

We will show that this condition is also sufficient.

This can be done using the reduction to a MaxFlow on theprevious slide (see also the first three slides). If the algorithm stopsand returns a flow saturating all arcs leaving s then we obtain thedesired flow. Otherwise, find a minimum cut δout(X ). This st-setX is a set violating Hoffman’s cut condition. (Exercise)

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Hoffman’s circulation theorem

Theorem. (Hoffman, 1960) Let D = (V ,A) be a digraph withcapacities l , u : A → R such that l 6 u. Then there exists a

circulation x such that l 6 x 6 u if and only if

l(δin(X )) ≤ u(δout(X )) for every X ⊆ V .

Furthermore, if l , u are integral then x can be chosen integral.

We present here another proof of Hoffman’s theorem. The proofdoes not imply a polynomial algorithm for this problem, butillustrates some finer points.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Proof of Hoffman’s theorem

We can assume that l > 0 by modifying the network ifnecessary. (Why?)

Initialize x := 0. Thus, x 6 u but possibly l 66 x .

We say that an arc a is unfeasible if x(a) < l(a) and feasible ifl(a) 6 x(a).

Idea of the algorithm/proof: at each iteration we choose anunfeasible arc a and try to increase x(a). If this is not possible,then we find a set X violating Hoffman’s cut condition.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Proof of Hoffman’s theorem

Define a residual graph D(x) as follows.

For a feasible arc a

(1) if x(a) < u(a) then put a in D(x)with residual capacity u(a)− x(a), and

(2) if l(a) < x(a) then put a−1 in D(x)with residual capacity x(a)− l(a).

For an unfeasible arc a

(3) put a in D(x) with residual capacity u(a)− x(a).

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Proof of Hoffman’s theorem

At each iteration the algorithm selects an unfeasible arca = (v ,w).

Suppose first that there exists a wv -path P in D(x).

Since the residual capacities are positive, the algorithmincreases the flow along the cycle P + a, reducing the“unfeasibility”of a.

Note that this operation does not affect the feasiblity of theremaining arcs.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Proof of Hoffman’s theorem

Suppose then that there exists no wv -path in D(x).

Let X be the set of vertices reachable from w in D(x).

Then

x(a) = u(a) for every a ∈ δout(X ) and

x(a) ≤ l(a) for every a ∈ δin(X ).

Note that (v ,w) belongs to δin(X ) e x(v ,w) < l(v ,w).

Therefore,l(δin(X )) > u(δ+(X )),

and X violates Hoffman’s cut condition.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Some consequences

Theorem. Let D = (V ,A) be a digraph, b : V → R be afunction with b(V ) = 0 and l , u : A → R be arc capacity

functions with l 6 u. Then the system

x(δout(v))− x(δin(v)) = b(v) for every v ∈ V ,

l(a) ≤ x(a) ≤ u(a) for every a ∈ A,

has a a solution if and only if

u(δout(X ))− l(δin(X )) ≥ b(X )

for every X ⊆ V . Furthermore, if b, l , u are integral, we canchoose x integral.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Some consequences

Sketch of proof.

Add a new vertex r and for each v ∈ V add an arc (v , r) withl(u, r) := u(v , r) := b(v).

Then there exists a solution x if and only if there exists acirculation x ′ in the new network with l ≤ x ′ ≤ u.

Hoffman’s cut condition is equivalent to the cut condition of thetheorem.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Some consequences

Theorem. (Gale, 1957) Let D = (V ,A) be a digraph,b : V → R be a function with b(V ) = 0 and u : A → R an

arc capacity function. Then the system

x(δout(v)) − x(δin(v)) = b(v) para todo v ∈ V ,

0 ≤ x(a) ≤ u(a) para todo a ∈ A,

has a solution if and only if

u(δout(X )) ≥ b(X )

for every X ⊆ V . Furthermore, if b, u are integral, we canchoose x integral.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Some consequences

Exercise. Derive from Hoffman’s theorem a necessary andsufficient cut condition that a generalized network (D, s, t, l , u)must satisfy to have a feasible flow.

Theorem. (MinFlow MaxCut) Let (D, s, t, l , u) be ageneralized network which has a feasible st-flow. Then theminimum value of an st-flow is equal to the maximum of

l(δout(X ))− u(δin(X ))

for every st-set X . Furthermore, if l , u are integral then thereexists an integral minimum flow.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

Some consequences

Sketch of proof. (very very sketchy. . . )

Let α be a real parameter. Add a new arc (t, s) with l(t, s) := 0and u(t, s) := α.

Then there exists a feasible flow f with val(f ) = α if and only ifthere exists a feasible circulation x ′ in the new network withx ′(t, s) = α. By Hoffman’s cut condition this holds if and only if

l(δout(X ))− u(δin(X )) 6 α

for every st-set X .

Thus the minimum value of α for which this holds corresponds tothe maximum of the statement of the theorem.

Orlando Lee – Unicamp Topics in Combinatorial OPtimization

References

A. Schrijver, Combinatorial Optimization, Vol. A, Springer.

W.J. Cook, W.H. Cunningham, W.R. Pulleyblank and A.Schrijver, Combinatorial Optimization, Wiley.

R.K. Ahuja, T.L. Magnanti, J.B. Orlin, Network Flows:Theory, Algorithms and Applications, Prentice-Hall.

Some old slides of mine. . .

Orlando Lee – Unicamp Topics in Combinatorial OPtimization