Chapter 11, Multi-Echelon Systems with Batch Ordering
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 works Part I of Chapter 11 on its running example: four storerooms, each seeing one fuse cutout failure a week and ordering one for one, supplied by a hub that runs \((r_0, Q_0)\) with a three-week lead time from its supplier and one week of transit to each storeroom. Holding costs $28.75 a unit a year at both levels and a crew waiting costs $287.50 a unit a year. Choose the hub’s policy and the storerooms’ stock, and see what the hub’s batching does to the wait it imposes and to the storerooms.
The hub’s position is equally likely to sit at each of \(r_0 + 1, \ldots, r_0 + Q_0\), so its measures, and the chance that a request waits no longer than \(w\), are base-stock measures averaged over those positions:
The hub’s measures and the wait are computed in your browser. The storerooms’ backorders by the chapter’s three routes, and Axsäter’s exact backorders and cost, need the recursion of the chapter and are read from values the book’s code computed for every \(r_0\) from 0 to 20, \(Q_0\) from 1 to 16 and \(S_j\) from 0 to 6. The page records nothing. The cost prices holding and waiting crews only; the hub’s ordering cost, which is what makes batching worth doing, is not in it.
The Hub and Its Storerooms
viewof r0 = Inputs.range([0,20], {step:1,value:9,label:"Hub reorder point, r₀"})viewof Q0 = Inputs.range([1,16], {step:1,value:8,label:"Hub batch, Q₀"})viewof Sj = Inputs.range([0,6], {step:1,value:3,label:"Stock at each storeroom, Sⱼ"})resetButton([viewof r0, viewof Q0, viewof Sj])
{const n = (x, k =4) => x.toFixed(k);const exact = plan.exactBackorders[Sj];const routes = [["The mean wait only", plan.mean_only[Sj]], ["Two moments", plan.two_moment[Sj]], ["Conditioned on the wait", plan.conditioned[Sj]]];const against = x => exact <1e-12?"":Math.abs(x / exact -1) <5e-4?"exact":`${(100*Math.abs(x / exact -1)).toFixed(1)}% ${x < exact ?"low":"high"}`;returnhtml`<table class="table table-sm" style="max-width: 34rem"> <thead><tr><th>The hub at (${r0}, ${Q0})</th><th></th></tr></thead> <tbody> <tr><td>Lead time demand, mean θ₀ = λ₀L₀</td><td>${n(hub.theta,0)}</td></tr> <tr><td>Expected backorders, B̄₀</td><td>${n(hub.B0)}</td></tr> <tr><td>Ready rate, RR₀</td><td>${n(hub.RR0)}</td></tr> <tr><td>Expected on hand, Ī₀</td><td>${n(hub.I0)}</td></tr> <tr><td>Mean wait, B̄₀/λ₀ (weeks)</td><td>${n(hub.littleWait)}, or ${n(7* hub.littleWait,2)} days</td></tr> <tr><td>Variance of the wait (weeks²)</td><td>${n(plan.hub.varWait)}</td></tr> </tbody></table> <table class="table table-sm" style="max-width: 34rem"> <thead><tr><th>Backorders at one storeroom, Sⱼ = ${Sj}</th><th>Value</th><th>Against exact</th></tr></thead> <tbody> <tr style="font-weight: 600"><td>Exact, Axsäter</td><td>${n(exact)}</td><td></td></tr>${routes.map(([name, x]) =>html`<tr><td>${name}</td><td>${n(x)}</td><td>${against(x)}</td></tr>`)} </tbody></table> <p>The exact cost of the system is <strong>$${n(plan.exactCost[Sj])}</strong> a week, in holding at both levels and crews waiting. The check: Ī₀ − B̄₀ = ${n(hub.I0- hub.B0)} and r₀ + (Q₀ + 1)/2 − θ₀ = ${n(r0 + (Q0 +1) /2- hub.theta)}.</p>`;}
The first plot is the distribution of the wait a request suffers at the hub. It has a lump at zero, the hub’s ready rate, marked by the red dot: the chance a request ships at once. It rises to one at the hub’s lead time of three weeks. The dashed line is the mean wait.
Plot.plot({style: plotStyle,height:230,marginLeft:55,marginBottom:45,x: {label:"Wait at the hub, w (weeks)",labelAnchor:"center",labelOffset:38,domain: [0,3],grid:true},y: {label:"P(W ≤ w)",domain: [0,1],grid:true},marks: [ Plot.line(d3.range(0,301).map(k => ({w:3* k /300,F:waitCdf(sys,3* k /300)})), {x:"w",y:"F",stroke: theme.primary,strokeWidth:1.75}), Plot.dot([{w:0,F: hub.RR0}], {x:"w",y:"F",r:5,fill: theme.accent}), Plot.ruleX([hub.littleWait], {stroke: theme.muted,strokeDasharray:"5,3"}) ],ariaLabel:"The distribution of the wait at the hub",ariaDescription:`A request ships at once with probability ${hub.RR0.toFixed(4)}.`})
The second plot holds \(Q_0\) and \(S_j\) where you set them and moves the hub’s reorder point, showing the exact cost a week. The red dot is your \(r_0\) and the gray square the cheapest one; when you choose the cheapest, the dot sits on the square.
{const rows = data.plans.filter(p => p.Q0=== Q0).map(p => ({r: p.r0,c: p.exactCost[Sj]}));const best = rows.reduce((a, b) => (b.c< a.c? b : a));return Plot.plot({style: plotStyle,height:230,marginLeft:55,marginBottom:45,x: {label:"Hub reorder point, r₀",labelAnchor:"center",labelOffset:38,grid:true},y: {label:"Exact cost ($ a week)",grid:true,domain: [0,Math.min(d3.max(rows, d => d.c),4* best.c)]},marks: [ Plot.line(rows, {x:"r",y:"c",stroke: theme.primary,strokeWidth:1.5,clip:true}), Plot.dot([best], {x:"r",y:"c",r:6,symbol:"square",fill: theme.muted}), Plot.dot(rows.filter(d => d.r=== r0), {x:"r",y:"c",r:6,fill: theme.accent,clip:true}) ],ariaLabel:"The exact cost against the hub's reorder point",ariaDescription:`The cheapest reorder point is ${best.r}, at $${best.c.toFixed(4)} a week.` });}
Things to Try
Start at the running example, \((r_0, Q_0) = (9, 8)\) with \(S_j = 3\). The hub has stock 60.30% of the time and owes 1.0273 units; a request waits 0.2568 weeks on average, about 1.8 days. By Axsäter’s exact recursion the storeroom owes 0.0726 units. Conditioning on the wait gets that; two moments give 0.0712, 2.0% low; the mean wait alone gives 0.0505, 30.5% low. The system costs $7.0195 a week, the least over every \(r_0\) and \(S_j\) at \(Q_0 = 8\).
Raise the storerooms to 4. The mean wait alone is now 49.3% low: the further out in the tail a backorder calculation reads, the more the wait’s spread matters.
Return to 3 and lower the hub to \(r_0 = 4\). The hub has stock 17.12% of the time and a request waits 6.88 days on average; the exact cost rises to $9.3561 a week.
Set \(Q_0 = 1\), a base-stock hub like the depot of Chapter 10. The cheapest reorder point is 11, at $6.5493 a week, less than any batch of 8 can manage, because the page prices no ordering at the hub. At \(Q_0 = 16\) the best is \(r_0 = 6\) at $8.1804.
Check What You Found
Check what you found
1. At the running example the hub’s mean wait is 0.2568 weeks, yet a storeroom computed with a lead time of \(O_j + \bar{W} = 1.2568\) weeks owes 0.0505 units, against the exact 0.0726. Why does the mean wait fall short?