∇ProvenDecisions
Ctrl K

Machine scheduling (makespan): an integer programming example, solved and checked

The machine scheduling (makespan) 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 6, at x1 = 0, x2 = 0, x3 = 1, x4 = 1, x5 = 1, T = 6. All 3 constraints are satisfied exactly. Optimal within gap tolerance.

Solve your own version free, no account needed

The problem

Five jobs of 3, 3, 2, 2 and 2 hours go to two identical machines. Assign them to finish everything as early as possible.

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: time at which all jobs are finished (hours)
limit 1: left side cannot exceed the right side
limit 2: left side cannot exceed the right side
finish time of the last machine, the makespan (hours) cannot be negative
yes (1) or no (0)

In matrix form

With its numbers:

What is being decided

There are 6 decision variables.

VariableTypeMeaning
x1binary (0 or 1)1 if the 3-hour job A is on machine 1, 0 if on machine 2
x2binary (0 or 1)1 if the 3-hour job B is on machine 1, 0 if on machine 2
x3binary (0 or 1)1 if the first 2-hour job is on machine 1, 0 if on machine 2
x4binary (0 or 1)1 if the second 2-hour job is on machine 1, 0 if on machine 2
x5binary (0 or 1)1 if the third 2-hour job is on machine 1, 0 if on machine 2
Treal numberfinish time of the last machine, the makespan (hours)

Goal and limits

Minimize time at which all jobs are finished (hours) subject to 3 constraints, of which 1 are simple bounds on a single variable.

Problem type

MILP, 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.

x10x20x31x41x51T6

Which constraints hold the answer in place

Binding (no slack left): (1) 3*x1 + 3*x2 + 2*x3 + 2*x4 + 2*x5 <= T; (2) -3*x1 - 3*x2 - 2*x3 - 2*x4 - 2*x5 + 12 <= T. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
13*x1 + 3*x2 + 2*x3 + 2*x4 + 2*x5 <= T660yes
2-3*x1 - 3*x2 - 2*x3 - 2*x4 - 2*x5 + 12 <= T660yes
3T >= 0606

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

x1 = cp.Variable(name='x1', boolean=True)  # 1 if the 3-hour job A is on machine 1, 0 if on machine 2
x2 = cp.Variable(name='x2', boolean=True)  # 1 if the 3-hour job B is on machine 1, 0 if on machine 2
x3 = cp.Variable(name='x3', boolean=True)  # 1 if the first 2-hour job is on machine 1, 0 if on machine 2
x4 = cp.Variable(name='x4', boolean=True)  # 1 if the second 2-hour job is on machine 1, 0 if on machine 2
x5 = cp.Variable(name='x5', boolean=True)  # 1 if the third 2-hour job is on machine 1, 0 if on machine 2
T = cp.Variable(name='T')  # finish time of the last machine, the makespan (hours)

objective = cp.Minimize(T)
constraints = [
    3*x1 + 3*x2 + 2*x3 + 2*x4 + 2*x5 <= T,
    -3*x1 - 3*x2 - 2*x3 - 2*x4 - 2*x5 + 12 <= T,
    T >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('x1 =', x1.value)
print('x2 =', x2.value)
print('x3 =', x3.value)
print('x4 =', x4.value)
print('x5 =', x5.value)
print('T =', T.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 6 on the integer optimum 6, a duality gap of 0. Integer problems generally have a gap.

Dual variablePricesValue
y1price of constraint '3*x1 + 3*x2 + 2*x3 + 2*x4 + 2*x5 <= T' (objective change per extra unit of its right-hand side)-0.5
y2price of constraint '-3*x1 - 3*x2 - 2*x3 - 2*x4 - 2*x5 + 12 <= T' (objective change per extra unit of its right-hand side)-0.5
y3price of constraint 'x1 <= 1' (objective change per extra unit of its right-hand side)0
y4price of constraint 'x2 <= 1' (objective change per extra unit of its right-hand side)0
y5price of constraint 'x3 <= 1' (objective change per extra unit of its right-hand side)0
y6price of constraint 'x4 <= 1' (objective change per extra unit of its right-hand side)0
y7price of constraint 'x5 <= 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 T
subject to
3 x1 + 3 x2 + 2 x3 + 2 x4 + 2 x5 <= T
3 (1 - x1) + 3 (1 - x2) + 2 (1 - x3) + 2 (1 - x4) + 2 (1 - x5) <= T
T >= 0
binary: x1, x2, x3, x4, x5
# x1 = 1 if the 3-hour job A is on machine 1, 0 if on machine 2
# x2 = 1 if the 3-hour job B is on machine 1, 0 if on machine 2
# x3 = 1 if the first 2-hour job is on machine 1, 0 if on machine 2
# x4 = 1 if the second 2-hour job is on machine 1, 0 if on machine 2
# x5 = 1 if the third 2-hour job is on machine 1, 0 if on machine 2
# T = finish time of the last machine, the makespan (hours)
# objective = time at which all jobs are finished (hours)

Change the numbers and solve it

Checked: the app's answer matches the reference answer in our test set, which two solvers (HIGHS, SCIP) 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: