Professional Documents
Culture Documents
Discrete
Optimization
Course notes for 2AGI class: Industrial Engineering
Atidel B. Hadj‐Alouane
09/09/2019
DISCRETE OPTIMIZATION 2AGI
TABLE OF CONTENTS
2
DISCRETE OPTIMIZATION 2AGI
1.1 Introduction
Linear programming allows for modeling a variety of real optimization problems by
expressing the related objective functions and constraints in terms of decision variables.
However, linear programming imposes certain assumptions that restrict its application
range. These assumptions are the following:
Proportionality: implies that cost terms and resource utilization are proportional to the
associated activity level.
Additivity: implies that the total consumption (or production) of an item is equal to the sum
of the various quantities of the item consumed (or produced) in carrying out each individual
activity at its specified level. The proportionality and the additivity assumptions together are
known as the linearity assumptions.
Divisibility: It is assumed that each variable in the model can take all the real values in its
range of variation.
Therefore, and due to divisibility assumption, linear programming does not handle problem
where decision variables represent indivisible entities such as an individual, a building or a
project. The class of mathematical programming that makes the linearity assumption
(proportionality and additivity) but restricts some variables to be integers is called Integer
Programming (IP).
Production planning
Facility location
Project selection
Portfolio optimization, …
3
DISCRETE OPTIMIZATION 2AGI
A Linear program where only some decision variables have to be integers is called a
The Linear relaxation of an integer program (mixed or binary) consists of relaxing the
integrality constraints in order to obtain a linear (continuous) program.
( IP ) s. to Ax = b
x 0
4
DISCRETE OPTIMIZATION 2AGI
The linear relaxation of the binary integer program (BIP) is the following:
Max cx
( BIP ) s. to Ax = b
0≤ xj ≤ 1 j
Note:
An integer program can be viewed as a linear program with added constraints (i.e.
For any maximization program (IP), the optimal objective value of the relaxed problem
( IP ) is larger than or equal to the optimal objective value of the integer program (IP) :
Z(IP) Z( IP ) (1.1)
where Z(IP) and Z( IP ) are the optimal objective values of IP and IP , respectively. The
difference Z( IP )‐Z(IP) is called the duality gap.
5
DISCRETE OPTIMIZATION 2AGI
However, for a problem where one has to decide whether to build an Electrical Plant (binary
variables), rounding off a fractional solution of 0.4 has no sense. It would make a big
difference whether the solution is rounded down to 0 or up to 1. Therefore, in this case,
rounding off is not appropriate.
1.3 Example
Consider the following integer program:
Max z = 21 x1 + 11 x2
S. to 7 x1 + 4 x2 13
x 1, x 2 0
x1, x2 integers
2,5
2,0
7 x1 + 4 x2 = 13
1,5
Feasible Domain of
1,0
According to figure 1.1, the feasible solutions to the problem are given by the set:
S = {(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1)},
and the optimal integer solution is (0,3) with z*=33. If we had to round off the optimal
continuous solution (13/7, 0) we would obtain:
Round up: (2,0) infeasible
Round down: (1, 0) feasible but far from optimal (z(1, 0) = 21)
6
DISCRETE OPTIMIZATION 2AGI
Notes:
1. Contrary to linear programs, the feasible domain of an integer program is not convex.
2. By computing and comparing the objective values, z, for each feasible solution in S,
we obtain the optimal solution (0, 3) for which z = 33. This is possible whenever the
feasible domain is bounded (or finite).
4. For some integer programs, all round offs are infeasible. Consider the following
example:
Max z = 4 x1 + x2
S. to 2 x1 + x2 5
2 x1 + 3x2 = 5
x1, x2 0
x1, x2 integers
The continuous optimal solution is (5/2, 0). Rounding up gives (3, 0) and rounding down
gives (2, 0); and both solutions are infeasible!
In conclusion, even though the feasible domain of an IP is included in the feasible domain of
its corresponding linear relaxation, solving integer programs is generally much more
difficult than solving linear programs. However, one can still raise the following question:
When do we expect to efficiently solve an IP? This question is addressed in the following
section.
7
DISCRETE OPTIMIZATION 2AGI
where B is mxm nonsingular and N is called the non-basic matrix. Then, the extreme point
solution is xB = B‐1 b; xN = 0. It is known in linear programming that if an optimal solution
exists there must be at least one extreme point that is optimal. It is therefore, interesting to
characterize the data of an integer program such that all extreme points are integral.
From the expression xB = B‐1 b, it is easy to notice that if all elements of B‐1 are integers and b
is an integral vector, than xB must be integral. The following results formalize this
observation.
Definition: a matrix A is totally unimodular each square submatrix, B, of A has a
determinant equal to 0, +1 or –1.
Consequence
This implies that the elements of a totally unimodular matrix are themselves equal to 0, +1
or –1, since they are the determinants of submatrices of order 1.
The following theorem gives a sufficient condition related to the integrality of basic solutions
on an IP.
Theorem 1.1: [Hoffman‐Kruskal, 1956]
Consider the linear program {min cx subject to: Ax = b}. If b is integral and A is totally
unimodular, then all basic solutions to this LP are integral.
Example 1.2
Max z = c1 x1 + c2 x2
S. to x1 + x2 b
x1, x2 0
x1, x2 integer
The matrix A = (1 1) is totally unimodular. If, in addition, b is integer than all extreme points
of the relaxed problem are integral.
8
DISCRETE OPTIMIZATION 2AGI
x2
2,0
x1 + x2 = b
1,5
b =1
1,0 b =2
0,5
Example 1.3
Max z = 4 x1 + 6 x2
S. to x1 + 2 x2 b
x1, x2 0
x1, x2 integer
x2
2,0
x 1 + 2 x2 = b
1,5
b =1
1,0 b =2
b =3
0,5
How do we know if A is totally unimodular? The following theorem gives sufficient (but not
necessary) conditions for the total unimodularity of A.
9
DISCRETE OPTIMIZATION 2AGI
q
S. to x
j 1
ij = ai i = 1, …, p
x
i 1
ij = bj j = 1, …, q
xij 0 i = 1, …, p j = 1, …, q
where:
p q
ai =
i 1
b
j 1
j : balance condition
cij 0 i = 1, …, p j = 1, …, q
10
DISCRETE OPTIMIZATION 2AGI
ai > 0 i = 1, …, p
bj > 0 j = 1, …, q
For a problem with 2 supply sites and 3 demand sites, the constraints are written as
follows:
x11 + x12 + x13 = a1
x21 + x22 + x23 = a2
x11 + x21 = b1
x12 + x22 = b2
x13 + x23 = b3
The constraint matrix, A, of the integer program is the following:
The matrix A is totally unimodular. Hence, as long as ai and bj are integers for all i and j, the
optimum solution of the transportation problem obtained by the Simplex algorithm will be
an integer solution. This result makes integer programs of the transportation problem easy
to solve.
11
DISCRETE OPTIMIZATION 2AGI
Introduction
This chapter shows, through practical examples, how to formulate real problems as integer
programs. It starts with simple and common problems, then builds up to more complicated
formulations.
In a similar way to linear programming, formulating integer programs involves the following
three steps:
1. Define the decision variables;
2. Write the objective function in terms of the decision variables;
3. Write the constraints in terms of the decision variables.
Project 1 2 3 4
Initial investment ($) 5000 7000 4000 3000
NPV ($) 16000 22000 12000 8000
Currently, a budget of $14 OOO can be made available for these investments. The problem
consists of selecting, among these 4 projects, those that maximize the total yield (NPV) while
satisfying the budget constraint.
1. Decision variables :
12
DISCRETE OPTIMIZATION 2AGI
2. Objective function:
3. Constraints :
Since the selection of a project requires an initial investment, the total investment cannot
exceed the available budget of $14 000. This is translated by the following linear constraint:
5000 x1 + 7000 x2 + 4000 x3 + 3000 x4 14000
For example, if the decision is to select projects 1, 3 and 4 (x2 = 0 and x1 = x3 = x4 = 1), the
total investment is 5000 + 4000 + 3000 = 12 000 14 000 (feasible solution).
The resulting model is a binary integer program:
Profitability
Project 1 3.2
Project 2 3.14
Project 3 3
Project 4 2.67
Why does the optimal solution exclude the most profitable project?
13
DISCRETE OPTIMIZATION 2AGI
Notice that combining project 1 with any other project (projects 1 and 2 or projects 1, 3 and
4) does not require more than $12000 as initial investment. This means that $2000 will
remain non invested; Whereas selecting projects 2, 3 and 4 allows for a full use of the budget
and yields the maximum NPV.
Note:
An integer program of the same type as (BIP.1) is called the Knapsack problem (an IP in
which there is only a single constraint on the variables, other than the nonnegative integer
requirement). This problem relates to the situation where a camper has to fill a knapsack, of
a given capacity, with some useful items in order to go to camp. The question is what should
he put in the knapsack to maximize his satisfaction function without exceeding the knapsack
capacity?
Additional Constraints:
Suppose that for some practical reasons, the following restrictions are imposed:
At most two projects can be selected.
14
DISCRETE OPTIMIZATION 2AGI
since x4 = 0 or 1, then x4 = 0
- if x2 = 0, then x4 1 , which implies no further restriction on the value of x4.
Shirts 200 6 12 3 4
Shorts 150 4 8 2 3
Pants 100 8 15 6 4
Each week, there are 150 hours of labor and 160 dm2 of cloth available for production.
The problem is to determine the weekly production level for each item such that total weekly
profit is maximized.
1. Decision variables:
Define, for each type of clothing, an integer variable that denotes the number of unit to
produce per week.
x1: the number of shirts to produce per week.
x2: the number of shorts to produce per week.
x3: the number of pants to produce per week.
We notice that the machine rental cost depends on the clothing type to produce and not on
the quantity produced. Therefore, we define a decision variable that denotes whether or not
to produce a clothing type:
15
DISCRETE OPTIMIZATION 2AGI
3. Constraints:
The company is faced to two types of constraints:
Constraint 1 : at most, 150 hours of labor are available each week,
3 x1 + 2 x2 + 6 x3 150
Constraint 2 : at most 160 dm2 of cloth is available each week,
4 x1 + 3 x2 + 4 x3 160
The integer program is written as follows:
16
DISCRETE OPTIMIZATION 2AGI
pants without paying for machinery rental (the solution indicates x1>0 whereas y1=0 !). This
is because the formulation is incomplete. We need to specify the relationship between xi and
yi, otherwise nothing would stop us from setting y1 = y2 = y3 = 0 (setting yi = 0 costs less than
yi = 1).
The following constraints have to be added to the formulation:
x1 M y1
x2 M y2
x3 M y3
where M is a very large number.
Consider the following example. There are six cities (cities 1-6) in Washtenaw County. The
county must determine where to build fire stations. The county wants to build the minimum
number of fire stations needed to ensure that at least one fire station is within 15 minute
17
DISCRETE OPTIMIZATION 2AGI
(driving time) of each city. The times required to drive between the cities in Washtenaw
County are shown in Table 2.4.
The problem consists of finding how many fire stations to build and where to build them.
Table 2.4 Travel times (in minutes) between every pair of cities
1. Decision variables:
At each city, the county has to decide whether to build a fire station. Then, define a 0-1
variable for each city i=1, …, 6 :
xi = 1 if a fire station is built at city i,
= 0 otherwise.
2. Objective function:
The number of fire stations has to be minimized:
Min z = x1 + x2 + x3 + x4 + x5 + x6
3. Constraints :
The county has to ensure that every city can be reached by at least one fire station, within at
most 15 minutes. From Table 2.4, we can deduce, for each city, those cities that are within
15 minutes of driving time. The results are summarized on Table 2.5.
18
DISCRETE OPTIMIZATION 2AGI
For example, for city 1, the neighboring cities that are within 15 minutes are cities 1 and 2.
The corresponding constraint should state that one fire station has to be built either at city
1 or city 2:
x1 + x2 1
The same logic leads to the following constraints for the remaining cities:
x1 + x2 + x6 1 : City 2
x3 + x4 1 : City 3
x3 + x4 + x5 1 : City 4
x4 + x5 + x6 1 : City 5
x2 + x5 + x6 1 : City 6
The binary integer program for the above problem is:
(BIP.2) Min z = x1 + x2 + x3 + x4 + x5 + x6
S. to x1 + x2 1
x1 + x2 + x6 1
x3 + x4 1
x3 + x4 + x5 1
x4 + x5 + x6 1
x2 + x5 + x6 1
xi = 0 or 1, for i = 1,…, 6
Consider a problem where at least one of the following two constraints is satisfied:
f(x1, x2, …., xn) 0
g(x1, x2, …., xn) 0
In a mathematical programming formulation, these constraints have to be included but not
necessarily both of them are satisfied. These constraints are called "disjunctive" or of the
"either‐or" type.
One way to model this situation is to replace the either-or constraints by the following two
"conjunctive" constraints:
19
DISCRETE OPTIMIZATION 2AGI
where y is a binary variable and M is a sufficiently large number such that f(x1, x2, …., xn)
M and g(x1, x2, …., xn) M for any values of x1, x2, …., xn that satisfy the rest of the constraints.
For y = 0, the constraints (2.1) and (2.2) become: f(x) 0 and g(x) M and hence the
To handle this situation, we first note that this condition is equivalent to the previous one :
Either f(x1, x2, …., xn) 0 or g(x1, x2, …., xn) 0. Therefore, it can be replaced with the system:
y = 0 or 1.
Again, M is a sufficiently large number such that f(x1, x2, …., xn) M and g(x1, x2, …., xn) M
for any values of x1, x2, …., xn that satisfy the rest of the constraints.
If f(x) > 0 the constraints (2.3) and (2.4) are verified only if y = 1. This implies that
g 0 ; which is the desired outcome.
If f(x) > 0 is not verified then y = 0 or 1. In this case, there is no restriction on the
variables x1, x2, …., xn and g(x) < 0 or g(x) 0 are both possible.
20
DISCRETE OPTIMIZATION 2AGI
3.1 Introduction
Consider the following IP: {max cx, s.to Ax = b, x 0 and x integral}. Recall that, if the
constraint matrix A is not totally unimodular, or there are non-integer right hand sides (bi) ,
it is possible for the linear programming relaxation to have non-integral extreme points.
In this case, linear programming algorithms, such as Simplex, are not appropriate for solving
the IP.
In this chapter, we present a well-known approach for solving integer programs: Branch-
and-Bound. It is an enumeration-based and a decomposition approach that consists of
schematically describing the solution set as a search tree, then intelligently searching this
tree to obtain an optimal solution.
max f x
x D
Where f(x) is any real function of x n and D n .
D1 D2
D3 D4
21
DISCRETE OPTIMIZATION 2AGI
Let fi* be the optimal solution for section i, and f* the optimal solution to the entire problem.
Then f max f i .
i
Suppose one subproblem, say the 2nd, turns out to be difficult as well break it further into
subproblems.
D21
D1 D23
D22
D3 D4
Figure 3.3 below shows a tree diagram related to the above problems.
Original Problem
Subproblem 1
Subproblem4
Subproblem 2 Subproblem 3
Subproblem21 Subproblem23
Subproblem22
22
DISCRETE OPTIMIZATION 2AGI
Suppose we found f1* and we discovered only an upper bound B3 for subproblem 3 that is
worse than f1*, i.e., B3 f1*. Since f3* B3, then f3* f1* . Therefore, there is no need to
continue solving subproblem 3: The solutions in sub3 have been implicitly enumerated. The
process of evaluating the subproblems in order to compare them with the best found
solution is called "Bounding".
Practically, this process of alternately branching and bounding requires finding a "good"
implicit evaluation of f(x) over all subsets Di and rapidly obtaining a "good" feasible solution
of f(x) over D.
As a consequence, when a feasible solution of IP is found, the implicit evaluation allows for
implicitly searching the integer branches of the constructed tree without necessarily
examining all subproblems (also called "nodes").
max c x
(P) s.to A x b
x0, x integral
A : mxn matrix.
A branch-and-bound tree is a directed graph with nodes corresponding to
23
DISCRETE OPTIMIZATION 2AGI
A node that is proven to have no optimal solution with a better objective value than
newly discovered solution becomes the new incumbent and therefore a reference for
fathoming other nodes. Once a node becomes an incumbent, it is also fathomed.
A node that has been branched from and is not fathomed, is called “unfathomed”.
Consider again:
max c x
(P) s.t. A x b
x0, x integral
(Sub2)
(Sub1)
max c x
max c x
s.t. A x b
s.t. A x b
x1 5
x1 4
x0, x integral
x0, x integral
Algorithm 3.1 (Dakin, for a maximization problem)
i
Let P be the linear relaxation of subproblem i, where i=0 designates the original problem
(P).
Step 1: (Initialization) Set z* = - or some lower bound on the objective value. Solve P .
- If it is infeasible, so is P; stop.
- If the optimal solution is such that x is integral, then stop, it is optimal for P.
Otherwise, set i=0 and Go to step 2.
24
DISCRETE OPTIMIZATION 2AGI
Step 2:
i
Branching: From the optimal solution to P , pick xk that is not integer (that is, its value x̂ k
is not integer). Add the constraints:
xk x̂ k (largest integer x̂ k )
xk x̂ k + 1
Example 3.1
Max 3 x1 + 4 x2
s.to x1 + x2 4.5
x2 2
x1, x2 0, integer
25
DISCRETE OPTIMIZATION 2AGI
Note: at every node, we solve the linear relaxation using, for example, the Simplex method.
z* = -
(x1, x2)
z = 15,5 for x = (2,5 ; 2)
x1 2 x1 3
Example 3.2 (graphical resolution)
Max z = 3 x 1 + 2 x2
s. to - 2 x 1 + 2 x2 7
2 x1 + 3 x2 18
9 x1 - 2 x2 36
x1, x2 0 and x1, x2 integers.
26
DISCRETE OPTIMIZATION 2AGI
z* = -
(x1, x2)
z = 19+23/31 for x = C (4+20/31 ; 2+28/31)
x2 2 x2 3
(OEFD) : Point F (ABHG) : Point H
z = 17+1/3 for x = (4+4/9 ; 2) z = 19+1/2 for x = (4+1/2 ; 3)
x1 4 x1 5
(ABIJG) : Point I
z = 18+2/3 for x = (4 ; 3+1/3) infeasible
x2 3 x2 4
([JG]) (BKL)
z* = 18 for x = J (4 ; 3) z = 17 for x = L (3 ; 4)
x2
-2x1+2x2=7
9x1-2x2=36
B
K L
A I
H
G J C (4+20/31 ; 2+28/31)
E (0 ; 2)
F
2x1+3x2=18
O x1
D (4 ; 0)
3.3.3 B&B exploration :
In Dakin's algorithm, the node selection is based on the LP bound. In general, there are two
different strategies for node selection:
Progressive Selection: it is based on the best bound or the best evaluation. It is also called
breadth-first search, since it generally leads to wide trees. This strategy is typically
27
DISCRETE OPTIMIZATION 2AGI
memory consuming, but is interesting when the problem at hand has an "easy" structure and
feasible good solutions are relatively easy to find.
Sequential Selection: It consists of choosing, among the unfathomed nodes, the node that is
the closest to the most recently explored node (the node just branched on). This is reduced
to perform a "depth first" search or "backtracking" (or also LIFO). This strategy is less
memory consuming that the breadth-first search since data storing is limited to offspring
nodes of the considered node.
To solve mixed integer programs, Dakin's algorithm can be used by branching only on
variables restricted to be integers.
Example 3.3
Max z = 2 x 1 + x2
s.to 5 x1 + 2 x2 8
x 1+ x2 3
x1, x2 0 and x1 integer.
z* = - (x1, x2)
z = 11/3 for x = (2/3 ; 7/3)
x1 0 x1 1
z = 3 z = 7/2
x1 = 0 x1 = 1
x2 = 3 x2 = 3/2
First incumbent Last incumbent
28
DISCRETE OPTIMIZATION 2AGI
after the due date. If the task is completed before or on the due date, its tardiness is then
zero. We would like to determine the order in which the tasks have to be processed in a way
to minimize the total tardiness, denoted by T.
We may formulate this problem as an integer program, by defining the following variables:
It turns out that we can develop a B&B algorithm that does not use the linear programming
relaxation. We may, however, use the definition of the variables to show how the
subproblems are constructed.
Since the problem consists of finding the optimal sequence of tasks, we define a subproblem
by fixing the positions of some tasks and computing a lower bound of what is called of
solution completion. For example we can choose fixing the task at the last position. In this
case, we may finish the sequence by task 1, 2, 3 or 4. This means:
x14 = 1 or x24 = 1 or x34 = 1 or x44 = 1
This results in 4 subproblems or branches corresponding to the 4 considered tasks.
How to compute the bound of each branch ?
Take the branch corresponding to x44 = 1, which means task 4 is processed last. We know
that, for any sequence, the last task will be completed at: 6 + 4 + 5 + 8 = 23. Then, if the last
task is task 4, its tardiness will be = 23 – 16 = 7 days. Therefore, any sequence that ends with
29
DISCRETE OPTIMIZATION 2AGI
task 4 has a total tardiness ≥ 7 days. Hence, the Lower bound of this branch will be LB = 7
days. Proceeding this way, we obtain the following B&B tree.
x14 = 1 x44 = 1
x24 = 1 x34 = 1
Branch 1 Branch 4
Branch 2 Branch 3
LB = 15 LB = 7
LB = 19 LB = 11
x13 = 1
x33 = 1
x13 = 1 x23 = 1
x23 = 1 x43 = 1
x12 = 1
x22 = 1
Branch 8 Branch 9
T = 12 T = 16
To move across the B&B tree, we chose the Breadth First. This means that the next branch
to explore is the one having the smallest lower bound. For example, after creating the first 4
branches, we chose to explore Branch 4. To do so, we further decompose the solution space
corresponding to Branch 4 into 3 branches or subproblems : 5, 6 and 7.
For each branch, we compute the new lower bound. For example, for Branch 7, the 3rd task
will be finished at the end of day 15 (= 23-8) which will result in a tardiness of 15 – 12 = 3
additional days. Hence the total tardiness T will be at least = 7 + 3 = 10 days.
Then, the next branch to explore is Branch 7 since it has the lowest LB.
The process continues until the first complete solution is found. Since the LB corresponding
to a complete solution is actually equal to its total tardiness, T, every branch of the tree that
has LB≥T can be crossed (or fathomed). When branch 7 is explored the complete solution
having T=12 will allow to fathom all branches except Branch 3. Here, we record Branch 8 as
the best solution so far and continue to explore Branch 3. In this example, this branch
30
DISCRETE OPTIMIZATION 2AGI
resulted in three lower bound ≥ 12. These branches are fathomed because any further
exploration will be useless. Once all branches are explored, the best solution so far must be
the optimum. In this case, Branch 8 gives the optimal sequence: 2, 1, 3 and 4, with T=12.
31
DISCRETE OPTIMIZATION 2AGI
4.1 Introduction
Up to this point, the methods and models presented in this course have one unifying
characteristic which is their static aspect. They address optimization problems over a fixed
planning period. The whole decision problem is considered in its totality for the whole
period.
However, this does not exclude the use of these models and methods for problems with a
dynamical nature or those involving sequential decision processes. For example, a
production and inventory control problem over a horizon of several periods can be modeled
as an integer program and solved by branch-and-bound methods.
On the other hand, problems with sequential decision processes, where a decision at one
stage influences the outcome and the decisions of the following stages are, in general,
naturally and best modeled using another technique called "dynamic Programming".
Definition 4.1
Dynamic programming is a mathematical programming technique based on implicit
enumeration that is used to model optimization problems involving sequential decision
processes.
This technique was developed by R. Bellman in 1950 (USA). It consists in decomposing a
problem into subproblems or stages that can be easily solved.
Application examples:
1. Production and inventory control: It consists in 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 an equipment should be kept before it is replaced (or
traded in).
32
DISCRETE OPTIMIZATION 2AGI
Most of these problems can be solved using linear or integer programming. However,
dynamic programming is more efficient for problems with low dimensions (a small number
of resources to assign to a number of activities). Also, 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)
In this course we consider only: Discrete, finite horizon and both deterministic and
stochastic dynamic programming.
xT
x1 x2
s1 s2 … sT sT+1
33
DISCRETE OPTIMIZATION 2AGI
For many other applications, it is easier to use a dynamic programming formulation using
backward reasoning. This results into a backward formulation. Backward reasoning may
sometimes make a seemingly difficult problem easy to solve.
Example 4.1
Consider the following game. We have 30 matches. I begin by taking 1, 2 or 3 matches. Then,
comes my opponent's turn to also take 1, 2 or 3 matches. We continue this way until there
is only one match left. The player who takes the last match loses the game. As a first player,
how can I guarantee to win the game?
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
If he takes 3 I will take 1
Similarly, 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 guarantee 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.
1. The problem can be decomposed into stages or periods each representing a point of
decision.
34
DISCRETE OPTIMIZATION 2AGI
2. Each stage is associated with a number of states, where a state is the set of
information (state variables) that is necessary in order to make a feasible decision.
3. The state variables have to be defined such that, to make an optimal decision at each
stage, all we need to know is at which state we started that stage but not how we
reached the state. In other words, 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.
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.
The following are the data given for each period t = 1,… , T :
- dt : demand of the period, known at the beginning of period 1,
- ct : fixed production cost during period t,
- pt : unit production cost during period t,
- ht : unit holding cost during period t; the quantity held in stock is the quantity left
unsold at the end the period t.
The production and inventory control can be formulated as a linear or integer program
(depending on whether the quantities are continuous or discrete) and thus solved using
appropriate algorithms. However, one major assumption has to be made:
35
DISCRETE OPTIMIZATION 2AGI
- the cost functions have to be linear in terms of the quantities produced or held in
stock.
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
Decision variables:
xt : the quantity to produce during period t.
Boundary conditions:
fT(iT)= minfeasible xT {gT(iT, xT)}
Objective: find f1(i1), where i1 is the initial inventory (known).
36
DISCRETE OPTIMIZATION 2AGI
Example 4.2
A company knows the demands of the next 4 months:
Month t 1 2 3 4
Demand dt 1 3 2 4
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 ProdCap = 5 units/month
- Storage capacity StorCap = 4 units at the end of the month.
At the beginning of each month, the company must determine the quantity to produce.
Therefore, all is needed is to know the stock level at the beginning of the month.
The state variables correspond to the stock level at the beginning of the month, which is
nothing but the stock level at the end of the previous month.
it = 0, 1, …, StorCap (= 4) for t = 2, 3, 4
i1= 0.
Recursive function of the backward formulation:
gt(xt, it) = 3 + 1 xt + 0.5 (it + xt – dt) if xt>0
0.5(it ‐ dt) if xt=0
37
DISCRETE OPTIMIZATION 2AGI
Define ft(it) as the minimal cost production plan for months t,…, 4 if the inventory level at the
beginning of month t is it.
ft(it) = minfeasible xt {gt(xt, it) + ft+1(it+xt - dt)} for t=1,2,3
In order to take into account the capacity constraints, we have to ensure:
0 xt 5
0 it 4 t
As a consequence, we must choose xt such that 0 it+1 = it + xt+1 ‐ dt 4
Boundary conditions:
f4(i4) = 3 + (d4 – i4) if i4 d4
f4(i4)= 0 if i4 d4
Objective : find f1(0)
Month 4 : the company must produce just the necessary quantity to satisfy the month 4
demand. Since the stock level is zero at the end of month 4, the holding cos twill be zero.
f4(i4) = minx4 {g4(i4, x4)}
where
g4(i4, x4) = 3 + x4 if x4 >0
= 0 if x4 = 0 ;
i5 = i4 + x4 – 4 = 0
0 x4 5 and 0 i4 4
f4(0) = 3 + 4 = 7$ x4 = 4
f4(1) = 3 + 3 = 6$ x4 = 3
f4(2) = 3 + 2 = 5$ x4 = 2
F4(3) = 3 + 1 = 4$ x4 = 1
f4(4) = 0 + 0 = 0$ x4 = 0
Month 3 : we have to determine the quantities to produce during month 3 so as to minimize
the total cost for months 3 and 4: f3(i3)
f3(i3) = minx3 {g3(i3, x3) + f4(i3 + x3 ‐ d3)}
where
g3(i3, x3) = 3 + x3 + 0,5 (i3 + x3 ‐ 2) if x3 >0
= 0,5 (i3 ‐ 2) if x3 = 0
38
DISCRETE OPTIMIZATION 2AGI
i4 = i3 + x3 ‐ 2
0 x3 5 ; 0 i3 4 ; 0 i4 4
i3 x3 i4 g3 f4(i3+x3‐2) Total cost f3(i3) and x3(i3)
0 2 0 0+5=5 7 5 + 7 = 12*
0 3 1 0,5 + 6 = 6,5 6 6,5 + 6 = 12,5 f3(0) = 12
0 4 2 1+7=8 5 8 + 5 = 13 x3(0) = 2
0 5 3 1,5 + 8 = 9,5 4 9,5 + 4 =13,5
1 1 0 0+4=4 7 4 + 7 = 11
1 2 1 0,5 + 5 = 5,5 6 5,5 + 6 = 11,5 f3(1) = 10
1 3 2 1+6=7 5 5 + 7 = 12 x3(1) = 5
1 4 3 1,5 + 7 = 8,5 4 8,5 + 4 = 12,5
1 5 4 2 + 8 = 10 0 10 + 0 =10*
2 0 0 0+0=0 7 0 + 7 = 7*
2 1 1 0,5 + 4 = 4,5 6 4,5 + 6 = 10,5 f3(2) = 7
2 2 2 1+5=6 5 6 + 5 = 11 x3(2) = 0
2 3 3 1,5 + 6 = 7,5 4 7,5 + 4 = 11,5
2 4 4 2+7=9 0 9+0=9
3 0 1 0,5 + 0 = 0,5 6 0,5 + 6 = 6,5*
3 1 2 1+4=5 5 5 + 5 = 10 f3(3) = 6,5
3 2 3 1,5 + 5 = 6,5 4 6,5 + 4 = 10,5 x3(3) = 0
3 3 4 2+6=8 3 8 + 3 = 11
4 0 2 1+0=1 5 1 + 5 = 6* f3(4) = 6
4 1 3 1,5 + 4 = 5,5 4 5,5 + 4 = 9,5 x3(4) = 0
4 2 4 2+5=7 0 7+0=7
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(i2, x2) + f3(i2 + x2 – d2)}
where
g3(i2, x2) = 3 + x2 + 0,5 (i2 + x2 ‐ 3) if x2 >0
= 0,5 (i2 ‐ 3) if x2 = 0
39
DISCRETE OPTIMIZATION 2AGI
i3= i2 + x2 ‐ 3
0 x2 5 ; 0 i2 4 ; 0 i3 4
i2 x2 i3 g2 f3(i2+x2‐3) Total cost f2(i2) and x2(i2)
0 3 0 0+6=6 12 18 f2(0) = 16
0 4 1 0,5 + 7 = 7,5 10 17,5 x2(0) = 5
0 5 2 1+8=9 7 16*
1 2 0 0+5=5 12 17
1 3 1 0,5 + 6 = 6,5 10 16,5 f2(1) = 15
1 4 2 1+7=8 7 15* x2(1) = 4
1 5 3 1,5 + 8 = 9,5 6,5 16
2 1 0 0+4=4 12 16
2 2 1 0,5 + 5 = 5,5 10 15,5 f2(2) = 14
2 3 2 1+6=7 7 14* x2(2) = 3
2 4 3 1,5 + 7 = 8,5 6,5 15
2 5 4 2 + 8 = 10 6 16
3 0 0 0+0=0 12 12*
3 1 1 0,5 + 4 = 4,5 10 4,5 + 10 = 14,5 f2(3) = 12
3 2 2 1+5=6 7 6 + 7 = 13 x2(3) = 0
3 3 3 1,5 + 6 = 7,5 6,5 7,5 + 6,5 = 14
3 4 4 2+7=9 6 9 + 6 = 15
4 0 1 0,5 + 0 = 0,5 10 10,5*
4 1 2 1+4=5 7 12 f2(4) = 10,5
4 2 3 1,5 + 5 = 6,5 6,5 13 x2(4) = 0
4 3 4 2+6=8 6 14
Month 1 : We have to determine the quantities to produce during month 1 so as to minimize
the total cost over the months 1, 2, 3 and 4: f1(0)
f1(0) = minx1 {g1(0,x1) + f2(x1 ‐ d1)}
where
g1(0,x1) = 3 + x1 + 0,5 (0 + x1 ‐ 1)
1 x1 5; i2 = x1 – 1; 0 i2 4
40
DISCRETE OPTIMIZATION 2AGI
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
2, 3 3, 3 4, 3
2, 4 3, 4 4, 4
Figure 4.2 Network representation of the production and inventory control problem
41
DISCRETE OPTIMIZATION 2AGI
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 stock 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)
Define ft(it) to be the minimum expected net cost incurred during periods t, t+1, …, 3 when
the inventory at the beginning of period t is it units. Then,
42
DISCRETE OPTIMIZATION 2AGI
Where feasible xt means xt{0,2,3,4} and 2 ≤ xt + it and xt + it ‐1≤ 3 which means that (2‐
it) ≤ xt ≤ (4‐ it)
Generalizing this reasoning yields the following important observation concerning the
formulation of SDP : suppose the possible states during period t+1 are s1, s2, …sn and the
probability that the period t+1 state will be sk is pk. Then the minimum expected cost incurred
during periods t+1, t+2, …, T is
k=1,n pkft+1(sk)
where ft+1(sk) is the minimum expected cost incurred from period t+1 to the end of the
horizon, given that the state during period t+1 is sk.
We define xt(it) to be a period t production level attaining the min for the expression of ft(it).
We now work backwards until f1(1) is determined. Since each period's ending inventory
must be non-negative and cannot exceed 3 units, the state during each period t must be
either (t,0), (t,1), (t,2) or (t,3).
43
DISCRETE OPTIMIZATION 2AGI
f3(0)=13/2 x3=2
f4(0)=0
x3(0) = 2 c(x3)=7 d3=2
d2=2
c(x2)=7 3, 4, 0
f2(0)=25/2 x3=3
x2=2 d2=1
x2(0) = 3 or 4 x3=4 c(x3)=9 d3=1
d1=2 x2=3 c(x3)=11
2,
1≤x1≤3 c(x2)=9
d2=2 f3(1)=9/2
c(x2)=11 f4(1)=‐2
d1=1 f2(1)=21/2 x2=4
x1=1 x3(1) = 1
x2(1) = 2 or 3 4,1
c(x1)=5 d2=1 3,
⋮
2,
d1=2 d2=2
x1=2 f3(1)=‐1/2
1, 1
c(x1)=7 d1=1
f2(2)=6
x2(2) = 0
⋮ x3(1) =0 d3=2 f4(2)=‐4
f1(1)=65/4
2, 4, 2
x1(1) = 3 c(x2)=0 d2=2
d2=1 3,
x1=3 d1=2 d3=1
c(x1)=9
x2=0
d1=1 d2=1
d2=2
x3=0
c(x2)=0
2,
x2=1 f4(2)=‐6
d3=2
f2(3)=7/2 d2=1
c(x2)=5 3,
4, 3
x2(3) = 0
f3(3)=‐3/2 x3=1 d3=1
x3(1) =0 c(x2)=5
For example,
7 + ½(0+0)+ ½ (1-2) = 13/2 x3(0) = 2; f3(0) = 13/2
f3(0) = min 9 + ½(1-2) + ½(2-4)= 15/2
11 + ½(2-4) + ½(3-6) = 17/2
Notice that holding cost of it units is attributed to each state demand outcome or state (t,it).
Important aspect of SDP: If a random factor (e.g., demand) influences transitions from the
period t state to the period t+1 state, the optimal action for period t cannot be determined
until period t's state is known.
44
DISCRETE OPTIMIZATION 2AGI
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 analyzer will be sold for its
salvage value.
C = maintenance cost + purchase cost – salvage value
Y1 Y2 Y3 Y4 Y5
45
DISCRETE OPTIMIZATION 2AGI
To solve this dynamic program, we start by computing f4(x4) then f3(x3) then f2(x2) then f1(x1)
and last f0(0).
For t = 1, 2, 3, 4:
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 ; 1.000 - 600 + 60 + ft+1(1): replace }
ft(3) =1.000 - 500 + 60 + ft+1(1) : replace the equipment
For t = 4 :
f4(1) = min {80 + f5(2) = -520, 1.000 - 800 + 60 + f5(1) = -540* }
f4(1) = -540 : replace the equipment
For t = 3 :
f3(1) = min {80 + f4(2) = -300*, 1.000 - 800 + 60 + f4(1) = -280 }
f3(1) = -300 : keep the equipment
46
DISCRETE OPTIMIZATION 2AGI
For t = 1 :
f1(1) = min {80 + f2(2) = 220*, 1.000 - 800 + 60 + f2(1) = 220* }
f1(1) = 220: keep or replace the equipment
We define :
State: (t) where t is a replacement year.
47
DISCRETE OPTIMIZATION 2AGI
Therefore, starting at a repalcement year t (or simply state (t)), the decision variable,
denoted by x, is the next replacement year. Hence,
ctx = the net cost of purchasing a new equipment and using it until year x.
Then, define the following recursive funcion:
g(t) = Minimal cost incurred during periods t, t+1, …, 5, including purchase cost and salvage,
given a new equipment has been purchased at period t.
Backward formulation:
g(t) = minx{ctx + g(x)} t = 0, 1, 2, 3, 4
where t+1 x t+3
x5
Boundary conditions: g(5) = 0
Objective : Find g(0)
ctx depends on the interval x‐t
ctx = 1.000 + m1 + … + mx‐t ‐ sx‐t
c01 = c12 = c23 = c34 = c45 = 1.000 + 60 - 800 = 260 MD
c02 = c13 = c24 = c35 = 1.000 + 60 + 80 - 600 = 540 MD
c03 = c14 = c25 = 1.000 + 60 + 80 + 120 - 500 = 760 MD
g(5) = 0
g(4) = c45 + g(5) = 260 MD
g(3) = min{c34 + g(4) ; c35 + g(5)} = min{260+260=520 ; 540+0+540} = 520
g(2) = min{c23 + g(3) ; c24 + g(4) ; c25 + g(5)} = min{780 ; 800 ; 760} = 760
g(1) = min{c12 + g(2) ; c13 + g(3) ; c14 + g(4)} = min{1020 ; 1060 ; 1020} = 1020
g(0) = min{c01 + g(1) ; c02 + g(2) ; c03 + g(3)} = min{1280 ; 1300 ; 1280} = 1280
The optimal solution consists in purchasing a new equipment at t = 0, use it until year 1 or 3,
then replace it with a new one.
If we replace it at year 1, we use it until year 2 or 4.
If we replace the equipment at year 2 or 4, we keep the newly purchased until year 5.
If we replace the equipment at year 3, we use it until year 4, then use the newly purchased
equipment until year 5.
48
DISCRETE OPTIMIZATION 2AGI
0 1 2 5 or 0 1 4 5 or 0345
The optimal cost is 1280 $.
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:
For the production problem: gt(xt, it) = ct + pt xt + ht(it + xt ‐ dt) if xt >0
= ht(it ‐ dt) if xt =0
49
DISCRETE OPTIMIZATION 2AGI
For the equipment replacement problem this cost is : ctx = 1.000 + m1 + … + mx‐t ‐ sx‐t
Aspect 3 : We have to specify how the state of stage t+1 depends on the value of t, the state
at the previous stage t and the decision take at stage t.
50
DISCRETE OPTIMIZATION 2AGI
References
[1] D. Bertsekas, 2001. Dynamic Programming and Optimal Control, Athena Scientific,
2nd Edition.
[2] E. Denardo, 1982. Dynamic Programming : Theory and Applications, Prentice Hall.
Day, Inc.
Wiley Interscience.
press.
51