Mixed-integer linear programming (MILP) is the class of optimization problems in which a linear objective function is minimized or maximized subject to linear constraints, while some decision variables must take integer values and the rest may remain continuous. In optimization for artificial intelligence, MILP is the standard language for discrete decisions with exact guarantees: scheduling, routing, resource allocation, neural network verification and many planning tasks that gradient methods cannot express.
The integer requirement is what makes MILP powerful and hard at the same time. A plain linear program can be solved in polynomial time, but adding integrality makes the general problem NP-hard. Modern solvers still handle instances with millions of variables in practice, because they combine branch and bound, cutting planes, presolve reductions and primal heuristics into a single search that proves how far the best known solution is from optimal.
How a MILP model is formulated
A MILP model is defined by decision variables, a linear objective and a set of linear constraints, together with an integrality condition on a chosen subset of variables. In matrix form, the problem minimizes c^T x subject to A x <= b, with bounds on every variable and with x_j integer for every index in the integer set. Binary variables, which can only be 0 or 1, are the most common integer type because they encode yes-or-no decisions.
The modeling skill lies in expressing logical relations through linear inequalities. Implications, fixed costs, either-or constraints and piecewise linear functions are all written with binary indicators. The big-M technique links a binary switch to a continuous quantity, for example forcing production to zero unless a facility is opened. Choosing a tight value for M matters greatly, because an oversized constant weakens the model.
The table below summarizes the building blocks of a typical formulation and the role each one plays.
| Component | Mathematical form | Typical meaning |
|---|---|---|
| Continuous variable | x in a real interval | Flow, quantity, time or power level |
| Integer variable | x in a range of integers | Number of vehicles, machines or batches |
| Binary variable | x in {0, 1} | Open a site, assign a task, select an item |
| Objective function | minimize c^T x | Cost, makespan, distance or lost revenue |
| Linear constraint | a^T x <= b | Capacity, demand, budget or precedence |
| Indicator constraint | z = 1 implies a^T x <= b | Conditional rule tied to a decision |
How solvers find and prove optimal solutions
MILP solvers rely on the linear programming relaxation, which drops the integrality requirement and yields a bound on the best achievable objective. If the relaxed solution already satisfies integrality, it is optimal. Otherwise the solver branches on a fractional variable, creating two subproblems with tighter bounds, and explores the resulting tree while pruning nodes whose bound cannot beat the incumbent.
Cutting planes strengthen the relaxation by adding inequalities that remove fractional points without cutting off any integer solution. Gomory cuts, mixed-integer rounding cuts, cover cuts and clique cuts are standard families. The combination of both ideas, called branch and cut, is the core of every competitive solver, and it is supported by presolve, which removes redundant rows and fixes variables before the search starts.
Progress is reported through the optimality gap, the relative difference between the best integer solution found and the best proven bound. A gap of zero certifies optimality, and many practical runs stop at a gap of 0.1 to 1 percent to save time. The table below lists the main solver components and their effect.
| Component | What it does | Effect on performance |
|---|---|---|
| Presolve | Removes redundant constraints and fixes variables | Smaller and tighter model |
| LP relaxation | Solves the problem without integrality | Provides the dual bound |
| Branching | Splits the domain of a fractional variable | Drives the tree search |
| Cutting planes | Adds valid inequalities to the relaxation | Closes the gap faster |
| Primal heuristics | Searches for good feasible solutions early | Improves the incumbent |
| Node selection | Chooses which open node to process next | Balances bound and solution quality |
MILP compared with related optimization classes
MILP sits between linear programming and more general nonlinear models. Pure integer programming is the special case in which every variable is integer, while quadratic and nonlinear variants allow curved objectives or constraints at a higher computational price. The comparison below helps decide which class a problem belongs to.
| Problem class | Variables | Complexity | Typical solution method |
|---|---|---|---|
| Linear programming | Continuous only | Polynomial time | Simplex or interior-point method |
| Mixed-integer linear programming | Continuous and integer | NP-hard in general | Branch and cut |
| Pure integer programming | Integer only | NP-hard in general | Branch and cut, enumeration |
| Mixed-integer quadratic programming | Continuous and integer | NP-hard in general | Branch and cut with QP relaxations |
| Constraint programming | Finite domains | NP-hard in general | Propagation and search |
| Metaheuristics | Any encoding | No optimality proof | Simulated annealing, tabu search |
The decisive difference from metaheuristics is the bound. A metaheuristic may find good solutions quickly, but only a MILP solver reports how far a solution is from the optimum, which is essential when decisions carry contractual or safety consequences.
Where MILP is used in artificial intelligence
In artificial intelligence, MILP serves both as a decision layer on top of predictions and as a tool for analyzing models. A demand forecast produced by a neural network often feeds a MILP that decides orders, shifts or routes, an approach known as predict-then-optimize. MILP also encodes ReLU networks exactly, because each ReLU unit can be modeled with one binary variable and big-M constraints.
- Neural network verification: proving that no input within a perturbation radius changes the predicted class.
- Counterfactual explanations: finding the smallest feature change that flips a model decision under feasibility rules.
- Optimal decision trees: training sparse trees with a proven optimal accuracy for a given depth.
- Learning to optimize: using graph neural networks to guide branching and heuristics inside solvers.
The last direction reverses the relationship: machine learning accelerates MILP solvers by imitating expensive branching rules or predicting promising partial assignments. These learned components usually keep the exactness of the solver, since the search still proves optimality.
Limitations and common modeling mistakes
Solve time for MILP is highly sensitive to the formulation. Two mathematically equivalent models can differ by several orders of magnitude in runtime, because one has a much tighter relaxation. Symmetry is another frequent problem: identical machines or vehicles create many equivalent solutions that the tree must explore repeatedly.
| Symptom | Likely cause | Remedy |
|---|---|---|
| Gap stays large for hours | Weak big-M values | Derive tight bounds for each constraint |
| Many equivalent solutions | Symmetric variables | Add symmetry-breaking constraints |
| Numerical warnings | Coefficients spanning many magnitudes | Rescale units and data |
| Model reported infeasible | Conflicting hard constraints | Compute an irreducible infeasible subset |
| Slow LP at each node | Very large dense model | Decompose or aggregate the data |
Linearity itself is a restriction. Nonlinear effects must be approximated with piecewise linear segments, which adds binary variables and can enlarge the search tree. For very large or time-critical tasks, practitioners often combine MILP with decomposition methods or accept a heuristic solution with a known gap.
Stripped to the essentials
MILP is a way to make the best possible choice under strict rules. Some choices are amounts, such as liters or hours. Other choices are whole numbers or simple yes-or-no decisions, such as whether to open a warehouse.
A computer explores the options in a smart order. It first solves an easier version that ignores the whole-number rule. Then it splits the problem into smaller cases and drops the cases that cannot win. In the end it delivers a plan and states how close that plan is to the true best.
Where it is applied
A regional grocery distributor uses a machine learning model to forecast daily demand for 240 stores. The forecasts feed a MILP that decides which of 12 depots serve each store, how many trucks to dispatch and which delivery windows to use. Binary variables represent depot-to-store assignments and truck usage, while continuous variables represent shipped volume.
The model has about 80,000 variables and 120,000 constraints. A commercial solver finds a plan within a 0.5 percent optimality gap in under ten minutes each night. Compared with the previous rule-based dispatch, the planning team reports fewer trucks on the road and fewer missed delivery windows, and it can explain every decision by pointing to the constraints that shaped it.