HW2Solutions PDF
HW2Solutions PDF
Fall 2015
Homework 2 - Solutions
August 28, 2015
Review
cv : buying price per item
cp : selling price
cs : salvage price for leftover item
E[# of sold item ] = E[y D]
E[# of unsold item] =E[y D]+
E[# of lost sale] =E[D y]+
v
For a continuous random demand, the optimal order quantity y that solves F (y ) = ccppc
.
cs
For a discrete random demand, the optimal order quantity y is the smallest y that satisfies
v
.
F (y) ccppc
cs
P (D, y) = cp (y D) + cs (y D)+ cv y (profit)
E[P (D, y)] = cp E(y D) + cs E(y D)+ cv y (expected profit)
1. David buys fruits and vegetables wholesale and retails them at Davids Produce on La
Vista Road. One of the difficult decisions is the amount of bananas to buy. Let us
make some simplifying assumptions, and assume that David purchases bananas once a
week at 25 cents per pound and retails them at 60 cents per pound during the week.
Bananas that are more than a week old are too ripe to sell and David will pay workers
to take them away. It costs 4 cent to get rid of each pound of unsold bananas. Suppose
that the weekly demand for bananas is uniformly distributed between 1000 and 2000
pounds.
(a) Assume David orders 1500 pound of bananas each week, calculate the expected
number of sold bananas, expected number of unsold bananas, expected number of lost
sale, and the expected weekly profit.
Solution:
cp = 60, cv = 25, cs = 4.
The expected number of sold bananas: E[1500 D]
Z
E[1500 D] = E[min(1500, D)] =
min(1500, x)f (x)dx
Z 2000
1
=
min(1500, x)
dx
1000
1000
Z 1500
Z 2000
1
1
=
min(1500, x)
dx +
min(1500, x)
dx
1000
1000
1000
1500
Z 1500
Z 2000
1
1
=
x
dx +
1500
dx
1000
1000
1000
1500
x2 1500 1500 500
=
+
2000 1000
1000
= 1375
(1)
Z 2000
1
max(1500 x, 0)
=
dx
1000
1000
Z 1500
Z 2000
1
1
=
max(1500 x, 0)
dx +
max(1500 x, 0)
dx
1000
1000
1000
1500
Z 1500
Z 2000
1
1
(1500 x)
0
=
dx +
dx
1000
1000
1000
1500
x2 1500
1500
500
=
1000
2000 1000
= 125
(2)
The expected number of lost sale: E[(D 1500)+ ]
Z
+
max(x 1500, 0)f (x)dx
E[(D 1500) ] = E[max(D 1500), 0] =
Z 2000
1
max(x 1500, 0)
dx
=
1000
1000
Z 1500
Z 2000
1
1
max(x 1500, 0)
=
max(x 1500, 0)
dx +
dx
1000
1000
1000
1500
Z 1500
Z 2000
1
1
0
(x 1500)
=
dx +
dx
1000
1000
1000
1500
x2 2000 1500
=
500
2000 1500 1000
= 125
(3)
The expected weekly profit: E[P (1500, D)]
E[P (D, 1500)] = cp E(y D) + cs E(y D)+ cv y
= 60 1375 4 125 25 1500 (by (1) and (2))
= 44500
(b) (R Simulation) Read your textbook Section 1.4 Simulation. Let n be the number
of random demands you will generate. Test the policy where David orders 1500 pound
of bananas each week for n = 10, 100, 1000, 100000. Write down your code, compare
your result with question (a), and explain your findings.
R code to test the policy:
# Setup up parameters
Cp = 60; Cv = 25; Cs = -4;
# How many random demands will be generated?
2
n = 10000;
# Generate n random demands from the discrete demand distribution
Dmd=runif(n,min=1000,max=2000)
# Test the policy where David orders 1500 pounds of bananas each week;
y <- 1500;
# The average number of sold bananas:
mean(pmin(Dmd,y));
# The average number of unsold bananas:
mean(pmax(y-Dmd,0));
# The average number of lost sale:
mean(pmax(Dmd-y,0));
# The average weekly profit:
mean(Cp*pmin(Dmd1,y)+Cs*pmax(y-Dmd1,0)- y*Cv);
The results of the simulation for n=10, 100, 1000, 100000 are listed in the following
table, where Di is the ith simulated value of D.
Test
Pn 1500Di
n
Pn i=1(1500D
+
i)
i=1
n
Pn (Di 1500)+
i=1
Weekly Profit
n=10
1339.354
160.6456
70.66225
42218.68
n=100
1389.346
110.6538
146.1864
45418.15
n=1000
1371.795
128.2051
126.2385
44294.87
n=100000
1375.956
124.0437
126.2112
44561.2
Since D unif (1000, 2000), F (y ) = 20001000 . The following formula gives optimal
order quantity y = 1546.88 1547.
y 1000
60 25
=
2000 1000
60 + 4
(d) What is the optimal expected weekly profit?
If order quantity is 1547, then
E[P (D, 1547)] = cp E(y D) + cs E(y D)+ cv y
= 60 1397.3955 4 149.6045 25 1547 (by (5) and (6))
= 44570.312
3
(4)
[Expectation evaluations]
E[1547 D] = E[min(1547, D)]
Z
min(1547, x)f (x)dx
=
Z 2000
1
min(1547, x)
=
dx
1000
1000
Z 2000
Z 1547
1
1
min(1547, x)
dx +
min(1547, x)
dx
=
1000
1000
1000
1547
Z 1547
Z 2000
1
1
x
1547
=
dx +
dx
1000
1000
1000
1547
x2 1547 1547
=
(2000 1547)
+
2000 1000 1000
= 1397.3955
(5)
Z 2000
1
=
max(1547 x, 0)
dx
1000
1000
Z 1547
Z 2000
1
1
=
max(1547 x, 0)
dx +
max(1547 x, 0)
dx
1000
1000
1000
1547
Z 2000
Z 1547
1
1
0
=
(1547 x)
dx +
dx
1000
1000
1547
1000
x2 1547
1547
=
(1547 1000)
1000
2000 1000
= 149.6045
(6)
E[(D 1547)+ ] = E[max(D 1547), 0] (we dont use this quantity, just for illustration purpose)
Z
=
max(x 1547, 0)f (x)dx
Z 2000
1
=
max(x 1547, 0)
dx
1000
1000
Z 1547
Z 2000
1
1
=
max(x 1547, 0)
dx +
max(x 1547, 0)
dx
1000
1000
1000
1547
Z 1547
Z 2000
1
1
=
0
dx +
(x 1547)
dx
1000
1000
1000
1547
x2 2000 1547
=
(2000 1547)
2000 1547 1000
= 102.6045
(7)
4
(e) Now assume that the demand for bananas is exponentially distributed with mean
1500. How many pound of bananas should be ordered? What is the optimal expected
weekly profit in this case?
Set up just like equation (4) as following:1
1
1 e 1500 y =
60 25
60 + 4
(8)
1187
e1/1500x 1187
= xe1/1500x
1187 e1/1500x 1187
0
1/1500
= 820.14
(9)
1187e1/1500x + xe1/1500x +
= 366.86
1187
1/1500x
e
1187
1/1500 0
(10)
Remind that an exponential random variable with parameter has cdf F (x) = Pr {(}X x) = 1 ex for
x 0, and = 0 otherwise. Another way to say Exponential r.v. with parameter is to say Exponential r.v. with
mean 1/.
1
(f) (R Simulation) Again, let n be the number of random demands you will generate.
Test the policy you obtained in (e) for n = 10, 100, 1000, 100000, where the demand for
bananas is exponentially distributed with mean 1500. Write down your code, compare
your result with question (e) and explain your findings. you may use rexp(n, rate
= 1/1500) to generate exponential random variable. The code to test the policy is
below:
# Setup up parameters
Cp = 60; Cv = 25; Cs = -4;
# How many random demands will be generated?
n = 100000;
# Generate n random demands from the discrete demand distribution
Dmd=rexp(n, rate = 1/1500)
# Test the policy where David orders 1187 pounds of bananas each week;
y<-1187;
# The average weekly profit:
mean(Cp*pmin(Dmd1,y)+Cs*pmax(y-Dmd1,0)- y*Cv);
The result of the simulation is 18110.44, which is close to what we have calculated.
In addition to the 2 observations listed in (b), we see the power of SLLN. It indeed
works for ANY type of distributions. It was uniform in (b), now it is exponential.
2. Suppose that during a football game, lemonade sells for $25 per gallon but only costs $3
per gallon to make. If they run out of lemonade during the game, it will be impossible
to get more. On the other hand, leftover lemonade has a value of $1. Assume that you
believe the fans would buy 20 gallons with probability 1/8, 25 gallons with probability
1/4, 30 gallons with probability 1/4, 35 gallons with probability 1/4, 40 gallons with
probability 1/8. You need to decide how many gallons of lemonade to have on hand at
the beginning of the game.
cv = 3, cp = 25, cs = 1.
The pmf of demand can be written as following:
d
20
25
30
35
40
P (D = d)
.125
.25
.25
.25
.125
(b) If 30 gallons are prepared, what is the expected profit from a game?
If order quantity is 30, then
E[P (D, 30)]
= cp E(y D) + cs E(y D)+ cv y
= 25 27.5 + 1 2.5 3 30 (by (12) and (13))
= 600
[Expectation evaluations]
E[max(D 30, 0)] =
40
X
x=20
40
X
max(30 x, 0)p(x)
x=20
P (D d)
.125
.375
.625
.875
1.0
Search for smallest y s.t. F (y ) 11/12, the optimal order quantity is y = 40.
(d) Now suppose that the demand was normally distributed with mean 800 gallons and
variance 100 gallons. How much lemonade should be ordered?
We need to find optimal order quantity
y such that F (y ) = P (D y ) = 0.916. Note
y 800
D800
that P (D y ) = P ( 10 10 ) = P (Y y 800
) = 0.916, where Y = D800
10
10
N (0, 1). From cdf table of standard normal distribution, we have P (Y 1.38) 0.916.
Hence, y 800
= 1.38 , we get y = 1.38 10 + 800 813.8.
10
7