CalcTypes
Calculator

Integer Linear Programming Calculator

Last updated:  |  View sources  |  Methodology
Jump to Calculator

Integer Linear Programming (ILP/MILP) Calculator

Solve integer, binary (0–1), and mixed-integer linear programs. Shows LP relaxation bound and branch-and-bound steps.

Inputs

Branch & Cut is limited to small models (n ≀ 6, m ≀ 8). Learn more: Branch-and-bound Β· Gomory cutting plane method

Advanced solver settings

Learn more: Integrality tolerance

Model tables (edit your ILP here)

Tables render automatically when you change n or m. For very large nΓ—m, rendering can be slow; use Render tables if needed. Learn modeling tips: How to model ILP.

Advanced sharing (Import/Export JSON)

JSON is an advanced format for saving/restoring the exact model. If you’re new, you can ignore this section. Learn: What is model JSON?

Method: β€” n: β€” m: β€” Gap: β€” Nodes: β€”

Results

Status
β€”
Objective (integer)
β€”
LP relaxation bound
β€”
Optimality gap
β€”
Nodes explored / pruned
β€”
Runtime
β€”

Enter your model in the tables and click Solve.

Solution walkthrough (very detailed, your current model)
Solve a model to generate a detailed walkthrough here.

Format: #wt=…&autocalc=1

Graph

For n = 2, this shows a feasible-region scatter. For n > 2, this shows a solution-value bar chart (not a feasible region, since higher-dimensional regions cannot be visualized in 2D). Chart.js is used only if your site already provides it.

Solve a model, then open this section to render the graph.
Branch-and-Bound steps

Node table shows LP bounds, fractional variables, branch decisions, parent-child relationships, and fathom reasons.

Why Parent / Branch can be blank: the root node has no parent or incoming branch. If the root LP relaxation is already integer-feasible, the solver can finish without creating child nodes, so no Parent / Branch values will appear. To confirm that branching is being logged, try a model whose LP relaxation is fractional, for example: maximize x1, subject to 2x1 ≀ 3, with x1 integer and x1 β‰₯ 0. The root relaxation is x1 = 1.5, so branch-and-bound must create child nodes.

Steps will appear after you solve (if enabled).

On this page

Worked Examples

Each example includes a β€œLoad this example” button that fills the tables for you.

Beginner

B1 β€” ILP (2 vars): Max 3x + 2y
Maximize Z = 3x + 2y
2x + y ≀ 4
x + 2y ≀ 5
x,y β‰₯ 0 integers
Expected optimum: x=1, y=2, Z=7
B2 β€” Binary (2 vars): Choose at most one
Maximize Z = 5×1 + 3×2
x1 + x2 ≀ 1
x1,x2 ∈ {0,1}
Expected optimum: x1=1, x2=0, Z=5
B3 β€” Minimization (2 vars): Simple cost minimization
Minimize Z = 2x + 3y
x + y β‰₯ 4
2x + y β‰₯ 6
x,y β‰₯ 0 integers
Notes: LP relaxation gives a bound; branching forces integrality.
Expected optimum: x=4, y=0, Z=8.

Medium

M1 β€” MILP: One integer + one continuous variable
Maximize Z = 4x + 1y
2x + y ≀ 7
x + 2y ≀ 8
x integer β‰₯0, y continuous β‰₯0
This shows why MILP can mix variable types.
Expected optimum: x=3, y=1, Z=13.
M2 β€” Equality constraint (requires artificials in simplex)
Maximize Z = x + y
x βˆ’ y = 0
x ≀ 5, y ≀ 5
x,y integers β‰₯0
Good for testing equality handling + bounds.
Expected optimum: x=5, y=5, Z=10.
M3 β€” Infeasible ILP (diagnostic example)
Maximize Z = x + y
x + y ≀ 1
x + y β‰₯ 3
x,y integers β‰₯0
Expected: infeasible.

Difficult

D1 β€” Binary knapsack (4 items)
Maximize Z = 8×1 + 10×2 + 6×3 + 4×4
4×1 + 6×2 + 3×3 + 2×4 ≀ 9
x1,x2,x3,x4 ∈ {0,1}
Notes: a classic B&B workload.
Expected optimum: x1=1, x2=0, x3=1, x4=1 (weight 9), Z=18.
D2 β€” Mixed signs (tests numeric stability)
Maximize Z = 3×1 βˆ’ 2×2 + 4×3
x1 βˆ’ x2 + x3 ≀ 4
βˆ’2×1 + x2 + 2×3 ≀ 3
x1,x2,x3 integers β‰₯0
Notes: negative coefficients are allowed.
Expected status: unbounded. Raising x1 and x2 together (x1 = x2 = t) keeps both constraints satisfied while Z grows by t, so there is no maximum. Add an upper bound (for example x1 ≀ 10) to get a finite optimum.
D3 β€” MILP with bounds (tests UB/LB)
Minimize Z = x + 2y + z
x + y + z β‰₯ 7
2x + y ≀ 10
x integer [0,10], y continuous [0,10], z binary
Notes: bounds significantly affect feasibility and speed.
Expected optimum: x=4, y=2, z=1, Z=9.

Extreme (still browser-safe)

X1 β€” 6-variable binary knapsack (heavier B&B)
Maximize Z = 9×1 + 6×2 + 7×3 + 10×4 + 4×5 + 8×6
5×1 + 3×2 + 4×3 + 6×4 + 2×5 + 5×6 ≀ 12
x1..x6 ∈ {0,1}
Notes: may explore many nodes; adjust node/time limits if needed.
Expected optimum: x1=x2=x3=1, others 0 (weight 12), Z=22.
X2 β€” Branch & Cut β€œsmall mode” demo (n=6,m=8)
Maximize Z = 2×1 + 3×2 + x3 + 4×4 + 2×5 + 5×6
x1 + x2 + x3 ≀ 4
x4 + x5 + x6 ≀ 4
x1 + x4 ≀ 4
x2 + x5 ≀ 4
x3 + x6 ≀ 4
x1 + x2 + x4 ≀ 5
x2 + x3 + x5 ≀ 5
x3 + x4 + x6 ≀ 5
x1..x6 integers β‰₯0
Notes: intended for β€œBranch & Cut (small; Gomory)” mode.
Expected optimum: x2=4, x6=4, others 0, Z=32.

Questions People Ask

Integer Linear Programming basics (ILP vs LP)

What is the difference between linear programming and integer linear programming?

LP allows continuous variables, so optimal solutions can be fractional. ILP forces some or all variables to be integers (often 0–1), making the feasible set discrete and typically harder.

This calculator shows the LP relaxation bound and the integer solution.

Why does the LP relaxation give a fractional solution in ILP?

Relaxing integrality expands the feasible region to a continuous polytope. The best corner point can fall between integer lattice points.

Branch-and-bound (and optional cuts in small mode) enforces integrality.

What’s the difference between ILP and MILP?

ILP means all decision variables are integer. MILP allows a mix of integer/binary and continuous variables.

Set each variable type in the Variables table. Learn more: ILP vs MILP.

Can I use simplex directly for integer programming?

Simplex by itself solves the LP relaxation and does not enforce integer restrictions.

Integer and mixed-integer solvers add an integer-optimization procedure such as branch-and-bound or branch-and-cut to enforce integrality.

Branch-and-Bound step-by-step (how the calculator decides)

How does branch and bound guarantee the optimal integer solution?

Each node solves an LP relaxation that bounds the best possible integer solution within that branch.

Nodes are pruned if infeasible, already integral, or dominated by bounds. When all nodes are fathomed, the best found integer solution is optimal.

What is an LP relaxation bound and how is it used for pruning?

For maximization, the node LP objective is an upper bound on integer solutions in that node.

If that bound is ≀ the incumbent objective, the node cannot improve and is pruned. The node table shows the prune reason. Learn more: LP relaxation bound.

Which variable should I branch on (most fractional vs largest impact)?

β€œMost fractional” chooses an integer-restricted variable whose fractional part is closest to 0.5, producing relatively balanced branches. β€œLargest impact” is a heuristic that prioritizes variables estimated to matter more to the objective or feasibility.

This calculator supports both and logs the chosen branch constraint.

What does β€œfathomed node” mean in branch and bound?

A node is fathomed when it no longer needs explorationβ€”because it is infeasible, integral, or dominated by bounds.

The calculator records the fathom reason for each node.

What is the optimality gap in integer programming?

The gap compares the incumbent objective to the best remaining bound from unexplored nodes. 0% means optimality is proven.

If time/node limit stops early, the gap estimates how close the solution is to optimal. Learn more: Optimality gap in MIP.

How This Calculator Works (methodology)

This calculator is a browser-based educational ILP/MILP solver. It solves a sequence of LP relaxations (via a Big-M simplex method) and enforces integrality using Branch-and-Bound. For deeper learning, see the ILP Beginner’s Guide, our Branch-and-Bound guide, and the LP relaxation bound explainer.

Internally, the solver: (1) normalizes constraints, (2) handles variable bounds by turning upper bounds into constraints, (3) applies a nonnegative-variable transformation by shifting lower bounds, (4) solves each node’s LP relaxation, (5) checks integrality using your tolerance, (6) branches on a fractional integer variable, and (7) prunes nodes that are infeasible, integral, or cannot improve the incumbent.

Big‑M simplex note: equalities and β€œβ‰₯” constraints introduce artificial variables. A large penalty (M) discourages them in the optimum. This approach is simple and educational, but can be sensitive to scaling. If you use very large/small coefficients, consider rescaling your model.

Objective:  Z = Ξ£ c_i x_i + constant
Constraints: Ξ£ a_(j,i) x_i  (≀, =, β‰₯)  b_j

Integrality check: |x_i - round(x_i)| ≀ tol
Display rounding: 6 decimals (internals full precision)

Gap:
  max: (BestBound - Incumbent) / max(1, |BestBound|)
  min: (Incumbent - BestBound) / max(1, |Incumbent|)

Note: browser solvers can be sensitive to degeneracy and numeric conditioning. For mission-critical decisions, validate with OR‑Tools / CBC / Gurobi / CPLEX and compare results.

IMPORTANT DISCLAIMER (Read before using): This ILP/MILP calculator runs entirely in your browser and is intended for learning, demonstrations, and planning only. It may produce incorrect or incomplete results for numerically difficult models (e.g., poor scaling, degeneracy, very large coefficients, tight Big‑M bounds, or large branch-and-bound trees). Do not use this output as the sole basis for high‑stakes decisions (financial, legal, safety, medical, compliance, or operational-critical). Always validate with a production-grade solver and/or a qualified professional. See our Disclaimer.
Sources
  1. Google OR-Tools β€” Solving a MIP Problem. Link
  2. COIN-OR CBC Solver β€” Branch and Bound. Link
  3. AMPL β€” Introduction to Linear and Integer Programming. Link

Assumptions and Limitations

Assumptions

  • The objective and every constraint are linear, and all coefficients are known constants.
  • Variables marked integer or binary must take whole-number (or 0/1) values; others are continuous.
  • Branch-and-bound stops at the node and time limits shown, using the integrality tolerance you set.

Limitations

  • Large or poorly formulated models may hit the limits before optimality is proven; the gap is reported.
  • Software uses floating-point arithmetic, so tiny rounding differences from hand calculations are normal.
  • The result is only as good as the model: a missing constraint gives a correct answer to the wrong problem.