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

The feasible region

Session 1 left Ravensworth written down and unsolved. Before any method, the problem has a shape: each constraint cuts the space of plans in half, the surviving intersection is the set of plans the mill could actually run, and a linear objective is always maximised at one of its corners. That last fact is what turns an infinite search into a finite one, and the picture shows something the answer alone never does, which is which walls the plan is pressed against.

🟡 Foundations Anyone who will write the model Anyone who has to explain an optimum 45 min
0-3 · Setup 3-18 · Half-planes 18-30 · Walls and slack 30-45 · Build-along and Q&A
Part 0

A plan is a point, and most points are illegal

Take the three quantities Ravensworth chooses and read them as coordinates. Every conceivable plan is then a single point, and the mill's three ceilings each rule out everything on one side of a flat wall. What survives all three is a region, and the mill's job is to find the best point in it. Written that way the problem has a geometry, and the geometry answers a question that would otherwise need an infinite search: where can the best plan possibly be.

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

★ What you walk out with tonight. The corner argument said in one breath, without notation: moving in a straight line you keep improving until a wall stops you, so the best plan is where walls meet. Ravensworth's region drawn and its corners checked in the page, including the measured fact that thousands of random legal plans never beat the corner. And a grip on what the picture cannot do, which is exist above three variables, which is the whole reason the next session is about algebra.

LiveHalf-plane, region, corner4 min▶

One inequality, 1.1 S + 1.5 D <= 131, describes a line and everything on one side of it. That is a half-plane: the boundary is the plans that use the milling capacity exactly, and the interior is the plans that use less. The inequality is not a line, it is a line and a side, and the side is the half that matters.

Three inequalities plus the two non-negativity conditions give five half-planes, and the plans that satisfy all of them at once are the overlap. That overlap is the feasible region. It is flat-sided by construction, because every wall came from a linear inequality, and its sharp points, where two or more walls meet, are its corners.

Real world

Ravensworth makes three products, so its real region is a solid rather than a flat shape. Every picture tonight is the slice at Show = 0, which is an honest place to stand: the optimal plan makes no Show at all, so the slice contains the answer. The general claim being taught does not depend on the slice, and the algebra in session 3 never draws anything.

Self-studyThe words tonight adds3 min▶
  • Half-plane. One linear inequality: a boundary line and the side of it that satisfies the inequality.
  • Feasible region. The intersection of all the half-planes. Every plan in it is legal, and almost all of them are poor.
  • Corner, or vertex. A point where enough walls meet to pin it down. In two variables that means two walls.
  • Extreme point. The same idea said precisely: a feasible point that is not the midpoint of any two other feasible points.
  • Binding constraint. A wall the chosen plan is touching. Its inequality holds with equality there.
  • Slack. How far a plan is from a wall, in that wall's own unit. Blending finishes with 0.2414 hours unused.
  • Objective contour. The set of plans earning the same margin. A straight line here, and every contour is parallel to every other.
  • A tie. When a contour lies flat along an edge, every point on that edge is optimal and a corner is still among them. The solver ships one on purpose: max x + y subject to x + y <= 10, optimum 10.
Part 1 · covers the region and the corner argument

Three walls, an overlap, and the last line that touches it

20 min live

Build the region one wall at a time and it stops being abstract. Then put the objective on top of it, not as a number but as a family of parallel lines, and the corner result stops needing a proof. You can watch it happen: slide the line outward for more margin and the region runs out at a point.

Tonnes of Standard across, tonnes of Dairy up, with Show held at zero 1 · One row is a half-plane 1.1 S + 1.5 D at most 131 50 50 100 Dairy Standard milling 2 · Three rows, three walls milling, blending and protein together 50 50 100 Dairy Standard milling blending protein 3 · What survives all three every plan the mill could run the optimum sits here Dairy Standard Three products means the real region is a solid, not a shape on paper. These are the slice at Show = 0. That is where the optimal plan lives, so the slice contains the answer rather than hiding it. The corner result being taught here holds in any number of variables. Only the drawing stops at two.
🔍 Click to zoom - panel 2 has three lines and panel 3 shows that only two of them ever touch the best plan.
LiveWhy the optimum is at a corner5 min▶

Put the objective on the picture as a family of parallel lines. Every plan earning 3,000 lies on one line; every plan earning 3,500 lies on another, parallel to it and further out. Maximising the margin means pushing that line as far out as it will go while still touching the region.

Now the argument, in one breath. Stand anywhere inside the region and start walking in the direction that increases margin. Nothing stops you improving until you hit a wall. Once you are on a wall, walk along it in whichever direction still improves, and again nothing stops you until you hit another wall. Where two walls meet you can no longer move in any improving direction at all, and that is a corner. So the search never needs to look at the interior.

Said precisely, the claim is that at least one corner is optimal, which is slightly weaker than "the optimum is a corner" and is the version that is always true. If a contour happens to lie flat along an edge, then every plan on that edge earns the same and all of them are optimal, corners included. The solver in this page ships exactly that case in its own tests: maximise x + y subject to x + y at most 10, where the optimum is 10 and an entire edge achieves it. Ravensworth is not such a case, and it was checked: exactly one integer plan reaches 4,656.00.

Push the margin line out until the region runs out margin rising 50 50 100 tonnes of Dairy tonnes of Standard the last contour touches here only Milling hours 1.1 S + 1.5 D comes to exactly 131. The plan is pressed against this wall. Nothing left over. BINDING Premium protein 0.1 S + 0.4 D comes to exactly 29. The store is emptied by this plan. Nothing left over. BINDING Blending hours The plan stops short of this wall and never touches it. 0.2414 hours left unused SLACK Which walls the corner touches is the answer to a question the plan alone cannot answer. Two walls meet at the optimum and those two are the binding constraints. The third is not touched, and that gap is its slack.
🔍 Click to zoom - the blending line passes just above the corner. That near miss is worth 0.2414 hours and it decides a spending question in session 4.
LiveWhat this buys: a finite search4 min▶

Before the corner result, the search space is every point in a continuous region, which is not a list and cannot be enumerated. After it, the search space is the corners, which is a finite list. That single step is what makes linear programming a solvable thing rather than an aspiration, and every method in the rest of the practitioner track depends on it.

It also tells you what a solver is allowed to skip. Nothing in the interior ever has to be evaluated, no matter how promising it looks, because any interior point can be improved by walking. That is a strong claim and it is easy to test rather than believe: the box below throws thousands of random legal plans at the mill and reports the best of them against the corner.

Live The real solver, running in this page. Every corner found by intersecting walls, valued, and ranked.

The corners of the region at Show = 0, and what each one earns

...

...

...
Self-studyCorners are found by solving equations4 min▶

A corner in two variables is where two walls meet, and "meet" means both inequalities hold as equalities at once. So finding a corner is solving two linear equations in two unknowns, which is arithmetic anyone can do. The two walls can be two constraints, or one constraint and an axis, or the two axes at the origin.

Not every pair gives a corner of the region. Two walls may cross at a point that breaks a third constraint, in which case the crossing is real but it is outside the region and not a candidate. That is the check the box above performs: solve each pair, then test the crossing point against every constraint and discard it if it fails one. The test uses the same feasibility function the rest of the course uses.

This is also where the geometric view starts to cost something. With three variables a corner needs three walls meeting, so the pairs become triples. With ten variables it is ten walls at a time, and the number of combinations to test grows far faster than the number of variables does. Enumerating corners is correct and it is not a method anyone can use at scale, which is precisely the gap the simplex method fills.

Part 2 · covers what the picture shows, and where it stops

Two variables draw, three imagine, four gone

16 min live

The geometry earns its place twice. It makes the corner result obvious rather than asserted, and it makes binding and slack visible as touching and not touching, which is the whole content of a shadow price before any arithmetic. Then it stops working, quite abruptly, and being clear about where it stops is part of knowing it.

How far the drawing goes Two variables A flat shape on paper. A corner is where two lines cross. Three variables A solid with flat faces. A corner is where three faces meet. Four or more ? Nothing to look at. A corner is still where that many walls meet, and you cannot see it. The result never depended on the picture, only your confidence in it did. Which is why the next session does the same walk in algebra, where the number of variables makes no difference to the method.
🔍 Click to zoom - a real model has hundreds of variables, so the third panel is the normal case and the first two are the teaching aid.
Reading the geometry off the solved problem
var c = [38, 54, 71];
var A = [[1.1, 1.5, 2.3], [0.6, 0.9, 1.7], [0.1, 0.4, 1.0]];
var b = [131, 77, 29];

var r = OPT.solveLP(c, A, b);

r.binding;   // which walls the corner is touching
r.slack;     // how far the plan is from each wall, in that wall's unit

// a corner is two walls solved as equations, then tested
OPT.isFeasible(A, b, [30.6897, 64.8276, 0]);   // is this crossing inside the region
OPT.objectiveOf(c, [30.6897, 64.8276, 0]);     // what a given plan earns
LiveTouching and not touching, which is all a shadow price is4 min▶

Look at the corner in the second diagram and notice that the blending line passes above it without touching. That gap is 0.2414 hours of blending capacity that the best plan never uses. Now ask what would happen if the blending ceiling were raised: the wall moves further away from a corner it was not touching, the corner does not move, the plan does not change, and the margin does not change.

That is the entire argument for a shadow price of zero, and it was made with no arithmetic at all. The same picture makes the opposite case just as plainly: the milling wall is touching, so moving it outward moves the corner, which moves the plan and changes the margin. Session 4 puts a figure on how much, and finds that the figure has a much shorter shelf life than anyone quoting it expects.

LiveThe picture answers "why", which the number cannot4 min▶

A plan on its own is unarguable and unexplainable. Add the geometry and it becomes a sentence somebody can push back on: this plan is where the milling wall meets the protein wall, and it is there because every direction that would earn more runs into one of those two. Somebody who disagrees now has something to disagree with. They can challenge a ceiling, or a rate, or the objective, and each challenge points at a specific number.

This matters more than it sounds, because an optimum that cannot be explained tends not to be run. The binding set is the shortest honest explanation of any linear plan, it is two or three items long even on large models, and it comes free with the answer in r.binding.

Self-studyWhere serious people disagree5 min▶

Whether to teach the geometry first, or at all, is a live argument among people who teach this for a living, and it is not about taste.

One camp says the picture is the subject and everything else is bookkeeping. Without it, the simplex method is a ritual of row operations that students execute and do not understand, and binding, slack and the dual are memorised words rather than things you can see. On this view the drawing is what makes the algebra meaningful, and a practitioner who cannot sketch a two-variable region cannot debug a two-hundred-variable model either.

The other camp says the picture builds an intuition that then has to be unlearned. Real problems have thousands of variables, the number of corners grows far faster than anyone's mental image can accommodate, and there are perfectly good methods that never visit a corner at all: interior point methods cut straight through the middle of the region and converge on the optimum from inside. A student who has been taught that optimisation means walking corners will find that whole family of methods surprising, and will carry a picture that quietly misleads about what is expensive in a large model.

Both camps are describing something true. The corner result is correct in any number of dimensions and the picture is the fastest way to believe it. The picture is also the reason people are surprised that a method could work from the inside. There is no resolution on offer here, only the recommendation to notice which one you are relying on when you next explain a model to somebody.

Part 3 · build-along

Find the corners, then try to beat them

20 min hands on

Six steps with the live box and a console. The aim is to leave able to say where an optimum is, not just what it earns, and to name the walls it is against without looking anything up.

Solve two walls by hand

Set Show to zero and solve 1.1 S + 1.5 D = 131 together with 0.1 S + 0.4 D = 29 on paper. Compare your answer with the corner marked in the second diagram. That single crossing is the optimal plan, and you just computed it without a solver.

Test a crossing that is not a corner

Now solve the milling wall against the blending wall instead. Take the result and pass it to OPT.isFeasible(A, b, [S, D, 0]). Say what the answer means geometrically: the two lines really do cross, and the crossing is outside the region.

Read the corner table

In the live box, check every corner against the one the solver returns. Confirm that the best row and the solver's answer are the same point, and note how few candidates there were in total.

Try to beat a corner from the inside

Read the random-plan line under the table. Thousands of legal plans, none of them better than the corner. Then say why that is not luck, in the language of walking in an improving direction.

Name the binding set out loud

Call OPT.solveLP(c, A, b) and read r.binding and r.slack. Say the plan in one sentence of the form "this is where the X wall meets the Y wall, and Z has room left over". That sentence is what you take into a meeting.

Move a wall and watch the corner move

Re-solve with b = [132, 77, 29], then with b = [131, 78, 29]. One of those changes the plan and one does not. Predict which before you run them, then explain the result by pointing at the second diagram.

The habit to keep. When somebody shows you an optimal plan, ask which constraints are binding. Not because the number is suspect, but because the binding set is where the plan came from: it is the two or three walls the answer is wedged against, it is the shortest explanation anybody will accept, and it is the list of things worth arguing about. Everything with slack is, for this week, irrelevant.

Check yourself

Three questions

Why does checking only the corners of the feasible region find the best plan?

The argument is about improvement, not legality. Interior points are perfectly legal and there are infinitely many of them, which is why the geometric result matters: nothing in the interior can be best, since a straight-line move keeps improving until a wall intervenes. That turns an infinite search into a finite list.

At Ravensworth's optimum the blending line passes above the corner without touching it, leaving 0.2414 hours unused. What does that tell you before any arithmetic?

Raising a ceiling the plan never reaches moves a wall away from a corner it was not touching. The corner does not move, so the plan does not move, so the margin does not move. Being close to a wall is not the same as touching it, and 0.2414 hours of room is still room.

A model has forty variables. What survives from tonight, and what does not?

The region, its corners, the binding set and the slacks are all defined by inequalities rather than by pictures, and they behave identically at forty variables. The only casualty is your ability to look at it, and that is exactly the gap a tableau fills.

Before session 3

Homework

Thirty minutes, mostly on paper.

Draw your own two-variable region

Take the model you wrote in session 1, keep two variables and set the rest to zero, and draw the region by hand with a ruler. Mark the corners, work out which one your objective picks, and name the walls that meet there. If it takes more than ten minutes, the model has a unit problem worth finding.

Walk the corners on paper, in order

Start at the origin of Ravensworth's slice and list the corners in the order you would reach them by always moving to a neighbouring corner that earns more. Keep the list. Session 3 does exactly that walk, mechanically, and your list is the thing to check the tableau against.

Covered tonight

What this session covers

✓A constraint is a half-planeA boundary line and the side of it that satisfies the inequality.
✓The feasible regionThe intersection of all of them, drawn for Ravensworth at Show = 0.
✓Why a corner is optimalKeep improving until a wall stops you, and at least one corner is always best.
✓What that buysA finite list of candidates instead of a continuous region, tested live against random plans.
✓Binding is touchingMilling and protein are touched exactly; blending has 0.2414 hours spare.
✓Finding a corner is solving equationsTwo walls as equalities, then a feasibility test to discard crossings outside the region.
✓Where the picture stopsDrawable at two variables, imaginable at three, gone after that.
◐Ties along an edgeNamed, with the solver's own deliberate tie: max x + y subject to x + y at most 10.
◐What a binding wall is worthArgued geometrically tonight. Priced, with its range, in session 4.
○How a solver walks the cornersSlack variables, the tableau and pivoting are session 3.
○Interior point methodsNamed in the disagreement as a family that never visits a corner. Not taught here.
○Whole tonnesInteger plans sit inside the region, not on its corners. Session 5.
Take this with you

Cheat sheet

An inequality is a line and a side. The side is the half that matters.
The region. Everything that satisfies all of them at once. Flat-sided, by construction.
The corner argument. Keep improving until a wall stops you, then slide along it until walls meet.
The precise claim. At least one corner is optimal, which stays true when a whole edge ties.
Binding means touching. Milling and protein at Ravensworth. Two walls, one corner, one plan.
Slack means room. Blending has 0.2414 hours unused, so more of it changes nothing.
A corner is an equation. Two walls as equalities, solved, then tested against every other wall.
The picture runs out at three. The result does not, which is why the next session is algebra.