LP dual with equality constraints: a linear programming example, solved and checked
The LP dual with equality constraints 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
minimize 2x + y + 3z
subject to
x + y + z = 10
x - y >= 2
x, y, z >= 0
# asked: the dual problem and its optimal dual prices
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
- A shadow price is the change in the best objective when that constraint's right-hand side grows by 1: for example, x + y + z = 11 instead of 10 changes the best value by the price of constraint (1).
- The dual problem's prices y1 and y2 are the same numbers, found by solving the dual directly.
The model
Each line has a plain-language note on the right.
| make as small as possible: total cost 2x + y + 3z (cost units) | |
| limit 1: left side must equal 10 | |
| limit 2: left side must reach at least 2 | |
| decision variable x in the primal (units) cannot be negative | |
| decision variable y in the primal (units) cannot be negative | |
| decision variable z in the primal (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 (16).
| Dual variable | Prices | Value |
|---|---|---|
| y1 | price of constraint 'x + y + z = 10' (objective change per extra unit of its right-hand side) | 1.5 |
| y2 | price of constraint 'x - y >= 2' (objective change per extra unit of its right-hand side) | 0.5 |
What is being decided
There are 3 decision variables.
| Variable | Type | Meaning |
|---|---|---|
| x | real number | decision variable x in the primal (units) |
| y | real number | decision variable y in the primal (units) |
| z | real number | decision variable z in the primal (units) |
Goal and limits
Minimize total cost 2x + y + 3z (cost units) subject to 5 constraints, of which 3 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.
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) x + y + z = 10; (2) x - y >= 2; (5) z >= 0. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | x + y + z = 10 | 10 | 10 | 0 | yes |
| 2 | x - y >= 2 | 2 | 2 | 0 | yes |
| 3 | x >= 0 | 6 | 0 | 6 | |
| 4 | y >= 0 | 4 | 0 | 4 | |
| 5 | z >= 0 | 0 | 0 | 0 | yes |
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 a lower 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 | x + y + z = 10 | 3/2 |
| 2 | x - y ≥ 2 | 1/2 |
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
x = cp.Variable(name='x') # decision variable x in the primal (units)
y = cp.Variable(name='y') # decision variable y in the primal (units)
z = cp.Variable(name='z') # decision variable z in the primal (units)
objective = cp.Minimize(2*x + y + 3*z)
constraints = [
x + y + z == 10,
x - y >= 2,
x >= 0,
y >= 0,
z >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('x =', x.value)
print('y =', y.value)
print('z =', z.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).
minimize 2*x + y + 3*z
subject to
x + y + z = 10
x - y >= 2
x, y, z >= 0
# x = decision variable x in the primal (units)
# y = decision variable y in the primal (units)
# z = decision variable z in the primal (units)
# objective = total cost 2x + y + 3z (cost units)
# asked: the dual problem and its optimal dual pricesChecked: 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.