Mathwords logoMathwords

Simplex Algorithm — Definition & Example

The simplex algorithm is a method for finding the largest or smallest value of a linear objective under linear inequality constraints. It starts at one corner of the feasible region and moves along edges to neighboring corners that improve the objective. It stops when no neighboring corner does better, or when it finds that the objective can grow without limit (an unbounded problem).

Consider a linear program max⁡ cTx\max\, c^T x subject to Ax≤bAx \le b, x≥0x \ge 0, with b≥0b \ge 0. Add slack variables s≥0s \ge 0 so the constraints become Ax+s=bAx + s = b. The simplex method moves through basic feasible solutions. In each pivot, one nonbasic variable enters the basis and one basic variable leaves it. The entering variable is one whose coefficient is positive when zz is written in terms of the nonbasic variables. In a tableau whose bottom row is z−cTx=0z - c^T x = 0, this shows up as a negative entry. The leaving variable is the one with the smallest ratio bi/aijb_i / a_{ij} over rows with aij>0a_{ij} > 0. The method stops in one of two ways. If no such coefficient is positive (no negative entry in the tableau's bottom row), the current solution is optimal. If the entering column has no positive entry, the problem is unbounded. An anti-cycling rule such as Bland's rule guarantees that the method finishes.

Key Formula

maximize z=cTxsubject to Ax≤b,  x≥0\text{maximize } z = c^T x \quad \text{subject to } Ax \le b,\; x \ge 0
Where:
  • xx = Vector of decision variables
  • cc = Vector of objective coefficients
  • AA = Matrix of constraint coefficients
  • bb = Vector of constraint limits, with b ≥ 0 so the origin is a feasible starting corner
  • zz = Objective value to be maximized

Worked Example

Problem: Maximize z=5x+4yz = 5x + 4y subject to x+y≤5x + y \le 5, 2x+y≤82x + y \le 8, and x,y≥0x, y \ge 0.
Step 1: Add slack variables s1,s2≥0s_1, s_2 \ge 0 to turn the inequalities into equations. Start at the corner x=y=0x = y = 0, where z=0z = 0. Both objective coefficients are positive, so you can still improve zz. Pick xx to enter because it has the larger coefficient.
x+y+s1=5,2x+y+s2=8x + y + s_1 = 5, \qquad 2x + y + s_2 = 8
Step 2: Use the ratio test to decide how far xx can increase. Row 1 allows 5/1=55/1 = 5 and row 2 allows 8/2=48/2 = 4. The smaller ratio is 4, so s2s_2 leaves. Solve row 2 for xx and substitute into zz. The coefficient of yy is still positive, so yy enters next.
x=4−12y−12s2,z=20+32y−52s2x = 4 - \tfrac{1}{2}y - \tfrac{1}{2}s_2, \qquad z = 20 + \tfrac{3}{2}y - \tfrac{5}{2}s_2
Step 3: Run the ratio test for yy. Now s1=1−12y+12s2s_1 = 1 - \tfrac{1}{2}y + \tfrac{1}{2}s_2, which allows 1÷12=21 \div \tfrac{1}{2} = 2. The xx row allows 4÷12=84 \div \tfrac{1}{2} = 8. So s1s_1 leaves. After you substitute, every coefficient in zz is negative. That means no move can raise zz, and the current corner is optimal.
y=2−2s1+s2,x=3+s1−s2,z=23−3s1−s2y = 2 - 2s_1 + s_2, \quad x = 3 + s_1 - s_2, \quad z = 23 - 3s_1 - s_2
Answer: The maximum is z=23z = 23 at x=3x = 3, y=2y = 2. The path visited three corners: (0,0)→(4,0)→(3,2)(0,0) \to (4,0) \to (3,2).

Why It Matters

Simplex is the core algorithm of a first operations research course. Solvers use it to schedule airline crews, plan refinery output, and route shipments. Klee and Minty showed in 1972 that it can take exponentially many steps on specially built inputs, yet it runs fast on almost every real problem.

Common Mistakes

Mistake: Choosing the leaving variable by the largest ratio, or by the row where the entering variable first appears.
Correction: Always take the smallest nonnegative ratio, and skip rows where the entering column's entry is zero or negative. In the example, letting x=5x = 5 from row 1 would force s2=8−10=−2s_2 = 8 - 10 = -2. That breaks s2≥0s_2 \ge 0 and leaves the feasible region.

Related Terms

  • Algorithm — General idea of finite step procedures that simplex follows
  • Greedy Algorithm — Simplex picks each pivot by a locally best improvement
  • NP Problem — Integer versions of linear programs are NP-hard
  • Feasible Region — Region whose corners the algorithm moves between
  • Constraint — Limits that define the corners the method explores
  • Linear Programming — The optimization problem the simplex algorithm solves