The optimality gap is the absolute or percentage difference between the objective value of the best-known feasible solution (the incumbent) and a proven bound on the optimal value. For a minimization problem, this bound is a lower bound; for maximization, it is an upper bound. A gap of zero confirms optimality, while a positive gap indicates the potential for improvement. This metric is fundamental for evaluating heuristic and exact algorithms in problems like the Vehicle Routing Problem (VRP) and Job Shop Scheduling.
Glossary
Optimality Gap

What is Optimality Gap?
The Optimality Gap is a core metric in mathematical optimization and operations research, quantifying how close a feasible solution is to the theoretical optimum.
In practice, calculating the exact optimality gap is often impossible for NP-hard problems, as the true optimum is unknown. Solvers instead use the best available bound, such as the linear programming relaxation in Mixed-Integer Programming (MIP). The gap is crucial for decision-making, allowing CTOs and operations researchers to trade off solution quality against computation time. A small, proven gap provides high confidence in a schedule or plan's efficiency within complex spatial-temporal scheduling systems.
Key Components of the Optimality Gap
The optimality gap is not a single value but a composite metric derived from the interplay between solution quality and computational bounds. Understanding its components is essential for interpreting its value and guiding optimization efforts.
The Incumbent Solution
The incumbent solution is the best feasible solution found by the solver at a given point in the search. It represents the upper bound (for minimization problems) on the optimal solution's cost. Its quality directly determines the gap's numerator.
- Role: Provides the known, implementable plan (e.g., a specific vehicle route schedule).
- Source: Typically found by heuristic algorithms (like a greedy construction) early in the search and improved via local search or metaheuristics.
- Key Property: As the solver runs, the incumbent should monotonically improve, tightening the gap from above.
The Lower Bound
The lower bound is a provable, mathematical estimate of the best possible objective value, derived without necessarily finding a feasible solution. For minimization, the true optimum lies between this bound and the incumbent.
- Calculation Methods: Often comes from solving a Linear Programming (LP) relaxation of the original Mixed-Integer Programming (MIP) model, or from combinatorial arguments like the Held-Karp bound for the Traveling Salesman Problem (TSP).
- Role: Provides an absolute benchmark for solution quality. A gap of 0% means the incumbent's cost equals the lower bound, proving optimality.
- Progression: In exact algorithms like Branch and Bound, the global lower bound strengthens as the search tree is explored.
The Absolute Gap
The absolute gap is the raw numerical difference between the incumbent solution's objective value and the best-known lower bound. It is the fundamental, unscaled measure of sub-optimality.
- Formula:
Absolute Gap = Incumbent Value - Lower Bound Value(for minimization). - Interpretation: A gap of 50 means the current best solution is 50 units (e.g., meters, seconds, dollars) worse than the theoretical optimum.
- Termination Criterion: Solvers often stop when the absolute gap falls below a user-defined tolerance (e.g.,
MIPGap = 0.001in Gurobi), accepting a near-optimal solution.
The Relative Gap (%)
The relative gap (or optimality gap percentage) is the absolute gap expressed as a percentage of the lower bound (or sometimes the incumbent). It is the standard, scale-invariant metric for reporting solution quality.
- Standard Formula:
Relative Gap = ((Incumbent - Lower Bound) / |Lower Bound|) * 100%. - Business Interpretation: A 5% gap indicates the current operational plan is at most 5% more expensive than the perfect, undiscovered plan. This quantifies the value of further computation.
- Decision Tool: Helps CTOs perform a cost-benefit analysis: Is closing the final 0.5% gap worth hours of additional compute time?
The Dual Bound
In the context of Mixed-Integer Programming (MIP), the dual bound is synonymous with the best global lower bound during the optimization process. It is the solution to the continuous relaxation of the active branch-and-bound nodes.
- Mechanism: As the solver branches on integer variables, it creates nodes with LP relaxations. The dual bound is the minimum objective value among all active node relaxations.
- Convergence: The dual bound increases (for minimization) during the search, while the incumbent decreases. The optimality gap closes as these two values converge.
- Practical Insight: A rapidly improving dual bound indicates the solver is effectively pruning the search space.
The Integrality Gap
The integrality gap is a specific, structural component of the optimality gap for integer programs. It is the worst-case ratio between the optimal integer solution and the optimal solution to its LP relaxation.
- Definition: It's a property of the problem formulation, not a specific instance. A large integrality gap means the LP relaxation is weak, providing a poor lower bound and making the problem harder to solve.
- Impact on Solving: Problems with a large integrality gap (e.g., certain Vehicle Routing Problem (VRP) formulations) will have a large initial optimality gap, requiring sophisticated cutting-plane methods or stronger formulations to tighten bounds.
- Distinction: The optimality gap for a specific instance includes the integrality gap of its formulation but can be larger due to incomplete search.
Calculation and Practical Context
The optimality gap is a critical performance metric in optimization, quantifying how close a practical solution is to the theoretical best. Its calculation and interpretation are central to evaluating solution quality in complex, real-world scheduling and routing problems.
The optimality gap is calculated as the percentage difference between the objective value of the best-known feasible solution (the incumbent) and a proven lower bound (for minimization) or upper bound (for maximization) on the optimal solution. Formally, for a minimization problem, Gap = (Incumbent Value - Lower Bound) / Lower Bound * 100%. A gap of 0% certifies optimality, while a larger gap indicates remaining room for improvement. Solvers for NP-hard problems like the Vehicle Routing Problem (VRP) often report this gap as a termination criterion.
In practical spatial-temporal scheduling for a heterogeneous fleet, a small optimality gap (e.g., <5%) provides high confidence in the operational plan's efficiency regarding travel distance, makespan, or cost. It serves as a key observability metric, allowing operations researchers and CTOs to trade off computation time against solution quality. When real-time replanning is required, a known gap informs the decision to deploy the current plan or continue searching for a better one.
Optimality Gap Across Solver Types
A comparison of how different classes of optimization algorithms approach and report the optimality gap, highlighting trade-offs between solution quality, computational cost, and applicability to real-time scheduling.
| Solver Characteristic | Exact Solvers (MIP, CP) | Metaheuristics (GA, SA, TS) | Constructive Heuristics (Greedy, NN) | Reinforcement Learning (PPO, DQN) |
|---|---|---|---|---|
Theoretical Guarantee on Gap | Yes (provable bound) | No (no guarantee) | No (no guarantee) | No (asymptotic convergence only) |
Typical Reported Gap for VRP | < 0.1% | 1% - 5% | 10% - 25% | Varies widely (5% - 15%) |
Computational Time to First Feasible Solution | Minutes to hours | Seconds to minutes | < 1 second | Hours to days (training); < 1 sec (inference) |
Computational Time to Proven Optimality / Convergence | Hours to days (may not terminate) | Seconds to hours (convergence) | N/A (single pass) | Hours to days (training) |
Primary Method for Gap Calculation | Best bound vs. incumbent | Best found vs. estimated bound or best-known | Solution cost vs. estimated lower bound | Episode reward vs. estimated optimal reward |
Handles Dynamic Replanning (Online) | ||||
Scalability to Large Problems (>1000 nodes) | ||||
Solution Quality Under Tight Time Windows |
Frequently Asked Questions
The optimality gap is a critical metric in operations research and combinatorial optimization, quantifying how close a practical solution is to the theoretical best. In the context of spatial-temporal scheduling for heterogeneous fleets, understanding and minimizing this gap is essential for maximizing throughput and resource efficiency.
The optimality gap is a numerical metric that quantifies the difference between the value of the best-known feasible solution (the incumbent) and a proven bound (a lower bound for minimization problems, an upper bound for maximization problems) on the optimal solution's value. It is typically expressed as an absolute difference or, more commonly, as a percentage relative to the bound. A gap of 0% indicates proven optimality, while a larger gap signifies the potential room for improvement in the current solution.
In mathematical terms, for a minimization problem: Optimality Gap = (Incumbent Value - Lower Bound) / Lower Bound * 100%. This metric is the primary output of Mixed-Integer Programming (MIP) solvers and metaheuristic algorithms when reporting solution quality.
Enabling Efficiency, Speed & Accuracy
Intelligent Analysis, Decision & Execution
We build AI systems for teams that need search across company data, workflow automation across tools, or AI features inside products and internal software.
Talk to Us
Search across company data
Give teams answers from docs, tickets, runbooks, and product data with sources and permissions.
Useful when people spend too long searching or get different answers from different systems.

Automate internal workflows
Use AI to route work, draft outputs, trigger actions, and keep approvals and logs in place.
Useful when repetitive work moves across multiple tools and teams.

Add AI to products and internal tools
Build assistants, guided actions, or decision support into the software your team or customers already use.
Useful when AI needs to be part of the product, not a separate tool.
Related Terms
The optimality gap is a core metric within the broader field of combinatorial optimization and scheduling. These related concepts define the problems, constraints, and solution methods used to quantify and close this gap in practical systems.
Mixed-Integer Programming (MIP)
A primary mathematical optimization technique used to model and solve problems like the VRP and job shop scheduling. MIP solvers compute both a best incumbent solution and a proven lower bound, providing the exact components needed to calculate the optimality gap. The gap closes to 0% when the solver proves optimality.
- Key Components: Linear objective function, linear constraints, integer decision variables.
- Solver Output: Incumbent value, best bound, optimality gap percentage.
NP-Hard Problem
A classification of computational complexity indicating that no known algorithm can solve the problem to guaranteed optimality in polynomial time for all cases. Most practical scheduling and routing problems (VRP, TSP, job shop) are NP-hard. This intrinsic intractability is the fundamental reason why we accept non-zero optimality gaps in real-world applications—finding the provably optimal solution is often computationally prohibitive for large instances.
Heuristic & Metaheuristic Algorithms
Practical algorithms designed to find good feasible solutions to NP-hard problems within reasonable time, but without optimality guarantees. They are the primary source of incumbent solutions.
- Heuristic: Problem-specific, fast method (e.g., nearest neighbor, greedy insertion).
- Metaheuristic: High-level strategy guiding heuristics (e.g., Genetic Algorithms, Simulated Annealing, Tabu Search).
The optimality gap quantifies how far these heuristic solutions are from the best-known lower bound, guiding the trade-off between solution quality and compute time.
Branch and Bound
An exact algorithm for solving integer programming problems like MIPs. It systematically explores the solution space by:
- Branching: Dividing the problem into smaller subproblems.
- Bounding: Calculating optimistic bounds for each subproblem.
- Pruning: Discarding subproblems that cannot beat the current best solution.
This process continuously improves the global lower bound and updates the incumbent solution, dynamically reducing the optimality gap until it reaches zero (proving optimality) or the search is terminated by a time limit.
Objective Function
The mathematical expression that defines the goal of an optimization problem, such as minimizing total travel distance, makespan, or cost. The optimality gap is calculated relative to the value of this function.
- Formula: (Incumbent Value - Best Bound) / |Best Bound| * 100%.
- Minimization vs. Maximization: For minimization, the incumbent is an upper bound and the solver finds a lower bound. The gap is the percentage by which the incumbent exceeds the lower bound.

About the author
Prasad Kumkar
CEO & MD, Inference Systems
Prasad Kumkar is the CEO & MD of Inference Systems and writes about AI systems architecture, LLM infrastructure, model serving, evaluation, and production deployment. Over 5+ years, he has worked across computer vision models, L5 autonomous vehicle systems, and LLM research, with a focus on taking complex AI ideas into real-world engineering systems.
His work and writing cover AI systems, large language models, AI agents, multimodal systems, autonomous systems, inference optimization, RAG, evaluation, and production AI engineering.
Partnered with leading AI, data, and software stack.
How We Work
Custom AI workflows for your Business
One-fit-all AI don't work for modern businesses. At Inferensys, we aim to understand your business & custom requirements; which we use to define most efficient agentic workflows, the data, and the tools for your business.
01
Review the use case
We understand the task, the users, and where AI can actually help.
Read more02
Pick the right approach
We define what needs search, automation, or product integration.
Read more03
Build the first useful version
We implement the part that proves the value first.
Read more04
Improve from there
We add the checks and visibility needed to keep it useful.
Read moreThe first call is a practical review of your use case and the right next step.
Talk to Us