Professional Documents
Culture Documents
The Transhipment Problem: Formulation
The Transhipment Problem: Formulation
Formulation
Michel Bierlaire
The transhipment problem, also known as the min-cost flow problem, is probably
the most typical network optimization problem.
In this video, we provide its formulation.
Motivation
Logistics
◮ Goods have to be transported
◮ from the warehouses,
◮ to the clients.
◮ They can be transhipped anywhere on the network.
◮ Transportation costs must be minimum.
Data
Ne
Be
Nodes Fr
◮ Supply (warehouses). Or
◮ Demand (customers).
◮ Transhipment. La
Si
Data
Supply/demand
Ne
◮ si > 0 if supply node. Be
◮ si < 0 if demand node.
Fr
◮ si = 0 is transhipment node. Or
Validity La
X si
si = 0.
i∈N Si
Data
Ne
Links Be
◮ Costs.
Fr
◮ Capacities. c ij
Or
Validity , u ij]
La [ℓ ij
ℓij ≤ uij .
Si
Decision variables
Ne
Be
Fr
Flow vector Or x ij
x ∈ Rn .
La
Si
Objective function
Ne
Be
Total costs Fr
x ij
X Or
cij xij .
(i,j)∈A La
Si
Constraints
Ne
Be
u ij Fr
Capacity x ij
≤
Or ≤
ℓ ij
ℓij ≤ xij ≤ uij , ∀(i, j) ∈ A.
La
Si
Constraints
Ne
Be
Flow conservation
Fr
div(x)i = si , ∀i ∈ N . Or
X X
xij − xki = si , ∀i ∈ N .
La
j|(i,j)∈A k|(k,i)∈A
div(x)i = si
Si
Linear optimization problem
X Ne
minn cij xij
x∈R Be
(i,j)∈A
Fr
subject to
Or
X X
xij − xki = si , ∀i ∈ N .
j|(i,j)∈A k|(k,i)∈A
La
ℓij ≤ xij ≤ uij , ∀(i, j) ∈ A.
Si
Summary
Michel Bierlaire
X Ne
minn cij xij
x∈R Be
(i,j)∈A
Fr
subject to
Or
X X
xij − xki = si , ∀i ∈ N .
j|(i,j)∈A k|(k,i)∈A
La
ℓij ≤ xij ≤ uij , ∀(i, j) ∈ A.
Si
Set the lower bounds to zero
subject to
X X X X
xij′ − xki′ = si + ℓki − ℓij = si′ , ∀i ∈ C,
j|(i,j)∈A k|(k,i)∈A k|(k,i)∈A j|(i,j)∈A
X
minn cij xij′
x∈R
(i,j)∈A
subject to X X
xij′ − xki′ = si′ ∀i ∈ C,
j|(i,j)∈A k|(k,i)∈A
si sj
xij′ (0, uij )
i j
cij
si − uij uij sj
yij (0, +∞) xij′ (0, +∞)
i j
0 cij
Illustration
3 −3
3(−5, 5)
i j
cij
8 −8
8(0, 10)
i j
cij
−2 10 −8
2(0, +∞) 8(0, +∞)
i j
0 cij
Problem in standard form: modified network
X
minn cij xij min c T x
x∈R x∈Rn
(i,j)∈A
subject to
subject to Ax = s,
X X x ≥ 0.
xij − xki = si , ∀i ∈ N ,
j|(i,j)∈A k|(k,i)∈A
xij ≥ 0, ∀(i, j) ∈ A.
Incidence matrix
X X
xij − xki = si , ∀i ∈ N .
j|(i,j)∈A k|(k,i)∈A
3 4
2
1 2 3 4 5 ···
3 4 1
5 2
2 3
1
5
1 4
5
6
6
Summary
Michel Bierlaire
X
minn cij xij min c T x
x∈R x∈Rn
(i,j)∈A
subject to
subject to Ax = s,
X X x ≥ 0.
xij − xki = si , ∀i ∈ N ,
j|(i,j)∈A k|(k,i)∈A
xij ≥ 0, ∀(i, j) ∈ A.
Lagrangian
X
minn cij xij Lagrangian: L(x, λ, µ) =
x∈R
(i,j)∈A
X
subject to cij xij
X X (i,j)∈A
xij − xki = si , ∀i ∈ N ,
j|(i,j)∈A k|(k,i)∈A X X X
xij ≥ 0, ∀(i, j) ∈ A. + λi xij − xki − si
i∈N j|(i,j)∈A k|(k,i)∈A
X
− µij xij .
(i,j)∈A
First order optimality conditions (KKT)
X ∂L
= cij + λi − λj − µij = 0.
L(x, λ, µ) = cij xij ∂xij
(i,j)∈A
µij = cij + λi − λj
X X X µij ≥ 0 and µij xij = 0
+ λi xij − xki − si
i∈N j|(i,j)∈A k|(k,i)∈A
X
− µij xij ,
(i,j)∈A
Comments
cij + λi − λj ≥ 0.
cij + λi − λj = 0.
Michel Bierlaire
X
minn cij xij min c T x
x∈R x∈Rn
(i,j)∈A
subject to
subject to Ax = s,
X X x ≥ 0.
xij − xki = si , ∀i ∈ N ,
j|(i,j)∈A k|(k,i)∈A
xij ≥ 0, ∀(i, j) ∈ A.
Incidence matrix
3 4
2
1 2 3 4 5 ···
3 4 1 1 1 0 0 0
5 2 0 0 0 1 -1
2 3 0 0 -1 -1 0
1
5
1 4 0 -1 0 0 0
5 -1 0 1 0 0
6 0 0 0 0 1
6
Optimal solution
xB∗ = B −1 s.
Cramer’s rule
1
xB∗ = C (B)T s
det(B)
Each entry of the matrix is 0, 1 or -1.
Each entry of C (B) is an integer.
If s is integer, C (B)T s is integer.
If det(B) is 1 or -1, xb∗ is integer.
Total unimodularity
Definition
The matrix A ∈ Zm×n is totally unimodular
if the determinant of each square submatrix of A is
0, −1 or + 1.
Total unimodularity
Definition
The matrix A ∈ Zm×n is totally unimodular
if the determinant of each square submatrix of A is
0, −1 or + 1.
In particular,
every entry of the matrix is 0, −1 or +1.
Example
Each square submatrix of size 1, that is
each element of the matrix, is 0, −1 or
+1. Each square submatrix of size 2 is
unimodular:
−1 0
−1 0 1 det = 1,
A= 0 −1
0 −1 1
.
−1 0
det = −1,
1 1
0 −1
det = 1.
1 1
Integrality of the basic solutions
{x ∈ Rn |Ax = b, x ≥ 0} ,
Michel Bierlaire
X
minn cij xij min c T x
x∈R x∈Rn
(i,j)∈A
subject to
subject to Ax = s,
X X x ≥ 0.
xij − xki = si , ∀i ∈ N ,
j|(i,j)∈A k|(k,i)∈A
xij ≥ 0, ∀(i, j) ∈ A.
Incidence matrix
3 4
2
1 2 3 4 5 ···
3 4 1 1 1 0 0 0
5 2 0 0 0 1 -1
2 3 0 0 -1 -1 0
1
5
1 4 0 -1 0 0 0
5 -1 0 1 0 0
6 0 0 0 0 1
6
Theorem 22.6
Context
◮ B is k × k.
◮ det(B) 6∈ {0, 1, −1}.
◮ ∀ ℓ × ℓ submatrices B’: det(B ′ ) ∈ {0, 1, −1}.
◮ One column of B contains only zeros.
Impossible, because it would mean that det(B) = 0.
Therefore, no column of B contains only 0s.
One non-zero entry
Context
◮ B is k × k.
◮ det(B) 6∈ {0, 1, −1}.
◮ ∀ ℓ × ℓ submatrices B’: det(B ′ ) ∈ {0, 1, −1}.
◮ One column of B contains only one non-zero entry.
b11 b12 · · · b1k
0
B= ..
. B′
0
det(B) = b11 det(B ′ ) = det(B ′ ) or − det(B ′ )
Impossible as B is the smallest matrix.
Two non-zero entries
Context
◮ B is k × k.
◮ det(B) 6∈ {0, 1, −1}.
◮ ∀ ℓ × ℓ submatrices B’: det(B ′ ) ∈ {0, 1, −1}.
◮ Each column of B contains exactly two non-zero entries.
The two non zero entries are 1 and -1.
If you sum the elements of each column, it is equal to zero.
So, summing all the rows of B gives 0
B is singular, and its determinant is zero.
Contradiction.
Corollary
Michel Bierlaire
Definition
X X
C (P) = cij xij − cij xij .
(i,j)∈P → (i,j)∈P ←
Forward path
X X
C (P) = cij xij = cij xij
(i,j)∈P → (i,j)∈P
Transhipment
Flow
Send one unit of flow from o to d. Cost of a path
Supply at o: so = 1
X X
Supply at d: sd = −1 C (P) = cij xij = cij
Supply at any other node: si = 0 (i,j)∈P (i,j)∈P
Total unimodularity: if there is a
solution, flow on (i, j): 0 or 1
Transhipment
subject to
X X
xoj − xko = 1,
j|(o,j)∈A k|(k,o)∈A
X X
xdj − xkd = −1,
j|(d,j)∈A k|(k,d)∈A
X X
xij − xki = 0, ∀i ∈ N , i 6= o, i 6= d,
j|(i,j)∈A k|(k,i)∈A
xij ≥ 0, ∀(i, j) ∈ A.
Transhipment
Summary
Michel Bierlaire
The maximum flow problem was motivated by the analysis performed by the
American army of the railway network operated by the Soviet Union across
Eastern Europe during the Cold War.
We have a network, where each arc has a capacity
Consider an origin o and a destination d
What is the maximum amount of flow that the network can carry from o to d.
The maximum flow problem
1
4
2 3 2
o 2 3 d
3
Transhipment
1
4
2 3 2
o 2 3 d
3
Transhipment
0,
4 supply/demand for each node: 0
0,
◮
1
0, 2 0, 3 0, 2 ◮ lower bound on each arc: 0
o 2 3 d ◮ upper bound on the artificial arc:
∞
0, 3
◮ upper bound on every other arc:
−1, ∞ from the problem definition
Transhipment
min −xdo
x∈Rn+1
subject to
X X
xij − xki = 0, ∀i ∈ N , (1)
j|(i,j)∈A∪(d,o) k|(k,i)∈A∪(d,o)
Michel Bierlaire
Suppliers
◮ Mühleberg: 3110 GWh/year
◮ Beznau: 3198 GWh/year
◮ Leibstadt: 10205 GWh/year
Customers
◮ Zürich: 8961 GWh/year
◮ Geneva: 3777 GWh/year
◮ Lausanne: 2517 GWh/year
◮ Bern: 1258 GWh/year
Electricity in Switzerland
Unit costs
Mention that the problem definition does not involve a network, contrarily to the
shortest path problem and the max flow problem.
We need to create one.
Plot two or three arcs with their costs by hand.
Network
Bern
5
Leibstadt 7
16
9 Lausanne
Beznau 13 10
16
Geneva
9
6 14
Mühleberg
9
18
Zürich
Network
Bern
Leibstadt
Lausanne
Beznau
Geneva
Mühleberg
Zürich
Network
Bern
5
Leibstadt 7
16
9 Lausanne
Beznau 13 10
16
Geneva
9
6 14
Mühleberg
9
18
Zürich
Transhipment
subject to
X
md
xij = si , i = 1, . . . , mo ,
j=1
Xmo
xij = tj , j = 1, . . . , md ,
i=1
xij ≥ 0, i = 1, . . . , mo , j = 1, . . . , md ,
xij = 0, if i does not serve j.
Transhipment
Summary
Michel Bierlaire
−8000 Harry
−11000
−9000
−9000
−13000 Ron
−14000 −12000
−11000 Hermione
−12000
−0.01
Ginny
Network
Harry
Ron
Hermione
Ginny
Network
−8000 Harry
−11000
−9000
−9000
−13000 Ron
−14000 −12000
−11000 Hermione
−12000
−0.01
Ginny
Transhipment
subject to
X
n
xij = 1, i = 1, . . . , n, (1)
j=1
Xn
xij = 1, j = 1, . . . , n, (2)
i=1
xij ≥ 0, i = 1, . . . , n, j = 1, . . . , n, (3)
xij ≤ 1, i = 1, . . . , n, j = 1, . . . , n. (4)
The variable xij is to take on the value 1 if resource i is assigned to task j, and 0
otherwise.
Transhipment
Summary