learn-prescriptive-analytics-with-phoebe / Practitioner session 8 of 10
Learn Prescriptive Analytics with Phoebe · Practitioner session 8 of 10

Robust and stochastic, in outline

Session 7 measured the shape of what Ravensworth's plan actually delivers. The obvious next move is to put that shape inside the problem rather than outside it, so the solver chooses with the spread in view. There are three standard ways to do that and they answer three different questions. Tonight names each one honestly, draws what it takes in and what it hands back, and is straight about the part that is a judgement call rather than a calculation.

🟠 Intermediate Anyone who will write the model Comfortable reading a little JavaScript 45 min
0-3 · Setup 3-18 · Three formulations 18-30 · The trade, measured 30-45 · Build-along and Q&A
Part 0

Putting the spread inside the problem

Ravensworth's plan was computed from one demand figure per product and then measured against many. That ordering is the thing to change. The three formulations below all move the uncertainty inside the statement, so the plan is chosen knowing that demand varies. None of them removes the variation, and none of them produces a plan that is good in every week, because there is only ever one plan and there are many weeks.

Live = presented in the 45 minutes Self-study = the full depth, after class 🔍 Every diagram zooms

★ What you walk out with tonight. Three formulations you can tell apart in a meeting and say what each one takes in. The trade stated plainly and then measured by hand in the page: a better 5th percentile costs you mean. The exact list of things you would have to measure before any of this could be solved for Ravensworth. And a clear sight of the assumption that carries the most weight and gets the least scrutiny, which is the set of futures you decided to protect against.

LiveWhy one more solve does not make the problem go away4 min▶

It is easy to hear "stochastic optimisation" as the fix for what session 7 found, and it is not. The mill still commits one production plan on Monday and then lives through one week. Writing the distribution into the problem changes which single plan you get and it cannot change the fact that a single plan faces many futures. The shortfall against a figure computed at the average does not vanish; the plan is simply chosen with the shortfall in view instead of in ignorance of it.

What actually changes is the objective you are optimising. At the moment the objective is profit in one imagined average week. It can become expected profit across the whole distribution, or profit in the worst week of some set, or profit subject to a promise about how often the plan works. Those are three different numbers and they pick three different plans.

Real world

Notice what does not change at all. The mill still has 131 milling hours, 77 blending hours and 29 tonnes of premium protein, and every formulation below is still subject to those. Uncertainty here is on the demand side. Uncertain capacity is a different and harder problem, because then feasibility itself becomes a question of chance.

Self-studyThe words, and what each one commits you to4 min▶
  • Scenario. One complete set of values for the uncertain inputs. A draw from session 7 is a scenario.
  • Expected value formulation. Maximise the average objective across many scenarios, all of them in the problem at once. Commits you to a probability for every scenario.
  • Two-stage problem. Some decisions are made before the uncertainty resolves and some after. Ravensworth's production is a first-stage decision; nothing here is second stage.
  • Uncertainty set. The collection of futures a robust formulation promises to survive. Commits you to a boundary: inside it you are protected, outside it you are not.
  • Robust formulation. Maximise the worst objective over the uncertainty set. Commits you to the set, and pays for the protection in average performance.
  • Price of robustness. The average performance given up to buy that worst-case floor. Always positive unless the set is trivial.
  • Chance constraint. A requirement that a condition hold in at least a stated fraction of futures. Commits you to naming the fraction.
  • Conservatism. How wide the set or how high the fraction. The dial that turns a formulation from useless to paralysing, and it is set by a person.
Part 1 · covers the three formulations

Three questions, three different plans

15 min live

Side by side, with the deterministic version kept on the left for comparison. Read across the rows rather than down the columns: what each one wants from you, what it gives back, what it buys and what it costs. The row that decides most arguments is the last one, and it is the row that tends to be missing when one of these is proposed.

What each formulation asks for, and what it hands back DETERMINISTIC AT THE MEAN EXPECTED VALUE ROBUST CHANCE CONSTRAINED YOU GIVE IT One demand figure per product. Usually the mean. YOU GIVE IT Many scenarios, each with a probability attached. YOU GIVE IT An uncertainty set: the futures you will survive. YOU GIVE IT A condition and a fraction, such as 95 percent of weeks. IT RETURNS One plan, the best one for that single week. IT RETURNS One plan, the best average across all the scenarios. IT RETURNS One plan, the best worst case inside that set. IT RETURNS One plan meeting the stated promise, where one exists. IT BUYS YOU One small solve, and a statement anyone can read. IT BUYS YOU A plan chosen knowing that demand varies. IT BUYS YOU A floor you can say out loud and defend. IT BUYS YOU A service level that is stated rather than implied. IT COSTS YOU A plan tuned to a week that does not happen, and no sight of the bad ones. IT COSTS YOU A far larger problem, and an average that still hides the bad weeks inside it. IT COSTS YOU Average performance in every ordinary week, and the set is never measured. IT COSTS YOU A harder problem, and a fraction chosen by a person that drives the whole answer. Every column returns exactly one plan. None of them returns a plan that is good in every week. Choosing between the columns is choosing which number you want to be good: the average week, the worst week in a set you drew, or the fraction of weeks that work. That choice is about the business, and no solver makes it.
🔍 Click to zoom - the bottom row is the one that decides arguments, and the one that is usually left out of the pitch.
LiveExpected value is still one plan for many futures4 min▶

This is the honest limit and it deserves saying before anyone gets attached to the idea. Put five hundred scenarios in the problem, weight them, maximise the average, and what comes back is one vector of tonnages. It is a better-informed vector than the one computed at the mean, because it knows that light weeks exist and that tonnes made in a light week earn nothing. It is still a single commitment facing a distribution.

There is a second thing worth being clear about. Maximising an average is a statement that you are indifferent between a steady plan and a volatile one with the same mean. If that is not true of the business, the expected value formulation is optimising the wrong thing, and it will do so very competently.

The case where a two-stage version genuinely changes the picture is when some decision can wait. If the mill could hold part of its protein unallocated and blend late, that later decision is second stage, it is allowed to see the week, and the value of having it is exactly the sort of thing a stochastic formulation is good at pricing. Ravensworth as written has no second stage, so the plan is one commitment and nothing else.

LiveWhat a chance constraint actually promises4 min▶

"Feasible in 95 percent of weeks" sounds like a guarantee and is a statement about a model of the weeks. It is only as good as the distribution it was computed against, and it says nothing whatever about the other 5 percent. A plan that fails gently in one week in twenty and a plan that fails catastrophically in one week in twenty satisfy the same chance constraint.

That is why the fraction is rarely the interesting question. The interesting question is what happens on the wrong side of it, and answering that means going back to a simulation and reading the tail rather than the threshold. A chance constraint is a good way to write a service promise into a model and a poor way to think about risk on its own.

Self-studyWhat you would have to measure before any of this could be solved here5 min▶

Nothing above has been solved for Ravensworth, and the reason is that the inputs each formulation needs do not exist for the mill. The list is short and worth writing out, because it is the same list every time somebody proposes one of these.

  • A demand distribution somebody will defend. Not just a mean and a spread but the shape, fitted to a stated number of weeks of order history, with a view on whether it is stable across the season.
  • Whether the products move together. Two independent demands and two demands that rise and fall with the same customer give very different tails, and the difference is larger than most people expect.
  • A scenario set and its probabilities, for the expected value version. Sampling from the fitted distribution is the usual route, and then the number of scenarios is a convergence question of exactly the kind session 7 measured.
  • An uncertainty set, for the robust version. A boundary in demand space, with somebody prepared to say what is inside it and what is deliberately outside.
  • A fraction, for the chance-constrained version, named by whoever owns the consequence rather than by whoever writes the model.
  • What a bad week actually breaks. Until that is written down, there is no basis for choosing how much mean to spend, and the conservatism dial gets set by temperament.

Every item on that list is a measurement or a decision, and none of them is a solver feature. That is the honest state of the problem, and it is a more useful thing to hand a client than a plan computed from assumed inputs.

Part 2 · covers the trade and the set

You are buying a floor, and the price is the average

12 min live

The trade underneath all three formulations is the same one and it can be stated without any mathematics: a plan that does better in the bad weeks does worse in the ordinary ones. Session 7 measured one point on that trade, the plan Ravensworth actually has. Everything else is direction, and tonight it gets found by hand rather than quoted.

One measured point, and a direction that has not been measured 5TH PERCENTILE MEAN PROFIT ACROSS THE DRAWS BUYING A BETTER BAD WEEK a worse mean is the price the plan plan 33 / 63 / 0 mean 4,318 to 4,331 5th pctile 3,540 to 3,591 measured across five seeds THE CURVE IS A SHAPE, NOT A MEASUREMENT only the filled point has numbers behind it To draw the rest of it properly A demand distribution somebody will defend, with a shape and a stated number of weeks of order history behind it. Whether the two products move together, because correlation changes the tail far more than it changes the mean. A seed and a draw count on every point, or the curve is noise drawn with a confident pen. And a statement of what a bad week breaks. Where to sit on that curve is not a mathematical question. Two mills with the same numbers and different balance sheets should sit in different places, and both would be right. The curve says what is available. It does not say which point to buy, and no formulation supplies that.
🔍 Click to zoom - one filled point, measured across five seeds. The dashed line is the shape of the trade, not a result.
Live A hand search, not a robust solve. The grid below enumerates plans and measures each one, which is only affordable because there are two variables.

...

...
LiveWhat the grid search is and is not4 min▶

Press the button and the page walks every whole-tonne plan in a range, checks it against the three capacity rows, simulates the feasible ones, and reports the best few by average and the best few by 5th percentile. They are different plans, which is the trade made visible with no formulation at all.

It is worth being exact about what that is. It is enumeration, and it works here only because Ravensworth has two active products and whole tonnes, so the grid has a few hundred entries. Add a third active product and it has tens of thousands; add a week-by-week horizon and it stops being possible. A stochastic or robust formulation is what you reach for when you can no longer afford to look at every plan, and its job is to get the same answer without the enumeration.

It is also not a robust solution in the technical sense. Nothing here maximises a worst case over a declared set. It samples one distribution, at a stated seed and draw count, and reads a percentile off it, which is a different object and a weaker promise.

LiveLook for ties in the bad-week column3 min▶

In the results, several different plans often share exactly the same 5th percentile. That is not a rounding artefact and it is worth a minute. If the draw sitting at that percentile is one where demand came in below the plan on both products, then everything the mill made was surplus to that week, what got sold was the demand itself, and the profit for that draw does not depend on the plan at all.

The consequence is useful and slightly deflating: over part of the range, raising production does not move the bad week. The tail is being set by the demand draw rather than by the decision, and no amount of extra production buys anything there. Knowing which part of a distribution your decision can actually reach is worth more than the percentile itself.

The same uncertainty, three boundaries, three different worst cases A BOX DAIRY STANDARD worst case: both products low at once every combination inside is allowed AN ELLIPSE DAIRY STANDARD worst case: both moderately low together a double extreme is ruled out as unlikely A BUDGET DAIRY STANDARD worst case: one product far off, one central at most one thing goes badly wrong at a time The amber dot moves, so the plan moves, so the price of robustness moves. The three sets hold different futures, and a robust plan is only as meaningful as the boundary it was solved against. No data ever arrives labelled with which of these is the correct shape. Somebody chooses.
🔍 Click to zoom - the grey dot is where demand usually sits. The amber dot is the week each set makes you plan for.
LiveWhy the box is usually too pessimistic3 min▶

A box is the easiest set to write and the easiest to defend line by line, because each product gets its own honest range. The trouble is what it implies jointly. It says that every product can sit at its worst value in the same week, and if there are three products with independent demand, the corner it protects against is a week nobody has ever seen.

The ellipse and the budget set are both attempts to fix that by limiting how many things may go wrong at once. Both are more realistic and both introduce a new dial that somebody has to set. There is no version of this where the conservatism is derived rather than chosen, and pretending otherwise is the main way robust plans get oversold.

Self-studyWhere serious people disagree5 min▶

The unresolved argument is not about any of the mathematics above. It is whether a business should plan for the worst plausible week or the average one, and it is decided by facts about the business rather than by the model.

One camp plans for the average and holds its nerve. A mill runs fifty-odd weeks a year; good and bad both turn up, and what accumulates is the average. Every pound of mean given up to protect a 5th percentile is given up in all fifty-odd weeks, most of which were never going to be bad. On this view robustness is an insurance premium paid continuously against an event that is survivable, and the discipline is to stop buying it.

The other camp says the business does not experience the average, it experiences weeks, and weeks are where things break. Three bad ones in a quarter can breach a covenant, empty a cash buffer or lose a customer, and a strong August repays none of that. On this view the mean is the right number only for a firm with enough balance sheet to be indifferent to sequence, and the floor is what should be optimised.

Both positions are held by people who run real operations and neither is a misunderstanding of the other. What settles it in a particular case is a small number of facts nobody usually writes down: how much buffer exists, whether bad weeks cluster, and what precisely a bad week breaks. Notice that the argument is about the business and not the formulation, and that a robust model does not resolve it, it just moves the same judgement into the width of a set.

Part 3 · build-along

Find the trade by hand, then price it

15 min hands on

Six steps, using the live box above and a page console. The aim is to leave able to describe all three formulations from memory, and able to say out loud what you would need before promising any of them to a client.

Confirm the point on the curve

Leave the plan at 33 and 63 and read the measured mean and 5th percentile. Check them against the diagram. This is the only point on the trade with numbers behind it, and everything below moves away from it.

Run the grid and compare the two winners

Press the search button. Write down the best plan by mean and the best plan by 5th percentile, and how far apart they are in tonnes. Then write down what each one gives up to the other, as money a week.

Say the trade in one sentence with a price on it

"Giving up X a week on the average buys Y a week on the bad week." Fill in both numbers from your own run, with the draw count and seed attached. Then decide, out loud, whether you would sign that trade for Ravensworth and say what fact made you decide.

Draw your own uncertainty set

On paper, over Standard demand and Dairy demand, draw the boundary you would actually defend to a plant manager. Mark the worst corner or point of it. Then say what week you have just declared yourself willing to lose money in, because that is the other half of drawing the boundary.

Hunt for the ties

In the search results, find two plans with the same 5th percentile and different means. Work out why the bad week is identical, and say in one sentence what that tells you about the range over which production can move the tail at all.

Write the honest handover

One short paragraph you would send to somebody asking for a robust plan: what you can say today, what you would have to measure first, and which item on that list is a decision rather than a measurement. Session 9 turns the attention onto the solver itself.

The habit to keep. When somebody proposes a robust or stochastic formulation, ask for three things before the maths: the distribution and what it was fitted to, the set or the fraction and who chose it, and what a bad week breaks. If those are not available, the honest deliverable is a measured trade and a list, not a plan.

Check yourself

Three questions

A colleague says moving to an expected value formulation will fix the shortfall session 7 measured. What is wrong with that?

The mill commits once and lives through one week. Putting the distribution inside the problem improves the choice; it cannot make one vector of tonnages good in every week. It also assumes indifference between a steady plan and a volatile one with the same mean.

What does a robust formulation cost, and why is it unavoidable?

The plan optimised for the worst point of a set is not the plan optimised for the centre of it. Unless the set is trivial those are different plans, so the floor is bought with mean. That price is called the price of robustness and it is always there.

Two teams are given identical demand data and produce robust plans that differ substantially. What is the most likely explanation?

The set is an input, and it is chosen rather than measured. Two defensible boundaries over the same data put the worst case in different places, so they produce different plans and different prices of robustness. Asking to see the set is the first question about any robust plan.

Before session 9

Homework

Thirty minutes, most of it on one decision your own operation already makes under uncertainty.

Write the three formulations for your own problem

Pick a recurring commitment made before the facts are known. Write one paragraph each: the inputs an expected value version would need, the set a robust version would need, and the fraction a chance-constrained version would need. Mark every item you could not supply today.

Ask what a bad one breaks

Find the person who owns the consequence and ask them what happens in the worst month they can remember, specifically. Bring the answer. It is the fact that decides where on the trade curve the business should sit, and it is almost never in any model. Session 9 asks a different question entirely: whether the solver producing all these numbers is correct.

Covered tonight

What this session covers

✓Expected value formulationScenarios with probabilities, and the limit: one plan still faces many futures.
✓Robust formulationBest worst case over an uncertainty set, and the price paid in mean.
✓Chance constraintsFeasible a stated fraction of the time, and what the promise leaves out.
✓Uncertainty setsBox, ellipse and budget over the same data, and three different worst cases.
✓The trade, measured by handA grid search in the page: the best plan by mean is not the best by 5th percentile.
✓What you would have to measureThe six-item list standing between the outline and a solved plan.
◐A solved robust or stochastic plan for RavensworthNot computed. The inputs it needs are not measured for this mill, and no figure is quoted for one.
◐Two-stage recourseNamed as where a stochastic formulation earns its keep. Ravensworth has no second stage.
○Uncertain capacityOnly demand varies here. Random ceilings make feasibility itself probabilistic.
○Fitting the demand distributionModel choice and evaluation belong to the prediction courses.
○Sampling a posteriorSimilar name, different technique. MCMC lives in the Bayesian course.
Take this with you

Cheat sheet

The one sentence. You buy a better 5th percentile with a worse mean, and where to sit on that trade is a business question.
Expected value. Many scenarios with probabilities, one plan, best on average. Still one plan for many futures.
Robust. Best worst case over a set you drew. Pays in ordinary weeks, every week.
Chance constraint. Works in a stated fraction of futures, and says nothing about the rest.
The set is an input. Box, ellipse, budget. Different futures, different plans, and nobody measures which is right.
A box is jointly pessimistic. It protects a week where everything goes wrong at once.
Enumeration is the cheap stand-in. Two variables and whole tonnes, so every plan can be measured. It does not scale.
Ask three things first. The distribution and its fit, the set or fraction and who chose it, and what a bad week breaks.