theme = Generators.observe(notify => {const read = () => {const css =getComputedStyle(document.body);const v = (name, fallback) => (css.getPropertyValue(name).trim() || fallback);return {dark:document.body.classList.contains("quarto-dark"),fg:v("--bs-body-color","#212529"),bg:v("--bs-body-bg","#ffffff"),muted:v("--bs-secondary-color","#6c757d"),grid:v("--bs-border-color","#dee2e6"),primary:v("--bs-link-color","#0d6efd"),accent:v("--bs-danger","#dc3545"),good:v("--bs-success","#198754") }; };// Quarto swaps stylesheets when the theme changes, and the new variables apply only once// the stylesheet has loaded; read them again shortly after, and keep the last reading.let last ="";const emit = () => {const t =read();const key =JSON.stringify(t);if (key !== last) { last = key;notify(t); } };const update = () => { emit();setTimeout(emit,100);setTimeout(emit,400); };update();const observer =newMutationObserver(update); observer.observe(document.body, {attributes:true,attributeFilter: ["class"]});return () => observer.disconnect();})
plotStyle = ({// "inherit" takes the page's text color directly, so axes and labels follow a theme// switch even before the plot redraws.color:"inherit",background:"transparent",fontSize:"13px",overflow:"visible"})
themedButton = (label, counterLabel =null) => {const button =html`<button type="button" class="btn btn-sm btn-outline-primary bisc-explorer-button">${label}</button>`;// The counter shows which run is on screen, so every press visibly does something and a// reader can tell runs apart. It reads 1 at page load and after Reset.const counter = counterLabel?html`<span class="bisc-run-counter" aria-live="polite"></span>`:null;const form =html`<form class="bisc-explorer-control">${button}${counter ||""}</form>`;const show = () => { if (counter) counter.textContent=`${counterLabel}${form.value+1}`; }; form.value=0;show(); button.onclick= () => { form.value+=1; form.dispatchEvent(newEvent("input", {bubbles:true})); };// Reset sets the value back to 0 and dispatches input; refresh the counter either way. form.addEventListener("input", show);return form;}
resetButton = (controls, label ="Reset to the starting values") => {// This runs once per page, because the cell that calls it depends on the controls// themselves (viewof), not on their values; so these are the values at page load.const start = controls.map(c => c.value);const button =html`<button type="button" class="btn btn-sm btn-outline-primary bisc-explorer-button">${label}</button>`; button.onclick= () => { controls.forEach((c, k) => { c.value= start[k]; c.dispatchEvent(newEvent("input", {bubbles:true})); }); };returnhtml`<div style="margin: 0.5rem 0">${button}</div>`;}
// A small seeded generator (mulberry32), so a run can be repeated.makeRandom = (seed) => {let a = seed >>>0;return () => { a = (a +0x6D2B79F5) >>>0;let t = a; t =Math.imul(t ^ (t >>>15), t |1); t ^= t +Math.imul(t ^ (t >>>7), t |61);return ((t ^ (t >>>14)) >>>0) /4294967296; };}
This explorer evaluates an \((r, Q)\) policy for the storeroom’s pad-mount transformer of Chapter 8, and it computes every number exactly, as the chapter does. Choose a reorder point and an order quantity, and the page shows what the policy delivers and what it costs. The chapter’s tables show the same quantities at a few chosen policies; here you can move between them and watch how the cost and the fill rate change together.
The item is the chapter’s. Demand arrives one unit at a time in a Poisson process at \(\lambda = 45\) units a year, an order costs \(k = \$220\), holding costs \(h = \$950\) per unit per year, and a backorder costs \(b = \$8{,}550\) per unit per year. Let \(r\) represent the reorder point and \(Q\) the order quantity. Let \(\theta = 7.5\) units represent the mean lead time demand, and let \(G^{1}\) and \(G^{2}\) represent its first and second order loss functions. Recall that the inventory position is uniform over \(r + 1\) through \(r + Q\), so each measure is the base-stock measure averaged over that band:
and the cost rate is \(C(r, Q) = k\lambda/Q + h\bar{I} + b\bar{B}\). Since demand is Poisson, the fill rate equals the ready rate.
The lead time demand can be either of the chapter’s two models of the supplier. With a lead time of two months exactly it is Poisson with mean 7.5. With a lead time that averages two months and has a standard deviation of one month it is negative binomial with the same mean and a variance of 21.5625.
The page runs in your browser and records nothing. Its formulas are a restatement in JavaScript of the book’s code, and they are tested against that code’s values.
To evaluate an item of your own, with its own costs and lead time demand, use the general explorer.
The Policy
viewof model = Inputs.select(newMap([ ["Poisson: two months exactly","poisson"], ["Negative binomial: two months on average","negativeBinomial"]]), {value:"poisson",label:"Lead time demand"})viewof r = Inputs.range([0,20], {step:1,value:9,label:"Reorder point, r"})viewof Q = Inputs.range([1,15], {step:1,value:5,label:"Order quantity, Q"})resetButton([viewof model, viewof r, viewof Q])
{const n = (x, d =4) => x.toFixed(d);const dollars = x =>"$"+ x.toLocaleString("en-US", {minimumFractionDigits:2,maximumFractionDigits:2});const rows = [ ["Expected backorders, B̄ (units)",n(here.B),n(opt.B)], ["Ready rate = fill rate",n(here.RR),n(opt.RR)], ["Expected on hand, Ī (units)",n(here.I),n(opt.I)], ["Orders a year, λ/Q",n(here.OF,2),n(opt.OF,2)], ["Ordering, kλ/Q",dollars(here.ordering),dollars(opt.ordering)], ["Holding, hĪ",dollars(here.holding),dollars(opt.holding)], ["Backorders, bB̄",dollars(here.backorder),dollars(opt.backorder)], ["Total cost a year",dollars(here.total),dollars(opt.total)] ];returnhtml`<table class="table table-sm" style="max-width: 42rem"> <thead><tr><th>Measure</th><th>Your policy (${r}, ${Q})</th><th>The optimum (${best.r}, ${best.Q})</th></tr></thead> <tbody>${rows.map(row =>html`<tr><td>${row[0]}</td><td>${row[1]}</td><td>${row[2]}</td></tr>`)}</tbody> </table>`;}
{const lo = r +1, hi = r + Q, s = best.S;const inside = lo <= s && s <= hi;const extra =100* (here.total/ opt.total-1);returnhtml`<p>The position runs over ${lo} through ${hi}. The optimal base-stock level is S* = ${s}, which ${inside ?"lies inside that band, as it must for the optimal policy":"lies outside that band, so this policy cannot be optimal"}. Your policy costs ${extra <0.005?"the same as the optimum": extra.toFixed(1) +"% more than the optimum"}.</p>`;}
The first plot is the cost against the reorder point, with the order quantity held at your \(Q\). Each blue dot is one reorder point, and the red dot is your policy. Notice how flat the curve is near its lowest point, and how steeply it rises on the left, where backorders are charged at $8,550 a unit-year.
byR = d3.range(0,21).map(x => ({r: x,...cost(ltd, x, Q, costs)}))Plot.plot({style: plotStyle,height:260,marginLeft:70,marginBottom:45,x: {label:"Reorder point, r",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Cost a year ($)",grid:true,domain: [0,Math.max(20000,1.05* here.total)]},marks: [ Plot.line(byR, {x:"r",y:"total",stroke: theme.primary,strokeWidth:1.5,clip:true}), Plot.dot(byR, {x:"r",y:"total",r:2.5,fill: theme.primary,clip:true}), Plot.dot([{r,total: here.total}], {x:"r",y:"total",r:6,fill: theme.accent}) ],ariaLabel:"Cost a year against the reorder point at the chosen order quantity",ariaDescription:`At Q = ${Q}, the least cost over r is $${d3.min(byR, d => d.total).toFixed(2)}, at r = ${byR[d3.minIndex(byR, d => d.total)].r}. Your policy at r = ${r} costs $${here.total.toFixed(2)}.`})
The second plot is the fill rate against the reorder point at the same \(Q\), with your policy as the red dot. Notice that it keeps climbing past the reorder point the cost curve prefers. The cost stops falling where one more unit of reorder point saves less in backorders than it adds in holding, and the fill rate takes no part in that comparison.
Plot.plot({style: plotStyle,height:240,marginLeft:70,marginBottom:45,x: {label:"Reorder point, r",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Fill rate",grid:true,domain: [0,1]},marks: [ Plot.line(byR, {x:"r",y:"RR",stroke: theme.primary,strokeWidth:1.5}), Plot.dot([{r,RR: here.RR}], {x:"r",y:"RR",r:6,fill: theme.accent}) ],ariaLabel:"Fill rate against the reorder point at the chosen order quantity",ariaDescription:`At Q = ${Q}, the fill rate rises from ${byR[0].RR.toFixed(3)} at r = 0 to ${byR[20].RR.toFixed(3)} at r = 20. Your policy's fill rate is ${here.RR.toFixed(4)}.`})
The third plot is the least cost over the reorder points 0 to 20 at each order quantity, with your \(Q\) as the red dot. Notice how little the cost rises as \(Q\) moves away from its best value: choosing the wrong quantity is cheap.
byQ = d3.range(1,16).map(q => {const row = d3.range(0,21).map(x =>cost(ltd, x, q, costs).total);return {Q: q,total: d3.min(row),r: d3.minIndex(row)};})Plot.plot({style: plotStyle,height:240,marginLeft:70,marginBottom:45,x: {label:"Order quantity, Q",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Least cost over r ($)",grid:true,domain: [0,Math.max(16000, d3.max(byQ, d => d.total))]},marks: [ Plot.line(byQ, {x:"Q",y:"total",stroke: theme.muted,strokeWidth:1.5}), Plot.dot(byQ, {x:"Q",y:"total",r:2.5,fill: theme.muted}), Plot.dot([byQ[Q -1]], {x:"Q",y:"total",r:6,fill: theme.accent}) ],ariaLabel:"Least cost over the reorder point at each order quantity",ariaDescription:`The least cost is $${d3.min(byQ, d => d.total).toFixed(2)} at Q = ${byQ[d3.minIndex(byQ, d => d.total)].Q}. At your Q = ${Q} it is $${byQ[Q -1].total.toFixed(2)}, with r = ${byQ[Q -1].r}.`})
Things to Try
Start at the chapter’s worked policy, \(r = 9\) and \(Q = 5\), with Poisson lead time demand. The table shows \(\bar{B} = 0.1202\), a fill rate of 0.8990, \(\bar{I} = 4.6202\) and a cost of $7,396.80 a year, the row the chapter works by hand.
Hold \(Q = 5\) and move \(r\) from 7 to 11. The cost runs $8,016.43, $7,405.97, $7,396.80, $7,792.96 and $8,442.11, while the fill rate climbs from 0.7492 to 0.9683. Notice that \(r = 8\) and \(r = 9\) cost almost the same, although their fill rates differ by six points.
Set \(Q = 1\) and \(r = 10\). This is the base-stock policy at \(S = 11\), and it costs $14,759.83 a year, of which $9,900 is ordering.
Go to the optimum, \(r = 8\) and \(Q = 7\). The band of positions, 9 through 15, contains \(S^{*} = 11\). Then move \(Q\) up and down from 7 and watch the third plot. At \(Q = 5\) the best cost is 2.4% above the optimum, and at \(Q = 10\) it is 5.7% above it.
Keep \(r = 8\) and \(Q = 7\) and switch the lead time demand to the negative binomial. The same policy now costs $11,797.36 a year and fills 0.8051 of demand, and the optimum moves to \(r = 10\) and \(Q = 8\) at $11,079.73. Both decisions rise, \(r\) because the tail of the lead time demand is heavier and \(Q\) because each cycle is more expensive to start.
Check What You Found
Check what you found
1. With Poisson lead time demand and \(Q = 5\), moving the reorder point from \(r = 8\) to \(r = 9\) changes the cost from $7,405.97 to $7,396.80 a year and the fill rate from 0.8357 to 0.8990. What does that say?
2. The optimum is \((8, 7)\) at $7,225.15 a year when the lead time is two months exactly. When it averages two months with a standard deviation of one month, the same policy costs $11,797.36, and the optimum moves to \((10, 8)\) at $11,079.73. What is a reliable supplier worth to the storeroom each year?