You are on page 1of 51

National

Engineering School of Tunis

Discrete
Optimization
Course notes for 2AGI class: Industrial Engineering

Atidel B. Hadj‐Alouane     
09/09/2019 
DISCRETE OPTIMIZATION 2AGI

TABLE OF CONTENTS

Chapter 1 Introduction to Integer Programming ..................................................................... 3

1.1 Introduction ........................................................................................................................................................ 3

1.2 Basic concepts and definitions .................................................................................................................... 4

1.3 Example ................................................................................................................................................................. 6

1.4 Concept of unimodularity .............................................................................................................................. 7

Chapter 2 Integer programming Formulations ...................................................................... 12

2.1 The capital budgeting problem ............................................................................................................... 12

2.2 Fixed‐Charge Problems ............................................................................................................................... 15

2.3 The set covering problem ........................................................................................................................... 17

2.4 Other types of formulations ....................................................................................................................... 19

Chapter 3 The Branch‐and‐Bound Approach .......................................................................... 21

3.1 Introduction ..................................................................................................................................................... 21

3.2 The concepts of branching and bounding ........................................................................................... 21

3.3 Branch‐and‐Bound based on linear programming ......................................................................... 23

3.4 Branch‐and‐Bound for scheduling ......................................................................................................... 28

Chapter 4 Dynamic Programming ............................................................................................... 32

4.1 Introduction ..................................................................................................................................................... 32

4.2 Dynamic Programming formulations ................................................................................................... 33

4.3 Characteristics of dynamic programming applications ............................................................... 34

4.4 Production and inventory control .......................................................................................................... 35

4.5 Probabilistic Inventory model .................................................................................................................. 42

4.6 Equipment replacement .............................................................................................................................. 45

4.7 Summary of general aspects of dynamic programming ............................................................... 49 

2
DISCRETE OPTIMIZATION 2AGI

Chapter 1 Introduction to Integer Programming

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).

Applications of IP : Industrial and operations planning, Economics, Finance, …


 Assignment and scheduling

 Production planning

 Facility location

 Transportation and distribution

 Project selection

 Portfolio optimization, …

3
DISCRETE OPTIMIZATION 2AGI

1.2 Basic concepts and definitions


Definitions:
A linear program where all decision variables have to be integers is called a Pure Integer
Program or simply an Integer Program (IP).

A pure integer program can be written as follows:


Max cx
(IP) s. to Ax = b
x  0
x integral
where A is (m x n) matrix (m  n), and b  m.

Example 1.1
max z = 3 x1 + 2 x2
s.to x1 + x2  6
x1, x2  0
x1, x2 integers

 A Linear program where only some decision variables have to be integers is called a

Mixed Integer Program.


 A Linear program where all decision variables have to be binary (0 or 1) is called a

Binary Integer Program or 0‐1 Integer Program:


Max cx
(BIP) s. to Ax = b
xj  {0,1} for all j

The Linear relaxation of an integer program (mixed or binary) consists of relaxing the
integrality constraints in order to obtain a linear (continuous) program.

The linear relaxation of (IP) gives the following linear program ( IP ):


Max cx

( 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.

integrality constraints). As a consequence, the feasible domain of IP is contained in


the feasible domain of IP :
D(IP)  D( IP ),

where D(IP) and D( IP ,) are the feasible domains of IP and IP , respectively.

 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.

At this point, two major questions are raised:


Q1: Can we use linear programming algorithms (Simplex or Interior Point methods) to solve
integer programs? When can we say that an optimal solution to IP is also optimal to IP?
Q2: If linear programming algorithms give non-integral solutions, how can we solve integer
programs?
The application of linear programming algorithms may sometimes give an integral solution,
which, in this case, would also be optimal to the integer program. In this case, there is no
duality gap (see the inequality (1.1)). Unfortunately, this is rarely the case as linear
programming solutions are usually fractional.
Rounding off fractional solutions to the nearest integer might work for some cases. However,
for most problems, it can result in solutions that are far from the optimum or even infeasible.
Consider the problem where an automobile manufacturer who needs to determine the
number of cars to produce in a given year. If the solution of the corresponding linear program
is such that 150,000.4 cars are to be produced, we can safely round off to 150,000.

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

x2 Optimal integral Solution


(0, 3) with z* = 33
3,0

2,5

2,0
7 x1 + 4 x2 = 13
1,5
Feasible Domain of

1,0

Optimal continuous solution


0,5
(13/7, 0) with z* = 39

0,5 1,0 1,5 2,0 x1

Figure 1.1 Geometric representation of an integer/linear program

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).

3. If the feasible domain of an IP is bounded, then it contains a finite number of feasible


solutions. In theory, such an IP could be solved by enumerating all points and
choosing the best. However, in practice, most integer programs have an extremely
large number of feasible solutions. Therefore, enumerating all possible solutions may
require a very large computing time.

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.

1.4 Concept of unimodularity


Consider the following linear program in the standard form:
Max cx
s. to Ax = b
x  0
Assume rank(A) = m. An extreme point of the polyhedral representing the feasible domain
of the linear program can be found by rewriting Ax = b in terms of a basis B:
B xB + N xN = b,

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

0,5 1,0 1,5 2,0 2,5 3,0 x1


Figure 1.2 Extreme points for Example 1.2

Example 1.3
Max z = 4 x1 + 6 x2
S. to x1 + 2 x2  b
x1, x2  0
x1, x2 integer

If b = 3, the optimal solution of the relaxed problem is (0 ; 3/2).


If b = 2, all extreme points of the relaxed problem are integral even though the matrix
A = (1 2) is not totally unimodular.

x2
2,0
x 1 + 2 x2 = b
1,5
b =1
1,0 b =2
b =3
0,5

0,5 1,0 1,5 2,0 2,5 3,0 x1

Figure 1.3 Extreme points for Example 1.3

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

Theorem 1.2: (Hoffman‐Gale)


An integral matrix A which elements are 0 or 1 is totally unimodular if:
 No more than two nonzero elements appear in each column.
 The rows can be partitioned into 2 sets, R1, R2, such that:
- If a column contains two nonzero elements of the same sign, they are in the
opposite sets.
- If a column has two elements of different sign, they are in the same set.

Proof: As exercise (by induction)


Example 1.4 The transportation problem
In the classical transportation problem, there are p (i = 1, …, p) supply sites and q (j = 1, …, q)
demand sites. A product is shipped from the supply sites to the demand sites. The shipment
of a unit from the supply site i to demand site j costs cij. The problem is to determine the
quantities to ship from each supply site to every demand site such as total shipment cost is
minimized while satisfying the following two constraint types:
- Supply capacity: the quantity shipped out of a supply site i cannot exceed its capacity,
ai units.
- Demand satisfaction: The quantity shipped to a demand site j has to cover its demand
of bj units.
Let xij be the number of units shipped from i to j; i = 1, …, p and j = 1, …, q. The problem is then
formulated as follows:
p q
min z =  c ij x ij
i 1 j 1

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:

Basis x11 x12 x13 x21 x22 x23 Solution


Z c11 c12 c13 c21 c22 c23 0
1 1 1 0 0 0 a1
Supply sites (R1)
0 0 0 1 1 1 a2
1 0 0 1 0 0 b1
Demand sites (R2)
Redundant 0 1 0 0 1 0 b2
0 0 1 0 0 1 b3

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

Chapter 2 Integer Programming Formulations

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.

2.1 The capital budgeting problem


Consider an investment selection problem where 4 possible projects can be selected. Each
project requires an initial cash outflow and yields a certain net present value (NPV), given
in Table 2.1 below:

Table 2.1 Data for an example of a capital budgeting problem

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 :

Define a binary variable for each project:


xi (i = 1, 2, 3, 4) = 1 if project i is selected
= 0 otherwise.

12
DISCRETE OPTIMIZATION 2AGI

2. Objective function:

The objective is to maximize the total yield:


z (x) = 16000 x1 + 22000 x2 + 12000 x3 + 8000 x4
For example, if x1 = 1, the objective function will include the yield of related to project 1 ($16
000), otherwise (x1 = 0), project 1 will not contribute in the total yield. Therefore, for any
decision, the objective function will include only the yields related to selected projects.

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:

(BIP1) Max z(x) = 16000 x1 + 22000 x2 + 12000 x3 + 8000 x4


S. to 5 x1 + 7 x2 + 4 x3 + 3 x4  14
xi = 0 or 1 (i = 1, 2, 3, 4)
Solving BIP1 (for example by complete enumeration) gives the following optimal solution: x
= (x1,x2,x3,x4) = (0,1,1,1) with z* = $42 000, which implies investing in projects 2, 3 and 4,
and not in project 1.
If we compute the profitability of each project, which means the yield per dollar invested, we
find that project 1 is the most profitable (see Table 2.2 below).

Table 2.2 Profitability per project

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.

 If project 2 is selected then project 1 has to be selected.

 If project 2 is selected than project 4 cannot be selected.

The formulation (BIP.1) should be modified by adding the following constraints.

Constraint (1): Simply add x1 + x2 + x3 + x4  2

Constraint (2): Add x2  x1


This constraint implies that:
- if x2 = 1, the constraint becomes 1  x1
since x1 = 0 or 1, then x1 = 1
- if x2 = 0, the constraint becomes 0  x1 ; this allows x1 to be 0 or 1.

Constraint (3): x2 + x4 1


This constraint implies that either project 2 or project 4 can be selected, but not both. In fact,
we have:
- if x2 = 1, then 1 + x4  1 or x4  0

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.

2.2 Fixed‐Charge Problems


These problems involve a fixed cost that is associated with carrying out an activity
independently of its level. Examples facility location, machine set-up, equipment rentals, etc.
Consider the case of a clothing company that can produce 3 types of clothing: shirts, shorts
and pants. The machinery needed to manufacture each type of item must be rented at a
weekly price given on Table 2.3. The same table also shows the production costs, the sales
prices, the required labor and raw material (cloth) per unit.

Table 2.3 Data for the fixed charge example

Rental Production Sales Labor/unit Cloth


price/week ($) cost/unit ($) price/unit ($) (hours) (dm2)

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

y1 =1 if x1> 0 (if shirts are produced),


=0 otherwise,
y2 =1 if x2> 0 (if shorts are produced),
=0 otherwise,
y3 =1 if x3> 0 (if pants are produced),
=0 otherwise.
2. Objective function:
The company is interested in maximizing the weekly profit, which can be written as follows:
(Weekly profit) = (weekly sales revenue) – (weekly variable costs)
- (weekly machine rental costs: fixed costs)

(Weekly sales revenue) = 12 x1 + 8 x2 + 15 x3


(Weekly variable costs) = 6 x 1 + 4 x 2 + 8 x3
(Weekly machine rental costs) = 200 y1 + 150 y2 + 100 y3
 Maximize z = 6 x1 + 4 x2 + 7 x3 - 200 y1 - 150 y2 - 100 y3

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:

(IP.2) Max z = 6 x1 + 4 x2 + 7 x3 - 200 y1 - 150 y2 - 100 y3


S.to 3 x1 + 2 x2 + 6 x3  150
4 x1 + 3 x2 + 4 x3  160
x1, x2, x3  0 ; x1, x2, x3 integers
y1, y2, y3 = 0 or 1.

An optimal solution of the above integer program is : x1 = 30, x3 = 10, x2 = y1 = y2 = y3 = 0.


However, this solution is practically wrong since the company cannot produce shirts or

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.

With the above constraints,


- if xi > 0 then 0< M yi . Since yi = 0 or 1 then we must have yi = 1.
This constraint becomes xi  M, which does not restrict the value of xi.
- if xi = 0 then 0  M yi. This allows yi to be either 0 or 1, without any restriction. Since yi
= 0 costs less than yi = 1, the optimal solution would be such that yi = 0 if xi = 0.
What is an appropriate value for M ?
M has to be fixed at a value larger than or equal to the maximum value any xi could take. In
the clothing example, we know from the capacity constraints that:
160  160  160 
x1    ; x2    and x 3  
 4   3   4 
We can safely set M=53 (or larger).

2.3 The set covering problem


This problem belongs to an important class in integer programming, or combinatorial
optimization. Set covering involves a given set (Set 1) that has to be covered by elements of
another set (Set 2). The objective is to cover the set 1 by a minimum number of elements
from Set 2. The set covering problem arises in many applications such as crew scheduling,
and public facility planning.

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

From / To City 1 City 2 City 3 City 4 City 5 City 6


City 1 0 10 20 30 30 20
City 2 10 0 25 35 20 10
City 3 20 25 0 15 30 20
City 4 30 35 15 0 15 25
City 5 30 20 30 15 0 14
City 6 20 10 20 25 14 0

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.

Table 2.5 Cities within 15 minutes of driving time

City 1 City 2 City 3 City 4 City 5 City 6


1; 2 1; 2; 6 3; 4 3; 4; 5 4; 5; 6 2; 5; 6

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

2.4 Other types of formulations

2.4.1 "Either‐Or" constraints (at least)

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

f(x1, x2, …., xn)  M y ( 2.1)

g(x1, x2, …., xn)  M (1 – y) ( 2.2)

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

constraint on f(x) has to be verified but there is no restriction on g(x).


 For y = 1, the constraints become: f(x)  M and g(x)  0. Therefore, the constraint on

g(x) has to be verified but there is no restriction on f(x).

2.4.2 "If‐Then" constraints

In many applications, the following situation arises: We need to ensure that:


If the constraint f(x1, x2, …., xn) > 0 is verified then g(x1, x2, …., xn)  0 also has to be verified.
Otherwise g(x1, x2, …., xn)  0 may or may not be verified (i.e. there is no restriction on g(x)).
This type of constraints is called if‐then constraints.

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:

f(x1, x2, …., xn)  M y ( 2.3)

g(x1, x2, …., xn)  M (1 – y) ( 2.4)

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

Chapter 3 The Branch‐and‐Bound Approach

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.

3.2 The concepts of branching and bounding


Consider the following program:

max f x


 x D


Where f(x) is any real function of x   n and D   n .

3.2.1 Branching procedure

It consists of breaking up the feasible domain, D, into sections  subproblems (See


Figure 1.1).

D1 D2

D3 D4

Figure 3.1 Breakdown of the feasible domain D into four sections

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.2 Further breakdown of section 2 into three subsections

Now f* = max{f1*, f21*, f22*, f23*, f3*, f4*}

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

Figure 3.3 Search tree corresponding to the branching process

22
DISCRETE OPTIMIZATION 2AGI

3.2.2 Bounding procedure

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".

The combination of the breakup and bound computation is called branch-and-bound


(“Séparation et Evaluation Successive”).

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").

3.3 Branch‐and‐Bound based on linear programming

3.3.1 Basic Definitions:

Consider the following integer program:

max c x
(P) s.to A x  b
x0, x integral
A : mxn matrix.
 A branch-and-bound tree is a directed graph with nodes corresponding to

subproblems of a "father" problem. An arc exists from a father problem to its


immediate offspring.
 An incumbent is the best (integral) solution found so far.

23
DISCRETE OPTIMIZATION 2AGI

 A node that is proven to have no optimal solution with a better objective value than

the incumbent is considered completely explored. The node is then fathomed.


 If we solve a subproblem and find an integer solution better than the incumbent, the

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”.

3.3.2 Branch‐and‐bound algorithms for integer programs

Consider again:
max c x
(P) s.t. A x  b
x0, x integral

Bounding: LP relaxation (Simplex)


Branching: Suppose we solved the LP relaxation and we got x1 = 4.33. We could create two
subproblems to push for the integrality of x1:

(Sub2)
(Sub1)
max c x
max c x
s.t. A x  b
s.t. A x  b
x1  5
x1  4
x0, x integral
x0, 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

to get two new subproblems (or node of the tree).


Bounding:
- For each new node: if the optimal value to the linear program, 𝑧̅, is  z*, or the LP is
infeasible, fathom the node.
- For each new node, if the Linear relaxation has an integral solution, and value > z*,
record it as the new incumbent, update z*, and fathom it. Then, fathom any
unfathomed node that has un upper bound  new value of z*.
Otherwise, record the upper bound of the node (𝑧̅) and mark the node as unfathomed.
Go to step 3.
Step 3:
- If all nodes are fathomed, stop. If an incumbent exists, it is optimal; otherwise P is
infeasible.
- If there are unfathomed nodes, go to step 4.
Step 4:
Choose the unfathomed node with the largest upper bound and let i be the index of the
corresponding subproblem. Go to step 2.

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

z* = 14 for x = (2 ; 2) z = 15 for x = (3 ; 1,5)


x2  1 x2  2

z = 14,5 for x = (3,5 ; 1) infeasible


x1  3 x1  4

z = 13 for x = (3 ; 1) z = 14 for x = (4 ; 0,5)

Figure 3.4 B&B tree for Example 3.1



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)

Figure 3.5 B&B tree for Example 3.2

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.

3.3.4 B&B for mixed integer programs

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

3.4 Branch‐and‐Bound for scheduling


Here, we will look at a specific scheduling problem: the single machine tardiness problem.
Consider an example of 4 tasks to be processed on one machine. The processing time and the
due date for each task are shown on Table 3.1 below. The tardiness of a task is defined as
the difference between the actual completion time and the due date, if the task is completed

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.

Table 3.1: Processing times and due dates of jobs


Processing times (days) Due dates
Task 1 6 End of day 8
Task 2 4 End of day 4
Task 3 5 End of day 12
Task 4 8 End of day 16

We may formulate this problem as an integer program, by defining the following variables:

xij = 1 if task i is the jth to be processed,


= 0 otherwise.

Exercise: Continue the formulation of the above problem.

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

Branch 10 Branch 11 Branch 12 Branch 5 Branch 6 Branch 7


LB = 21 LB = 25 LB = 13 LB = 14 LB = 18 LB = 10

x12 = 1
x22 = 1

Branch 8 Branch 9
T = 12 T = 16

Figure 3.6: B&B search tree for scheduling

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

Chapter 4 Dynamic Programming

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.

4.2 Dynamic Programming formulations

4.2.1 General form of a dynamic program

A dynamic program can be written as:


T
Max/Minx1, x2,… xT 
t
gt
1
st , xt

(DP) st = t (st+1, xt+1) t = 1, …, T


ST+1 is given
t : period.
xt : decision variables relative to period t,
st : state variable describing the system at period t
t : a recursive function that transforms the state of the system from st to st+1 if decision xt is
made.

xT
x1 x2

g1(s1, x1) g2(s2, x2) gT (sT, xT)

s1 s2 … sT sT+1

Figure 4.1 Graphical representation of a dynamic program

33
DISCRETE OPTIMIZATION 2AGI

In general, a problem is decomposed into smaller subproblems. For example, a problem


having T variables can be decomposed into T subproblems of only one variable.

4.2.2 Backward formulation

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.

4.3 Characteristics of dynamic programming applications


Dynamic programming applications have certain common characteristics such as:

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.

5. If a problem is formulated using the concept of stages, there must be a recursive


equation that determines the cost or the profit of a state at any stage t, t+1, …, T as a
function of the cost of the profit of states belonging to stages t+1, 2, …, , T

ft (j) = Mini {ft+1 (i) + cij} where j belongs to stage t
fT+1(iT+1) = 0 (for example) boundary conditions
Objective : find f1(i1), where i1 is known

4.4 Production and inventory control


A company must decide how much to produce of a given product in order to satisfy
customers' demand over a horizon of T periods. The demand at a period t can be satisfied
either from production during the current period or from inventory that is available at the
beginning of the current period.
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, 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.

State variables (t,it)


t: stage index
it = inventory available at the beginning of period t.
Define ft(it) (also denoted by f(t,it)) as the minimum cost production and inventory plan for
periods t,…, T if the initial inventory at period t is it.

The recursive equation of the backward formulation is:


ft(it)= minfeasible xt {gt(it, xt) + ft+1(it +xt ‐ dt)}
it+1
where gt(it, xt) = ct + pt xt + ht(it +xt ‐ dt) if xt > 0
ht(it ‐ dt) If xt = 0
and it  [0, dt + dt+1 + … + dT]

Total demand left to satisfy

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.

We suppose that there is no unit at hand at the beginning of period 1.


To formulate the problem of finding the minimum cost production and inventory plan, one
has to define the states and if possible the stages of the problem. The stages have to be
defined such that, if just one stage is left, the problem becomes easy to solve. In this case, if
we are at the beginning of the 4th month, the company can satisfy the demand, d4, at a
minimal cost by producing just the necessary quantity based on the stock level at the
beginning of the month and the known demand.
 We can define the stage as the month since the problem corresponding to only one month
is easy to solve.

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

i1 x1 i2 g1 f2(x1‐1) Total cost f1(0) and x1(0)


0 1 0 0+4=4 16 20*
0 2 1 0,5 + 5 = 5,5 15 20,5 f1(0) = 20
0 3 2 1+6=7 14 21 x1(0) = 1
0 4 3 1,5 + 7 = 8,5 12 20,5
0 5 4 2 + 8 = 10 10,5 20,5
The cost of the optimal production and inventory plan 20$.
Optimal production plan:
Month t 1 2 3 4
Production xt 1 5 0 4
Exercise
This problem can be addressed as a shortest route problem in a network, which consists of
finding the shortest route from node (1, 0) to node (5, 0) represented in Figure 5.3.

Month Inventory level at the end of the horizon

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)

4.5 Probabilistic Inventory model


Here we modify the previous inventory model to allow for uncertain demand. This will
illustrate the difficulties involved in solving Stochastic (or probabilistic) Dynamic
Programming (SDP) for which the state during the next stage is uncertain, given the current
state and current decision.

Consider the following 3-period inventory problem.


- Production cost c(0) and c (x) = 3+2x for x>0,
- Unit holding cost h = 1$/unit left at the end of the period,
- Production capacity : ProdCap = 4 units/month,
- Storage capacity : StorCap = 3 units at the end of the month,
- Demand : each period's demand is equally likely to be 1 or 2 units.

Demand has to be met on time and any inventory on hand at the end of period 3 can be sold
at 2$ per unit. Initial inventory = 1 unit.

Question : Use SDP to determine a production policy that minimizes the expected net cost
incurred during the 3 periods.

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,

f3(i3) = minx3 {c(x3) + ½ (i3 + x3 ‐ 1)+ ½( i3 + x3 – 2) – (½)2(i3 + x3 ‐ 1)‐ (½)2( i3 + x3 – 2)}


where x3{0,2,3,4} and
i3 + x3 ≥ 2 and i3 + x3 – 1 ≤ 4  (2‐ i3) ≤ x3 ≤ (4‐ i3)
For t=1,2

42
DISCRETE OPTIMIZATION 2AGI

(t+1, it+ xt-1)


dt = 1 ft+1(it+ xt‐1)
Prob = 1/2
Cost=( it+ xt‐1)
Decision xt
(3, i3)
Cost= c(xt)
Cost= ( it+ xt‐2)
dt = 2
ft+1( it+ xt‐2)
Prob = 1/2 (t+1, it+ xt-2)


Therefore, ft(it ) = minfeasible xt{ c(xt) + ½ (it + xt ‐ 1)+ ½ ft+1(it + xt‐1)
+ ½( it + xt – 2)+½ ft+1(it + xt‐2)}

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).

Solution: We begin by producing x1(1) = 3 units during period 1. We cannot, however,


determine period 2's production level until period 1's demand is observed. Also, period 3's
production level cannot be determined until period 2's demand is observed. Look at the case
where d1 = d2 = 2 (solution: x1(1) = 3; x2(2) = 0; x3(0) =2).

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

4.6 Equipment replacement


The problem is to determine when an equipment or a machine should be replaced over a
given horizon.
Example 4.3
An auto repair shop uses an engine analyzer. The purchase cost of a new analyzer is 1000 $.
The maintenance cost depends on the age of the analyzer. We denote by mi the maintenance
cost of the analyzer at it ith year of utilization.
The analyzer 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

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

t=0 t=1 t=2 t=3 t=4 t=5


After the purchase of a new analyzer, the manager has to know when to replace it with a new
one.

4.6.1 A dynamic programming formulation with stages

Stage: t : the time of year t.


State variable: xt : age of the equipment at year t.
Decision variable: replace or keep the equipment.
Recursive function:
ft(xt) : minimal cost incurred for years t, t+1, …, 5, starting year t with an equipment that has
been used for xt years.
For t = 1, 2, 3, 4, we compute ft(1), ft(2) and ft(3)

45
DISCRETE OPTIMIZATION 2AGI

ft(xt) = min {mx+1 + ft+1(xt+1) ; 1.000 - sx + m1 + ft+1(xt+1)} for xt = 1 or 2


xt + 1 1
ft(3) = 1.000 – s3 + m1 + ft+1(1)

Equation linking the state variables and the decision variables:


If the decision is to replace the equipment: xt+1 = 1
If the decision is to keep the equipment: xt+1 = xt + 1

Boundary conditions: f5(1) = - 800 ; f5(2) = -600 ; f5(3) = -500


Objective: Find f0(0) = 1.000 + 60 + f1(1) (at the begining oft he horizon, we have to buy
an analyser and keep it for at least one year)

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

f4(2) = min {120 + f5(3) = -380*, 1.000 - 600 + 60 + f5(1) = -340 }


 f4(2) = -380 : keep the equipment

f4(3) =1.000 - 500 + 60 + f5(1) = -240 : 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

f3(2) = min {120 + f4(3) = -120*, 1.000 - 600 + 60 + f4(1) = -80 }


 f3(2) = -120 : keep the equipment

f3(3) =1.000 - 500 + 60 + f4(1) = 20 : replace the equipment


For t = 2 :
f2(1) = min {80 + f3(2) = -40*, 1.000 - 800 + 60 + f3(1) = -40* }
 f2(1) = -40: keep or replace the equipment

f2(2) = min {120 + f3(3) = 140*, 1.000 - 600 + 60 + f3(1) = 160 }


 f2(2) = 140: keep the equipment

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

Therefore, f0(0) = 1000 + 60 + f1(1) = 1280.

The optimal solutions can be represented as follows:


1 2 3 4 5

keep the equipment replace the equipment


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 de x‐t.

4.6.2 A dynamic programming formulation without stages

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
x5
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 0345
The optimal cost is 1280 $.

Exercise: network representation of the problem.

4.7 Summary of general aspects of dynamic programming


In general, in dynamic programming, a stage is composed of all states possible of the system
being in that stage.
Typically, a backward formulation is such that:
ft(i) = minimal cost from stage t until the last stage (T), given that at stage t, the system
is state i.
And, for a forward formulation:
ft(i) = minimal cost from stage 1 until the last stage t, given that at stage t, the system
is state i.

We can identify 3 different aspects of dynamic programming:



Aspect 1 : the set of possible decisions for a given state and a stage:
For the production problem:
If it-1 is the inventory level at the beginning of month t, the set of possible decisions at
stage t is xt such that :
0  xt  5 and 0  it‐1 + xt ‐ dt  4  ‐ it‐1 + dt  xt  4 ‐ it‐1 + dt

For the equipment replacement problem:


If xt is the age of the equipment at stage t, the set of possible decisions at this stage is:
Replace or keep the equipment if 1  xt < 3
Replace the equipment if xt = 3

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.

For the production problem: it+1 = it + xt ‐ dt


For the equipment replacement problem:
If the decision is to replace the equipment: xt+1 = 1
If the decision is to keep the equipment: xt+1 = xt + 1
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).

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.

[3] F. S. Hillier and G. J. Lieberman, 2001. Introduction to Operations Research. Holden-

Day, Inc.

[4] G. L. Nemhauser and L. A. Wolsey, 1988. Integer and Combinatorial Optimization.

Wiley Interscience.

[5] W. L. Winston, 1994. Operations Research : Applications and Algorithms, Duxbury

press.

51

You might also like