Simplex Method
calculator.
Solve a linear program with tableaux, pivots and, for two variables, a drawing.
- Pivots
- 2
- Binding constraints
- 2 of 3
- Method
- One phase
Constraints 2 and 3 are binding: met exactly, so they set the answer. Constraint 1 has 2 to spare.
The feasible region
- x₁ ≤ 4
- 2x₂ ≤ 12
- 3x₁ + 2x₂ ≤ 18
- z = 36
The shaded area holds every point that meets all the constraints, with 5 corners. The dashed line is z = 36, and it touches the region last at (2, 6).
z at every corner
| Corner | z there |
|---|---|
| (0, 0) | 0 |
| (4, 0) | 12 |
| (4, 3) | 27 |
| (2, 6) | 36best |
| (0, 6) | 30 |
Every tableau, pivot by pivot
1. Starting tableau
Each row is a constraint; the bottom row holds the reduced costs and the current objective value.
Starting tableau
| Basis | x₁ | x₂ | s₁ | s₂ | s₃ | RHS |
|---|---|---|---|---|---|---|
| s₁ | 1 | 0 | 1 | 0 | 0 | 4 |
| s₂ | 0 | 2 | 0 | 1 | 0 | 12 |
| s₃ | 3 | 2 | 0 | 0 | 1 | 18 |
| z row | −3 | −5 | 0 | 0 | 0 | 0 |
- s₁: RHS 4x₁ 1 · x₂ 0 · s₁ 1 · s₂ 0 · s₃ 0
- s₂: RHS 12x₁ 0 · x₂ 2 · s₁ 0 · s₂ 1 · s₃ 0
- s₃: RHS 18x₁ 3 · x₂ 2 · s₁ 0 · s₂ 0 · s₃ 1
- z row: RHS 0x₁ −3 · x₂ −5 · s₁ 0 · s₂ 0 · s₃ 0
2. Pivot 1: x₂ enters, s₂ leaves
x₂ has the most negative reduced cost; the minimum ratio test picks row 2 (ratio 6).
Pivot 1: x₂ enters, s₂ leaves
| Basis | x₁ | x₂ | s₁ | s₂ | s₃ | RHS |
|---|---|---|---|---|---|---|
| s₁ | 1 | 0 | 1 | 0 | 0 | 4 |
| x₂ | 0 | 1 | 0 | 0.5 | 0 | 6 |
| s₃ | 3 | 0 | 0 | −1 | 1 | 6 |
| z row | −3 | 0 | 0 | 2.5 | 0 | 30 |
- s₁: RHS 4x₁ 1 · x₂ 0 · s₁ 1 · s₂ 0 · s₃ 0
- x₂: RHS 6x₁ 0 · x₂ 1 · s₁ 0 · s₂ 0.5 · s₃ 0
- s₃: RHS 6x₁ 3 · x₂ 0 · s₁ 0 · s₂ −1 · s₃ 1
- z row: RHS 30x₁ −3 · x₂ 0 · s₁ 0 · s₂ 2.5 · s₃ 0
3. Pivot 2: x₁ enters, s₃ leaves
x₁ has the most negative reduced cost; the minimum ratio test picks row 3 (ratio 2).
Pivot 2: x₁ enters, s₃ leaves
| Basis | x₁ | x₂ | s₁ | s₂ | s₃ | RHS |
|---|---|---|---|---|---|---|
| s₁ | 0 | 0 | 1 | 0.3333 | −0.3333 | 2 |
| x₂ | 0 | 1 | 0 | 0.5 | 0 | 6 |
| x₁ | 1 | 0 | 0 | −0.3333 | 0.3333 | 2 |
| z row | 0 | 0 | 0 | 1.5 | 1 | 36 |
- s₁: RHS 2x₁ 0 · x₂ 0 · s₁ 1 · s₂ 0.3333 · s₃ −0.3333
- x₂: RHS 6x₁ 0 · x₂ 1 · s₁ 0 · s₂ 0.5 · s₃ 0
- x₁: RHS 2x₁ 1 · x₂ 0 · s₁ 0 · s₂ −0.3333 · s₃ 0.3333
- z row: RHS 36x₁ 0 · x₂ 0 · s₁ 0 · s₂ 1.5 · s₃ 1
Working
- 1Write each constraint as an equationAdd s₁, s₂, s₃: s for slack in a ≤ row, e for surplus in a ≥ row, a for an artificial start
- 2Pivot 1: x₂ enters, s₂ leavesx₂ has the most negative reduced cost; the minimum ratio test picks row 2 (ratio 6).
- 3Pivot 2: x₁ enters, s₃ leavesx₁ has the most negative reduced cost; the minimum ratio test picks row 3 (ratio 2).
- 4Read the answer from the final tableaux₁ = 2, x₂ = 6, z = 36
- 5Check: put the answer back into every constraintx₁ = 2, ≤ 4 holds2x₂ = 12, ≤ 12 holds3x₁ + 2x₂ = 18, ≤ 18 holdsz = 3x₁ + 5x₂ = 36
What if a right side changes?
What if a right side changes
| Right side | Best z | At |
|---|---|---|
| 8 | 20 | 0, 4 |
| 13 | 31 | 0.33, 6 |
| 18(yours) | 36 | 2, 6 |
| 23 | 41 | 3.67, 6 |
| 28 | 42 | 4, 6 |
Steps of 5. Raising the right side of constraint 3 by one step changes the best z by 1 for each unit. While the same constraints stay binding, that rate is the constraint's shadow price.
How it's worked out
A linear program asks for the largest or smallest value of a straight-line objective, subject to straight-line limits. Every variable must be 0 or more.
The corner point principle/03%3A_Linear_Programming_-_A_Geometric_Approach/3.01%3A_Maximization_Applications) says the best value, when one exists, sits at a corner of the region the limits allow. The simplex method starts at one corner and walks along edges to better corners until no neighbor is better.
- Slack. Each ≤ row gets a slack variable for the unused amount, so the row becomes an equation.
- Pivot column. The most negative entry in the bottom row/04%3A_Linear_Programming_The_Simplex_Method/4.02%3A_Maximization_By_The_Simplex_Method) picks the variable that raises z fastest.
- Pivot row. Divide each right side by the positive entry in that column. The smallest quotient wins, which keeps every variable at 0 or more.
- Stop. When the bottom row has no negative entry, z cannot rise any further.
A ≥ or = row has no slack to start from, because the origin breaks it. So it gets a surplus variable taken away and an artificial variable added. Phase 1 drives the artificial variables down to 0 to find a first corner. If it cannot, no point meets every limit. Phase 2 then runs the usual method on the real objective. A minimum is found by making −z as large as it can be.
Worked examples
The Wyndor glass plant picks a product mix
Each batch of product 1 earns 3 and each batch of product 2 earns 5, in thousands. Plant 1 has 4 hours, plant 2 has 12 and plant 3 has 18. Product 1 needs 1 hour in plant 1 and 3 in plant 3, and product 2 needs 2 hours in each of plants 2 and 3.
The method takes 2 pivots. Product 2 comes in first because 5 is the bigger profit, then product 1. The best plan is 2 batches and 6 batches, for z = 36.
The check puts the plan back in: plant 1 uses 2 of its 4 hours, so 2 are spare, while plants 2 and 3 are full. The 5 corners give z from 0 to 36, so the graph agrees. One more hour in plant 3 raises z to 37.
If product 1 earned 6 and product 2 only 2, the objective line would tilt and the best corner would move to (4, 3) with z = 30.
Niki splits her week between two jobs
Job I pays $40 an hour and job II pays $30. Niki can work at most 12 hours, and she has 16 hours to prepare. Each hour of job I takes 2 hours of preparation, and each hour of job II takes 1.
The best week is 4 hours of job I and 8 of job II, for $400. Both limits are used up, so both slack variables end at 0.
The what-if table shows which limit is worth more. One more working hour lifts her best pay to $420, which is $20 an hour. One more preparation hour lifts it to $410, only $10.
A cheapest diet that needs phase 1
Food 1 costs 2 a serving and food 2 costs 3. The diet needs at least 4 units of one nutrient and at least 6 of another.
Eating nothing breaks both rows, so the slack start does not work. Phase 1 takes 3 tableaux to reach a real corner. The cheapest plan is 3 servings of food 1 and 1 of food 2, at a cost of 9.
The other corners, (6, 0) and (0, 4), both cost 12.
Reading your result
Basis. The variables listed down the left of a tableau are the ones allowed to be above 0. Their values sit in the right-hand column, and every other variable is 0.
Binding and spare. A binding constraint is met exactly at the best point, so it holds the answer back. A constraint with some to spare is not limiting, and changing its right side a little changes nothing.
Rate per unit. When the right side of a binding constraint rises by 1 and the same constraints stay binding, z moves by a fixed amount, its shadow price. In the Wyndor plant one hour in plant 3 is worth 1.
A tie. If a variable outside the basis has 0 in the bottom row, another corner gives the same z, and so does every point on the edge between them.
No answer. Asking for x₁ + x₂ to be at most 2 and at least 5 is infeasible. Maximizing x₁ + x₂ with only x₁ − x₂ ≤ 1 is unbounded, because nothing caps x₂.
Common mistakes
- Flipping a ≥ row to ≤ and starting anyway. Multiplying x₁ + x₂ ≥ 4 by −1 leaves a negative right side, and the slack start is then not a real corner. That is the case phase 1 exists for.
- Choosing the pivot row by the biggest entry. The row comes from the smallest ratio of right side to a positive entry. A zero or negative entry is skipped.
- Rounding to whole numbers at the end. The best point may need fractions. The nearest whole numbers can break a limit or miss the true best whole-number plan.
- Mixing units in one row. Each constraint must count one thing, such as hours or kilograms, in every term and on the right side.
Questions people ask
Sources
- Sekhon and Bloom, Applied Finite Mathematics, section 4.2, Maximization by the Simplex Method (LibreTexts)
- Sekhon and Bloom, Applied Finite Mathematics, section 3.1, Maximization Applications (LibreTexts)
- Felix Fischer, Queen Mary University of London, optimization notes, chapter 8, The Two-Phase Simplex Method