Download as pdf or txt
Download as pdf or txt
You are on page 1of 104

The transhipment problem

Formulation

Michel Bierlaire

Optimization: principles and algorithms


Formulation

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

The transhipment problem consists in finding a flow vector of minimal cost,


consistent with supply and demand requests, as well as the network capacity
It is formulated as a linear optimization problem.
This problem allows to solve way more problems than the transhipment problem
used to motivate it.
As we will see, it has interesting properties.
Moreover, several important network optimization problems can be expressed as
special cases of the transhipment problem.
Consequently, they inherit its interesting properties.
The transhipment problem
Standard form

Michel Bierlaire

Optimization: principles and algorithms


Standard form

The transhipment problem is a linear optimization problem.


The simplex algorithm that we have seen requires the problem to be written in
standard form.
This is what we are doing in this video.
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
Set the lower bounds to zero

xij′ = xij − ℓij xij = xij′ + ℓij


X X X
minn cij xij′ + cij ℓij = minn cij xij′
x∈R x∈R
(i,j)∈A (i,j)∈A (i,j)∈A

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

0 ≤ xij′ ≤ uij − ℓij = uij′ , ∀(i, j) ∈ A.


Slack variables

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

0 ≤ xij′ ≤ uij′ , ∀(i, j) ∈ A.


Slack variables

0 ≤ xij′ ≤ uij , ∀(i, j) ∈ A.

Slack variables: yij

xij′ + yij = uij ,


xij′ ≥ 0, yij ≥ 0.
Interpretation

xij′ + yij = uij

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

For each arc (i, j) of index k,

aik = 1 and ajk = −1.


Incidence matrix

3 4
2
1 2 3 4 5 ···
3 4 1
5 2
2 3
1

5
1 4
5
6
6
Summary

The standard form can be interpreted as a transhipment problem on a modified


network
The matrix defining the flow conservation constraints is called the incidence
matrix
It has a specific structure: the column for arc (i, j) contains exactly two non zero
element: a 1 at row i and a -1 at row j.
The transhipment problem
Optimality conditions

Michel Bierlaire

Optimization: principles and algorithms


Optimality conditions

The transhipment problem is a linear optimization problem, where the constraints


have a special structure.
We analyze in this video the dual problem and the dual variables.
We show the optimality conditions called “complementarity slackness”.
Transhipment problem in standard form

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

Mention that only the differences of λ matters.


Complementarity slackness

For all (i, j)

cij + λi − λj ≥ 0.

For all (i, j) such that xij > 0

cij + λi − λj = 0.

Sufficient and necessary optimality conditions.


Summary

Simple optimality conditions


A dual variable is associated with each node in the network.
Only the difference between to adjacent nodes matters
The dual variables are often called “labels”.
The transhipment problem
Total unimodularity

Michel Bierlaire

Optimization: principles and algorithms


Total unimodularity

The incidence matrix defining the constraints of a transhipment problem has a


special structure
It also has a great property called “total unimodularity”.
It is great because it guarantees to generate an integer solution, if the data is
integer.
In this video, we introduce the definition of this property.
Transhipment problem in standard form

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

Consider the polyhedron represented in standard form

{x ∈ Rn |Ax = b, x ≥ 0} ,

where A ∈ Zm×n and b ∈ Zm .


If A is totally unimodular, then every basic solution is integer.
Proof
1
xB = B −1 b. xB = C (B)T b,
det(B)
Summary

We have introduced the concept of “totally unimodular” matrix


Each square submatrix has determinant 0, -1 or +1.
In this case, each basic solution of a linear optimization problem with A totally
unimodular and b integer is integer.
Next, we show that the incidence matrix of the transhipment problem is totally
unimodular.
The transhipment problem
Total unimodularity of the incidence matrix

Michel Bierlaire

Optimization: principles and algorithms


Total unimodularity of the incidence matrix

Total unimodularity of the matrix defining the constraints of a linear optimization


problem guarantees that the basic solutions are integer if the data are integer.
And, therefore, the optimal solution is also integer
This is a great property, given the difficulty of discrete optimization.
Transhipment problem in standard form

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

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
Theorem 22.6

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
◮ There exist square matrices with determinant 6∈ {0, 1, −1}.
Theorem 22.6

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
◮ There exist square matrices with determinant 6∈ {0, 1, −1}.
◮ Among all of them, consider the one with minimum size k: B.
Theorem 22.6

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
◮ There exist square matrices with determinant 6∈ {0, 1, −1}.
◮ Among all of them, consider the one with minimum size k: B.
◮ Note that k > 1.
Theorem 22.6

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
◮ There exist square matrices with determinant 6∈ {0, 1, −1}.
◮ Among all of them, consider the one with minimum size k: B.
◮ Note that k > 1.
◮ Number of non-zero entries in a column of B: 0, 1 or 2.
Theorem 22.6

The incidence matrix of a network is totally unimodular.


Proof
◮ By contradiction, assume that it is not the case.
◮ There exist square matrices with determinant 6∈ {0, 1, −1}.
◮ Among all of them, consider the one with minimum size k: B.
◮ Note that k > 1.
◮ Number of non-zero entries in a column of B: 0, 1 or 2.
◮ We treat each case separately.
No 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 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

If the supply vector s of the transhipment problem is integer, that is, if s ∈ Zm ,


and if the problem is bounded, then it has an optimal solution which is integer.
Summary

The incidence matrix of a network is totally unimodular


As the constraint matrix of the transhipment problem is the incidence matrix of
the network, we have the guarantee to obtain integer optimal solutions if the
demand and supply data are integer.
If you send trucks, there is no need to break them into pieces, or to rely on
discrete optimization.
The transhipment problem
The shortest path problem

Michel Bierlaire

Optimization: principles and algorithms


The shortest path problem

The transhipment problems embeds a variety of other problems.


These problems inherit the properties of the transhipment problem.
In particular, the integrality of the optimal solution if the data is integer.
In this video, we introduce the shortest path problem as an instance of the
transhipment problem.
Shortest path

Consider a network with nodes and arcs


Each arc is associated with a cost
Consider an origin and a destination
Find a simple forward path from o to d with the smallest cost
Shortest path
Shortest paths problems

In this video, single origin – single destination.


Shortest paths problems

◮ Single origin – single destination;


◮ Single origin – all destinations;
◮ All origins – single destination;
◮ All origins – all destinations.
Cost of a path

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

◮ cost on each arc: cij


◮ supply at the origin: so = 1
◮ supply at the destination: sd = −1
◮ supply at any other node: 0
◮ lower bound on each arc: 0
◮ upper bound on each arc: ∞
Transhipment
X
minn cij xij
x∈R
(i,j)∈A

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

The shortest path problem is a transhipment problem


It is equivalent to sending one unit of flow from the origin to the destination
The cost of a path is simply the sum of the cost of each arc along the path.
The transhipment problem
The maximum flow problem

Michel Bierlaire

Optimization: principles and algorithms


The maximum flow problem

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

Show the 3 possible paths


o → 2 → 4 → d: 1 unit of flow
o → 3 → d: 2 units of flow
o → 2 → 3 → d : saturated.
The maximum flow problem

1
4
2 3 2
o 2 3 d

3
Transhipment

Explain the idea of the artificial arc with infinite capacity


Add the cost on each arc
Transhipment

1
4
2 3 2
o 2 3 d

3
Transhipment

◮ cost on the artificial arc: −1


4
◮ cost on every other arc: 0

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)

xij ≤ uij , ∀(i, j) ∈ A, (2)


xij ≥ 0, ∀(i, j) ∈ A, (3)
xdo ≥ 0, (4)
Transhipment
Summary

The maximum flow problem can be written as a transhipment problem


An artificial arc, carrying every flow that reaches the destination back to the
origin, plays the role of a counter
The associated vector of flow must therefore be a circulation
Again, the max flow problem share the properties of the transhipment problem.
The transhipment problem
The transportation problem

Michel Bierlaire

Optimization: principles and algorithms


The transportation problem

The transportation problem is somehow a transhipment problem where


transhipment is not allowed.
We have suppliers and customers
There is a cost to transport items from a supplier to a customer
We need to decide how much each supplier will deliver to each customer
Electricity in Switzerland

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

Zürich Geneva Lausanne Bern


Mühleberg 18 6 10 9
Beznau 9 16 13 7
Leibstadt 14 9 16 5
Network

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

Bern ◮ cost on each arc: cij


Leibstadt
◮ supply for supplier nodes: si
Lausanne
◮ supply for customer nodes: −tj
Beznau
◮ lower bound on each arc: 0
Geneva
◮ upper bound on each arc: +∞
Mühleberg
Zürich
Transhipment
X
mo X
md
min cij xij
x∈Rn
i=1 j=1

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

The transportation problem does not have an underlying network structure.


Still, it can be modeled as a transhipment problem
A conceptual network is representing the problem.
Again, it inherits the properties of the transhipment problem, such as total
unimodularity.
The transhipment problem
The assignment problem

Michel Bierlaire

Optimization: principles and algorithms


The assignment problem

The assignment problem consists in assignment n tasks to n resources at minimal


cost.
Heirs

After the death of her husband,


my grandmother has discovered four masterpieces in her attic
She does not want to keep them,
She would like to sell each of them to one of her four children.
Each child made an offer for the masterpieces of interest
Heirs

Botticelli, 1485 Bruegel, 1558

Kandinsky, 1923 Bierlaire, 1971


Offers

She wants to sell exactly one masterpiece to each child.


Which masterpiece should she sell to which child, to maximize her revenues?
Offers (kEuros)

Botticelli Bruegel Kandinsky Bierlaire


Harry 8000 11000 — —
Ron 9000 13000 12000 —
Hermione 9000 — 11000 0.01
Ginny — 14000 12000 —
Network

−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

Harry ◮ cost on each arc: cij = −pij


◮ supply for each resource node: 1
Ron
◮ supply for each task node: −1
Hermione ◮ lower bound on each arc: 0
Ginny ◮ upper bound on each arc: 1
Transhipment
X
n X
n
min2 cij xij
x∈Rn
i=1 j=1

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

The assignment problem can be seen as a transportation problem where each


supplier sends one unit of flow, and each customer receives one.
Even if there is no underlying network structure, it can be modeled as a
transhipment problem
A conceptual network is representing the problem.
Again, it inherits the properties of the transhipment problem, such as total
unimodularity.
In this case, it guarantees that the flow will be 0 or 1 at the solution, even if no
constraint imposes it explicitly.

You might also like