Foundations of Operations Research: Master of Science in Computer Engineering
Foundations of Operations Research: Master of Science in Computer Engineering
Roberto Cordone
[email protected]
Tuesday 13.15 - 15.15
Thursday 10.15 - 13.15
http://homes.di.unimi.it/~cordone/courses/2013-for/2013-for.html
A flow model
A company manages a hydraulic network to supply water to a big consumer.
The network is known: in particular, each link has a maximum flow capacity,
the position of the water sources and of the consumer are given.
The aim is to estimate the maximum amount of water which is possible to
supply to the consumer through the network.
The network can be modelled by an arc-weighted directed graph G = (N, A)
the nodes stand for water sources and pipeline crossings, while
a fictitious node s (source) represents the overall origin of water,
and node t (sink) represents the consumer
the arcs stand for pipelines (two opposite arcs each),
including fictitious arcs from s to each water source node
the weight kij stands for the capacity of arc (i, j), i. e. the maximum
feasible water flow in the pipeline (possibly different in the two directions)
2 / 32
balance: in transhipment nodes the outgoing flow equals the ingoing flow
X
X
xjk =
xij
j N \ {s, t}
(j,k)+
j
(i,j)
j
(i, j) A
Examples
. . . nonbalanced
. . . violating a capacity
. . . nonminimal (f (x) = 2)
x is optimal (f (x ) = 6)
x is not an optimal
solution because it is. . .
. . . nonbalanced
5 / 32
S = {1, 2} +
S = {(1, 3) , (2, 3) , (2, 4)} and S = {(3, 2)}
Capacity of a cut is the sum of the capacities on the arcs of the outgoing cut
X
kS =
kij
(i,j)+
S
(i,j)
S
(s,k)+
s
(i,s)
s
Given any subset S including s and not t (s S N \ {t}), sum the balance
constraints over all nodes in S \ {s} and move both terms on the left side
X
X
X
X
xjk
xij = 0
jS\{s} (j,k)+
j
jS\{s} (i,j)
j
jS (i,j)
j
Split each sum, separating the arcs with both or only one extreme in S
X
X
X
X
x{s} =
xjk +
xjk
xij
xij = xS
(j,k)A:j,kS
(j,k)+
S
(i,j)A:i,jS
(i,j)
S
The flow across any cut equals that going out of s; in particular, f (x) = x{s}
8 / 32
xij
(i,j)+
S
xij
(i,j)
S
xij
(i,j)+
S
kij = kS
(i,j)+
S
9 / 32
Notice that the arcs express separation, and the associated cost
12 / 32
Any (s, t)-cut describes a partition of the modules between the two processors:
S includes s and the modules assigned to the first processor
N \ S includes t and the modules assigned to the second processor
the weights of the arcs in +
S represent:
the execution costs j for the second processor
the communication costs cij between the two processors
the execution costs i for the first processor
Overall, the weight of any (s, t)-cut equals the cost of the assignment, and the
minimum cut identifies the solution of minimum cost
13 / 32
Saturated arcs:
(2, 4) and (3, 2)
Saturated arcs:
(1, 3), (2, 3) and (3, 2)
14 / 32
An optimality condition
The capacity of a cut and the flow across it are equal if and only if
all outgoing arcs are saturated: xij = kij for all (i, j) +
S
all ingoing arcs are empty: xij = 0 for all (i, j)
S
Proof: The if part is trivial. As for the only if part:
X
X
X
xij
kS = xS
kij =
xij
(i,j)+
S
(i,j)+
S
(i,j)+
S
(i,j)
S
xij
(i,j)
S
xij 0
(i,j)
S
But since xij 0 for all (i, j) A, this implies xij = 0 for all (i, j)
S
Consequently,
X
(i,j)+
S
kij =
xij
(i,j)+
S
But since xij kij for all (i, j) A, this implies xij = kij for all (i, j) +
S
15 / 32
An algorithmic idea
Start with a trivial feasible flow: xij = 0 for all (i, j) A
Increase the current flow while keeping it feasible
If there is an (s, t)-cut whose capacity equals the flow, terminate;
otherwise, go to step 2
How to increase the flow while keeping it feasible?
If the flow on arc (i, j) increases, one of the following effects must occur
an increase in the flow on a subset of ingoing arcs of i
a decrease in the flow on a subset of outgoing arcs of i
a combination of the two modifications on a subset of incident arcs
16 / 32
Augmenting path
An augmenting path with respect to a feasible flow x : A R+ is an
undirected path P from s to t, such that the flow value f (x) can be increased
modifying the flow on its arcs
In general the augmenting path is not directed; it consists of
a set P + of forward arcs, directed from s to t, which must be nonsaturated
a set P of backard arcs, directed from t to s, which must be nonempty
The flow value f (x) increases by if
the flow function xij increases by on all forward arcs (i, j) P +
the flow function xij decreases by on all backward arcs (i, j) P
The increase and decrease must respect the capacity along the whole path
xij + kij
(i, j) P +
and
xij 0
(i, j) P
(i,j)P
Example
Backward arcs: P =
18 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min kij xij , min xij ;
(i,j)P +
(i,j)P
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
until Stop = True;
Return (f , x);
How can one find an augmenting path? Why does it works?
19 / 32
20 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
xij
22 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
xij
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
until Stop = True;
Return (f , x);
23 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
xij
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
until Stop = True;
Return (f , x);
24 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
xij
Augmenting path:
P = (1, 4, 3, 2, 6, 7)
;
f (x, P) = 1
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
until Stop = True;
Return (f , x);
25 / 32
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
Repeat
No augmenting path:
The nodes reachable from s form
+ =
S = {1, 4} with
S
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
xij
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
until Stop = True;
Return (f , x);
imax
X
(i)
Titer
i=1
FordFulkerson(N, A, k)
f := 0; xij := 0 for each (i, j) A;
Stop := False;
How many iterations imax of the loop?
Repeat
P := FindAugmentingPath(s, t, N, A, k, x);
If @P
then Stop := True;
else
"
#
:= min
min
(i,j)P +
(kij xij ) ,
min
(i,j)P
f := f + ;
xij := xij + for each (i, j) P + ;
xij := xij for each (i, j) P ;
xij
Consequently
f
mkmax
= m kmax
min
1
and the overall complexity is O kmax m2
imax
28 / 32
Pseudopolynomial algorithms
However, a maximum flow instance is given by a list of m arcs, and for each arc
the index of the tail node, an integer coded into log2 n bits
the index of the head node, an integer coded into log2 n bits
the capacity, an integer coded into log2 kmax bits
Thus, the size of the instance is m (2 log2 n + log2 kmax ) bits
Usually, n < kmax and the size is in O (m log kmax )
The problem is that kmax m2 is
polynomial with respect to m
but but exponential with respect to log kmax
Consequently, Ford and Fulkersons algorithm is not polynomial, but at least it
is not exponential with respect to the number of nodes and arcs
A pseudopolynomial algorithm is an algorithm which is
polynomial with respect to the number of elements of the problem
nonpolynomial with respect to the values of the weight functions
29 / 32
...
max f
X
(i,j)
j
xij
xjk
(j,k)+
j
0 xij
(1)
= 0
f
kij
if j = s
if j N \ {s, t}
(2)
if j = t
(i, j) A
(3)
It can be proved that this specific linear programming problem enjoys the
integrality property: if the data are integer, the optimal solution is integer
(if kij N, then xij N)
31 / 32