PrepShorts · Study sheet · Class 12 Mathematics · Chapter 12, Linear Programming
Chapter 12 · Linear Programming
Optimisation and the linearity that makes this class tractable, and how a stated situation becomes decision variables, constraints and an objective
This video could not be loaded. Reload the page to try again.
Sign in with Google23 min.
Keep your place in this chapter — sign in, it’s free.Sign in
The idea
The chapter names its subject twice over — an optimisation problem first, a linear programming problem second — and that order carries the first half of the explanation, because the second name is not a label but a pair of conditions to be checked before anything is drawn. Every relation in the running problem happens to be a straight-line one, and each of those straight lines is an assumption about the world rather than a fact: a table costs the same whether it is the first bought or the twentieth, a chair earns the same however many are already on the shelf. The chapter asserts all of that and justifies none of it. The other word of the name misleads in a different direction entirely — here programming is the drawing up of a plan, a usage older than the machines, and a student who has written code misreads the title from the first sentence and never gets corrected. The second half is where the answer is actually decided, and it is the step the chapter drills least: it turns its one worded paragraph into symbols, notices that the two numbers feeding the objective are the two profits while the two feeding the money limit are the two prices, and then never asks anyone to do it again. Nothing later on the page catches a student who swaps them. A read-back accounting for every number in the paragraph exactly once, and a units test on each constraint. Those two are the entire self-check available before the drawing starts, and once it starts a wrong constraint looks precisely like a right one.
What you should be able to do
- Name the larger family a linear programming problem belongs to, and say what membership of that family requires
- State the two extra demands that cut the family down to the class this chapter can solve
- Identify, in a stated situation, which quantity is being pushed up or down and which quantities the chooser actually controls
- Introduce a letter for each unknown quantity and state, in a sentence, exactly what that letter counts
- Turn each stated limit into one inequality, with the correct direction of the inequality sign
- Simplify a constraint by dividing through by a common positive factor, and say why the purchases it allows are unchanged
- Check that the two sides of a constraint carry the same unit before believing it
- Assemble the objective from the rates that pay, not from the rates that cost, and say which letters in it are fixed by the problem and which the solver sets
- Distinguish a constraint from the objective, and explain why the two are never interchangeable
- Explain why the non-negative conditions are constraints and not a separate kind of thing, and why the chapter still gives them a name of their own
- Set the finished problem out in the chapter's own layout — an instruction to maximise or minimise, then the linking phrase, then the list
- Read the finished formulation back against the original paragraph and account for every number in it
- Read the chapter's formal definition clause by clause and match each clause to a part of the running example
- Say what the word programming meant when the subject was named, and what it does not mean
- Place the subject's origin in the nineteen-forties and name the method this chapter does not teach
- State the scope of what follows — two variables, a graph, and two results that arrive unproved — and recognise that the chapter supplies exactly one worked formulation and no practice items at all
Words to know
| Term | Definition in one line | First introduced |
|---|---|---|
| optimisation problem | any problem that asks for the largest or smallest value of a quantity under stated limits | printed in this chapter (§12.1 and §12.2, Part II pp. 394 and 396) |
| linear programming problem | an optimisation problem whose objective and whose limits are all linear, with the variables not allowed to go negative — and the finished object a formulation produces | printed in this chapter (§12.1, Part II p. 394; defined in §12.2, Part II p. 396) |
| mathematical formulation | the act of turning the stated situation into letters, inequalities and one expression to optimise | printed in this chapter (the §12.2.1 heading, Part II p. 395) |
| objective function | the linear expression in the chosen variables whose value is to be pushed up or down | printed in this chapter (§12.2, Part II p. 396, and in the Summary, Part II p. 404) |
| decision variables | the quantities the chooser is free to set, which the formulation gives letters to | printed in this chapter (§12.2, Part II p. 396, and in the Summary, Part II p. 404) |
| constraints | the inequalities, equations or restrictions the chosen values must respect | printed in this chapter (§12.2.1 and §12.2, Part II pp. 395–396) |
| linear constraints | the chapter's name for that set of inequalities when it wants to stress their linearity | printed in this chapter (§12.2, Part II p. 396, and in the Summary, Part II p. 404) |
| non-negative constraints | the pair holding both letters at or above zero, under the name printed beside the first two numbered lines of the formulation | printed in this chapter (§12.2.1, Part II p. 395) |
| non-negative restrictions | the same pair one page later, under the chapter's other name for them | printed in this chapter (§12.2, Part II p. 396) |
| investment constraint | the chapter's own label for the money limit in the running example | printed in this chapter (§12.2.1, Part II p. 395) |
| storage constraint | the chapter's own label for the shelf limit in the running example | printed in this chapter (§12.2.1, Part II p. 395) |
| subject to | the phrase that separates the thing being optimised from the list of limits | printed in this chapter (§12.2, Part II p. 396) |
| optimal value | the largest or the smallest value the objective reaches, whichever the problem asked for | printed in this chapter (§12.2, Part II p. 396, and Part II p. 398) |
| graphical method | settling the problem by drawing it, which is the only method this chapter teaches | printed in this chapter (§12.1 and §12.2.2, Part II pp. 394 and 397) |
| programme | the plan of action the word programming originally referred to | printed in this chapter (§12.2, Part II p. 396) |
| simplex method | the iterative procedure named in the Historical Note and taught nowhere in this book | printed in this chapter (Historical Note, Part II p. 405) |
| transportation problem | the shipping question the Historical Note calls the first linear programming problem | printed in this chapter (Historical Note, Part II p. 405) |
| feasible | said of a choice that breaks none of the constraints | printed in this chapter, though only from §12.2.2 onward (Part II p. 397); this topic may name it but should not lean on it |
| linearity | the property the whole method rests on — every relation a straight-line one | an added noun; the chapter uses the adjective linear constantly and never forms this noun |
| units check | confirming that both sides of a constraint measure the same kind of thing | an added device; the chapter performs no such check anywhere |
| word problem | a problem stated in prose rather than in symbols | an added phrase, not printed in this chapter |
Where people slip up
- "Programming means writing a computer program." It does not, and the chapter says so in the same sentence in which it glosses linear. The word means drawing up a plan of action, and it predates the machines. Left unaddressed this misreading survives the whole chapter.
- "Linear just means the answer comes out neat." Linear is a condition on the problem, checked before anything is drawn: every constraint a straight line, the objective a straight-line expression, no squares, no products of the two variables, no rate that changes with quantity. If it fails, nothing in this chapter applies.
- "Every optimisation problem is a linear programming problem." The chapter is explicit that this is one class among many; it says outright that the class is special. Any problem asking for a largest or smallest is an optimisation problem; only the ones that pass the linearity check are in this chapter.
- "A letter is a letter; I do not need to say what it counts." Every later check depends on the meaning. Without it the coefficient of one in the shelf constraint cannot be justified, the non-negative conditions cannot be motivated, and the final pair of numbers cannot be read back as a purchase.
- "Dividing the constraint by five hundred changes the problem." It does not, because five hundred is positive. Say this in one line, because a student who distrusts the step will keep the large numbers and mis-plot the line's intercepts.
- "Both limits are about money." One is money and one is space. They happen to bind at different places, which is exactly why the answer is a mixture rather than all of one item. If a student treats them as the same kind of limit, the shelf constraint looks redundant.
- "The inequality signs are obvious from the words." The words of this one paragraph give caps, so every limit in it points the same way; at least would point the other. Verified by reading all ten printed items: five of the ten items of the chapter's own exercise carry at least one limit pointing the other way — three of the five state every one of their limits that way and two mix the directions in a single item. A student who has watched only this formulation will assume caps are the only kind there is.
- "The objective function is one of the constraints." It is the one expression that is not constrained — it has no inequality sign attached and it is not required to be anything in particular. Students who list it among the inequalities shade a half plane for it and get a smaller region than the problem has.
- "The constants in the objective are the costs." They are built from whatever the question asks to be made large or small, which here is profit. In the running example they are the two profit figures, and the costs live in a constraint instead. A student who swaps them gets a legitimate-looking graph and a wrong answer, and nothing on the page catches it. This is the most common formulation error in the whole chapter and it is invisible once the graph is drawn.
- "Non-negativity is a technicality you can leave out." It is a pair of constraints like any other, it does real work on the drawing — it is what confines the region to one quadrant — and the chapter gives it a name of its own. Drop it and half the corner points disappear.
- "The non-negative conditions come from the dealer." They come from what the letters count. Nothing in the paragraph forbids a negative table; arithmetic does.
- "Guessing three plans was a waste of time." It is what establishes that the answer is not at an extreme — neither all tables nor all chairs wins — and it is why the rest of the chapter is needed.
- "Since the chapter's examples are already in symbols, formulating is the easy part." It is the part the chapter does not drill at all. Every item on the page starts after this step is finished. A student sitting an examination that asks for a formulation has practised it exactly once, by watching.
- "There is only one method, since only one is taught." The chapter names the simplex method in its Historical Note and describes it as the efficient one, and it says in its introduction that other methods exist. What is on offer here is the drawing, and the drawing works only in two variables.
- "The Historical Note's diet and shipping problems are exercises later in the chapter." They are not. They appear once, as history, and this edition contains no worked problem of either kind. See Notes.
Ask your teacher a person
Your teacher reads this and writes back, usually within a day. For an instant answer, use Ask the video in the sidebar.
Your class sees the question and the answer. Only your teacher sees that it was you.
No questions on this topic yet.
Worked answers: Exercise 12.1
Transcript3,321 words
A dealer sells tables and chairs, and nothing else. He has fifty thousand rupees to spend. His shop has room on the shelf for sixty pieces of furniture, counting tables and chairs together. A table costs him two thousand five hundred rupees to buy, and a chair costs him five hundred. When he sells them again he makes two hundred and fifty rupees on a table and seventy five on a chair.
How many of each should he buy? That is the whole question, and the six numbers in it are the only numbers there will ever be. One capital, one shelf, two prices, two profits. Every single thing that appears later has to come from one of those six, and anything that does not is a mistake. The paragraph also ends with an assumption, quietly: that everything he buys, he sells. It is doing real work. Without it the profit on a table would not be a number you could multiply by, and nothing that follows would get off the ground.
Before any of the machinery, guess. Plan one: spend it all on tables. Fifty thousand divided by two thousand five hundred is twenty tables. They fit easily — twenty pieces on a shelf that holds sixty, so forty spaces sit empty. Twenty tables at two hundred and fifty rupees each is five thousand rupees of profit. Plan two: spend it all on chairs. The money would run to a hundred chairs, but the shelf stops him at sixty, and that leaves twenty thousand rupees unspent. Sixty chairs at seventy five is four thousand five hundred.
Plan three, a mixture: ten tables and fifty chairs. That is exactly sixty pieces and exactly fifty thousand rupees — nothing left over on either side. And the profit is six thousand two hundred and fifty. So the mixture beats all tables by one thousand two hundred and fifty, and beats all chairs by one thousand seven hundred and fifty. Which settles one thing immediately: the answer is not at either end. You cannot get it by picking the more profitable item and buying as many as you can.
Three guesses do not tell you the best plan. They tell you that guessing is not going to finish the job. Step back and name what kind of question this is, because the naming is two steps and almost everyone takes only the second. Any question that asks for the largest or the smallest value of something, under stated limits, is an optimisation problem. That is a very large family. The cheapest route, the strongest bridge for a fixed weight of steel, the fastest schedule — all optimisation.
Inside that family sits a much smaller one, and it is the only one this topic can settle by drawing a picture. A linear programming problem is an optimisation problem where everything in sight is a straight-line relation, and where the quantities are not allowed to go negative. The order matters. Meet the special case first and the word linear sounds decorative, like a label somebody stuck on. Meet the family first and it is what it actually is — a condition, to be checked before anything gets drawn.
And the other word of the name misleads in the opposite direction. Programming here means drawing up a programme, a plan of action. The word is older than the machines and has nothing to do with writing code. Anyone who has written code reads the title wrongly on the first page and is never corrected. So: what has to be linear, and how would you know? Not by looking at the algebra. A rule is linear when it does two things. Buy one lot, then buy another, and the rule has to give the same answer as buying both together. And buy three times as much and it has to give three times as much.
Take those two tests to the dealer's three relations. Money spent, shelf used, profit earned: over twenty eight thousand five hundred and sixty one pairs of purchases and eight hundred and forty five scalings, all three pass both tests every time. But look at why each one passes, because each is an assumption about the world and not a fact. Money spent is linear because a table costs the same whether it is the first he buys or the twentieth. Shelf used is linear because a table takes one space and always one. Profit is linear because the profit per table does not fall as the shop fills up.
None of those three is guaranteed by anything. Give him a bulk discount of two hundred rupees a table after the tenth, and the money rule stops adding — it fails at sixteen thousand seven hundred and thirty one of those pairs, and stops scaling at three hundred and thirty eight of the scalings too. Make the shelf harder to pack as it fills, or let the market flood so profit per chair drops, and each of those fails at twenty eight thousand two hundred and twenty four pairs.
Any one of those changes and none of what follows applies to the problem any more. Linear is a condition on the world. Check it first. Now turn the paragraph into symbols, which is where the answer is actually decided. Let x be the number of tables he buys, and let y be the number of chairs he buys. That second half of the sentence — the number of tables he buys — is not decoration, and leaving it out is the most expensive habit in this topic. A letter with no stated meaning gives you constraints you cannot check, an objective nobody can read back, and a final pair of numbers that is not obviously a purchase at all.
Write it down and keep it on the page. Everything for the rest of this video is checked against it. These two are the decision variables — the quantities the dealer is actually free to set. He is not free to choose the price of a table or the size of his shelf. He chooses x and he chooses y, and that is the whole of his freedom. The first limit is money. He spends two thousand five hundred rupees on each table and five hundred on each chair, and the total cannot exceed fifty thousand.
Two thousand five hundred x plus five hundred y is at most fifty thousand. The sign points that way because the words say he has fifty thousand — a cap, not a target. That is worth saying out loud, because every limit in this one paragraph is a cap, and a student who has only ever seen this formulation will assume caps are the only kind there is. The words at least point the other way, and plenty of questions use them.
Now the step the page takes without comment: divide through by five hundred. Five x plus y is at most a hundred. Why is that allowed? Because five hundred is positive. Multiply or divide both sides of an inequality by a positive number and the verdict on every single candidate is unchanged. That is not a thing to take on trust. Every purchase was put to both lines — whole numbers, halves, quarters, and purchases with negative entries, more than seventy five thousand of them in total — and the two lines disagree about exactly none.
It really is the sign that does the work, and not the number. Scale both sides by any of eight different positive factors, fractions included, and the verdict holds at all fifty nine thousand and forty eight trials. Do it with a negative factor and leave the sign where it was, and the verdict reverses at twenty nine thousand four hundred and forty of twenty nine thousand five hundred and twenty four — every purchase except the ones that spend the money exactly.
The second limit is space. The shelf holds sixty pieces. x plus y is at most sixty. Both coefficients are one, and that is worth a pause, because a student who has just written two thousand five hundred and five hundred sees a one and reads it as a number somebody forgot to fill in. It is not missing. It is there because a table takes one space on the shelf and a chair takes one space on the shelf. Count the pieces one at a time instead of multiplying, over every purchase on the grid, and you get the same answer every time.
And notice these two limits are limits of different kinds. One is money and one is room, and they bite in different places. Of the whole purchases on the grid, two hundred and twenty are ones the money allows and the shelf refuses; a thousand and forty are ones the shelf allows and the money refuses; eight hundred and fifty one break neither. If the two limits were really the same kind of limit, one of them would be doing no work. They are not, and neither is redundant. That is precisely why the answer came out a mixture.
Two more conditions, and they come from somewhere different. x is at least nothing, and y is at least nothing. These are the non-negative constraints, and they get a name of their own and are usually written first. They are constraints like any other — the separate name is emphasis, not a different kind of object. That is a reading, and worth saying so. Where they come from is the interesting part. They do not come from the dealer. Nothing in that paragraph forbids a negative table. The money limit and the shelf limit between them let in three thousand nine hundred and six purchases with a negative entry, and not one word of the question rules any of them out.
They come from what the letters count. x counts tables. You cannot buy minus four tables. The floors are arithmetic, not commerce, and they are exactly why you must say what each letter counts before you write anything else. And they do real work. Drop them and four thousand seven hundred and fifty seven purchases become allowed where eight hundred and fifty one were — more than five times as many.
Now, on this particular problem the best answer happens not to move when you drop them, and it is worth being honest about that. That is luck. Give the chair the table's profit and the table the chair's, and with the floors the best is fifteen thousand rupees at sixty chairs; without them the best simply runs away — fifteen thousand, then thirty two thousand five hundred, then sixty seven thousand five hundred as you look further out. Nothing stops it.
One thing left, and it is the one that decides the answer. What is being made large is profit. Two hundred and fifty rupees on every table and seventy five on every chair, so the profit is two hundred and fifty x plus seventy five y. Call it Z. This is the objective function, and it is not a constraint. It has no inequality sign attached and it is not required to be anything in particular — it is the one expression on the page that is being read rather than obeyed.
Students who list it among the inequalities and shade a half plane for it get a smaller region than the problem has. Shade it at five thousand, say, and the region loses a hundred and forty nine of its eight hundred and fifty one purchases — including, as it happens, the best one. Written in general the objective is a constant times x plus another constant times y. Two of those four symbols are fixed by the problem and two are chosen by the solver, and it is worth being clear which is which. The constants come from the paragraph. The variables are his to set.
Which brings us to the single most common formulation mistake there is, and it is invisible once the graph is drawn. The dealer's paragraph gives four rates. Two thousand five hundred and five hundred are what the furniture COSTS. Two hundred and fifty and seventy five are what it EARNS. The costs are already spent — they live inside the money constraint. The objective is built from the other two.
Put the prices in the objective by mistake and you are asking a perfectly sensible question, just not the one you were asked. You are asking which purchase spends the most money. Here is what that gets you. The swapped objective does not even point at one purchase. It comes to fifty thousand at eleven different purchases — the whole edge where the money runs out — and the real profits along that edge run from five thousand at one end to six thousand two hundred and fifty at the other.
So a student who swaps them and reads off the wrong corner, twenty tables and no chairs, loses one thousand two hundred and fifty rupees of profit. And nothing on the page catches it. The graph looks right, the region is right, the arithmetic is right, the answer is wrong. Set the whole thing out now, the way it is meant to be set out. Maximise Z equals two hundred and fifty x plus seventy five y.
Subject to: two thousand five hundred x plus five hundred y at most fifty thousand; x plus y at most sixty; and x and y both at least nothing. Three parts. An instruction saying what to do with what. The linking phrase, subject to. Then the list. One thing to expect. The order of the list carries no meaning, and you will see it written both ways — the two floors first while the constraints are being built up, and last when the finished programme is set out. Both are correct. Nobody is wrong. It is an ordering, nothing more.
This object has a name too. It is a linear programming problem, and that phrase names both the question and the written thing you have just produced. You have a formulation. Is it right? Once the drawing starts, a wrong constraint looks exactly like a right one, so whatever checking you are going to do has to happen now. There are two checks available, and between them they are the whole of the safety net.
The first is a read-back. Take every number from the paragraph and find it in the programme. Fifty thousand: in the money constraint. Two thousand five hundred and five hundred: in the money constraint. Sixty: in the shelf constraint. Two hundred and fifty and seventy five: in the objective. Six numbers, six homes, each exactly once. Nothing in the paragraph unused, and nothing in the programme unaccounted for once you set aside the two coefficients of one and the two floors, which came from the letters rather than from the question.
Now run that same check on the swapped version. The two prices turn up twice each and the two profits never turn up at all. The read-back catches it instantly. One warning about when to run it. Run it on the form with the true prices in it, not the divided form. Divide first and five, one and a hundred are numbers the paragraph never gave you, and the audit reports three of the six as missing on a formulation that is perfectly correct.
The second check is units, and it is one almost nobody performs. A unit is rarely written beside a term at all, and never checked. Every term in a constraint has to measure the same kind of thing, and so does the number on the right. The money constraint: rupees per table times a count of tables is rupees. Rupees per chair times a count of chairs is rupees. Fifty thousand is rupees. All three agree.
After the division, all three are counted in lots of five hundred rupees instead — which is a neat way of seeing why the division is harmless. Both sides were rescaled the same way. The shelf constraint: pieces, pieces, pieces. The objective: rupees. Now try writing a constraint that puts a price against a shelf space, and it refuses outright. It is wrong before you draw a single line. But here is the honest limit of the test, and it is the reason you need both checks. Profits and prices are both measured in rupees per item. An objective built from the prices passes the units test exactly as cleanly as the right one does. The units test does not catch the swap. The read-back does. They catch different mistakes, which is why neither one replaces the other.
With all of that in hand the formal definition reads as four conditions rather than as one long sentence, and all four have to hold at once. One: an optimal value is wanted — a largest or a smallest. For the dealer, a largest profit, and there is exactly one purchase that reaches it. Two: the thing being optimised is a linear function of the variables. The profit adds and scales, checked, not assumed.
Three: the variables are held at or above nothing. The two floors. Four: a set of linear inequalities has to be satisfied. Money and shelf, and both of those add and scale as well. Four conditions, four matches. And notice the parts get defined before the whole — objective function first, constraints second, and the problem they belong to third. Read them in that order and you are assembling something before you know what it is for. It is worth going the other way round.
A short history, because it explains the strange name. The subject came out of the planning of operations during the Second World War. In nineteen forty one the first problem of this kind was formulated, by a Russian mathematician and an American economist working separately — a question about shipping goods at least cost. In nineteen forty five an English economist asked for the cheapest diet that still met every nutritional requirement. In nineteen forty seven the simplex method arrived, a step-by-step procedure that finishes in finitely many steps. In nineteen seventy five the Nobel prize in economics was shared for this work.
Two things follow from that. The simplex method is how these problems are actually solved at any size, and it is not what you are about to be taught. And the shipping problem and the diet problem are history here rather than exercises — at this level you will not meet either of them worked through. What is taught here is the drawing, and the drawing only works with two variables.
So, what to carry out of this. Optimisation is the family; linear programming is the small part of it where every relation is a straight line and nothing goes negative, and that is a condition to be checked, not a label. Say what each letter counts before you write anything else. Build the objective from what the question wants made large, not from the rates that happen to be lying nearby. Dividing a constraint through by a positive number changes nothing, and by a negative number changes everything.
And run both checks before you draw. The read-back finds numbers in the wrong place. The units test finds terms that cannot belong together. After the drawing starts, neither mistake looks like a mistake. One last thing, and it is about the practice rather than the mathematics. Every worked problem you are about to meet begins with the formulation already done for you. The step this video is about is the one you will be asked for in an examination and the one you will have seen performed exactly once. Take a worded situation, any worded situation, and formulate it yourself.
Where this fits
Either side of this one
- Skew lines, what shortest distance can mean when two lines never meet, and computing it in both the skew and parallel casesClass 12 · Ch 11, Three Dimensional Geometry
- The feasible region as the overlap of the half planes the constraints allowClass 12 · Ch 12, Linear Programming