Skip to content

Simplex Method: 6 Solved Problems, Step by Step

Type
Practice problems
Problems
6
Levels
Easy · Medium · Hard

Six linear programming problems solved step by step with the simplex method: a graphical warm-up, three full tableau solutions, a minimization, an unbounded problem and a problem with infinitely many optimal solutions. Every tableau is shown, so you can check each pivot.

Contents2 sections

The simplex method in five steps

For a problem “maximize z=cTxz=c^{\mathsf T}x subject to Ax≤bAx\le b, x≥0x\ge 0” with b≥0b\ge 0:

  1. Add a slack variable to each constraint to make it an equation: a1x1+⋯+anxn+s=ba_1x_1+\dots+a_nx_n+s=b, s≥0s\ge 0.
  2. Write the tableau. The objective row holds −c-c (we write z−cTx=0z-c^{\mathsf T}x=0). The slack variables form the first basis, which is the corner x=0x=0.
  3. Entering variable: the column with the most negative entry in the zz row. If no entry is negative, the current solution is optimal.
  4. Ratio test: for each row with a positive entry in that column, divide the right-hand side by that entry. The smallest ratio picks the leaving row. If no entry is positive, the problem is unbounded.
  5. Pivot: divide the pivot row by the pivot, then clear the rest of the column with row operations. Go back to step 3.

Each pivot moves from one corner of the feasible region to a neighboring corner with a value of zz at least as large.

Problem 1

Easy

Solve graphically: maximize z=2x+3yz=2x+3y subject to x+y≤4x+y\le 4, x+3y≤6x+3y\le 6, x,y≥0x,y\ge 0.

Hint

An optimum of a linear program is always reached at a corner of the feasible region. List the corners.

View Solution

The corners are where the boundary lines meet:

  • (0,0)(0,0): z=0z=0
  • (4,0)(4,0) on x+y=4x+y=4: z=8z=8
  • (0,2)(0,2) on x+3y=6x+3y=6: z=6z=6
  • Intersection of x+y=4x+y=4 and x+3y=6x+3y=6: subtracting gives 2y=22y=2, so (3,1)(3,1): z=6+3=9z=6+3=9

The largest value is at (3,1)(3,1).

Answer: x=3, y=1, zmax⁡=9x=3,\ y=1,\ z_{\max}=9

Problem 2

Medium

Use the simplex method: maximize z=3x+5yz=3x+5y subject to x≤4x\le 4, 2y≤122y\le 12, 3x+2y≤183x+2y\le 18, x,y≥0x,y\ge 0.

Hint

Add s1,s2,s3s_1, s_2, s_3. The first entering variable is yy (coefficient −5-5 in the zz row).

View Solution
Initial tableau
Basisxxyys1s_1s2s_2s3s_3RHS
s1s_1101004
s2s_20201012
s3s_33200118
zz−3−50000

Pivot 1. Most negative in the zz row: −5-5, so yy enters. Ratios: s2 ⁣:12/2=6s_2\colon 12/2=6, s3 ⁣:18/2=9s_3\colon 18/2=9 (the s1s_1 row has 0 and is skipped). Smallest is 6, so s2s_2 leaves. Pivot on the 2.

After pivot 1 (y enters, s₂ leaves)
Basisxxyys1s_1s2s_2s3s_3RHS
s1s_1101004
yy01012\tfrac{1}{2}06
s3s_3300−116
zz−30052\tfrac{5}{2}030

Pivot 2. Now xx enters (−3-3). Ratios: s1 ⁣:4/1=4s_1\colon 4/1=4, s3 ⁣:6/3=2s_3\colon 6/3=2. So s3s_3 leaves; pivot on the 3.

After pivot 2 (x enters, s₃ leaves): optimal
Basisxxyys1s_1s2s_2s3s_3RHS
s1s_100113\tfrac{1}{3}−13-\tfrac{1}{3}2
yy01012\tfrac{1}{2}06
xx100−13-\tfrac{1}{3}13\tfrac{1}{3}2
zz00032\tfrac{3}{2}136

No negative entries remain in the zz row, so this is optimal. Read the basic variables from the RHS column: x=2x=2, y=6y=6, s1=2s_1=2 (the first constraint has 2 units of slack), z=36z=36.

Answer: x=2, y=6, zmax⁡=36x=2,\ y=6,\ z_{\max}=36

Problem 3

Medium

Maximize z=5x1+4x2+3x3z=5x_1+4x_2+3x_3 subject to

2x1+3x2+x3≤54x1+x2+2x3≤113x1+4x2+2x3≤8x1,x2,x3≥0.\begin{aligned}2x_1+3x_2+x_3&\le 5\\ 4x_1+x_2+2x_3&\le 11\\ 3x_1+4x_2+2x_3&\le 8\end{aligned}\qquad x_1,x_2,x_3\ge 0.
Hint

After the first pivot, a negative entry appears under x3x_3 even though the x1x_1 and x2x_2 entries are positive. Keep going.

View Solution
Initial tableau
Basisx1x_1x2x_2x3x_3s1s_1s2s_2s3s_3RHS
s1s_12311005
s2s_241201011
s3s_33420018
zz−5−4−30000

Pivot 1. x1x_1 enters (−5-5). Ratios: 5/2=2.55/2=2.5, 11/4=2.7511/4=2.75, 8/3≈2.678/3\approx 2.67. The smallest is 2.5, so s1s_1 leaves.

After pivot 1 (x₁ enters, s₁ leaves)
Basisx1x_1x2x_2x3x_3s1s_1s2s_2s3s_3RHS
x1x_1132\tfrac{3}{2}12\tfrac{1}{2}12\tfrac{1}{2}0052\tfrac{5}{2}
s2s_20−50−2101
s3s_30−12-\tfrac{1}{2}12\tfrac{1}{2}−32-\tfrac{3}{2}0112\tfrac{1}{2}
zz072\tfrac{7}{2}−12-\tfrac{1}{2}52\tfrac{5}{2}00252\tfrac{25}{2}

Pivot 2. The only negative entry is −12-\tfrac12 under x3x_3, so x3x_3 enters. Ratios (positive entries only): x1x_1 row 52÷12=5\tfrac52\div\tfrac12=5, s3s_3 row 12÷12=1\tfrac12\div\tfrac12=1. So s3s_3 leaves.

After pivot 2 (x₃ enters, s₃ leaves): optimal
Basisx1x_1x2x_2x3x_3s1s_1s2s_2s3s_3RHS
x1x_112020−12
s2s_20−50−2101
x3x_30−11−3021
zz03010113

All zz-row entries are now ≥0\ge 0: optimal. x1=2x_1=2, x3=1x_3=1, x2=0x_2=0 (nonbasic), and z=10+3=13z=10+3=13. Check the constraints: 4+0+1=5≤54+0+1=5\le 5, 8+0+2=10≤118+0+2=10\le 11, 6+0+2=8≤86+0+2=8\le 8.

Answer: x1=2, x2=0, x3=1, zmax⁡=13x_1=2,\ x_2=0,\ x_3=1,\ z_{\max}=13

Problem 4

Medium

Minimize w=x−3yw=x-3y subject to x+y≤4x+y\le 4, −x+y≤2-x+y\le 2, x,y≥0x,y\ge 0.

Hint

Minimizing ww is the same as maximizing z=−wz=-w.

View Solution

Maximize z=−x+3yz=-x+3y instead. The zz row holds −c=(1,−3)-c=(1,-3).

Initial tableau for max z = −x + 3y
Basisxxyys1s_1s2s_2RHS
s1s_111104
s2s_2−11012
zz1−3000

Pivot 1. yy enters (−3-3). Ratios: 4/1=44/1=4, 2/1=22/1=2. So s2s_2 leaves.

After pivot 1 (y enters, s₂ leaves)
Basisxxyys1s_1s2s_2RHS
s1s_1201−12
yy−11012
zz−20036

Pivot 2. xx enters (−2-2). Only the s1s_1 row has a positive entry: 2/2=12/2=1. So s1s_1 leaves.

After pivot 2 (x enters, s₁ leaves): optimal
Basisxxyys1s_1s2s_2RHS
xx1012\tfrac{1}{2}−12-\tfrac{1}{2}1
yy0112\tfrac{1}{2}12\tfrac{1}{2}3
zz00128

Optimal: x=1x=1, y=3y=3, zmax⁡=8z_{\max}=8. Since w=−zw=-z, the minimum of ww is −8-8. Check: 1−3⋅3=−81-3\cdot 3=-8.

Answer: x=1, y=3, wmin⁡=−8x=1,\ y=3,\ w_{\min}=-8

Problem 5

Hard

Maximize z=x+yz=x+y subject to x−y≤1x-y\le 1, −2x+y≤2-2x+y\le 2, x,y≥0x,y\ge 0. What does the simplex method report?

Hint

Do one pivot, then look closely at the column of the entering variable.

View Solution

First pivot: xx and yy both have −1-1; take xx. Only the first row has a positive entry, so s1s_1 leaves.

After pivot 1 (x enters, s₁ leaves)
Basisxxyys1s_1s2s_2RHS
xx1−1101
s2s_20−1214
zz0−2101

Now yy enters (−2-2), but every entry in the yy column is negative: no row limits how far yy can grow. The ratio test finds nothing, so the problem is unbounded.

Concretely, with y=t≥0y=t\ge 0 the tableau gives x=1+tx=1+t, s2=4+ts_2=4+t, all feasible, and z=1+2t→∞z=1+2t\to\infty.

Answer: unbounded, no maximum

Problem 6

Hard

Maximize z=2x+4yz=2x+4y subject to x+2y≤8x+2y\le 8, x≤6x\le 6, x,y≥0x,y\ge 0. Is the optimal solution unique?

Hint

In the final tableau, look at the zz-row entry of a nonbasic variable.

View Solution

yy enters (−4-4); the only positive entry is in the first row, ratio 8/2=48/2=4, so s1s_1 leaves.

After pivot 1 (y enters, s₁ leaves): optimal
Basisxxyys1s_1s2s_2RHS
yy12\tfrac{1}{2}112\tfrac{1}{2}04
s2s_210016
zz002016

The zz row has no negative entry, so zmax⁡=16z_{\max}=16 at x=0, y=4x=0,\ y=4. But the nonbasic variable xx has a zero in the zz row: bringing it in does not change zz. Pivoting xx in (ratios 4÷12=84\div\tfrac12=8 and 6÷1=66\div 1=6, so s2s_2 leaves) gives the corner x=6, y=1x=6,\ y=1, also with z=16z=16.

The reason is visible in the data: z=2x+4y=2(x+2y)z=2x+4y=2(x+2y), parallel to the first constraint. Every point of the segment from (0,4)(0,4) to (6,1)(6,1) is optimal.

Answer: zmax⁡=16z_{\max}=16, infinitely many optimal points

Frequently asked questions

What if a constraint is “≥\ge” or an equation?

Then the slack variables do not give a starting corner. Add artificial variables and use the Big M method or the two-phase method, which first finds a feasible corner and then optimizes.

What does a tie in the ratio test mean?

A tie means the next corner is degenerate (a basic variable becomes 0). Pick either row; in rare cases the method can cycle, which a rule such as Bland’s rule (always choose the lowest-index variable) prevents.

Is the simplex method the same as solving graphically?

It follows the same idea, moving from corner to corner, but works with any number of variables, where drawing is impossible.