Shadow prices of a production plan: a linear programming example, solved and checked
The shadow prices of a production plan is a classic linear programming problem. Here it is solved by a real solver (HIGHS) and checked: every constraint, the dual, and the optimality certificate. Change the numbers below and solve your own.
Solve your own version free, no account needed
The problem
A company makes products A and B. Each A needs 2 hours of labour and 1 unit of raw material and earns $3; each B needs 1 hour of labour and 2 units of raw material and earns $2. There are 100 labour hours and 80 units of raw material. Write the dual problem and find the dual prices of labour and raw material.
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
- A shadow price is how much the best profit rises for one more unit of a resource: the price of 2a + b ≤ 100 is the value of one more labour hour, and the price of a + 2b ≤ 80 is the value of one more unit of raw material.
- The dual problem asks for the lowest resource prices at which no product earns more than the resources it uses are worth; its best value equals the best profit.
The model
Each line has a plain-language note on the right.
| make this as large as possible | |
| limit 1: left side cannot exceed 100 | |
| limit 2: left side cannot exceed 80 | |
| units of product A produced (units) cannot be negative | |
| units of product B produced (units) cannot be negative |
In matrix form
With its numbers:
The dual problem
Every constraint of the original (primal) problem gets a price, and every primal variable becomes a constraint on those prices. Strong duality: primal and dual optima are equal (160).
| Dual variable | Prices | Value |
|---|---|---|
| y1 | price of constraint '2*a + b <= 100' (objective change per extra unit of its right-hand side) | 1.33333 |
| y2 | price of constraint 'a + 2*b <= 80' (objective change per extra unit of its right-hand side) | 0.333333 |
What is being decided
There are 2 decision variables.
| Variable | Type | Meaning |
|---|---|---|
| a | real number | units of product A produced (units) |
| b | real number | units of product B produced (units) |
Goal and limits
Maximize the objective subject to 4 constraints, of which 2 are simple bounds on a single variable.
Problem type
LP, complexity level 1: a small linear program. Solved with HIGHS at the Medium solver tier.
Picture
Shaded: every point that satisfies all the constraints. Dot: the optimum. Dashed: the objective's level line through it.
The answer at a glance
The optimal value of each decision, as the solver returned it.
Which constraints hold the answer in place
Binding (no slack left): (1) 2*a + b <= 100; (2) a + 2*b <= 80. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | 2*a + b <= 100 | 100 | 100 | 0 | yes |
| 2 | a + 2*b <= 80 | 80 | 80 | 0 | yes |
| 3 | a >= 0 | 40 | 0 | 40 | |
| 4 | b >= 0 | 20 | 0 | 20 |
Why this is optimal
A proof you can check by hand. Multiply each constraint in the table by its weight and add them up: the result is an upper limit on the objective that holds for every plan meeting the constraints. Our answer reaches that limit exactly, so no plan does better. Every step was checked in exact fractions, not rounded decimals.
| # | Constraint | Weight |
|---|---|---|
| 1 | 2·a + b ≤ 100 | 4/3 |
| 2 | a + 2·b ≤ 80 | 1/3 |
Algebraic model (low level)
Decision variables, objective and every constraint written out; this is exactly what the solver receives.
Standard form
As a linear program: minimize cᵀx subject to A x ≤ b (the inequality rows) and A_eq x = b_eq (the equations); a maximization is written as minimizing the negative.
Model code (cvxpy)
The same model in cvxpy, ready to run.
import cvxpy as cp
a = cp.Variable(name='a') # units of product A produced (units)
b = cp.Variable(name='b') # units of product B produced (units)
objective = cp.Maximize(3*a + 2*b)
constraints = [
2*a + b <= 100,
a + 2*b <= 80,
a >= 0,
b >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('a =', a.value)
print('b =', b.value)Solve your own
This is the model as the app reads it. Change any number and solve it in the free box on the front page (no account needed).
maximize 3*a + 2*b
subject to
2*a + b <= 100
a + 2*b <= 80
a, b >= 0
# a = units of product A produced (units)
# b = units of product B produced (units)
# asked: the dual problemChecked: the app's answer matches the reference answer in our test set, which two solvers (HIGHS, CLARABEL) agree on. Built 2026-11-10.
Related examples
Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.