Академический Документы
Профессиональный Документы
Культура Документы
COURSE NOTES
By
1998
(Last update: July 2009)
OPTIMIZATION 3A GI
CONTENTS
Chapter 1 Introduction to Network Programming ............................................................................................ 3
2.2 Applications........................................................................................................................................................ 9
2
OPTIMIZATION 3A GI
1.1 Introduction
Network programming is a field of mathematics, which constitutes one of the most
used instruments for solving a wide class of discrete optimization problems in the
domain of operations research. A network allows for representing, in a simple way, a
variety of problems. Generally, network programming is a tool for modeling problems
involving connections or transshipment in complex systems, through the expression of
the relations that exist between its components. Examples of applications include
transportation networks and communication networks.
Networks can also be used to model problems which do not appear to have a link to
physical networks, such as project scheduling, where nodes of a the networks
represent activities and the arcs represent the precedence relations between the
activities. Other examples include production and inventory planning, resource
management and financial planning.
Example:
Consider an amusement park with O as the entrance and T the tramway station.
Pb 1: shortest chain problem to go from O to T.
Pb 2: minmum spanning tree: design an electrical network using minimal cable
length.
Pb 3: maximum flow: transport the maximum of tramways from O to T.
3
OPTIMIZATION 3A GI
7
A
2 D 5
2 4
5
O B 3 1 T
1
E 7
4 C
4
1.2.1 Networks
A network, G, is defined by:
A set N of points, also called vertices or nodes ;
A set A ⊂ N ×N of lines, called arcs, each joining a pair of nodes together with
some associated data. Nodes i and j are said to be adjacent if there is a line
joining them. Two lines are said to be adjacent if they share at least one
node.
The network is denoted G=(N, A).
Let ⏐N⏐= n: the number of nodes in G ; Then G is said to be of order n.
u
i j
4
OPTIMIZATION 3A GI
A line joining i and j that can be used either from i to j or from j to i is called an edge
and is denoted by the unordered pair (i;j). It is incident at i and j.
A network is said to be directed if it contains only arcs. It is undirected if all its lines
are edges.
The degree of a node i d(i) is the number of lines (arcs or edges) incident at it. In a
directed network, the indegree d-(i) (outdegree d+(i) ) of a node is the number of arcs
incident into (out of) it. We have then: d(i) = d+(i) + d-(i)
A p-Network is a network in which there exist at most p lines between any pair of
nodes.
For a 1-network, G can be perfectly determined by the set of nodes and the set of
successors of each node.
A path is a chain which all the arcs are forward arcs. In Figure 1.2, the arcs (C, A), (A,
B) and (B, D) constitute a path from C to D.
5
OPTIMIZATION 3A GI
B
D
E
C
The length (or cardinality) of a chain or a path is the number of its arcs.
Rq: It is important to note that, in some references, the definitions of path and chain
are reversed.
B
D
E
C
A subnetwork of G = (N, A) is a network F = (N, A ) with the same set of nodes, but
with A ⊂ A. For example, If G is the network representing all the routes in Tunisia,
the network representing all national routes in Tunisia is a subnetwork.
6
OPTIMIZATION 3A GI
If u = (i, j) ∈ A, the column u has all its coefficients equal to zero except: eiu = +1 and
eju = -1.
Example:
The node-arc incidence matrix of the following network is given in Figure 1.4.
u1
1 2
u2 u4 +1 +1 0 0 0
u3 -1 0 +1 +1 0
4 3
0 -1 -1 0 +1
u5 0 0 0 -1 -1
Figure 1.4: Example of node-arc incidence matrix
7
OPTIMIZATION 3A GI
If u = (i, j) ∈ A, the column u has all its coefficients equal to zero except: eiu = +1 and
eju = +1.
Example:
The node-edge incidence matrix of the following network is:
u1
1 2 1 1 0 0 0
u2 u4
u3 1 0 1 1 0
0 1 1 0 1
4 3
0 0 0 1 1
u5
Example:
The node-node incidence matrix of the following network is:
u1
1 2 0 1 1 0
u2 u4
u3 0 0 1 1
0 0 0 1
4 3
0 0 0 0
u5
8
OPTIMIZATION 3A GI
2.1 Introduction
Consider a directed network G = (N, A), with n nodes and m arcs. To each arc is
associated a real number cu called the length or weight of the arc u. If u = (i, j), the
arc length is denoted by cij. We define the length of a path as the sum of the lengths
of all its arcs.
The shortest path problem (SPP) consists of determining a path joining two given
nodes: an origin, or source S, and a destination, or sink T, with a minimal length.
The arc lengths may correspond to:
• distances,
• transportation costs,
• costs of constructing the arcs,
• travel times, …
The arc lengths can be of arbitrary signs (+ or -). As a consequence, a path that
contains a circuit that has a strictly negative length is unbounded (as the circuit may
be visited an infinite number of times). A necessary condition for the existence of a
shortest path is the absence of circuits with negative lengths.
2.2 Applications
9
OPTIMIZATION 3A GI
values of p(i), v(x) et r(x) are supposed to be discounted to their present value at
year i = 0.
We can show that this problem is equivalent to the shortest path problem in a
particular network. Let us define the network G = (N, A) as follows (see figure 2.1):
A node is associated with each date, giving a total of T+1 nodes.
An arc joins the nodes i and j if and only if i < j. This arc corresponds to the decision
of bying an equipment at year i and replacing it at year j.
The length of each arc is the sum of purchasing and operational costs, from which the
selling price is subtracted:
cij = p(i) + ∑s=1,j-i r(s) - v(j-i)
0 1 2 T
In order to take advantage of price variabilities, the company may constitute a stock
of unused items for a cost of h(t) per unit during each period t. The company may
also backorder customer demands in the case of a shortage. However, in this case, a
10
OPTIMIZATION 3A GI
penalty, µ per unit per period, has to be paid. We consider the problem of finding the
minimum cost supply (or replenishment) plan.
We can show that this problem is equivalent to the shortest path problem in a
particular network. Let us define the network G = (N, A) as follows (see figure 2.2):
N contains one particular node S and T nodes corresponding to each period; therfore,
a total of T+1 nodes.
The node S is linked to each node t: the arc (S, t) is associated with the decision of
supplying the material at period t. The length of such arc is p(t).
Each arc t (t = 1,…, T-1) is linked to the node t+1. An arc (t, t+1) corresponds to the
decision of storing during period t. The length of such arc is h(t).
Each arc t (t = 2,…, T) is linked to the node t-1. An arc (t, t-1) corresponds to the
decision of backorder during period t. The length of such arc is µ.
p(T)
p(1)
p(2) p(3)
1 2 3 T
h(1) h(2)
µ µ µ
11
OPTIMIZATION 3A GI
Proof:
Let C = (i1, i2, …, ip-1, ip) be a shortest path from node i1 to ip. We will show that the
the sub-path C’ = (i1, i2, …, ip-1) is an optimal path from i1 to ip-1.
If there exists another path C’’ linking the two nodes i1 and ip-1 and shorter than C’,
then the path obtained by adding the arc (ip-1, ip) to C’’ is shorter than C. This is a
contradiction with a fact that C is optimal. By induction over all the nodes in C, one
can show that all sub-paths in C are optimal.
Let N = {1, 2, …, n} and define for each node j a label πj equal to the length of the
shortest path from 1 to j. One immediate consequence of theorem 2.1 is the Bellman
equations:
π1 = 0
πj = mink≠j (πk + ckj) j = 2, …, n.
Example:
For the network in 2.3, π5 = min {π2 + c25 ; π3 + c35 ; π4 + c45}
2 3
4 5
Solving these equations for the case of a network without a negative circuit, gives the
shortest path between the node 1 and all other nodes of the network. The algorithms
presented next allows for solving these equations.
12
OPTIMIZATION 3A GI
A label is assigned to each node. The nodes are portioned into two subsets: P and T:
• P is the set of nodes each having a permanent label,
• T is the set of nodes each having a temporary label.
A permanent label represents the length of the shortest path from node 1 to the
considered node and a temporary label represents an upper bound on that length.
For a network having n nodes, the algorithm executes n-1 iterations: at each
iteration, one node is ransferred from T to P, and the temporary labels are updated.
13
OPTIMIZATION 3A GI
If T = ∅ then terminate.
4
4 5
2
2 5
7 1
3
1 5
2
3 6
1 4
It is required to find the shortest path between node 1 and each of the sales points.
1 2 3 4 5 6
Itération
1 (0,1) (7,1) (1,1) +∞ +∞ +∞
2 - (6,3) - +∞ (3,3) (5,3)
3 - (5,5) - (8,5) - (5,3)
4 - - - (8,5) - (5,3)
5 - - - (8,5) - -
Step 1 : π1 = 0 π2 = 7 π3 = 1 π4 = π5 = π6 = ∞, P = {1}, T = { 2, 3, 4, 5, 6}
γ(2) = γ(3)= 1
14
OPTIMIZATION 3A GI
Dijkstra’s algorithm is based on label fixing principle: at each iteration, it selects one
node and permanently fixes its label πj.
Step 3 : Test
If for all j πj(k+1) = πj(k), terminate
if k≤n-1, Go to Step 2 with k=k+1
If k=n, There exists a negative circuit; terminate.
15
OPTIMIZATION 3A GI
Note: An improvement of this algorithm can be achieved by using the results of the
current iteration (i.e., using the updated labels of iteration k in the Bellman
equations).
Example: A salesman currently at city O decides to participate in an international fair
organized in city T. To get to his destination, he has to use the network presented in
figure 2.5. He estimates the ransportation cost as well as the benefits he can earn by
selling his products at different intermediate cities along his route. In order to
minimize his expenses, the salesman seeks the minimal cost route from city O to city
T. Costs are benefits (negative data) are shown on the arcs.
A 7
2 -8 D
5
4
-5
O B -1 T
3
1 7
4 E
C
4
The shortest path from city O to city T has to be found. We have to use Ford-Bellman
algorithm because of the negative lengths:
O A B C D E T
Itération
1 (0,O) (2,O) (-5,O) (4,O) +∞ +∞ +∞
2 (0,O) (2,O) (-6,A) (4,O) (-1,B) (-2,B) +∞
3 (0,O) (2,O) (-6,A) (4,O) (-3,E) (-3,B) (4,D)
4 (0,O) (2,O) (-6,A) (4,O) (-4,E) (-3,B) (2,D)
5 (0,O) (2,O) (-6,A) (4,O) (-4,E) (-3,B) (1,D)
16
OPTIMIZATION 3A GI
Ford algorithm is based on label corrections. It can change the label of any node until
the last iteration.
Finding the shortest path from all nodes to one given node
Step 1:
For a network without circuits, or order n, number the nodes such that for each arc
(i, j) of the network : i > j. To achieve this, one may proceed as follows:
17
OPTIMIZATION 3A GI
Assign the number 1 to the terminal node. Mark the node number 1 and delete it from
the graph and delete all arcs incident into it.
If all nodes are numbered, terminate,
Otherwise, in the new network, find the nodes without any successors and assign to
them the following numbers, and delete them from the network. Go to 2.
Step 2:
The labels are recursively computed:
π1 = 0
πj = mini≠j (πi + cji) j = 2, …, n.
4 3 D
6 6
3 B 1
O 6
2 4
9 E
C
4
Step 2 : Compute πi :
πO = 0
πA = min (0 + 6) = 6/O
πC = min (0 + 9) = 9/O
πB = min (0 + 3 ; 6 + 4 ; 9 + 2) = 3/O
πE = min (3 + 6 ; 9 + 4) = 9/B
πD = min (6 + 3 ; 9 + 1) = 9/A
πT = min (6 + 10 ; 9 + 6 ; 9 + 4) = 13/E
Particularly, the shortest path is: (O, B), (B, E) and (E, T) with a cost of 13.
18
OPTIMIZATION 3A GI
Step 1 : Numbering
T : 1, D : 2, E : 3, B : 4, A : 5, C : 6, O : 7.
Step 2: Compute πi :
πT = 0
πD = min (0 + 6) = 6
πE = min (0 + 4 ; 1 + 6) = 4
πB = min (4 + 6) = 10
πA = min (0 + 10 ; 6 + 3 ; 10 + 4) = 9
πC = min (4 + 4 ; 10 + 2) = 8
πO = min (10 + 3 ; 9 + 6 ; 8 + 9) = 13
Particularly, the shortest path is: (O, B), (B, E) and (E, T) with a cost of 13.
Note: The numbering is not unique; for example, we could have inverted the numbers
of nodes A and C.
19
OPTIMIZATION 3A GI
3.1 Introduction
Network flow problems concern the circulation of material on/through the arcs of a
given network. Historically, these problems have been studied to represent electrical
current circulating on a network of dipoles. Nowadays, there exist a large number of
real situations that can be modeled using the concept of network flow:
- Transportation of merchandise from different distribution sites to different
customers through urbain, railway, marine, airway networks, or in some cases
a mix of ransportation modes,
- flow of liquids inside pipelines,
- flow of information through communication networks,
- Inventory management,
- scheduling, …
3.2 Definitions
Given a network G = (N,A), we associate with each arc u of A a positive integer
number ku called capacity of arc u.
The set N contains two special nodes:
One node having a zero indegree, called the source S of G,
One node having a zero outdegree, called the sink T of G.
One property of such networks is their ability to transport flow on the arcs. A flow
vector is defined as ϕ = [ϕ1, ϕ2, …, ϕm]T ∈ ℜm with m components, where ϕu is the
amount of flow traversing arc u.
0 ≤ ϕ u ≤ ku , ∀ u = 1, …, m
20
OPTIMIZATION 3A GI
The maximum value flow problem consists in determining a feasible flow ϕ between S
and T in G0 of a maximum value (max v(ϕ)).
3.3.2 Applications
a. Finding the maximum capacity of a roadway network
Consider a roadway network composed of m links (arcs). Each link is characterized by
a maximum number of vehicles that can traverse it per a unit of time.
The problem consists of finding the maximum number of vehicles that can travel
between two given points of the network during a time unit.
In this case, the similarity with the maximum value flow problem is obvious.
21
OPTIMIZATION 3A GI
n
Let E = U
j =1
{rj, dj}. Ranking the elements of E results in at most 2n-1 time intervals
The capacity of an arc (S, j) is pj, the capacity of linking one task to a time interval is
(eh+1 - eh), and the capacity of an arc linking a node associated with a time interval to
T is m(eh+1 - eh).
A feasible schedule exists iff the maximum value flow between S and T has a value of
P = ∑j=1,n pj.
Finding the maximum number of disjoint paths between two nodes S and T is
equivalent to solving a maximum value flow problem. This is achieved by assigning a
capacitiy of 1 unit to each arc and finding the maximum value flow between S and T.
22
OPTIMIZATION 3A GI
partial subnetwork that contains no cycles). At the beginning, only S is labeled, and at
each iteration, one labeled node is selected in order to label all its sucessors. Every
time a node j is selected, it is included in the tree while noting its predecssor γ(i),
which is the node that was responsible for its labeling. The algorithm stops when:
• the node T is labeled or
• all successors of labeled nodes are examined without being able to label the
node T.
In the latter case, we conclude that there is no chain from S to T in the network.
Here we notice that nodes may be in three possible states: (1) unlabeled, (2) labeled
and unscanned, and (3) labeled and scanned. At each iteration, a labeled and
unscanned node is selected, in order to examine its neighboring nodes. Once this is
done, node i becomes scanned but remains labeled until T is labeled or the algorithm
stops without labeling T.
23
OPTIMIZATION 3A GI
If such a pair does not exist, there is a nonbreakthrough. The current flow vector is a
maximum value flow vector; Terminate. Otherwise, node i is the immediate
predecessor of j in a chain starting from S.
If j = T, there is a breakthrough, go to step 3. Otherwise repreat this step 2.
δ = min { min
u∈FC,forward
(ku − ϕu ); min
u∈FC,backward
ϕu }
Change the current flow vector, ϕ, as follows:
• Increase by δ the flow on each forward arc of FC,
• decrease by δ the flow on each backward arc of FC.
Erase the labels of all nodes and go back to step 1 with the new flow vector.
Example: Isopipe Company wants to send the maximum quantity of natural gas (per
hour) through its pipelines, from node O to node T of the following network (Figure
4.1). 4
1
T
1 2
2 4 5 5
3 1
S 3 2
2 3
2 2
1
1
24
OPTIMIZATION 3A GI
Figure 4.1. Determine the maximum quantity of gas that can be sent from O to T
through this network.
+S
1 (1)
4 +2
+4 T
1 (1) 2 (4)
2 4 5 5
-4
* (3) (1)
3 1
S 3 2
2
2 (2) 3
2
(2) +3
1
-3 1
Node 4 : arc (4, 5) unsaturated and 5 unlabeled; label node 5 with (+4).
arc (4, T) saturated.
arc (3, 4) is backward and has a positive flow, label node 3 with (−4).
Node 3 : arc (3, 2) unsaturated and 2 unlabeled; label node 2 with (+3).
arc (1, 3) has a positive flow , label node 1 with (−3).
Node 2 : arc (2, T) unsaturated and T unlabeled; label node T with (+2).
25
OPTIMIZATION 3A GI
Step 3 : The FC can be identified by starting from T and going backward: (O, 4), (3,
4), (3, 2), (2, T). δ = min {2,1,2,3} = 1 . Subtract 1 unit from the flow on (3, 4) and
add it to the flow of the remaining forward arcs to obtain the new solution:
ϕS1 = 2, ϕ13 = 2, ϕS3 = 3, ϕS4 = 1, ϕ4T = 1, ϕ35 = ϕ5T = 4, ϕ32 = ϕ2T = 1
Erase all labels and go to step 1.
Step 1: Label node S with (*) and go to step 2.
Step 2 :
(S, 1) and (S, 3) are saturated; (S, 4) is an saturated and unlabeled; label node 4 with
(+S).
Node 4 : arc (4, 5) unsaturated and 5 unlabeled; indicate (+4) on node 5.
arc (4, T) saturated.
arc (3, 4) has a zero flow.
Step 3 : The FC is : (S, 4), (4, 5), (5, T) and δ=1; add 1 unit to flow on forward arcs to
obtain the following solution:
ϕS1 = 2, ϕ13 = 2, ϕS3 = 3, ϕS4 = 2, ϕ45 = 1, ϕ4T = 1, ϕ35 = 4, ϕ5T = 5, ϕ32 = ϕ2T = 1
Erase the labels and go to step 1.
Step 2 :
Starting from node S, no node can be labeled since all arcs are saturated. Hence,
node T cannot be labeled. The current solution is then optimal, with a flow value
equal to 7.
26
OPTIMIZATION 3A GI
Special cuts are those that separate the source S from the sink T. By choosing a subset
X that contains the source S but not the sink T, the set of arcs (i, j) with i ∈ X and j ∉
X is a cut of the network. A cut separating S and T is a set of arcs such that if
eliminated, flow becomes impossible from S to T (S and T become disconnected).
Proof:
Let A1 = set of arcs (i,j) such that i and j ∈ X.
Flow leaving nodes of X = ϕ+ (X) + ∑ϕ
u∈A!
u
27
OPTIMIZATION 3A GI
Lemma 3.1:
The value of any flow is less than or equal to the capacity of any cut:
∀ ϕ and (X, Xc) separating S and T, we have v(ϕ) ≤ C(X, Xc)
Proof:
Taking into account the reverse arc: ϕ+(X) = ϕ-(X) = ∑ ϕu + ϕ0
u∈( X ,X c ),reverse arc
u≠(T,S)
3.5.1 Phase I
Let L+(i) = ∑ j∈Γ(i) lij : Sum of lower bounds of arcs incident out of i;
28
OPTIMIZATION 3A GI
Transform G into a network G' having zero lower bounds in order to find an initial
compatible flow for G. This is achieved by applying the following:
• Add the reverse arc (T, S) having a capacity = ∞
• Replace the capacity kij by k’ij = kij - lij
• Add a dummy source S’ and a dummy sink T’
• For each i such that L+(i) >0, add the arc (i, T’) of capacity L+(i)
• For each i such that L-(i)>0, add the arc (S’,i) of capacity L-(i)
Theorem 3.2
There exists a compatible flow vector ϕ for G iff G the maximum value flow vector ϕ'
of G’ has a value ∑i,j ∈Nlij .This means that ϕ' saturates the arcs incident out of S’ and
those incident into T’. In addition, for each arc (i, j) of G, we have:
ϕij = ϕ'ij + lij
3.5.2 Phase II
Once a compatible flow vector is found, Ford-Fulkerson algorithm can be applied with
a slight modification: node i is labeled if ϕji > lji and δ is computed based on the
difference (ϕji - lji)
The rest of the algorithm remains the same.
Example: 1 (0,3)
(1,5) (2,5)
(1,6) 3
T
S (2,4)
(0,7) 2 (1,1)
29
OPTIMIZATION 3A GI
+∞
+S’ (1)
(2)
1 3 (2)
2
+1
4
3 2
(2) (2)
2
5 3 (2)
S 2 T +3
7 (4)
0
+T 2
+S
(4) 4 T’
S’
(1)
1 +2
3 (3)
30
OPTIMIZATION 3A GI
3.6.2 Applications
a. Optimal production planning
Consider the case of company that wants to plan the production of a given product
over a horizon of n periods. Knowing for each period i (i = 1… n):
• The demand di,
• the maximal production capacity ui,
• production cost/unit ci,
• storage capacity si,
• storage cost/unit hi, which applies to quantities left unused at th end of period i,
This problem can be reduced to finding a flow vector of a fixed value in a network G =
(N, A, C) constructed as follows:
• Associate a node to each period i (i = 1…n),
• introduce two additional nodes S and T,
• link the node S to each node i with an arc (S, i) of capacity ui and a cost ci : a
flow on the arc (S, i) represents production during period i,
• link each node i with the node T with an arc (i, T) of capacity di and zero cost:
a flow on the arc (i, T) represents demand of period i,
• link each node i (i = 1…n-1) to node i+1 with un arc (i, i+1) of capacity si and a
cost hi : a flow on the arc (i, i+1) represents the quantity stored at the end of
period i.
It is easy to verify that to each feasible flow between S and T of a value v = ∑i di
corresponds a feasible production plan. The optimal plan is then obtained by solving a
minimum cost flow problem.
b. Assignment problem
Consider the situation where n operators have to be assigned to n jobs. Let cij be the
cost of assigning operator i to job j. The problem is to determine a minimum cost
31
OPTIMIZATION 3A GI
One can verify that to each flow between S and T of value n corresponds a feasible
assignment (and vice versa). The cost of such a flow is equal to the assignment cost.
Let ϕ = [ϕ1, ϕ2, …, ϕm]T be a feasible flow vector. The residual network associated
with ϕ is the network G’(ϕ) having the same set of nodes as G, and which the set of
arcs is defined as follows:
Theorem 3.3
A necessary and sufficient condition for a feasible flow ϕ to be of minimum cost in G
is that no negative circuit exists in G’(ϕ).
This theorem shows that an optimal flow may be obtained by starting with a feasible
flow of value v and searching for a negative circuit in the residual network. If such a
circuit does not exist, then we conclude that the current solution is optimal.
32
OPTIMIZATION 3A GI
Otherwise, it is possible to increase the flow in the circuit by the minimum residual
capacity. The total value of the flow remains the same but its cost decreases (see
illustrative example bleow).
1
100 100 200
T
200
S
0
3
100
100 100 0
Low cost arc 2
in G'
Starting with a maximum value flow (obtained for example by the Ford-Fulkerson
algorithm), we seek to determine negative circuits in the corresponding residual
network. If such circuits do not exist, then the current flow is of minimum cost;
otherwise, a substitution along one of these circuits gives a flow with a smaller cost.
In this case, a new residual network is constructed and the process continues.
33
OPTIMIZATION 3A GI
Step 1:
Let ϕt be the flow at the tth iteration.
Construct the residual network G’(ϕt) associated with ϕt.
Step 2:
Search for a negative circuit μ’ in G’(ϕt).
If such a circuit does not exist, the curent flow vector is optimal, Terminate.
If such a circuit exists, Let μ be the cycle corresponding to μ’ in G.
let δt = min(i,j)∈μ’ (k’ij) the residual capacity of circuit μ’. Define the flow vector ϕt+1 as
follows:
ϕu t+1 = ϕu t + δt if u+ ∈ μ’
ϕu t+1 = ϕut - δt if u- ∈ μ’
Set t = t + 1 and go back to step 1.
The main issue in this method is how to find a negative circuit. In fact, the search for
such circuits is achieved by planting a tree rooted at T (the destination) and covering
the considered residual network. The algorithm of Bennington solves this problem
through the enhancement of a first algorithm proposed by Klein.
34
OPTIMIZATION 3A GI
Otherwise:
If the path from T to x in Rt traverses y (see illustration below), then the
concatenation of the subpath extracted from Rt: (y, …, x) and the the (x, y) yields a
negative circuit,
Otherwise (see illustration below), modify the tree Rt by deleting the arc (z, y) of Rt
(where z is the unique predecessor of y in Rt) and adding the arc (x, y);
t = t + 1, go to step 1.
x
T T
x y
y
z
Rt traverses y Otherwise
Example: a flower vendor needs to transport flowers from its flower field (S) to the
city (T), using various vans of different capacities. The roadway network linking S to T
is given in Figure 4.5, where each arc is described by its capacity (in boxes/week) and
its unit travel cost (TND/box).
The vendor wants to study the problem of transporting the flowers per week so that
the maximum quantity is transported for a minimum cost.
1 (200, 16)
(400, 2)
T
(200, 2) (200, 9)
S 3 (300, 0)
35
OPTIMIZATION 3A GI
Step 0 : Using Ford-Fulkerson algorithm, we search for a maximum value flow vector
for G:
Let the initial solution be:
S→1→T : flow = 200
S→2→3→T : flow = 200
With this solution, we can no longer label the destination T: This is an optimal value
flow with a value of 500 boxes and a cost of 7300 TND.
Let ϕ0 be this flow.
Step 1:
1 (200, -16)
(200, 2) (100, -9) T
Step 2 : Look in G’(ϕ0) for a circuit μ’ with a negative cost relatively to the cost
vector c’. To do this, construct a spanning tree for G’(ϕ0) :
[-16]
1 (200, -16)
[-13] T
S 3 (300, 0) [0]
[0]
(200, 0) (200, -13)
2
[-13]
36
OPTIMIZATION 3A GI
The arc (1, S) dos not blong to the spanning tree and h1 + c’1S < hS (-18 < -13).
The path from T to 1 in the tree does not go through S: Erase the arc (2, S) and add
arc (1, S). hS = -18
The arc (1, 3) does not belong to the new tree and h1 + c’13 < h3 (-7 < 0).
The path from T to 1 in the tree does not go through node 3: Erase the arc (T, 3) and
add the arc (1, 3). h3 = -7 and h2 = -20.
[-16]
1 [0]
[-18] T
S 3
[-7]
2
[-20]
The arc (2, 1) does not belong to the newly chosen tree and h2 + c’21 < h1 (-18 < -16).
The path from T to 2 in the tree goes through node 1: we have a negative circuit with
a cost = -2 : (1, 3, 2, 1).
The smallest capacity on this circuit equals 100: in the network G, increase the flow
on the arcs (2, 1) and (1, 3) by 100 boxes and reduce the flow on the arc (2, 3) by 100
boxes.
Therefore, the cost is reduced by 100 * 2 = 200 TND
The new tree is obtained by eliminating the arcs (1, 3) and (3, 2) and by adding the
arcs (1, 2) and (2, 3).
37
OPTIMIZATION 3A GI
Step 1:
Determine, using an appropriate algorithm, a minimum cost path from S to T in the
residual network G’(ϕt).
If such a path does not exist, then Terminate: the current flow is optimal.
Otherwise, go to step 2.
Step 2:
To the path just found corresponds to an augmenting chain in G. Increase the flow in
G by the allowed amount δt on this chain. This gives the new flow vector ϕt+1 of value
v(ϕt+1) = v(ϕt) + δt.
Step 3:
Construct the residual network G’(ϕt+1) associated with this new flow vector.
Set t = t + 1 and go to step 1.
At the end of this algorithm, we obtain a maximum value flow having a minimum
cost. In case a lower value is sought, the algorithm should be stopped once this value
is reached.
38
OPTIMIZATION 3A GI
Iteration S 1 2 3 T
0 0 2 0 ∞ ∞
1 0 2 0 11 18
2 0 2 0 11 11
3 0 2 0 11 11
Step 2:
Increase the flow in G by the maximum allowed amount on the associated chain: δ =
200 boxes, giving the flow of value 200.
Step 3: The residual network G’(ϕ1) associated with this new flow vector is the
following:
1 (200, 16)
(400, 2)
(200, 0) T
(200, -9)
S (200, -2) 3 (100, 0)
39
OPTIMIZATION 3A GI
Step 1: Apply Ford-Bellman to find the shortest path, in terms of cost, from S to T in
G’(ϕ1).
Iteration S 1 2 3 T
0 0 2 ∞ ∞ ∞
1 0 2 0 ∞ 18
2 0 2 0 13 18
3 0 2 0 13 13
Step 2:
Increase the flow value in G by the maximum allowed amount δ=100 boxes. This gives
a flow ϕ2 having a value of 300.
Step 3: The residual network G’(ϕ2) associated with this new flow vector is the
following:
1 (200, 16)
(300, 2)
T
(100, -2) (100, -2) (200, -9) (300, 0)
F 3
(100, 2) (100, -13)
(200, 0) (100, 13)
2
Step 1: Apply Ford-Bellman to find the shortest path, in terms of cost, from S to T in
G’(ϕ2).
Iteration S 1 2 3 T
0 0 2 ∞ ∞ ∞
1 0 2 0 ∞ 18
40
OPTIMIZATION 3A GI
2 0 2 0 13 18
3 0 2 0 13 18
Step 2:
The flow value can be increased by δ = 200 boxes, giving the flow ϕ3 of a value 500.
Step 3: The residual network G’(ϕ3) associated with this new flow vector is the
following:
1 (200, -16)
(100, 2)
T
(300, -2) (100, -2) (200, -9) (300, 0)
S 3
(100, 2) (100, -13)
(200, 0) (100, 13)
2
41
OPTIMIZATION 3A GI
4.1 Introduction
Dynamic Programming is a modeling framework that is generally used for optimization
problems involving sequential decision processes. In these dynamical problems,
decisions are made for a planning horizon, which is divided into periods or stages, and
a decison at one stage influences the outcome and the decisions of all the flollowing
stages.
Application examples:
1. Production and inventory control: It consists of planning the production in a
way that satisfies demand while minimizing total production and holding cost.
2. Resource allocation: involves allocating limited resources to a set of activities.
3. Equipment replacement: deals with determining a minimum cost strategy that
specifies how long a machine or equipment should be kept before it is replaced
(or traded in).
Most of these problems can be solved using linear or integer programming. However,
dynamic programming is more efficient for problems with low dimensions (a finite set
of resources to assign to a number of activities) and, for some problems with
nonlinear cost or profit functions, it may be the only sensible method.
Dynamic programming can be used for problems having the following characteristics:
- Continuous or discrete decision variables
- Continuous or discrete horizons (or time)
- Finite of infinite horizons
- Deterministic or stochastic data (such as demand in production planning
problems)
42
OPTIMIZATION 3A GI
In this course we consider only: Discrete, finite horizon and deterministic dynamic
programming.
2 610
790
580 5 1030
760 540
1 3 7
940
6 1390
660 790
4
270
Each stage i contains the set of cities Joe can reach at the beginning of day i.
43
OPTIMIZATION 3A GI
t : period,
st : state variables,
xt : decision variables relative to period t.
Φt : a function that transforms the state of the system into another state if
decision xt is made.
x1 x2
xT
g1(s1, x1) g2(s2, x2) gT(sT, xT)
s1 s2 s3 …………. sT sT+1
44
OPTIMIZATION 3A GI
Then, define ft(j) as the length of the shortest route from city 1 to city j, given that
city j is at stage t.
Stage 1 : f1(1) = 0.
Stage 2 : f2(2) = 580
f2(3) = 760
f2(4) = 660
Stage 3 : the shortest route from city 1 to city 5 is the route having the minimal
disance among the different possible routes:
1→2→5 distance = c25 + f2(2) = 610 + 580 = 1190*
or 1→3→5 distance = c35 + f2(3) = 540 + 760 = 1300
or 1→4→5 distance = c45 + f2(4) = 790 + 660 = 1450
The shortest route between cities 1 and 5 is 1 → 2 → 5 with f3(5) = 1190.
Similarly, the shortest route from city 1 to city 6 is the one having the minimal
distance among the different possible routes:
1→2→6 distance = c26 + f2(2) = 790 + 580 = 1370
or 1→3→6 distance = c36 + f2(3) = 940 + 760 = 1700
or 1→4→6 distance = c46 + f2(4) = 270 + 660 = 930*
The shortest route between cities 1 and 6 is 1 → 4 → 6 with f3(6) = 930.
Stage 4 : the shortest route from city 1 to city 7 is the route having the minimal
disance among the different possible routes:
f4(7) = Min {c57 + f3(5) = 1030 + 1190 = 2220* ; c67 + f3(6) = 1390 + 930 = 2320}
45
OPTIMIZATION 3A GI
Applying this formulation to the shortest route example gives the following:
ft(j) = Mini {ft-1(i) + cij} where i is a state at stage t-1
f1(1) = 0 : boundary conditions
Objective: find f4(7)
In this case, ft(j) is the length of the shortest path from city 1 to city 7.
Example 4.1
If I make sure that it is my opponent's turn when there is only one match left, then I
would be sure of winning. Using the same reasoning by going backwards, if I make
sure it is my opponent's turn when there are 5 matches left, then I would be sure of
winning. The reason is that no matter how many matches he will take, I can always
make sure to get to the situation where it is his turn when there is only one match
left:
If he takes 1 I will take 3
If he takes 2 I will take 2
46
OPTIMIZATION 3A GI
Similarly, if if I make sure it is my opponent's turn when there are 9, 13, 17, 21, 25 or
29 matches left, then I would be sure of winning. This way, I can garantee to win if I
begin by taking 1 match. Then, at each one of my subsequent turns, I will make sure
to leave for my opponent either 25, 21, 17, 13, 9 or 5 matches.
With this backward reasoning, we are able to build up a full strategy starting from the
basic simple subproblem corresponding to “only one match”.
Let fk(sk) be the value of optimal sequence of decisions that takes the system from
state sk till state sT (final state)
The DP backward recursive formulation would be:
fk(sk) = Max/Minxk {gk(sk, xk) + fk+1(sk+1)}
sT+1 = ΦT(sT, xT) : boundary conditions
Objective: Find f1(s1)
Applying this formulation to the shortest route example give the following:
ft(i) = Minj {ft+1(j) + cij} where j is a state at stage t+1
f4(7) = 0 : boundary conditions
Objective: find f1(1)
Here, ft(i) is the length of the shortest route from city i to city 7, given that city i
is at stage t. In the backward recursion, the computation begins with the last
stage (or states)
Stage 4 : f4(7) = 0.
Stage 3 : f3(5) = 1030
f3(6) = 1390
Stage 2 : The shortest route between cities 2 and 7 is the route having the minimal
distance among all possible routes:
2→5→7 distance = c25 + f3(5) = 610 + 1030 = 1640*
or 2→6→7 distance = c26 + f3(6) = 790 + 1390 = 2180
The shortest route between cities 2 and 7 is 2 → 5 → 7 with f2(2) = 1640.
47
OPTIMIZATION 3A GI
Similarly, shortest route between cities 3 and 7 is the route having the minimal
distance among all possible routes:
3→5→7 distance = c35 + f3(5) = 540 + 1030 = 1570*
or 3→6→7 distance = c36 + f3(6) = 940 + 1390 = 2330
The shortest route between cities 3and 7 is 3 → 5 → 7 with f2(3) = 1570.
Similarly, the shortest route between cities 4 and 7 is the route having the minimal
distance among all possible routes:
4→5→7 distance = c45 + f3(5) = 790 + 1030 = 1820
or 4→6→7 distance = c46 + f3(6) = 270 + 1390 = 1660*
The shortest route between cities 4 and 7 is 4 → 6 → 7 with f2(4) = 1660.
Stage 1 : The shortest route between cities 1 and 7 is the route having the minimal
distance among all possible routes:
f1(1) = Min {c12 + f2(2) ; c13 + f2(3) ; c14 + f2(4)}
= Min {580 + 1640 ; 760 + 1570 ; 660 + 1660}
= Min {2220 ; 2330 ; 2320} = 2220
The shortest route between cities 1and 7 is 1 → 2 → 5 → 7 with f1(1) = 2220.
However, for problems of larger dimensions, dynamic programming can be much more
efficient than enumeration. Consider a network with a total of 27 nodes, and having 7
stages, with 5 nodes at each of stages 2, …, 6. Suppose in addition, that we can go
from any node at stage k to any other node at stage k+1. The problem is to find the
shortest route from state 1 to state 27.
48
OPTIMIZATION 3A GI
Using dynamic programming: Let ft(i) be the length of the shoretst route from city i to
city 27, given that city i is at stage t. We need to determine f1(1).
2. Each stage is associated with a number of states, where a state is the set of
information that is necessary in order to make a feasible decision. For the
shortest route problem, the state at stage i is simply the city where Joe is at,
at the beginning of day i.
3. We note that, to make an optimal decision at each stage, Joe does not need to
know how he reached a given city. All he needs to know is at which city he is at
a given stage.
4. The decision taken at a given stage describes the transition of the system from
a state at a given stage into a state of the next stage. For the shortest route
49
OPTIMIZATION 3A GI
problem, the decision made by Joe (here, Joe is both the system and the
decision maker) at a given stage is the city at which he will spend the following
night.
5. Given a state of a current stage, the optimal decision for each of the following
stages has to be independent of the previous decisions. This is the principle of
optimality of Bellman. For the shortest route problem, this principle states
that each optimal route is composed of optimal sub-routes.
50
OPTIMIZATION 3A GI
Production and inventory holding costs vary from one period to another. the
problem is to determine how much to produce during each period so as to
minimize total production and holding cost.
The following are the data given for each period t = 1,… , T :
- dt : demand of the period, know at the beginning of period 1,
- ct : fixed production cost during period t,
- pt : unit production cost during period t,
- ht : unit holding cost per during period t; the quantity held in stock is the
quantity left unsold at the end the period t.
Let xt : be the quantity to produce during period t.
In some practical settings, this assumption is too restrictive if the cost functions have
to be nonlinear. In this case the problem can be solved using dynamic programming.
Problem formulation
State variables
it = Inventory at hand at the beginning of period t.
Decision variables:
xt : the quantity to produce during period t.
Let ft(it) : optimal cost corresponding to periods t,…, T if the inventory level at the
beginning of period t is st.
51
OPTIMIZATION 3A GI
Example 4.2
At the beginning of each month t, the company has to determine the quantities to
produce xt, given that :
- Fixed production cost c = 3$,
- Unit production cost p = 1$/unit,
- Unit holding cost h = 0,5$/unit left at the end of the period.
- Production capacity Lp= 5 units/month
- Storage capacity Li = 4 units at the end of the month.
52
OPTIMIZATION 3A GI
At the beginning of each month, the company must determine the quantity to
produce. Therefore, all is needed is to know the inventory level at the beginning of
the month.
⇒ The state variables correspond to the inventory level at the beginning of the
month, which is nothing but the inventory level at the end of the previous month.
i(t, i) for t = 2, 3, 4 and i = 0, 1, …Li= 4
i(1, 0) for t = 1, i=0
Boundary conditions :
f4(i4) = 3 + (d4 – s3) if s3 < d4
f4(i4) = 0 if s3 ≥ d4
53
OPTIMIZATION 3A GI
54
OPTIMIZATION 3A GI
Month 2 : (Exercise)
We have to determine the quantities to produce during month 2 so as to minimize the
total cost over the months 2, 3 and 4: f2(i2)
f2(i2) = minx2 {g2(x2, i2) + f3(i2 + x2 – d2)}
where
g2(x2, i2) = 3 + x2 + 0,5 (i2 + x2 - 2) if x2>0
g2(x2, i2) = 0,5 (i2 + x2 - 2) if x2 =0
i3 = i2 + x2 - 2
0 ≤ x3 ≤ 5 ; 0 ≤ i3 ≤ 4 ; 0 ≤ i2 ≤ 4
55
OPTIMIZATION 3A GI
The cost of the optimal production and inventory plan is 20$. Optimal production plan:
Month t 1 2 3 4
Production xt 1 5 0 4
x2 x3
2, 0 3, 0 4, 0
x4
x1
2, 1 3, 1 4, 1
1, 0 2, 2 3, 2 4, 2 5, 0
56
OPTIMIZATION 3A GI
2, 3 3, 3 4, 3
2, 4 3, 4 4, 4
Theorem 4.1
The production and inventory control problem has a solution such that:
1. it * xt = 0 t = 1,…, T
2. If xt > 0 then xt = ∑j=tn dj t ≤ n ≤ T
3. If it > 0 then it = ∑j=tq dj t≤q≤T
Consequence
Using a backward procedure, if the inventory level at the beginning of a period is non
zero, then it is optimal not to produce at that period.
Example : (2, 3) (3, 1) and (3, 2) (4, 1)
Example 4.3
An auto repair shop uses an engine analyser. The purchase cost of a new analyser
is 1000 $. The maintnance cost depends on the age of the analyser. We denote by
mi the maintnance cost of the anlyser at its ith year of utilisation.
The analyser can be used for up to 3 years. After its ith year, it can be replaced
by a new one. It can also be sold for an amount that is equal to its salvage value,
denoted by si. The values of mi and si are summarized below:
Year i 1 2 3
mi ($) 60 80 120
si ($) 800 600 500
57
OPTIMIZATION 3A GI
The shop manager needs to determine a replacement policy that minimizes total
cost over the next 5 years, assuming that at the end the 5-year period the
analyser will be sold for its salvage value.
C = maintnance cost + purchase cost – salvage value
58
OPTIMIZATION 3A GI
To solve this dynamic program, we start by computing f5(x5) then f4(x4) then f3(x3)
then f2(x2) then last f1(0).
For t = 2, 3, 4, 5:
ft(1) = min {80 + ft+1(2) : keep the equipment
1.000 - 800 + 60 + ft+1(1) : replace the equipment }
ft(2) = min {120 + ft+1(3) : keep the equipment
1.000 - 600 + 60 + ft+1(1) : replace the equipment }
ft(3) = 1.000 - 500 + 60 + ft+1(1) : replace the equipment
For t = 5 :
f5(1) = min {80 + f6(2) = -520, 1.000 - 800 + 60 + f6(1) = -540* }
⇒ f5(1) = -540 : replace the equipment
For t = 3 :
f3(1) = min {80 + f4(2) = -40*, 1.000 - 800 + 60 + f4(1) = -40* }
⇒ f3(1) = -40: keep or replace the equipment
59
OPTIMIZATION 3A GI
For t = 1 :
f2(1) = min {80 + f3(2) = 220*, 1.000 - 800 + 60 + f3(1) = 220* }
⇒ f2(1) = 220: keep or replace the equipment
2 3 4 5
1 3 4 5
4 5
Note :
We have assumed that costs are the same over the years. This is just to simplify
the computation of the costs ctx, which usually depend on t rather than the
difference
x-t.
60
OPTIMIZATION 3A GI
g(6) = 0
g(5) = c56 + g(6) = 260 MD
g(4) = min{c45 + g(5) ; c46 + g(6)} = min{260+260=520 ; 540+0+540} = 520
g(3) = min{c34 + g(4) ; c35 + g(5) ; c36 + g(6)} = min{780 ; 800 ; 760} = 760
g(2) = min{c23 + g(3) ; c24 + g(4) ; c26 + g(6)} = min{1020 ; 1060 ; 1020} = 1020
g(1) = min{c12 + g(2) ; c13 + g(3) ; c14 + g(4)} = min{1280 ; 1300 ; 1280} = 1280
1 → 2→ 3 → 6 or 1 → 2 → 5 → 6 or1 → 4 → 5 → 6
The optimal cost is 1280 $.
61
OPTIMIZATION 3A GI
E1 E2 EN
E1 EN
EN
In order to increase the reliability of the system, usually redundance is used. The
reliability Ri and the cost Ci of each equipment i is dependent on the number of units
(copies) ki of the equipment, placed in parallel.
Given a limited budget, the reliability problem consists of determining the number of
elements to place in parallel, of each equipment so as to maximize the reliability of
the whole system.
Example 4.4
Consider the case of a system having 3 machines placed in series. Suppose that at
most 3 elements can be placed in parallel for each of the machines. The reliability
Ri and the cost Ci (in K$) of each machine i are given in the table below, as a
function of the number of elements palced in parallel:
M1 M2 M3
ki R1 C1 R2 C2 R3 C3
1 0.6 1 0.7 3 0.5 2
2 0.8 2 0.8 5 0.7 4
3 0.9 3 0.9 6 0.9 5
62
OPTIMIZATION 3A GI
3
S. to ∑C (k ) ≤ b
i =1
i i
ki = 1, 2 ou 3
Stage : i : machine
State variable: yi : available budget at the beginning of stage i, for stages i, i+1, …,
3
Decision variable: ki: number of machines i
Recursive function :
fi(yi) : optimal reliability for stages i, i+1, …, n, if the available budget is yi
fi(yi) = maxki∈{1,2,3} {Ri(ki) * fi+1(yi+1)}
Equation linking the state variables to the decision variables: yi+1 = yi - Ci(ki)
Objective: f1(10)
Resolution :
i = 3 : y3 ∈ [2, 6]
y3 f3(y3) = R3(k3) k3
2 0.5 1
3 0.5 1
4 0.7 2
5 0.9 3
6 0.9 4
63
OPTIMIZATION 3A GI
y2 f2(y2) k 2, k 3
5 R2(1)*f3(2) = 0.7*0.5 = 0.35 1, 1
6 R2(1)*f3(3) = 0.7*0.5 = 0.35 1, 1
7 Max {R2(1)*f3(4) ; R2(2)*f3(2)} = 1, 2
Max {0.49 ; 0.4} = 0,49
8 Max {R2(1)*f3(5) ; R2(2)*f3(3) ; R2(3)*f3(2)} = Max {0.63 ; 0.4 ; 0.45} 1, 3
= 0,63
9 Max {R2(1)*f3(6) ; R2(2)*f3(4) ; R2(3)*f3(3)} = Max {0.63 ; 0.56 ; 1, 3
0.45} = 0,63
i = 1 : y1 = 10
y1 f1(y1) k 1, k 2, k 3
10 Max {R1(1)*f2(9) ; R1(2)*f2(8) ; R1(3)*f3(7)} = Max {0.378 ; 0.504 ; 2, 1, 3
0.441} = 0,504
f1(10) = 0,504
Note:
Knowing the initial state, we can also use a forward formulation. To do this, we
define yi = the amount of money spent during the stages 1,…, i.
The stage and the decision variables being the same, the recursive function
becomes:
fi(yi): the optimal reliability for stages 1,…, i, if the amount spent is yi.
fi(yi) = maxki∈{1,2,3} {Ri(ki) * fi-1(yi-1)}
The equation linking the state variables to the decision variables is: yi = yi-1 +
Ci(ki)
Boundary conditions: y1 ∈ [1, 3]
Objective: maxy3 f3(y3) with y3 ∈ [6, 10] = [C1(1)+C2(1)+C3(1), 10]
64
OPTIMIZATION 3A GI
Aspect 1 : the set of possible decisions for a given state and a stage:
For the production problem:
If st-1 is the stock level at the beginning of month t, the set of possible
decisions at stage t is xt such that :
0 ≤ xt ≤ 5 and 0 ≤ st-1 + xt - dt ≤ 4 ⇒ - st-1 + dt ≤ xt ≤ 4 - st-1 + dt
65
OPTIMIZATION 3A GI
Aspect 2 : We have to specify how the cost during the current stage t depends on the
value of t, the current state and the decision taken at that stage: c(t) = f(st-1, xt)
Aspect 3 : We have to specify how the state of stage t depend on the value of t, the
state at the previous stage t-1 and the decision take at stage t.
Notes:
Not all aspects are necessarily found in all recursions. very often, when the stage
contains sufficient information, it is used to define the state (ex: equipment
replacement problem).
For problems with a large number of states, dynamic programming becomes less
efficient than Integer programming techniques such as Branch-and-Bound.
dynamic programming is, in general, efficient for low dimensional problems.
There are techniques that make solving high dimensional problems possible with
dynamic programming (e.g. turnpike theorem for the knapsack problem).
66
OPTIMIZATION 3A GI
References
Hall.
Holden-Day, Inc.
Duxbury press.
67