∇ProvenDecisions
Ctrl K

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.

Answer. The smallest objective value is 9, at xA1 = 0, xA2 = 1, xA3 = 0, xB1 = 1, xB2 = 0, xB3 = 0, xC1 = 0, xC2 = 0, xC3 = 1. All 6 constraints are satisfied exactly. Optimal within gap tolerance.

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.

🎙️ Spoken (20 seconds)

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.”

📷 Photographed
Photo of the assignment problem written on a note

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.

VariableTypeMeaning
xA1binary (0 or 1)1 if worker A does job 1, else 0
xA2binary (0 or 1)1 if worker A does job 2, else 0
xA3binary (0 or 1)1 if worker A does job 3, else 0
xB1binary (0 or 1)1 if worker B does job 1, else 0
xB2binary (0 or 1)1 if worker B does job 2, else 0
xB3binary (0 or 1)1 if worker B does job 3, else 0
xC1binary (0 or 1)1 if worker C does job 1, else 0
xC2binary (0 or 1)1 if worker C does job 2, else 0
xC3binary (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.

xA10xA21xA30xB11xB20xB30xC10xC20xC31

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.

#ConstraintValueLimitSlackBinding
1xA1 + xA2 + xA3 = 1110yes
2xB1 + xB2 + xB3 = 1110yes
3xC1 + xC2 + xC3 = 1110yes
4xA1 + xB1 + xC1 = 1110yes
5xA2 + xB2 + xC2 = 1110yes
6xA3 + xB3 + xC3 = 1110yes

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 variablePricesValue
y1price of constraint 'xA1 + xA2 + xA3 = 1' (objective change per extra unit of its right-hand side)0
y2price of constraint 'xB1 + xB2 + xB3 = 1' (objective change per extra unit of its right-hand side)2
y3price of constraint 'xC1 + xC2 + xC3 = 1' (objective change per extra unit of its right-hand side)1
y4price of constraint 'xA1 + xB1 + xC1 = 1' (objective change per extra unit of its right-hand side)4
y5price of constraint 'xA2 + xB2 + xC2 = 1' (objective change per extra unit of its right-hand side)2
y6price of constraint 'xA3 + xB3 + xC3 = 1' (objective change per extra unit of its right-hand side)0
y7price of constraint 'xA1 <= 1' (objective change per extra unit of its right-hand side)0
y8price of constraint 'xA2 <= 1' (objective change per extra unit of its right-hand side)0
y9price of constraint 'xA3 <= 1' (objective change per extra unit of its right-hand side)0
y10price of constraint 'xB1 <= 1' (objective change per extra unit of its right-hand side)0
y11price of constraint 'xB2 <= 1' (objective change per extra unit of its right-hand side)0
y12price of constraint 'xB3 <= 1' (objective change per extra unit of its right-hand side)0
y13price of constraint 'xC1 <= 1' (objective change per extra unit of its right-hand side)0
y14price of constraint 'xC2 <= 1' (objective change per extra unit of its right-hand side)0
y15price 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)

Change the numbers and solve it

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

All 50 solved examples

Try ProvenDecisions free: type, photograph or say an optimization problem; every answer is checked by a solver.

What do you want to optimize?

Type the math, describe it in words, snap a photo or say it. ProvenDecisions builds the model, solves it, checks it and walks you through it.

One constraint per line, or separated by commas. Add integer: x, y or binary: z for whole-number decisions. LaTeX works too.

Try: