Chapter 6, Material and Distribution Requirements Planning
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 plans the distributor’s network of Chapter 6: three regional warehouses selling belts to dealers, all replenished from one central warehouse. Choose the rule the regions use and the rule the center uses, and watch what the regions’ batching does to the demand the center sees. Transit is one month to the north and west and two to the south, the center’s own supplier takes two months, and every location orders at $200 a time (the center at $400) and carries a $50 belt at 2% a month.
Recall that the center is planned as a component is, with every quantity per equal to one:
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 under every pairing of the two rules.
The Network
ruleNames = ["Lot-for-lot","Periodic order quantity","Wagner-Whitin","Silver-Meal","Least unit cost","Part-period balancing","Adjusted economic order quantity"]viewof regions = Inputs.select(ruleNames, {value:"Lot-for-lot",label:"Rule at every region"})viewof center = Inputs.select(ruleNames, {value:"Lot-for-lot",label:"Rule at the center"})resetButton([viewof regions, viewof center])
{const dollars = x => { const whole =Math.abs(x -Math.round(x)) <0.005;return"$"+ x.toLocaleString("en-US", {minimumFractionDigits: whole ?0:2,maximumFractionDigits: whole ?0:2}); };const n = x =>Math.round(x).toLocaleString("en-US");const cw = plan.records.CW;const seen =vc(cw.GR.slice(2,15)), sells =vc(sold);const outside = cw.GR.reduce((a, x, t) => a + (t <2|| t >14? x :0),0);const rows = [["North releases", plan.records.N.Rel], ["South releases", plan.records.S.Rel], ["West releases", plan.records.W.Rel], ["Center's gross requirements", cw.GR], ["Center's releases", cw.Rel]];returnhtml`<div style="overflow-x: auto; max-width: 100%"> <table class="table table-sm" style="font-size: 0.85rem; white-space: nowrap"> <thead><tr><th>Period</th>${cw.GR.map((_, t) =>html`<th style="text-align: right">${t +1}</th>`)}</tr></thead> <tbody>${rows.map(([name, xs], j) =>html`<tr style="${j ===3?"font-weight: 600":""}"><td>${name}</td>${xs.map(x =>html`<td style="text-align: right">${n(x)}</td>`)}</tr>`)}</tbody> </table></div> <p>The regions sell a pattern whose variability coefficient is ${sells.toFixed(4)}. Over periods 3 through 15, the center sees ${seen.toFixed(4)}, ${(seen / sells).toFixed(2)} times as variable as what the dealers bought.${outside >0?`This rule also puts ${n(outside)} units of the center's requirement outside those periods.`:""}</p> <p>The regions cost ${dollars(plan.relevant- cw.relevant)} and the center ${dollars(cw.relevant)}, ${dollars(plan.relevant)} in all.</p>`;}
The plot sets what the center is asked for, as bars, against what the dealers bought from the three regions together, as a line. Under lot-for-lot the bars follow the line, a month or two early; under a rule that batches they bunch into fewer, larger requirements.
Plot.plot({style: plotStyle,height:260,marginLeft:60,marginBottom:45,x: {label:"Period",labelAnchor:"center",labelOffset:38},y: {label:"Belts",grid:true},color: {domain: ["Center's gross requirements","Dealers' purchases"],range: [theme.primary, theme.accent],legend:true},marks: [ Plot.barY(plan.records.CW.GR.map((x, t) => ({t: t +1, x,s:"Center's gross requirements"})), {x:"t",y:"x",fill:"s",fillOpacity:0.7}), Plot.line(sold.map((x, t) => ({t: t +5, x,s:"Dealers' purchases"})), {x:"t",y:"x",stroke:"s",strokeWidth:1.5}), Plot.dot(sold.map((x, t) => ({t: t +5, x,s:"Dealers' purchases"})), {x:"t",y:"x",fill:"s",r:3}) ],ariaLabel:"The center's gross requirements against the dealers' purchases",ariaDescription:`The largest requirement the center sees is ${d3.max(plan.records.CW.GR)} belts.`})
The second plot tries every rule at the regions and shows the variability coefficient the center sees under each. Each blue dot is one rule, the dashed line is what the dealers buy, and the red ring marks your rule.
{const rows = ruleNames.map(name => {const {items, usages, mps} =network({regions: name, center});return {rule: name,vc:vc(explode(items, usages, mps).records.CW.GR.slice(2,15))}; });return Plot.plot({style: plotStyle,height:260,marginLeft:10,marginBottom:45,marginTop:10,x: {label:"Variability coefficient at the center",labelAnchor:"center",labelOffset:38,grid:true,domain: [0,1.1* d3.max(rows, d => d.vc)]},y: {label:null,axis:null,domain: ruleNames,padding:0.5},marks: [ Plot.ruleX([vc(sold)], {stroke: theme.muted,strokeDasharray:"5,3"}), Plot.dot(rows, {y:"rule",x:"vc",r:5,fill: theme.primary}), Plot.dot(rows.filter(d => d.rule=== regions), {y:"rule",x:"vc",r:9,stroke: theme.accent,strokeWidth:2}), Plot.text(rows, {y:"rule",x:0,text: d =>`${d.rule}: ${d.vc.toFixed(4)}`,dy:-12,textAnchor:"start",fill: theme.fg,fontSize:11}) ],ariaLabel:"The variability coefficient at the center under each rule at the regions",ariaDescription:`The variability coefficient ranges from ${d3.min(rows, d => d.vc).toFixed(4)} to ${d3.max(rows, d => d.vc).toFixed(4)}.` });}
Things to Try
Start with lot-for-lot everywhere. The center’s gross requirements are the chapter’s roll-up, 10 in period 3 (the south alone) and 50 in period 4, and its variability coefficient is 0.6334, within three percent of the 0.6191 the dealers buy. The network costs $11,800.
Put the periodic order quantity at the regions. The center now sees 1.5896, 2.57 times what the dealers buy, although the dealers bought the same belts. That is the bullwhip effect.
Try Wagner-Whitin at the regions: 1.1403, and the network costs $7,030, less than lot-for-lot’s $11,800. In a world of known demand the amplification costs nothing.
Keep Wagner-Whitin at the regions and put it, or Silver-Meal, at the center too. The center falls from $3,200 to $2,510, and the network to $6,340.
Check What You Found
Check what you found
1. When every region uses the periodic order quantity, the center sees demand with a variability coefficient of 1.5896, 2.57 times the 0.6191 the dealers buy, and the network costs $7,510 against $11,800 under lot-for-lot. What follows?