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 runs the storeroom’s transformer under the \((R, S)\) policy of Chapter 9: every \(R\) the stock is reviewed and an order raises the inventory position to \(S\). Demand is Poisson at 45 a year, the lead time is \(L = 2\) months, and the costs are the chapter’s: $220 an order, $950 to hold a transformer for a year, and $8,550 to owe one. Choose the review interval and the order-up-to level and see what the policy delivers, what it costs, and what not watching the item continuously costs against the chapter 8 optimum.
Recall that the policy is exposed to demand over the protection interval\(R + L\), and that the measures average a base-stock measure over the review cycle. Let \(\bar{G}\) represent the distribution function of demand over \(L + U\), with \(U\) uniform over the cycle, averaged over the cycle. The best level is the smallest \(S\) with \(\bar{G}(S) \ge b/(b + h) = 0.90\), and the cost is
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. For an item of your own, use the general explorer.
{const n = (x, d =4) => x.toFixed(d);const dollars = x =>"$"+ x.toLocaleString("en-US", {minimumFractionDigits:2,maximumFractionDigits:2});const rows = [ ["Order-up-to level, S",String(here.S),String(opt.S)], ["Expected backorders, B̄",n(here.B),n(opt.B)], ["Expected on hand, Ī",n(here.I),n(opt.I)], ["Fill rate",n(here.fillRate),n(opt.fillRate)], ["Ready rate",n(here.readyRate),n(opt.readyRate)], ["Safety stock, S − λ(R + L)",n(here.safetyStock,2),n(opt.safetyStock,2)], ["Orders a year",n(here.orderFrequency,4),n(opt.orderFrequency,4)], ["Ordering",dollars(here.ordering),dollars(opt.ordering)], ["Holding",dollars(here.holding),dollars(opt.holding)], ["Backorders",dollars(here.backorder),dollars(opt.backorder)], ["Total cost a year",dollars(here.total),dollars(opt.total)] ];returnhtml`<p>The review interval is ${months.toFixed(2)} months, ${(months *52/12).toFixed(2)} weeks, so the protection interval is ${(months +2).toFixed(2)} months.</p> <table class="table table-sm" style="max-width: 42rem"> <thead><tr><th>Measure</th><th>Your level</th><th>The optimal level</th></tr></thead> <tbody>${rows.map(r =>html`<tr><td>${r[0]}</td><td>${r[1]}</td><td>${r[2]}</td></tr>`)}</tbody> </table> <p>At this interval the best level costs ${dollars(opt.total)} a year. Continuous review with the chapter 8 optimum, (r, Q) = (${continuous.r}, ${continuous.Q}), costs ${dollars(continuous.cost)}, so reviewing every ${months.toFixed(2)} months costs ${dollars(opt.total- continuous.cost)} a year more, or ${(100* (opt.total/ continuous.cost-1)).toFixed(1)}%.</p>`;}
The first plot is the cost against the order-up-to level at your review interval. The red dot is your level. Notice that the curve is flat near its minimum.
byS = d3.range(4,31).map(s => ({S: s,total: model.evaluate(s).total}))Plot.plot({style: plotStyle,height:240,marginLeft:70,marginBottom:45,x: {label:"Order-up-to level, S",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Cost a year ($)",grid:true,domain: [0,2.5* opt.total]},marks: [ Plot.line(byS, {x:"S",y:"total",stroke: theme.primary,strokeWidth:1.5,clip:true}), Plot.dot([{S,total: here.total}], {x:"S",y:"total",r:6,fill: theme.accent,clip:true}) ],ariaLabel:"Cost against the order-up-to level",ariaDescription:`At R = ${months.toFixed(2)} months the least cost is $${opt.total.toFixed(2)} at S = ${best}.`})
The second plot is the cost against the review interval, with \(S\) set to its best value at each interval. The dashed line is the continuous-review optimum, $7,225.15; the gap between the two is the price of not watching. The red dot is your interval, and the gray square marks the interval that balances the fixed charge against the cycle stock, \(\sqrt{2k/(h\lambda)}\).
byR = d3.range(0.25,4.001,0.05).map(mo => {const m =rsModel({...item,R: mo /12}), s = m.optimalLevel();return {months: mo,S: s,total: m.evaluate(s).total};})econ = {const R =economicInterval({k: item.k,h: item.h,rate: item.rate}), m =rsModel({...item, R}), s = m.optimalLevel();return {months:12* R,total: m.evaluate(s).total};}Plot.plot({style: plotStyle,height:260,marginLeft:70,marginBottom:45,x: {label:"Review interval, R (months)",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Least cost a year ($)",grid:true,domain: [0,12000]},marks: [ Plot.ruleY([continuous.cost], {stroke: theme.muted,strokeDasharray:"5,3"}), Plot.line(byR, {x:"months",y:"total",stroke: theme.primary,strokeWidth:1.5}), Plot.dot([econ], {x:"months",y:"total",r:6,symbol:"square",fill: theme.muted}), Plot.dot([{months,total: opt.total}], {x:"months",y:"total",r:6,fill: theme.accent}) ],ariaLabel:"Least cost against the review interval",ariaDescription:`The least cost over the intervals shown is $${d3.min(byR, d => d.total).toFixed(2)}; continuous review costs $${continuous.cost}.`})
Things to Try
Press Use the optimal level at a review interval of 1 month. The level is \(S^{*} = 14\), at $8,397.22 a year with a fill rate of 0.8928, the chapter’s example; it costs $1,172.07 a year more than continuous review.
Move \(S\) to 13 and to 15. They cost $8,465.46 and $8,720.37, 0.8% and 3.8% more than 14.
Set the interval to 1.44 months, 0.120 year. The best level is 15, at $8,186.92, the best periodic policy the chapter finds, and still $961.77 a year more than continuous review.
Compare the gray square: the economic interval of about 1.22 months (5.3 weeks) costs $8,222, within half a percent of the best interval, although it ignores shortages entirely.
Set the interval to 3 months. The level rises to 20 and the cost to $9,583.79: a longer interval needs more protection, and the cycle stock it creates is no longer cheap.
Check What You Found
Check what you found
1. Across review intervals from about four to eight weeks, the transformer’s least cost stays within 5% of the best. What should a storeroom take from that?
2. The best periodic policy costs $8,186.92 a year, against $7,225.15 for continuous review of the same item. Where does the $961.77 come from?