1 Problem 1: Chicken Wings

Whole Foods has decided to make 35 roasted chickens for the lunch rush. The store has determined that daily demand will follow the distribution shown in the following table:

Daily Demand 15 20 25 30 35 40

Probability 0.07 0.12 0.26 0.21 0.20 0.14

Each chicken costs Whole Foods 7.50 dollar to make and can be sold for 15 dollar. It is possible for Whole Foods to sell any unsold chickens for $5 the next day.

1.1 Profit

  1. Simulate one month (30 days) of operation to calculate Whole Food’s total monthly roasted chicken profit. Replicate this calculation 20 times to compute the average total monthly profit.

The simulated one month profit is around 7537.5 dollars. (because everytime i run the program, it generates new results)

The 20 replications of monthly profit is around 7536.25 dollars.

dailydemand <- c(15,20,25,30,35,40)
prob <- c(0.07 ,0.12, 0.26, 0.21 , 0.20, 0.14)
food= data.frame(dailydemand,prob)
food$ulc <- cumsum(food[,2])
food$llc <- food$ulc-food$prob


food
##   dailydemand prob  ulc  llc
## 1          15 0.07 0.07 0.00
## 2          20 0.12 0.19 0.07
## 3          25 0.26 0.45 0.19
## 4          30 0.21 0.66 0.45
## 5          35 0.20 0.86 0.66
## 6          40 0.14 1.00 0.86
#simulate for 1 month
set.seed(888)
rand <- runif(30)
chicken = data.frame(rand)
chicken$num <- ifelse(chicken$rand < 0.07 , 15,
                   ifelse(chicken$rand <0.19 & chicken$rand >=0.07, 20, ifelse(chicken$rand <0.45 & chicken$rand >=0.19, 25, ifelse(chicken$rand <0.66 & chicken$rand >=0.45, 30, ifelse(chicken$rand <0.86 & chicken$rand >=0.66,35, 40)))))

chicken$left <- ifelse(35-chicken$num> 0, 35-chicken$num,0)

chicken$profit <- chicken$num*(15-7.5)+ chicken$left*5
sum(chicken$profit)
## [1] 7537.5
# simulate monthly profit 20 times
set.seed(8)
randm <- runif(600)
chickenm = data.frame(randm)

chickenm$num <- ifelse(chickenm$randm < 0.07 , 15,
                  ifelse(chickenm$randm <0.19 & chicken$rand >=0.07, 20, ifelse(chickenm$randm <0.45 & chickenm$randm >=0.19, 25, ifelse(chickenm$randm <0.66 & chickenm$randm >=0.45, 30, ifelse(chickenm$randm <0.86 & chickenm$randm >=0.66,35, 40)))))

chickenm$left <- ifelse(35-chickenm$num> 0, 35-chickenm$num,0)

chickenm$n <-as.numeric(row.names(chickenm))
chickenm$sort <- ceiling(chickenm$n/30)
chickenm$profit<- chickenm$num*7.5 +chickenm$left*5

chickenm2 <- group_by(chickenm, sort)

chickenm3 <- summarise(chickenm2,  count=n(),
                  tprofit= sum(profit))

mean(chickenm3$tprofit)
## [1] 7536.25

1.2 Quantity recommendation

  1. Whole Foods would like to verify the profitability of making 20, 25, 30, or 40 chickens during the lunch rush. Which quantity would you recommend? Why?

We recommend the Whole Foods make 40 chicken wings, because the epected value of 25 chicken wings is the highest, 214 dollars.

e20= 0.12*7.5*20+ 0.88*20*5
e20
## [1] 106
e25=0.26*7.5*25+ 0.74*25*5
e25
## [1] 141.25
e30=0.21*7.5*30 + 0.79*5*30
e30
## [1] 165.75
e40=0.14*7.5*40+ 0.86*(40*5)
e40
## [1] 214

2 Problem 2: Kiekpatrick Aircrafts

Kirkpatrick Aircrafts operates a large number of computerized plotting machines. For the most part, the plotting devices are used to create line drawings of complex wing airfoils and fuselage part dimensions. The engineers operating the automated plotters are called loft lines engineers.

The computerized plotters consist of a minicomputer system connected to a 4×5-foot flat table with a series of ink pens suspended above it. When a sheet of clear plastic or paper is properly placed on the table, the computer directs a series of horizontal and vertical pen movements until the desired figure is drawn.

The plotting machines are highly reliable, with the exception of the three sophisticated ink pens that are built in. The pens constantly clog and jam in a raised or lowered position. When this occurs, the plotter is unusable. Currently, Kirkpatrick Aircrafts replaces each pen as it fails. The service manager has, however, proposed replacing all three pens every time one fails. This should cut down the frequency of plotter failures. At present, it takes one hour and a half to replace one pen. All three pens could be replaced in two and a half hours. The total cost of a plotter being unusable is 600 dollars per hour. Each pen costs 76 dollars. The following breakdown data are thought to be valid:

one pen replace hours between failures 10 20 30 40 50 60 Probility 0.12 0.15 0.18 0.21 0.20 0.14

3 pens replace hours between failures 70 100 110 120 130 140 probility 0.05 0.12 0.25 0.32 0.21 0.05

2.1 20 Failure

  1. For each option (replacing one pen at a time and replacing all three pens at a time), simulate the average total time a plotter would operate before it would have 20 failures. Then compute the total cost per hour for each option to determine which option Kirkpatrick Aircrafts should use. Use 200 replications.

After 200 simulation, we found replace 1 pen each time cost about 26.9 dollars, where replace 3 pens together cost around 14.89 dollars per pen. So we suggest repair 3 pens together.

rplace1pen <- c(10,20,30,40,50,60)
prob <- c(0.12 ,0.15, 0.18, 0.21 , 0.20, 0.14)
rpen1= data.frame(rplace1pen,prob)
rpen1$ulc <- cumsum(rpen1[,2])
rpen1$llc <- rpen1$ulc-rpen1$prob

rpen1 
##   rplace1pen prob  ulc  llc
## 1         10 0.12 0.12 0.00
## 2         20 0.15 0.27 0.12
## 3         30 0.18 0.45 0.27
## 4         40 0.21 0.66 0.45
## 5         50 0.20 0.86 0.66
## 6         60 0.14 1.00 0.86
rplace3pen <- c(70,100, 110, 120, 130 ,140)
prob <- c(0.05 ,0.12, 0.25, 0.32 , 0.21, 0.05)
rpen3= data.frame(rplace3pen,prob)
rpen3$ulc <- cumsum(rpen3[,2])
rpen3$llc <- rpen3$ulc-rpen3$prob
rpen3
##   rplace3pen prob  ulc  llc
## 1         70 0.05 0.05 0.00
## 2        100 0.12 0.17 0.05
## 3        110 0.25 0.42 0.17
## 4        120 0.32 0.74 0.42
## 5        130 0.21 0.95 0.74
## 6        140 0.05 1.00 0.95
#Replace 1 pen 20 failures with 200 simulations.
set.seed(61)
rand <- runif(4000)

rpen1d= data.frame(rand)
rpen1d$hr <- ifelse(rpen1d$rand < 0.12 , 10,
                   ifelse(rpen1d$rand <0.27 & rpen1d$rand >=0.12, 20, ifelse(rpen1d$rand <0.45 & rpen1d$rand >=0.27, 30, ifelse(rpen1d$rand <0.66 & rpen1d$rand >=0.45, 40, ifelse(rpen1d$rand <0.86 & rpen1d$rand >=0.66,50, 60)))))

rpen1d$n <-as.numeric(row.names(rpen1d))
rpen1d$sort <- ceiling(rpen1d$n/20)
rpen1d$cost <- 1.5*600+76

rpen1d1 <- group_by(rpen1d, sort)
rpen1d2 <- summarise(rpen1d1,  count=n(),
                  totalhr= sum(hr) , tcost=sum(cost))

mhr <- mean(rpen1d2$totalhr)
tcost <-mean(rpen1d2$tcost)
mhr
## [1] 725
tcost
## [1] 19520
costperhr <- tcost/mhr
costperhr
## [1] 26.92414
#Replace 3 pen 20 failures with 200 simulations.
set.seed(62)
rand <- runif(4000)

rpen3d= data.frame(rand)
rpen3d$hr <- ifelse(rpen3d$rand < 0.05 , 70,
                   ifelse(rpen3d$rand <0.17 & rpen3d$rand >=0.05, 100, ifelse(rpen3d$rand <0.42 & rpen3d$rand >=0.17, 110, ifelse(rpen3d$rand <0.74 & rpen3d$rand >=0.42, 120, ifelse(rpen3d$rand <0.95 & rpen3d$rand >=0.74,130, 140)))))

rpen3d$n <-as.numeric(row.names(rpen3d))
rpen3d$sort <- ceiling(rpen3d$n/20)
rpen3d$cost <- 2.5*600+76*3

rpen3d1 <- group_by(rpen3d, sort)
rpen3d2 <- summarise(rpen3d1,  count=n(),
                  totalhr= sum(hr) , tcost=sum(cost))

mhr3 <- mean(rpen3d2$totalhr)
mhr3
## [1] 2325.75
tcost3 <-mean(rpen3d2$tcost)
tcost3
## [1] 34560
costperhr3 <- tcost3/mhr3
costperhr3
## [1] 14.85972

2.2 Total Cost

  1. Compute the total cost per hour analytically for each option. How do these results compare with the simulation results?

We apply the following formula, found out the analytic method to fix 1 pen is 26.78 dollars, and fix 3 pens together, the cost for each pen is 14.9 dollars, which are consistent with out previous simulation work.

\[ repair\; cost\; for\; 1 pen = \frac{ 600*1.5+75 }{ Expect \; Hour} \] \[ repair\; cost\; for\; 3 pen = \frac{ 600*2.5+75*3 }{ Expect \; Hour} \]

# 1 pen repair calculation
rpen1$ehr <- rpen1$rplace1pen*rpen1$prob
ehrpen1 <- sum(rpen1$ehr)
ccost <-(600*1.5+75)/ehrpen1
ccost
## [1] 26.78571
# 3 pens repair calculation
rpen3$ehr <- rpen3$rplace3pen*rpen3$prob
ehrpen3 <- sum(rpen3$ehr)
ccost3 <-(600*2.5+75*3)/ehrpen3
ccost3
## [1] 14.90925