∇ProvenDecisions
Ctrl K

Cutting stock problem: an integer programming example, solved and checked

The cutting stock 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. Assumed: only these maximal cutting patterns are needed, since any other pattern is dominated by one of them; extra pieces beyond demand are allowed (>=). The smallest objective value is 3, at n1 = 0, n2 = 2, n3 = 1. All 5 constraints are satisfied exactly. Optimal within gap tolerance.

Solve your own version free, no account needed

The problem

Rolls are 10 m wide. Customers need four pieces 3 m wide and three pieces 4 m wide. What is the fewest rolls to cut?

How the model was built

The objective as written from the problem, before the numbers are multiplied out:

Assumptions:

The model

Each line has a plain-language note on the right.

make as small as possible: total number of 10 m rolls cut (rolls)
limit 1: left side must reach at least 4
limit 2: left side must reach at least 3
rolls cut with pattern A: three 3 m pieces (9 m used) (rolls) cannot be negative
rolls cut with pattern B: two 3 m pieces and one 4 m piece (10 m used) (rolls) cannot be negative
rolls cut with pattern C: two 4 m pieces (8 m used) (rolls) cannot be negative
whole numbers only

In matrix form

With its numbers:

What is being decided

There are 3 decision variables.

VariableTypeMeaning
n1integerrolls cut with pattern A: three 3 m pieces (9 m used) (rolls)
n2integerrolls cut with pattern B: two 3 m pieces and one 4 m piece (10 m used) (rolls)
n3integerrolls cut with pattern C: two 4 m pieces (8 m used) (rolls)

Goal and limits

Minimize total number of 10 m rolls cut (rolls) subject to 5 constraints, of which 3 are simple bounds on a single variable.

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.

n10n22n31

Which constraints hold the answer in place

Binding (no slack left): (1) 3*n1 + 2*n2 >= 4; (3) n1 >= 0. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
13*n1 + 2*n2 >= 4440yes
2n2 + 2*n3 >= 3431
3n1 >= 0000yes
4n2 >= 0202
5n3 >= 0101

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

n1 = cp.Variable(name='n1', integer=True)  # rolls cut with pattern A: three 3 m pieces (9 m used) (rolls)
n2 = cp.Variable(name='n2', integer=True)  # rolls cut with pattern B: two 3 m pieces and one 4 m piece (10 m used) (rolls)
n3 = cp.Variable(name='n3', integer=True)  # rolls cut with pattern C: two 4 m pieces (8 m used) (rolls)

objective = cp.Minimize(n1 + n2 + n3)
constraints = [
    3*n1 + 2*n2 >= 4,
    n2 + 2*n3 >= 3,
    n1 >= 0,
    n2 >= 0,
    n3 >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('n1 =', n1.value)
print('n2 =', n2.value)
print('n3 =', n3.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 2.5 on the integer optimum 3, a duality gap of 0.5. Integer problems generally have a gap.

Dual variablePricesValue
y1price of constraint '3*n1 + 2*n2 >= 4' (objective change per extra unit of its right-hand side)0.25
y2price of constraint 'n2 + 2*n3 >= 3' (objective change per extra unit of its right-hand side)0.5

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 n1 + n2 + n3
subject to
3 n1 + 2 n2 >= 4
n2 + 2 n3 >= 3
n1, n2, n3 >= 0
integer: n1, n2, n3
# n1 = rolls cut with pattern A: three 3 m pieces (9 m used) (rolls)
# n2 = rolls cut with pattern B: two 3 m pieces and one 4 m piece (10 m used) (rolls)
# n3 = rolls cut with pattern C: two 4 m pieces (8 m used) (rolls)
# objective = total number of 10 m rolls cut (rolls)
# assume: only these maximal cutting patterns are needed, since any other pattern is dominated by one of them; extra pieces beyond demand are allowed (>=)

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: