Part II Dynamic Programming
Part II Dynamic Programming
IE 411:
Operations Research II
1
9/2/2021
3
Maximize p (x )
n 1
n n
subject to
3
x
n 1
n 5,
and
xn are nonnegativ e integers, n 1, 2, 3
2
9/2/2021
DP Formulation of Example 1
• Stage n: country, n = 1, 2, 3
• Decision variable xn: number of medical teams allocated to the nth
country
• State sn: number of medical teams still available for allocation to
remaining countries (n, …, 3)
• State transformation:
where s1 = 5.
• Recursive Relationship:
3
9/2/2021
DP Solution Procedure
n=3
S3 f3*(S3) X3*
DP Solution Procedure
n=2
X2 𝒇𝟐 𝒔𝟐 , 𝒙𝟐 = 𝒑𝟐 𝒙𝟐 + 𝒇𝟐 ∗ 𝒔𝟐 − 𝒙𝟐
S2 f2*(S2) X2*
0 1 2 3 4 5
4
9/2/2021
DP Solution Procedure
n=1
X1 𝒇𝟏 𝒔𝟏 , 𝒙𝟏 = 𝒑𝟏 𝒙𝟏 + 𝒇𝟏 ∗ 𝒔𝟏 − 𝒙𝟏
S1 f1*(S1) X1*
0 1 2 3 4 5
DP Solution Procedure
Optimal solution:
s1*= 1,
s2 = s1 – x1* = 5 – 1 = 4 => x2* = 3
s3 = s2 – x2* = 4 – 3 = 1 => x3* = 1
x1
5
9/2/2021
, i = 1, 2, 3.
6
9/2/2021
DP Formulation of Example 2
• Stage n: team n = 1, 2, 3
• Decision variable xn: number of additional scientists allocated to team n
• State sn: number of scientists still available for allocation to remaining teams
(n, …, 3)
• State transformation:
• Recursive Relationship:
DP Solution Procedure
n=3
S3 f3*(S3) X3*
7
9/2/2021
DP Solution Procedure
n=2
X2 𝒇𝟐 𝒔𝟐 , 𝒙𝟐 = 𝒑𝟐 𝒙𝟐 + 𝒇𝟐 ∗ 𝒔𝟐 − 𝒙𝟐
f2*(S2) X2*
S2 0 1 2
DP Solution Procedure
n=1
X1 𝒇𝟏 𝒔𝟏 , 𝒙𝟏 = 𝒑𝟏 𝒙𝟏 + 𝒇𝟏 ∗ 𝒔𝟏 − 𝒙𝟏
S1 f1*(S1) X1*
0 1 2
8
9/2/2021
DP Solution Procedure
Optimal solution:
x1*= 1,
s2 = s1 – x1* = 2 – 1 = 1 => x2* = 0
s3 = s2 – x2* = 1 – 0 = 1 => x3* = 1
9
9/2/2021
DP Formulation of Example 3
• Stage n: activity n = 1, 2
• Decision variable xn: activity level
• State vector sn: amount of resources still available for allocation to
remaining activities sn = (R1, R2, R3) with s1 = (4,12,18)
• State transformation:
stage n stage n+1
xn
sn=(R1,R2,R3) sn+1=(R1- α1nxn, R2- α2nxn, R3- α3nxn)
max[c n x n fn 1 (s n 1 )]
*
• Recursive Relationship: fn*(R1, R2, R3): =
xn
Curse of Dimensionality: the number of calculations required “blows up” with the
number of state variables.
Dynamic Programming©Dr. Ammar Y. Introduction to Operations Research 9th Edition 19
Alqahtani
DP Solution Procedure
x1*=2 =>
R1 = 4 – 2 = 2, R2 = 12, R3 = 18 – 3(2) = 12
R 12 R 12
x 2 min 2 , 3 6
*
10
9/2/2021
f n ( sn ) max f n ( sn , xn ), 0 xn sn
DP Solution:
Stage n = 2
f 2 (s 2 , x 2 ) g 2 ( x 2 ) x 2 f 2 (s 2 ) max x 2 s 2 ; x 2 s 2
0 x2 s2
Stage n = 1
f1 (s1 , x1 ) g1 ( x1 ) f 2 (s1 x1 ) 2x1 x12 f2 (3 x1 )
f1 (3) max 2 x1 x12 3 x1
max x1 x12 3
0 x1 3 0 x1 3
f1 (3, x1 )
1 2 x1 0 x1 1
x1 2
f1 (3, x1 )
2
yields a maximum (since 2 0 )
x12
x1 1
2 x2 2
5 with z f1 (3) 3 1
4
11
9/2/2021
Knapsack Problem
Suppose that a 20-Kg knapsack is to be filled with three types of items. The
weight and benefit of an item depends on type, as shown in the table below.
In order to maximize total benefit, how should the knapsack be filled if at
least one item from each type should be included. Formulate and solve by
Dynamic Programming.
Type (n) Weight (wn) Benefit (cn)
1 4 10
2 3 7
3 5 12
Integer Programming Formulation of the Knapsack Problem.
• Recursive Relationship:
fn(sn,xn) = c n x n + fn+1*(sn+1)
fn*(sn): = max fn (s n , x n )
xn
12
9/2/2021
DP Solution Procedure
n=3
S3 f3*(S3) X3*
DP Solution Procedure
n=2
X2 𝒇𝟐 𝒔𝟐 , 𝒙𝟐 = 𝒑𝟐 𝒙𝟐 + 𝒇𝟐 ∗ 𝒔𝟐 − 𝒙𝟐
f2*(S2) X2*
S2 1 2 3
13
9/2/2021
DP Solution Procedure
n=1
X1 𝒇𝟏 𝒔𝟏 , 𝒙𝟏 = 𝒑𝟏 𝒙𝟏 + 𝒇𝟏 ∗ 𝒔𝟏 − 𝒙𝟏
S1 f1*(S1) X1*
1 2 3
Capacity Expansion
A state expects the following annual growth in electricity demand during the next ten
years.
Year (n) 1 2 3 4 5 6 7 8 9 10
Growth in MWs (dn) 2 3 1 5 2 3 5 3 2 1
To meet the demand, capacity must be constructed. The cost of capacity as a function
of size is shown in the table below.
14
9/2/2021
• Recursive Relationship:
fn(sn,xn) = c n ( x n ) + [fn+1*(sn+1)]/(1+i)
fn*(sn): = min fn (s n , x n )
xn 0,1,...,5
Machine Replacement
Plan the replacement policy for a machine which must perform some function for the
next 10 years. The machine is currently 3 years old. To purchase a new machine
requires an investment of $40K. A machine can be used for at most five years. The
operating cost and trade-in value depend on the age of machine as in the table below:
Age (k) 1 2 3 4 5
Operating Cost, in $1000s, op(k) 13[1] 14 16 19 22
Trade-in Value, in $1000s, tr(k) 30[2] 25 20 18 16
The salvage value at the end of the ten years period is the same as the trade-in value.
The discount rate for time value of money calculations is i=.10. Find the machine
replacement policy that minimizes the present value of investment plus operating
cost less trade-in and salvage values.
Hint: The stage is the current year and the state is the age of the machine. The
decision variable xn takes the value 1 if machine is replaced at the beginning of year
n and 0 if it is not.
[1] Operating cost during the first year of operation
[2] Trade-in value after exactly one year of operation (age = 1).
15
9/2/2021
fn(sn, xn) : minimum present value of the total cost for the remaining years n, n+1, …,
10, given that at the beginning of year n the existing machine is sn years old and the
replacement decision is xn
op(s10 1) t r (s10 1) / 1.1, for x10 0
f10(s10, x10)
13 40 t r (s10 ) t r (1) / 1.1, for x10 1
Dynamic Programming©Dr. Ammar Y. Introduction to Operations Research 9th Edition 31
Alqahtani
16