← Optimization theory
PART 4 · 15 Optimization theory · 03

The Simplex Method and Duality

Simplex Method and Duality · Finding the optimum and reading the value of resources

Simplex methodSlack variablesSimplex tableauDual problemStrong · weak dualityShadow prices

Climbing along the cornersWhat resources are worthProcess 1 · $46.67Process 2 · $6.67

How can we find the optimal solution efficiently, and interpret how valuable our limited resources are? In Chapter 02 we found the optimum by comparing the corner points of the feasible region. With two variables you can check this on a graph, but real problems have hundreds of products and thousands of constraints, so you cannot check every corner point one by one.

SECTION 01

Why do we need the simplex method?

The simplex method is an algorithm that finds the optimal solution by moving systematically from one corner point of the feasible region to another, improving the objective value as it goes. Instead of blindly comparing every feasible solution, it only moves from the current corner to a neighboring corner that is better.

SECTION 02

The basic idea of the simplex method

max Z = 60x + 100y   s.t.   x + 2y ≤ 8,   2x + y ≤ 8,   x, y ≥ 0
① Set an initial feasible solution

Start at x = 0, y = 0. Nothing is produced, so every constraint is satisfied.

② Look for an improving direction

Pick a variable that raises profit when increased. Usually the one with the largest unit profit is chosen.

③ Move to the next corner

Increase that variable as far as the constraints allow, and swap it into the basis for the variable that hits 0.

④ Check optimality

When no variable can raise profit any further, you have the optimum.

Step 0: (0, 0) · Z = 0Step 1: (0, 4) · Z = 400Step 2: (8/3, 8/3) · Z = 1280/3(4, 0) · not visited00112233445566xyGrow y first (bigger profit, $100),then grow x to reach the next corner
Figure 1. Corner points visited by the simplex method

In Figure 1 the simplex method starts at (0, 0), first increases y, which has the larger unit profit, to arrive at (0, 4), and then increases x to reach (8/3, 8/3). It visited only three of the four corners, and as the problem grows, the share of corners that are never visited becomes much larger.

SECTION 03

Slack variables and the simplex tableau

To apply the simplex method, we turn the inequality constraints into equations. If x + 2y of the 8 hours available in process 1 are actually used, we let s1 be the hours left unused and write:

x + 2y + s1 = 8,   2x + y + s2 = 8,   x, y, s1, s2 ≥ 0
s1, s2: slack variables — the amount of resource left unused

At the start x = y = 0, so s1 = s2 = 8. The variables whose values are determined this way are called basic variables, and the simplex method arranges these equations in a simplex tableau and swaps the basic variables one at a time. The Z row records how much profit falls when each variable is increased by one unit (a negative number means profit rises).

Step 0: (x, y) = (0, 0), Z = 0 · −100 is the smallest entry in the Z row, so y enters

Basisxys₁s₂RHS
s₁12108
s₂21018
Z row-60-100000

As y increases, process 1 can hold out until 8/2 = 4 and process 2 until 8/1 = 8. Process 1 runs out first, so its slack variable s1 leaves the basis (the minimum ratio test).

Step 1: (x, y) = (0, 4), Z = 400 · −10 remains in the Z row, so x enters

Basisxys₁s₂RHS
y1/211/204
s₂3/20-1/214
Z row-100500400

This time we increase x. The y row gives 4 ÷ (1/2) = 8 and the s2 row gives 4 ÷ (3/2) = 8/3, so s2 leaves.

Step 2: (x, y) = (8/3, 8/3), Z = 1280/3 · no negative entries in the Z row, so this is optimal

Basisxys₁s₂RHS
y012/3-1/38/3
x10-1/32/38/3
Z row00140/320/31280/3

With no negative entries left in the Z row, increasing any variable no longer raises profit. The optimal solution is x = y = 8/3, Z = 1280/3. The 140/3 and 20/3 in the slack-variable columns of the final Z row are the same values as the shadow prices we will see in Section 6.

SECTION 04

What is duality?

If the simplex method is a way of computing the optimal solution, duality is a way of interpreting the same problem from a different point of view.

Primal problem

Maximize profit with the resources available: how much of each product should we make?

Dual problem

Minimize cost while valuing the resources: what value should we put on one unit of time in each process so that it accounts for each product's profit?

SECTION 05

Building the dual of the production planning problem

Let the dual variables u and v be the values assigned to one unit of time in each of the two processes. Each process has 8 hours, so the total value of the resources is 8u + 8v. Product A uses 1 hour in process 1 and 2 hours in process 2, so the combined value of those resources must be at least A's profit of $60, and the same goes for B.

min W = 8u + 8v   s.t.   u + 2v ≥ 60 (product A),   2u + v ≥ 100 (product B),   u, v ≥ 0

Flipping (transposing) the primal's constraint coefficient matrix gives the dual problem. The primal's right-hand side (8, 8) becomes the dual's objective coefficients, and the primal's objective coefficients (60, 100) become the dual's right-hand side.

u + 2v ≥ 60 (product A)2u + v ≥ 100 (product B)(140/3, 20/3) · W = 1280/3002020404060608080u : value of one hour of process 1 ($)v : value of one hour of process 2Purple region = dual feasible regionRed dashed line = last line touched as W shrinks
Figure 2. Feasible region and optimal solution of the dual problem
SECTION 06

Strong duality and the value of resources

When both the primal and the dual have optimal solutions, strong duality says the two optimal values are equal. Setting the dual's two constraints as equations and solving gives u = 140/3, v = 20/3, and

W* = 8(140/3) + 8(20/3) = 1280/3 = Z*

The two optimal values match. u and v are the shadow prices of one unit of time in each process. They tell you how much the optimal profit rises if you secure one more hour of that resource while everything else stays the same.

ResourceShadow price (per hour)Range of available hours where the price holds
Process 1140/3 ≈ $46.674–16 hours
Process 220/3 ≈ $6.674–16 hours
02004006008009 hours: 473.33 (+140/3)8 hours: 426.67Slope = shadow price 140/3 (4–16 hour range)048121620Slope 0 beyond 16 hoursMaximum profit Z* ($)Hours available in process 1 (process 2 fixed at 8) · outside the range the slope, i.e. the value of an hour, changes
Figure 3. Maximum profit versus available hours in process 1

In Figure 3, raising process 1's time from 8 to 9 hours lifts the maximum profit from 1280/3 to $473.33, an increase of exactly 140/3. So in this model, securing extra time in process 1 is worth far more in marginal profit than extra time in process 2. If an extra hour of process 1 costs less than $46.67, adding it pays off. This interpretation, however, holds only in the 4–16 hour range. Beyond 16 hours process 2 becomes the bottleneck, and adding more process 1 time no longer raises profit.

SECTION 07

Weak duality and verifying the optimum

By weak duality, the profit of any feasible primal solution can never exceed the resource value of any feasible dual solution.

Z ≤ W  (objective value of a primal feasible solution ≤ objective value of a dual feasible solution)
0240400420426.67640800560960426.67Z* = W* = 1280/3Blue: profit Z of primal feasible solutions (always ≤ 1280/3)Orange: resource value W of dual feasible solutions (always ≥ 1280/3)
Figure 4. Weak duality: Z ≤ W

If a feasible primal solution earns $400 in profit and a feasible dual solution gives a resource value of $440, the optimal profit lies between $400 and $440. In this way the dual provides an upper bound on the optimal value (for a maximization problem), and the moment the two values become equal, both are proven optimal. This is also the principle behind the "optimality gap" that large-scale optimization software reports.

SECTION 08

How the simplex method and duality differ

AspectSimplex methodDuality
Core roleComputes the optimal solutionInterprets the problem's structure and the value of resources
Main viewMoves between corners while improving the feasible solutionLinks the primal and the dual
Typical outputOptimal decision variablesShadow prices, relation between optimal values
UseComputing production and allocation amountsValue of adding resources, verifying the optimum

Using the two ideas together lets you read an optimization result not as a bare number but as real decision information: "if we add this resource, how much more do we make?"

Example report

Solving the production planning model with the simplex method reached x = y = 8/3 and a maximum profit of 1280/3 ≈ $426.67 after two basis changes, and the optimal value of the dual problem matched at 1280/3. The shadow prices of process 1 and process 2 are 140/3 ≈ $46.67 and 20/3 ≈ $6.67, so as long as process 1's available time stays within 4–16 hours, adding one hour raises profit by $46.67.

✓ KEY TAKEAWAYS

The simplex method finds the optimum, and duality tells you what that optimum means.


Next is 04 Integer programming. It covers problems where decisions must be whole numbers, such as product quantities, numbers of staff, or numbers of vehicles.