Assignment problem: an integer programming example, solved and checked
The assignment problem is a classic integer 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: “Three workers, Alice, Ben and Cara, each get one of three jobs. Alice takes nine hours on job one, two hours on job two and seven hours on job three. Ben takes six, four and three hours. Cara takes five, eight and one hour. Each worker does exactly one job and each job gets exactly one worker. Minimize the total hours.”

The problem
Workers A, B, C take these hours on jobs 1, 2, 3: A = 9, 2, 7; B = 6, 4, 3; C = 5, 8, 1. Each worker does exactly one job and each job gets one worker. Minimize total hours.
How the model was built
The objective as written from the problem, before the numbers are multiplied out:
The model
Each line has a plain-language note on the right.
| make as small as possible: total hours worked (hours) | |
| limit 1: left side must equal 1 | |
| limit 2: left side must equal 1 | |
| limit 3: left side must equal 1 | |
| limit 4: left side must equal 1 | |
| limit 5: left side must equal 1 | |
| limit 6: left side must equal 1 | |
| yes (1) or no (0) |
In matrix form
With its numbers:
What is being decided
There are 9 decision variables.
| Variable | Type | Meaning |
|---|---|---|
| xA1 | binary (0 or 1) | 1 if worker A does job 1, else 0 |
| xA2 | binary (0 or 1) | 1 if worker A does job 2, else 0 |
| xA3 | binary (0 or 1) | 1 if worker A does job 3, else 0 |
| xB1 | binary (0 or 1) | 1 if worker B does job 1, else 0 |
| xB2 | binary (0 or 1) | 1 if worker B does job 2, else 0 |
| xB3 | binary (0 or 1) | 1 if worker B does job 3, else 0 |
| xC1 | binary (0 or 1) | 1 if worker C does job 1, else 0 |
| xC2 | binary (0 or 1) | 1 if worker C does job 2, else 0 |
| xC3 | binary (0 or 1) | 1 if worker C does job 3, else 0 |
Goal and limits
Minimize total hours worked (hours) subject to 6 constraints.
Problem type
ILP, complexity level 5: integer variables with linear objective and constraints. 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) xA1 + xA2 + xA3 = 1; (2) xB1 + xB2 + xB3 = 1; (3) xC1 + xC2 + xC3 = 1; (4) xA1 + xB1 + xC1 = 1; (5) xA2 + xB2 + xC2 = 1; (6) xA3 + xB3 + xC3 = 1. Changing a binding constraint changes the answer; a slack one can move a little without effect.
| # | Constraint | Value | Limit | Slack | Binding |
|---|---|---|---|---|---|
| 1 | xA1 + xA2 + xA3 = 1 | 1 | 1 | 0 | yes |
| 2 | xB1 + xB2 + xB3 = 1 | 1 | 1 | 0 | yes |
| 3 | xC1 + xC2 + xC3 = 1 | 1 | 1 | 0 | yes |
| 4 | xA1 + xB1 + xC1 = 1 | 1 | 1 | 0 | yes |
| 5 | xA2 + xB2 + xC2 = 1 | 1 | 1 | 0 | yes |
| 6 | xA3 + xB3 + xC3 = 1 | 1 | 1 | 0 | yes |
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
xA1 = cp.Variable(name='xA1', boolean=True) # 1 if worker A does job 1, else 0
xA2 = cp.Variable(name='xA2', boolean=True) # 1 if worker A does job 2, else 0
xA3 = cp.Variable(name='xA3', boolean=True) # 1 if worker A does job 3, else 0
xB1 = cp.Variable(name='xB1', boolean=True) # 1 if worker B does job 1, else 0
xB2 = cp.Variable(name='xB2', boolean=True) # 1 if worker B does job 2, else 0
xB3 = cp.Variable(name='xB3', boolean=True) # 1 if worker B does job 3, else 0
xC1 = cp.Variable(name='xC1', boolean=True) # 1 if worker C does job 1, else 0
xC2 = cp.Variable(name='xC2', boolean=True) # 1 if worker C does job 2, else 0
xC3 = cp.Variable(name='xC3', boolean=True) # 1 if worker C does job 3, else 0
objective = cp.Minimize(9*xA1 + 2*xA2 + 7*xA3 + 6*xB1 + 4*xB2 + 3*xB3 + 5*xC1 + 8*xC2 + xC3)
constraints = [
xA1 + xA2 + xA3 == 1,
xB1 + xB2 + xB3 == 1,
xC1 + xC2 + xC3 == 1,
xA1 + xB1 + xC1 == 1,
xA2 + xB2 + xC2 == 1,
xA3 + xB3 + xC3 == 1,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('xA1 =', xA1.value)
print('xA2 =', xA2.value)
print('xA3 =', xA3.value)
print('xB1 =', xB1.value)
print('xB2 =', xB2.value)
print('xB3 =', xB3.value)
print('xC1 =', xC1.value)
print('xC2 =', xC2.value)
print('xC3 =', xC3.value)The dual problem
Every constraint of the original (primal) problem gets a price, and every primal variable becomes a constraint on those prices. Integer variables are relaxed: this is the dual of the continuous (LP) relaxation, which gives a bound on the integer optimum, not its exact value. Only weak duality: the dual of the continuous relaxation gives an lower bound of 9 on the integer optimum 9, a duality gap of 0. Integer problems generally have a gap.
| Dual variable | Prices | Value |
|---|---|---|
| y1 | price of constraint 'xA1 + xA2 + xA3 = 1' (objective change per extra unit of its right-hand side) | 0 |
| y2 | price of constraint 'xB1 + xB2 + xB3 = 1' (objective change per extra unit of its right-hand side) | 2 |
| y3 | price of constraint 'xC1 + xC2 + xC3 = 1' (objective change per extra unit of its right-hand side) | 1 |
| y4 | price of constraint 'xA1 + xB1 + xC1 = 1' (objective change per extra unit of its right-hand side) | 4 |
| y5 | price of constraint 'xA2 + xB2 + xC2 = 1' (objective change per extra unit of its right-hand side) | 2 |
| y6 | price of constraint 'xA3 + xB3 + xC3 = 1' (objective change per extra unit of its right-hand side) | 0 |
| y7 | price of constraint 'xA1 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y8 | price of constraint 'xA2 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y9 | price of constraint 'xA3 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y10 | price of constraint 'xB1 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y11 | price of constraint 'xB2 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y12 | price of constraint 'xB3 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y13 | price of constraint 'xC1 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y14 | price of constraint 'xC2 <= 1' (objective change per extra unit of its right-hand side) | 0 |
| y15 | price of constraint 'xC3 <= 1' (objective change per extra unit of its right-hand side) | 0 |
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 9*xA1 + 2*xA2 + 7*xA3 + 6*xB1 + 4*xB2 + 3*xB3 + 5*xC1 + 8*xC2 + 1*xC3
subject to
xA1 + xA2 + xA3 = 1
xB1 + xB2 + xB3 = 1
xC1 + xC2 + xC3 = 1
xA1 + xB1 + xC1 = 1
xA2 + xB2 + xC2 = 1
xA3 + xB3 + xC3 = 1
binary: xA1, xA2, xA3, xB1, xB2, xB3, xC1, xC2, xC3
# xA1 = 1 if worker A does job 1, else 0
# xA2 = 1 if worker A does job 2, else 0
# xA3 = 1 if worker A does job 3, else 0
# xB1 = 1 if worker B does job 1, else 0
# xB2 = 1 if worker B does job 2, else 0
# xB3 = 1 if worker B does job 3, else 0
# xC1 = 1 if worker C does job 1, else 0
# xC2 = 1 if worker C does job 2, else 0
# xC3 = 1 if worker C does job 3, else 0
# objective = total hours worked (hours)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.