Product mix problem: a linear programming example, solved and checked
The product mix problem 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
Say it or snap it
You can give ProvenDecisions this problem out loud or as a photo. The app wrote down both, solved them, and got the same checked answer as the typed version.
What the app heard: “A company makes two products, product A and product B. Each unit of product A needs two hours of labor and one unit of raw material and earns three dollars of profit. Each unit of product B needs one hour of labor and two units of raw material and earns two dollars. There are 100 labor hours and 80 units of raw material. How many units of each product should the company make to maximize profit?”

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 profit; 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. How many of each should it make to maximize profit?
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
Assumptions:
- products can be made in fractional amounts (the optimum is whole anyway)
The model
Each line has a plain-language note on the right.
| make as large as possible: total profit ($) | |
| limit 1: left side cannot exceed 100 | |
| limit 2: left side cannot exceed 80 | |
| number of product A made (units) cannot be negative | |
| number of product B made (units) cannot be negative |
In matrix form
With its numbers:
What is being decided
There are 2 decision variables.
| Variable | Type | Meaning |
|---|---|---|
| a | real number | number of product A made (units) |
| b | real number | number of product B made (units) |
Goal and limits
Maximize total profit ($) 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 (and A x = b for equalities); 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') # number of product A made (units)
b = cp.Variable(name='b') # number of product B made (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)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 |
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 + 1*b <= 100
1*a + 2*b <= 80
a, b >= 0
# a = number of product A made (units)
# b = number of product B made (units)
# objective = total profit ($)
# assume: products can be made in fractional amounts (the optimum is whole anyway)Checked: 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.