Activity: Aircraft Stocking
Monte Carlo Methods Activities
We write this program together: the instructor types the code, and you type along. Before each run, write down a prediction; then run and check it.
The question. An aircraft carrier stocks a part that is replenished from a depot on shore each week. Parts left unused at the end of the week go back to the depot to be refurbished, so no stock carries over from one week to the next. If a part fails and none is on hand, operations stop until a replacement is flown out. How many parts should the carrier stock each week?
- Let \(D\) represent the demand (the number of failures) in a week. From 100 weeks of data, \(D\) has a gamma distribution with shape 6.5998 and scale 4.2653. Let \(F(d) = P(D \leq d)\) represent its cumulative distribution function.
- Let \(q\) represent the number of parts stocked at the start of the week: the decision.
- Let \(h = \$1000\) represent the cost to refurbish each part left over, and \(b = \$9000\) the cost of each part short (the airlift and the lost operations).
At the end of the week \(\max(0, q - D)\) parts are left over and \(\max(0, D - q)\) are short. Let \(G(q, D)\) represent the week’s cost:
\[G(q, D) = h \max(0, q - D) + b \max(0, D - q).\]
Choose \(q\) to minimize the expected weekly cost, \(E[G(q, D)]\), which we estimate by simulation. Start with 1000 simulated weeks, and use stream 1 for the demand.
Setup. Get the starter file AircraftStocking.kt from the code/ folder beside this activity. Put it in src/main/kotlin/student/activities in your KSL project, the package the file declares; create the folder if you do not have it. Run its main. It compiles and runs, but the statistics are NaN: the function marked TODO is what we write.
1. Before any code
The mean of a gamma distribution is shape \(\times\) scale and its variance is shape \(\times\) scale\(^2\). Compute the mean and the standard deviation of the weekly demand.
Why not simply stock the mean demand? Would the best \(q\) be above or below the mean, and why?
Write the pseudo-code to estimate \(E[G(q, D)]\) for one value of \(q\).
2. One stock level
We write weeklyCost (TODO) together.
Predict: at \(q = 30\), which cost dominates, refurbishing or shortage?
Run at \(q = 30\). Why is the standard deviation of the weekly cost larger than its average?
3. Search the stock levels
Change
lastQto 60 and run, 5 apart. Which \(q\) is best?Change the search to \(q\) from 38 to 48, 1 apart. Which \(q\) is best now? Can the half-widths separate it from its neighbors?
weeklyCostresets the demand’s stream for each \(q\). Why does that make the comparison of neighboring values of \(q\) fairer than separate samples would?
4. Check against the theory
Inventory theory gives the optimal stock level for this cost: the \(q^*\) with \(F(q^*) = b/(b + h)\), the critical ratio. Compute the critical ratio. Use the KSL’s
Gamma(shape, scale).invCDFto find \(q^*\). Does it agree with part 3?With 1000 weeks, the simulated best \(q\) is not \(q^*\). Predict what happens with 100,000 weeks, then run \(q\) from 40 to 46 and check.
Interpret the critical ratio: what fraction of weeks will have a shortage at the optimal stock level? Why is that sensible when \(b = 9h\)?