12. Linear Programming
12.1 Chapter Opener: Introduction and Optimization Foundations
Chapter 12
Linear Programming
Big idea: when time, material or money are limited, many plans are possible but only one is best. Linear programming finds that best plan with a picture and a short list of corner points.
A small workshop has two products and only a few machine hours each week. The owner can make more of one product and less of the other. Every mix is a plan. Some plans waste time. Some plans break the limits. One plan earns the most.
How can the owner be sure of finding that one plan? Trying every mix by hand is hopeless. There are far too many of them. This chapter builds a method that never misses.
The method has three stages. First, turn the story into mathematics. Second, draw the set of plans that obey every limit. Third, test a short list of corner points and read off the best value.
In this chapter you will learn:
- the decision variables, objective function and constraints of a linear programming problem;
- the feasible region: the picture of all plans that obey every limit;
- the corner-point method, which finds the best plan without trying every plan;
- what to do when a region is unbounded, has many best plans, or is empty.
Limits draw a shape. The best plan always sits at a corner of that shape.
A small workshop makes two products, P and Q. Making one P needs hours of cutting and hours of finishing. Making one Q needs hours of cutting and hours of finishing. Each week the workshop has hours of cutting time and hours of finishing time.
Each P gives a profit of units. Each Q gives units. The owner chooses how many of each to make. The question is simple: which mix gives the largest profit without breaking either time limit?
| One P needs | One Q needs | Available per week | |
|---|---|---|---|
| Cutting (hours) | |||
| Finishing (hours) | |||
| Profit (units) |
Read the table down each column. The P column says one P uses cutting hours and finishing hours. Each row will later become one mathematical limit.
Let us try five mixes and test each one. A plan is allowed only if it fits inside both time limits.
| Plan (P, Q) | Cutting hours used | Finishing hours used | Allowed? | Profit |
|---|---|---|---|---|
| Yes | ||||
| Yes | ||||
| Yes | ||||
| Yes | ||||
| No | — |
Check one row by hand. The plan uses cutting hours. That exactly matches the available. It uses finishing hours. That exactly matches the available. So it is allowed, and it gives profit units.
The plan needs cutting hours. Only are available. So it is not allowed, even though its profit would be high. A plan must pass the limits first. Profit comes second.
The feasible region of the workshop problem, a shaded four-sided shape with corners at (0, 0), (8, 0), (4, 6) and (0, 8). Five trial plans are marked: (8, 0), (0, 8), (4, 6) and (2, 2) lie inside the shaded shape, while (5, 5) lies outside it, beyond the cutting-time line.
Read the figure slowly. The shaded shape holds every allowed plan. Its slanted sides are the two time limits. The four allowed trial plans sit inside it. The rejected plan sits outside, past the cutting-time side. The plan sits exactly at a corner, where both limits bind.
Among the four allowed trials, earns the most. But is it the best of all possible plans? There are infinitely many mixes when fractions are allowed. Even with whole numbers only, the list is far too long to check by hand.
We need a method that is sure to find the best plan. Linear programming is that method. It works whenever two things are true:
- [Board Standard] you want to make one quantity as large or as small as possible, for example profit or cost;
- [HOTS] every limit is a straight-line condition such as .
Problems like this appear everywhere. A farm mixes feeds to meet nutrition needs at the lowest cost. A depot sends goods by several routes at the least shipping cost. A factory shares machine time between products for the most profit.
In this chapter we study problems with two unknowns. Then every limit is a line, and the whole problem can be drawn as a picture. The answer is read from that picture.
Trying a few plans can miss the best one. Linear programming checks every plan at once, through a picture.
Test yourself on the same workshop. Show each small step.
Linear programming grew out of the need to plan large operations with limited resources. It became important during the Second World War, when planners had to decide how to use scarce supplies, vehicles and workers as well as possible.
- About 1941: the mathematician Leonid Kantorovich and the economist Frank Hitchcock, working separately, each described the transportation problem: how to send goods from several sources to several destinations at the least total cost.
- 1945: the economist George Stigler described the diet problem: how to choose foods so that nutrition needs are met at the lowest cost.
- 1947: George Dantzig invented the simplex method, a step-by-step procedure that solves any linear programming problem in a finite number of steps, whatever the number of variables.
- 1975: Kantorovich and Tjalling Koopmans received the Nobel Prize in Economics for their pioneering work on the best use of resources.
With computers, the simplex method and later methods now solve problems with thousands of variables, in industry, transport, energy and many other areas. The two-variable pictures in this chapter show the main idea behind all of them: the best plan sits at a corner of the region of allowed plans.
12.2 Linear Programming Problems and Mathematical Formulation
Every linear programming problem (LPP) has the same four parts. Look back at the workshop and give each part its name.
- [Concept] Decision variables. The numbers you can choose. Here = number of P made and = number of Q made.
- [Board Standard] Objective function. The quantity you want to make as large or as small as possible. Here the profit . To optimise means to maximise or minimise.
- [Board Standard] Constraints. The limits. Here cutting time and finishing time .
- [HOTS] Non-negativity conditions. You cannot make a negative number of products: and .
In simple words: the decision variables are your choices, the objective function is your goal, and the constraints plus non-negativity are your rules. Every LPP in this chapter has exactly this shape.
The word linear says that the objective function and every constraint are straight-line expressions. Each variable appears only to the first power. Variables are never multiplied together.
| Allowed (linear) | Not allowed (not linear) |
|---|---|
| (variables multiplied) | |
| (objective) | (a square appears) |
| (a root appears) |
Only straight-line conditions cut the plane with a straight line. That is why the picture method of this chapter works. Curved conditions need other methods, which this chapter does not cover.
- [Concept] A feasible solution is any pair that satisfies all constraints and the non-negativity conditions.
- [Board Standard] The feasible region is the set of all feasible solutions.
- [HOTS] An optimal solution is a feasible solution that gives the best value of the objective function. That best value is the optimal value.
Notice the order. First a plan must satisfy every limit. Only then can it compete for the best value. “Feasible” means allowed. “Optimal” means best among the allowed.
The line splits the plane into two sides. One side satisfies and the other does not. To find which side, test a point. The origin gives , which is true, so the origin side is the allowed side. The point gives , which is false.
Why does this test work? A straight line divides the plane into two connected pieces. The expression changes smoothly. So it is below on the whole of one side and above on the whole of the other. One test point tells you which side is which.
To draw the line, use its intercepts. Set : then , so . Set : then , so . The line joins to .
A triangle with corners at (0, 0), (8, 0) and (0, 12), shaded. The slanted side lies on the line 3x plus 2y equals 24. Points inside the triangle satisfy the constraint; points beyond the slanted line do not.
Read the figure step by step. Find the two intercepts and on the axes. The slanted line joins them. The shaded triangle is on the origin side. The allowed test point sits inside it. The rejected point sits beyond the slanted side.
Now combine two limits: and , with and . Each limit allows one side of its line. The feasible region is where both allowed sides overlap.
Draw each line by its intercepts. For : setting gives , and setting gives . For : setting gives , and setting gives .
The four corners are where pairs of boundary lines meet: , (where meets ), (where meets ), and the crossing of the two slanted lines. Doubling the second equation gives . Subtracting the first equation leaves , so and . The crossing is (confirmed by computer).
The feasible region of two limits combined: a shaded four-sided shape with corners at (0, 0), (5, 0), (4, 2) and (0, 4). Two slanted lines cross at (4, 2): 2x plus y equals 10 and x plus 2y equals 8. The shaded shape is the overlap of the two allowed sides in the first quadrant.
Read the figure the same way. Each slanted line keeps its origin side. The shaded shape is the overlap, kept inside the first quadrant by and . Its corners are exactly the four points found above. Every later problem in this chapter follows this pattern: draw each line, keep the correct side, and read the overlap.
When several constraints combine, the feasible region is always a convex polygon (or an unbounded convex shape): a shape with no dents, where the straight line between any two of its points stays inside it. Dent-free shapes matter, because the corner-point method of Section 12.2.2 depends on them.
One limit keeps one side of a line. All limits together keep the overlap, and that overlap has no dents.
Work with the limits and , with .
12.3 Mathematical Formulation of Real-World Scenarios
To formulate a problem means to turn its words into mathematics. You do not solve anything yet. You only write down the choices, the goal and the limits. Follow these four steps every time:
- [Concept] Step 1. Read the problem. Decide what you are choosing. Name these decision variables and , and say what each means, with units.
- [Board Standard] Step 2. Write the objective function. Say whether to maximise it or minimise it.
- [Board Standard] Step 3. Write one constraint for each limit. Check the direction: “at most” gives , and “at least” gives .
- [HOTS] Step 4. Add and .
This is the workshop from Section 12.1. Step 1: let = number of P made per week and = number of Q made per week.
| Product P | Product Q | Available | |
|---|---|---|---|
| Cutting (hours) | |||
| Finishing (hours) | |||
| Profit (units) |
Step 2: the goal is the largest profit, so maximise . Steps 3 and 4: each table row gives one constraint. The problem is:
- [Concept]
- [Board Standard]
- [HOTS]
A quick check of one plan: making of P and of Q uses cutting hours and finishing hours. Both are within the limits, so the plan is allowed (confirmed by computer), and it gives units.
Notice what the check does. It substitutes the plan into every limit. It never skips a limit. Make this a habit: every plan you test must pass every line.
A farm mixes two foods, F1 and F2, for its animals. Each kilogram of F1 gives units of protein and unit of iron. Each kilogram of F2 gives unit of protein and units of iron. Each day the animals need at least units of protein and at least units of iron. F1 costs units per kilogram and F2 costs units per kilogram. Find the cheapest mix.
Step 1: let = kilograms of F1 per day and = kilograms of F2 per day. Step 2: the goal is the smallest cost, so minimise . Step 3: the needs are “at least”, so each need is a lower bound. The constraints use :
- [Concept]
- [Board Standard]
- [HOTS]
Check the mix , . Protein: , which is at least . Iron: , which meets the need of exactly. The mix is allowed (confirmed by computer), at a cost of units.
Compare with Example 1. A production problem has “at most” limits and maximises. A diet problem has “at least” needs and minimises. The direction of the inequality follows the words, not the example number.
A shop needs at least boxes of goods. Depot A can send at most boxes and depot B can send at most boxes. Sending a box from A costs units and from B costs units. How should the shop order to pay the least?
Step 1: let = boxes from A and = boxes from B. Step 2: minimise the shipping cost . Step 3 needs care, because this problem mixes both directions:
- [Concept]
- [Board Standard]
- [Board Standard]
- [HOTS]
Read each line in words. The first says depot A sends at most boxes. The second says depot B sends at most . The third says the total is at least . One problem can carry both and limits.
Check the order of boxes from A and from B. The total is boxes, which is at least . Both depot limits hold. The order is allowed (confirmed by computer), at a cost of units.
A print shop makes posters ( per day) and banners ( per day). A poster needs unit of ink and units of press time. A banner needs units of ink and unit of press time. The shop has units of ink and units of press time each day. A poster gives profit units and a banner gives . Plan the day for the most profit.
Step 1: the choices are the daily counts and . Step 2: maximise . Steps 3 and 4:
- [Concept]
- [Board Standard]
- [HOTS]
Check the plan of posters and banners. Ink: . Press: . Allowed (confirmed by computer), with units.
A look ahead at the print-shop feasible region: a shaded four-sided shape with corners at (0, 0), (19, 0), (12, 14) and (0, 20). The slanted sides lie on the lines x plus 2y equals 40 (ink) and 2x plus y equals 38 (press time). The sample plan (10, 10) sits inside the shape.
Read the figure as a promise. The shaded shape holds every allowed daily plan. The sample plan sits inside it. The corner will turn out to be the best plan of all, worth units. The next section shows how corners give the answer.
Name the choices, write the goal, turn each limit into one line, and never forget x, y ≥ 0.
A kitchen makes soup packs ( per day) and salad boxes ( per day). A soup pack needs units of stock and unit of packing time. A salad box needs units of stock and units of packing time. Stock is limited to units and packing time to units per day. A soup pack gives profit units and a salad box gives .
Formulate each problem from its words. Then test the given plan.
12.4 Graphical Method for Bounded Feasible Regions and Corner Points
With two variables we can solve an LPP by drawing it. The method has six steps. Example 1 shows every step. Later examples follow the same steps, with shorter comments.
- Step 1. Formulate the problem (Section 12.2.1).
- Step 2. Draw each constraint as a straight line. Use a test point, usually , to decide which side is allowed. The feasible region is where all allowed sides overlap, inside , .
- Step 3. Find the corner points of the region: the points where two boundary lines meet. Solve each pair of line equations together.
- Step 4. Calculate the objective function at every corner point.
- Step 5. Compare the values. The rule below tells you how, for bounded and unbounded regions.
- Step 6. Write the answer in words, with the units.
Step 1. Maximise subject to , , , .
Step 2. Draw the lines and by their intercepts. The first joins to . For the second, setting gives , so ; setting gives , so . It joins to . The origin passes both tests ( and ), so both allowed sides face the origin. Their overlap is the shaded shape below.
Step 3. The corners on the axes are easy: , (where meets ) and (where meets ). The fourth corner is where the two slanted lines meet. Halve the second equation to get . Subtract this from : , so . Then , so . The corner is (confirmed by computer).
The feasible region of the workshop problem, a shaded four-sided polygon with corners at (0, 0), (8, 0), (4, 6) and (0, 8). Two solid lines mark its slanted sides, 3x plus 2y equals 24 and 2x plus 4y equals 32. Three dashed parallel lines show profit values 200, 320 and 460. The line for 460 just touches the corner (4, 6).
Read the figure in three passes. First, find the four labelled corners of the shaded shape. Second, follow each slanted solid line: it is one time limit, and the shape lies on its origin side. Third, look at the three dashed profit lines. They are parallel. As the profit value grows from to to , each line sits further from the origin. The line only just touches the shape, at the single corner . No higher profit line can reach the shape at all.
Step 4. Evaluate at each corner, showing the substitution:
| Corner point | Substitution | Z = 40x + 50y |
|---|---|---|
Step 5. The region fits inside a small box, so it is bounded. The rule for bounded regions (Theorem 2 below) says the largest corner value is the maximum. Step 6. The largest value is at . So the workshop should make of P and of Q each week, for a profit of units.
Sanity check: does satisfy every limit? Cutting: . Finishing: . Both hold with equality, and . The answer passes all four lines.
Think of the profit lines . For each value of it is a straight line, and all these lines are parallel. As grows, the line slides away from the origin. The best plan lies on the last such line that still touches the feasible region. Because the region is a polygon with straight sides, the last point touched is a corner, unless the sliding line lands exactly along a whole side, in which case both ends of that side are corners. The picture above shows this sliding for , and .
This idea is stated in two theorems. We accept them without a long proof.
Theorem 1. If a linear programming problem has an optimal value, then it is attained at a corner point of the feasible region.
Theorem 2. If the feasible region is bounded (it fits inside some circle), then the objective function has both a maximum value and a minimum value, and each is attained at a corner point.
If two corners both give the optimal value, then every point on the line segment between them is also optimal. Example 4 below shows this.
Slide the profit line until it last touches the shape. That touching point is a corner, and it is the answer.
12.5 Unbounded Feasible Regions and Half-Plane Verification Tests
Step 1. Minimise subject to , , , (the diet problem from Section 12.2.1).
Steps 2 and 3. This time the region is unbounded: it goes on for ever to the right and upwards. The boundary lines are (intercepts and ) and (intercepts and ). Solving them together: tripling the second equation gives ; subtracting the first leaves , so and . The corners are , and (confirmed by computer).
The unbounded feasible region of the diet problem, shaded, lying above and to the right of two lines. The corners are (0, 9), (2, 3) and (8, 0). The region is cut off at the edge of the picture. A dashed line 4x plus 3y equals 17 passes through the corner (2, 3) and no part of the region lies below it.
Read the figure carefully. The shaded region has only three corners, and it continues past the edge of the picture. The dashed line is the cost line through . Slide it downward for smaller costs: it leaves the region at once. Slide it upward: it always cuts through the region. So is the lowest reachable cost, even though the region never ends.
Step 4. The corner values are:
| Corner point | Substitution | Z = 4x + 3y |
|---|---|---|
Step 5. The smallest corner value is at . But Theorem 2 does not apply, because the region is unbounded. A smallest corner value is only a candidate. We must check it with the half-plane test:
Step 6. Here the half-plane misses the region completely: the picture shows the whole region on or above the dashed line, and the computer confirms that no feasible point gives a smaller value. So the minimum cost is , using kg of F1 and kg of F2.
For a maximum there is none: the point is allowed and gives , and is allowed and gives (confirmed by computer). The cost can be made as large as you like by moving far out into the region.
Sanity check: gives protein and iron , meeting both needs exactly. The answer satisfies every limit.
Step 1. Minimise subject to , , , .
Steps 2 and 3. The boundary lines are (intercepts and ) and (intercepts and ). They cross at , since doubling the second equation gives and subtracting the first leaves . The corners are , and (confirmed by computer). The region is unbounded.
The unbounded feasible region above two lines, shaded. The corners are (0, 6), (2, 2) and (6, 0). The region extends upwards and to the right beyond the edge of the picture, including the point (7, 0) on the horizontal axis.
Read the figure with the -axis in mind. The shaded region sits above both slanted lines and stretches right without end. The corner is where the region meets the axis. Every point further right on the axis, such as , is also in the region.
| Corner point | Substitution | Z = -x + y |
|---|---|---|
Step 5. The smallest corner value is at . Is it the minimum? Test a point of the region further right: is allowed and gives (confirmed by computer), which is smaller. Moving right along the axis makes smaller without end. So there is no minimum, even though the table has a smallest corner value. The computer agrees: this problem is unbounded.
Compare with the same region and . Then moving away from the origin only makes larger, so the smallest corner value at passes the half-plane test and is the true minimum. Whether an unbounded problem has an answer depends on the direction of , not only on the shape.
Take the workshop region again, but change the profits to and units: maximise . The profit lines now have the same slope as the cutting-time line , because . So the last profit line to touch the region lies along a whole side.
The corners and both give : check and . So does every point on the side between them. For example is the midpoint, it is allowed (confirmed by computer), and . The problem has many optimal solutions, and every one has the same optimal value .
In general, when the objective line is parallel to a binding constraint side, the whole side is optimal. Report both end corners and say the segment between them is optimal too.
Maximise subject to , , , . The first says is at most . The second says it is at least . No point can do both, so the two allowed sides do not overlap.
Two parallel lines, x plus y equals 2 (lower left) and x plus y equals 5 (upper right). The point (1, 1) satisfies only the first limit, and the point (2, 4) satisfies only the second. No shaded overlap exists: the two allowed sides point away from each other.
Read the figure line by line. The lower line allows everything below it. The upper line allows everything above it. The two allowed sides point away from each other and never meet. Point passes only the first limit; point passes only the second (confirmed by computer). The feasible region is empty: there are no corners, and the problem is infeasible (it has no solution). Checking whole-number or fractional points will not help, because no point at all can satisfy both.
Maximise subject to , , , where and must be whole numbers of items.
The graphical method ignores the whole-number rule at first. The slanted lines are and . Tripling the second gives ; subtracting the first leaves , so and (confirmed by computer). The corner value there is .
But you cannot make of an item. Rounding to is allowed (confirmed by computer) but may not be best. Test the whole-number plans directly: the computer tried every whole pair with . The best whole-number plan is with , which is below . So the best whole-number answer is with value .
The lesson: a corner with fractions is only a starting hint for whole-item problems. Always test the nearby whole-number plans and report the best of those.
Solve each problem by all six steps. Draw the region, list every corner, show each substitution, and finish with a sentence that answers the question.
12.6 Exercise 12.1: Graded Corner-Point Problems
12.7 Chapter Summary and 5-Step LPP Solver Rubric
- LPP: optimise (maximise or minimise) a linear objective function subject to linear constraints and , .
- Feasible solution: a point satisfying all constraints. Feasible region: the set of all of them (a convex polygon, bounded or unbounded). Optimal solution: a feasible point giving the best value of .
- Formulating: name the variables, write the objective function, write one constraint per limit (“at most” is , “at least” is ), add .
- Corner-point method: draw the region, find the corners, evaluate at each corner, compare.
- Theorem 1: if an optimal value exists, it is attained at a corner point.
- Theorem 2: if the region is bounded, both a maximum and a minimum exist, at corner points.
- Unbounded region: the best corner value (or ) is only a candidate. It is the minimum (maximum) only if the open half-plane () has no point in common with the region. Otherwise there is no minimum (maximum).
- Many optimal solutions: if two corners give the same best value, every point on the segment between them does too.
- Infeasible: if the allowed sides do not overlap, the region is empty and there is no solution.
- Whole numbers: a corner may have fractions. If items must be whole, test whole-number plans directly.
| Region shape | Maximum | Minimum |
|---|---|---|
| Bounded | Exists, at a corner | Exists, at a corner |
| Unbounded | Exists only if misses the region | Exists only if misses the region |
| Empty (infeasible) | No solution | No solution |
Draw the shape, test the corners, and check the special cases. That is the whole chapter in one line.