Integer Linear Programming 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
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?
Results
Enter your model in the tables and click Solve.
Solution walkthrough (very detailed, your current model)
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.
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
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
x1 + x2 β€ 1
x1,x2 β {0,1}
Expected optimum: x1=1, x2=0, Z=5
B3 β Minimization (2 vars): Simple cost minimization
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
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)
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)
x + y β€ 1
x + y β₯ 3
x,y integers β₯0
Expected: infeasible.
Difficult
D1 β Binary knapsack (4 items)
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)
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)
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)
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)
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.
Sources
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.
Disclaimer
Please read before relying on this page. The ILP Solver uses branch-and-bound within the node and time limits shown. Large problems may stop before proving optimality, and the result depends entirely on the model you enter. Validate models and results before using them for real decisions.
Your responsibility. Results are estimates for general information and education only, and nothing here is professional advice. You use this page at your own risk; to the fullest extent permitted by law, CalcTypes, its authors and reviewers accept no liability for loss, injury or damage arising from reliance on it. Spotted an error? Use βReport an issueβ or our contact page. Full terms: Disclaimer Β· Terms of use.