ILP Beginner’s Guide: Integer Linear Programming

Last updated: Sources Methodology

ILP Beginner’s Guide: Integer Linear Programming from zero to “I can model it”

A simplified college-level lesson in plain English: how to model discrete decisions, why LP relaxation bounds matter, and how to read solver results without guesswork.

Learn by doing: open the Integer Linear Programming calculator and build a tiny model while you read. When we talk about “relaxing integrality” to get a bound, test that immediately in the Linear Programming calculator. When you see “stopped with gap,” use the optimality gap guide to interpret what’s certified.

On this page

Quick takeaway: ILP is the tool you use when decisions must be whole numbers (often yes/no). By the end of this guide, you should be able to: (1) translate a real-world decision into variables and constraints, (2) recognize common constraint patterns (budget, assignment, logic), (3) use an LP relaxation bound to predict difficulty (LP relaxation bound), and (4) interpret solver output using incumbent vs best bound and the optimality gap.

What is Integer Linear Programming (ILP) in plain English?

Beginner level

ILP is “choose the best combination” under rules

Think of ILP as a disciplined way to answer: “Out of many possible combinations, which one is best—while obeying all the rules?” The rules are constraints (budgets, capacity, logic). The best is your objective (min cost, max profit, min lateness, etc.).

The integer part matters because many decisions cannot be fractional: you can’t open 0.3 warehouses or assign 0.5 people to a shift. When a model forces those decisions to be whole numbers, it becomes an integer program.

Intermediate level

The standard math form you’ll see in solvers

minimize or maximize:   cᵀx
subject to: A x ≤ b
x ∈ ℤⁿ
Common special cases:
• Binary ILP: x ∈ {0,1}ⁿ
• Bounded integers: ℓ ≤ x ≤ u, x ∈ ℤⁿ

If you add continuous variables (flows, amounts, time) alongside integer variables, you get a mixed-integer linear program (MILP). If you’re not sure which you have, the decision-focused explanation in ILP vs MILP helps.

College-level (simplified)

Why ILP feels harder than LP: geometry + combinatorics

In linear programming (LP), the feasible region is a continuous polytope. In ILP, you’re restricted to integer points inside that polytope. The solver can’t simply slide to the best corner; it must reason about discrete combinations.

Practical implication: runtime depends heavily on how tight the LP relaxation is. That’s why professionals compute and compare an LP relaxation bound early (see LP relaxation bound).

A repeatable ILP modeling method (story → math)

Method

Step 1: Write the decision in one sentence

Example: “Choose which projects to fund to maximize expected value without exceeding budget and with at most one project per team.” This sentence already contains your objective and two constraint families.

Method

Step 2: Define variables that match the decision (not the math)

Beginners often define too many variables. Start with the smallest set that directly represents the decision. Common ILP variables: x_i = 1 if you choose item i; x_{ij} = 1 if you assign i to j.

Pro tip: If you can explain each variable aloud (“what does 1 mean?”), your model becomes easier to debug and explain.

Method

Step 3: Build constraints in “families”

Don’t write constraints randomly. Write them as families: “for each task…”, “for each worker…”, “for each day…”. This is also how you validate them (checking one row at a time).

If you want a pattern library for constraints and logic modeling, use how to model an ILP.

Method

Step 4: Decide objective coefficients and units (then sanity-check)

A common beginner error is unit mismatch: mixing dollars, hours, and penalties without scaling. Your objective coefficients should reflect one consistent “score” you genuinely want to optimize.

Sanity check: if you double every coefficient in the objective, the chosen solution should not change (only the objective scales).

Constraint “grammar” cheat sheet (patterns you’ll reuse forever)

Cheat sheet

Common patterns and how they read in English

Pattern Math form Plain-English meaning Where it shows up
Budget / knapsack Σ a_i x_i ≤ B Total resource used can’t exceed a limit Funding, capacity, time, weight, cost
Choose exactly one Σ x_i = 1 Pick one option and only one Configuration, category choice, routing step
Choose at most one Σ x_i ≤ 1 You may pick none or one Mutual exclusivity
Coverage / requirement Σ a_i x_i ≥ R Meet a minimum requirement Service levels, staffing, demand
Implication (binary) x ≤ y If x is 1, then y must be 1 Prerequisites, dependencies
At least k chosen Σ x_i ≥ k Select at least k items Diversity, redundancy, minimum teams

Once you can write these patterns from memory, the “hard part” becomes choosing the right variables and correct coefficients.

Binary vs integer vs continuous (and when MILP appears)

Domains

Choosing the domain is part of modeling—not a technical afterthought

Domain Typical meaning Beginner pitfall Good practice
Binary {0,1} Yes/no, choose/not choose Missing linking constraints makes binaries “float” Always connect binaries to real constraints (budget, assignment, capacity)
Integer Counts, batches No bounds → huge search space Add realistic lower/upper bounds whenever possible
Continuous Flow, amount, time Forcing continuous to be integer “just because” Use continuous unless discreteness is truly required

If you have both continuous and discrete decisions, you’re in MILP territory. Use ILP vs MILP to decide whether the mixed structure is necessary.

What happens if you relax integrality?

Key concept

LP relaxation: the fastest bound and the best modeling diagnostic

Relaxing integrality means turning binary/integer restrictions into continuous ones (while keeping bounds). Example: x ∈ {0,1} becomes 0 ≤ x ≤ 1.

The solution gives the LP relaxation bound. For minimization it’s a lower bound; for maximization it’s an upper bound.

How professionals use this: If the relaxation is far from your best integer solution, the model is often weak (Big-M too large, loose bounds, missing strengthening constraints). Deep dive: LP relaxation bound.

How ILP solvers work: branch-and-bound without the mystery

Solver mechanics

Branch-and-bound: “prove what’s impossible,” not “try random combinations”

Most ILP/MILP solvers use branch-and-bound (often with cutting planes). The solver repeatedly: (1) solves an LP relaxation to get a bound, (2) branches on a fractional variable, and (3) prunes regions that provably can’t beat the best feasible solution found (the incumbent).

Vocabulary: the best feasible solution is the incumbent; the best proven bound is the best bound. The difference is summarized by the optimality gap.

How to interpret results (optimal, feasible, infeasible, unbounded)

Interpretation

Read solver status like a scientist (what is certified?)

Status you see What it means What to do next
Optimal Solver proved no better integer solution exists (within tolerances). Implement; then do what-if analysis (sensitivity to budgets/capacity).
Feasible, not proven optimal You have an incumbent, but solver stopped early (time/gap limit). Use optimality gap to quantify uncertainty.
Infeasible No assignment satisfies all constraints. Debug constraints/data; test LP relaxation; check equalities and bounds first.
Unbounded Objective can improve without limit (usually modeling error). Check missing constraints, wrong inequality direction, or missing bounds.

If a run stops with a nonzero gap, treat it as information—not failure. The optimality gap guide shows how to interpret “2% gap” correctly.

Mini-labs with the calculators (step-by-step)

Mini-lab

Lab 1: See “integrality” with your own eyes (ILP vs LP relaxation)

  1. Solve a small binary selection model in the ILP calculator. Record the chosen items and objective.
  2. Relax each binary variable to 0 ≤ x_i ≤ 1 and solve the relaxed model in the LP calculator.
  3. Compare objectives. If the LP value is much better, your relaxation is loose—expect more branch-and-bound work. Read: LP relaxation bound.
Why this lab matters: it turns solver behavior into something measurable.

Mini-lab

Lab 2: Interpret early stopping using incumbent vs bound

  1. Run a model in the ILP calculator that may stop early.
  2. Capture the incumbent and the best bound (if reported).
  3. Interpret uncertainty using optimality gap in MIP.

If your gap is stubbornly large, tightening the formulation often works better than simply increasing runtime.

Worked examples (with “why” at every step)

Worked example (beginner)

Example 1: project selection under budget (0–1 ILP)

maximize Σ value_i x_i
subject to Σ cost_i x_i ≤ Budget
x_i ∈ {0,1}

Why this works: the budget constraint is the knapsack pattern; binaries enforce discrete selection.

Next, relax x_i to 0 ≤ x_i ≤ 1 in the LP calculator. Fractional items explain why ILP differs from LP.

Worked example (structure)

Example 2: assignment with “exactly one” constraints

minimize   Σ cost_ij x_ij
subject to Σ_i x_ij = 1 for each task j
           Σ_j x_ij ≤ cap_i for each worker i
           x_ij ∈ {0,1}

Most “wrong assignment” solutions happen because one constraint family is missing.

Worked example (logic)

Example 3: modeling a dependency (“if A then B”)

x_A ≤ x_B
x_A, x_B ∈ {0,1}

This blocks the only forbidden case: choosing A without choosing B.

For more logic patterns (either/or, at-most-k, linking), use how to model an ILP.

Debugging & common mistakes (what pros check first)

Debugging

Why is my ILP infeasible?

  • Check bounds: look for hidden contradictions like x ≥ 1 and x ≤ 0.
  • Check equalities: “exactly one” constraints clash easily with tight capacity.
  • Relax integrality: if even the LP is infeasible, the issue is constraints/data, not integrality.

The diagnostic logic is explained in LP relaxation bound.

Common mistakes

Mistake: “Not optimal” ≠ “bad solution”

Many solvers stop with a feasible incumbent but without a proof of optimality. Use the optimality gap to quantify what’s still possible.

Questions people ask about Integer Linear Programming (PAA)

People ask

How do I know whether my problem should be ILP or MILP?

If some decisions must be discrete (yes/no, counts) but other quantities are naturally continuous (flows, time, energy), you likely need MILP. If everything must be discrete, you’re in ILP. A practical guide is: ILP vs MILP.

People ask

Why does my ILP solution look “weird” even though it’s feasible?

Usually a missing rule. Rewrite your story sentence, then ensure each rule appears as a constraint family. The pattern checklist in how to model an ILP is designed for this.

People ask

What is the LP relaxation bound and why do professionals compute it?

It’s the objective value you get when you drop integrality but keep all linear constraints and bounds. It predicts how hard branch-and-bound may need to work and helps diagnose weak formulations: LP relaxation bound.

Next steps to build real ILP skill

Learning path

A progression that mirrors how ILP is learned in practice

  1. Build and solve 2–3 tiny models with the ILP calculator.
  2. Learn reusable constraint patterns with how to model an ILP.
  3. Use LP relaxation bounds as your diagnostic tool with the LP calculator.
  4. Interpret early stopping using optimality gap.
  5. Understand solver mechanics using branch-and-bound.

Disclaimer

This content and the associated calculators are provided for educational and informational purposes only. Results depend entirely on your model assumptions and input data. This is not legal, financial, operational, or safety advice. Always validate constraints, units, and feasibility against real-world requirements and consult a qualified professional for high-stakes decisions.

Sources
  1. Google OR-Tools Optimization Documentation
  2. Gurobi — Mixed-Integer Programming: An Introduction to the Basics
  3. SCIP Documentation