Integer programming (IP) is the branch of mathematical optimization in which some or all decision variables are restricted to integer values while an objective function is minimized or maximized subject to constraints. In its most common form, integer linear programming (ILP), both the objective and the constraints are linear, and the only departure from a linear program is the integrality requirement.
In artificial intelligence, integer programming is the standard tool for discrete decisions with hard rules: scheduling, resource allocation, structured prediction, model compression and planning. The integrality condition looks like a small change, yet it turns a problem solvable in polynomial time into one that is NP-hard in general, which is why solver technique, formulation quality and problem size dominate practical success.
How an integer program is formulated
An integer program consists of decision variables, a linear objective and a set of linear constraints, plus a statement of which variables must be integral. The canonical form is to minimize c^T x subject to Ax <= b, x >= 0 and x integer. When only some variables are integral, the model is a mixed-integer linear program (MILP); when every variable is limited to 0 or 1, it is a binary or 0-1 integer program.
Binary variables are the main modeling device. They encode yes-or-no choices, logical implications and fixed costs. A constraint such as y_i <= x_j expresses that item i can be used only if facility j is opened, and a big-M constraint can switch a continuous restriction on or off depending on a binary variable.
The following table lists the main problem classes that share the integer programming framework.
| Variant | Variable types | Typical use |
|---|---|---|
| Pure integer program | All integer | Cutting stock, lot sizing |
| Binary program | All 0 or 1 | Selection, assignment, set covering |
| Mixed-integer linear program | Integer and continuous | Supply chain, energy dispatch |
| Mixed-integer nonlinear program | Integer, continuous, nonlinear terms | Process design, network flow with losses |
| Integer quadratic program | Integer with quadratic objective | Portfolio selection with lot sizes |
Why integrality makes the problem hard
The feasible region of a linear program is a convex polyhedron, and an optimum always sits at a vertex, which the simplex algorithm or an interior-point method finds efficiently. Requiring integers replaces this convex set with a discrete lattice of points inside the polyhedron, so local improvement arguments no longer guarantee a global optimum.
Simply rounding the LP solution is unreliable. The rounded point may violate constraints, and even when it is feasible, it can be arbitrarily far from the true integer optimum. The difference between the best integer value and the relaxation value is called the integrality gap, and a small gap is the hallmark of a good formulation.
Formulation strength matters as much as solver speed. Two models with the same integer solutions can have very different LP relaxations; the tighter one, whose relaxation lies closer to the convex hull of integer points, is usually solved orders of magnitude faster.
Solution methods used by integer programming solvers
Modern solvers combine several exact and heuristic techniques in a single branch-and-cut framework. The table below summarizes the core methods and their roles.
| Technique | What it does | Effect on search |
|---|---|---|
| Branch and bound | Splits on fractional variables and prunes by bounds | Guarantees optimality, tree may grow exponentially |
| Cutting planes | Adds valid inequalities that remove fractional points | Tightens the relaxation, shrinks the tree |
| Presolve | Removes redundant rows, fixes variables, tightens bounds | Reduces model size before search |
| Primal heuristics | Finds good feasible solutions early | Improves the incumbent and enables pruning |
| Decomposition | Splits structure, as in column generation or Benders | Handles very large structured models |
Solvers report a lower bound and an incumbent solution throughout the run. The relative difference between them, the optimality gap, tells the user how far the current answer can be from optimal. Practitioners often stop at a gap of 0.1 to 1 percent when a proven optimum would take hours longer.
Widely used solvers include commercial engines such as Gurobi, CPLEX and Xpress, and open-source options such as HiGHS, SCIP and CBC. Modeling layers such as Pyomo, PuLP, JuMP and OR-Tools let developers express a model once and switch solvers.
Integer programming compared with related methods
Integer programming sits between continuous optimization and general combinatorial search. The comparison below helps decide which approach fits a given problem.
| Approach | Optimality guarantee | Strength | Weakness |
|---|---|---|---|
| Linear programming | Global, polynomial time | Fast and scalable | Cannot express discrete choices |
| Integer programming | Global with proof gap | Exact, expressive with binaries | Worst-case exponential time |
| Constraint programming | Global for satisfaction | Strong on scheduling logic | Weaker bounds for optimization |
| Metaheuristics | None | Flexible, fast first solutions | No quality certificate |
| Reinforcement learning | None | Learns policies across instances | Hard to enforce constraints exactly |
A distinctive advantage of integer programming is the certificate of solution quality. A simulated annealing run or a learned heuristic returns a solution without saying how good it is, whereas a branch-and-bound solver always reports a provable bound.
Uses of integer programming in AI systems
Integer programming appears throughout machine learning and AI, both as a component inside models and as the decision layer that acts on model predictions. Common roles include the following.
- Structured prediction: MAP inference in graphical models, dependency parsing and alignment can be written as ILPs with consistency constraints.
- Predict-then-optimize pipelines: a model forecasts demand or travel times, and an MILP turns the forecasts into feasible plans.
- Verification of neural networks: ReLU networks can be encoded exactly with binary variables to prove robustness properties.
- Model compression: choosing bit widths or pruned channels under a memory budget is a knapsack-style integer program.
- Learning to optimize: graph neural networks learn branching rules or heuristics that speed up classical solvers.
The integration also runs in the other direction. Research on machine learning for combinatorial optimization trains models on solver logs to choose branching variables, select cuts or warm-start the search, typically improving runtime on recurring problem families rather than on arbitrary instances.
Common mistakes and practical limits
Most performance problems come from the model rather than the solver. The table maps frequent symptoms to causes and remedies.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Huge search tree | Weak big-M values | Use the smallest valid M or indicator constraints |
| Many equivalent optima | Symmetry in identical resources | Add symmetry-breaking constraints |
| Numerical warnings | Coefficients spanning many magnitudes | Rescale units and data |
| No feasible solution found | Over-constrained or conflicting rules | Compute an irreducible infeasible subsystem |
| Slow on daily reruns | Cold start each time | Supply a warm start from the previous plan |
Problem size alone does not predict difficulty. Some models with millions of variables solve in seconds because their relaxation is nearly integral, while poorly structured models with a few hundred binaries can remain open for days. Testing on realistic instances is the only reliable way to judge solve time.
In plain words
Integer programming is a way to find the best plan when choices come in whole units. You cannot send half a truck or hire a third of a nurse. The method respects that rule and every other limit you write down.
The difficulty is the number of combinations. A computer cannot try them all. Good solvers rule out large groups of bad options at once. They also tell you how close the answer is to the best possible one.
A real-world example
A regional hospital builds monthly nurse rosters for 120 nurses across three shifts. Rules cover minimum staff per ward, at least 11 hours of rest between shifts, skill mix for intensive care and individual leave requests. Planners formerly spent about a week on the roster by hand.
The team models each assignment as a binary variable for nurse, day and shift, which gives roughly 11,000 binaries. A machine learning model forecasts patient admissions per ward, and the forecasts set the staffing constraints. An open-source MILP solver returns a roster within a 0.5 percent optimality gap in under ten minutes.
The result is a schedule that meets every hard rule and honors more leave requests than the manual plan. When a nurse calls in sick, the planner fixes the existing assignments, reruns the model with a warm start and receives a repaired roster in seconds.