Activity: Aircraft Stocking

Monte Carlo Methods Activities

Author

Manuel D. Rossetti, PhD P.E.

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?

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

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

  2. Why not simply stock the mean demand? Would the best \(q\) be above or below the mean, and why?

  3. Write the pseudo-code to estimate \(E[G(q, D)]\) for one value of \(q\).

2. One stock level

We write weeklyCost (TODO) together.

  1. Predict: at \(q = 30\), which cost dominates, refurbishing or shortage?

  2. Run at \(q = 30\). Why is the standard deviation of the weekly cost larger than its average?

3. Search the stock levels

  1. Change lastQ to 60 and run, 5 apart. Which \(q\) is best?

  2. 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?

  3. weeklyCost resets 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

  1. 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).invCDF to find \(q^*\). Does it agree with part 3?

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

  3. Interpret the critical ratio: what fraction of weeks will have a shortage at the optimal stock level? Why is that sensible when \(b = 9h\)?