∇ProvenDecisions
Ctrl K

Fixed-charge (setup cost) problem: an integer programming example, solved and checked

The fixed-charge (setup cost) 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 70, at x1 = 10, x2 = 2, y1 = 1, y2 = 1. All 5 constraints are satisfied exactly. Optimal within gap tolerance.

Solve your own version free, no account needed

The problem

An order of at least 12 parts can be made on two machines. Machine 1 costs $20 to set up, then $3 per part, and makes at most 10 parts; machine 2 costs $8 to set up, then $6 per part, and makes at most 15 parts. A machine that makes no parts is not set up. Parts are whole numbers. Minimize total cost.

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 cost of setup plus per-part costs ($)
limit 1: left side must reach at least 12
limit 2: left side cannot exceed the right side
limit 3: left side cannot exceed the right side
parts made on machine 1 (parts) cannot be negative
parts made on machine 2 (parts) cannot be negative
whole numbers only
yes (1) or no (0)

In matrix form

With its numbers:

What is being decided

There are 4 decision variables.

VariableTypeMeaning
x1integerparts made on machine 1 (parts)
x2integerparts made on machine 2 (parts)
y1binary (0 or 1)1 if machine 1 is set up, 0 otherwise (yes/no)
y2binary (0 or 1)1 if machine 2 is set up, 0 otherwise (yes/no)

Goal and limits

Minimize total cost of setup plus per-part costs ($) subject to 5 constraints, of which 2 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.

x110x22y11y21

Which constraints hold the answer in place

Binding (no slack left): (1) x1 + x2 >= 12; (2) x1 <= 10*y1. Changing a binding constraint changes the answer; a slack one can move a little without effect.

#ConstraintValueLimitSlackBinding
1x1 + x2 >= 1212120yes
2x1 <= 10*y110100yes
3x2 <= 15*y221513
4x1 >= 010010
5x2 >= 0202

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', integer=True)  # parts made on machine 1 (parts)
x2 = cp.Variable(name='x2', integer=True)  # parts made on machine 2 (parts)
y1 = cp.Variable(name='y1', boolean=True)  # 1 if machine 1 is set up, 0 otherwise (yes/no)
y2 = cp.Variable(name='y2', boolean=True)  # 1 if machine 2 is set up, 0 otherwise (yes/no)

objective = cp.Minimize(3*x1 + 6*x2 + 20*y1 + 8*y2)
constraints = [
    x1 + x2 >= 12,
    x1 <= 10*y1,
    x2 <= 15*y2,
    x1 >= 0,
    x2 >= 0,
]
problem = cp.Problem(objective, constraints)
problem.solve(solver='HIGHS')
print(problem.status, problem.value)
print('x1 =', x1.value)
print('x2 =', x2.value)
print('y1 =', y1.value)
print('y2 =', y2.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 63.0667 on the integer optimum 70, a duality gap of 6.93333. Integer problems generally have a gap.

Dual variablePricesValue
y1price of constraint 'x1 + x2 >= 12' (objective change per extra unit of its right-hand side)6.53333
y2price of constraint 'x1 <= 10*y1' (objective change per extra unit of its right-hand side)-3.53333
y3price of constraint 'x2 <= 15*y2' (objective change per extra unit of its right-hand side)-0.533333
y4price of constraint 'y1 <= 1' (objective change per extra unit of its right-hand side)-15.3333
y5price of constraint 'y2 <= 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 20*y1 + 3*x1 + 8*y2 + 6*x2
subject to
x1 + x2 >= 12
x1 <= 10*y1
x2 <= 15*y2
x1, x2 >= 0
integer: x1, x2
binary: y1, y2
# x1 = parts made on machine 1 (parts)
# x2 = parts made on machine 2 (parts)
# y1 = 1 if machine 1 is set up, 0 otherwise (yes/no)
# y2 = 1 if machine 2 is set up, 0 otherwise (yes/no)
# objective = total cost of setup plus per-part costs ($)

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: