Simulated Annealing (SA) is a probabilistic optimization technique that finds an approximate global optimum by occasionally accepting worse solutions during its search, with the probability of acceptance decreasing over time. This mechanism, inspired by the controlled cooling of metal in metallurgy, allows the algorithm to escape local optima—suboptimal solutions that trap greedy algorithms—and explore the broader solution space.
Glossary
Simulated Annealing (SA)

What is Simulated Annealing (SA)?
Simulated Annealing is a metaheuristic optimization algorithm that probabilistically escapes local optima to approximate the global optimum of a given function, making it highly effective for complex combinatorial problems like last-mile routing.
The algorithm is governed by a temperature parameter that controls exploration versus exploitation. At high temperatures, SA behaves like a random walk, freely accepting worse solutions to explore the landscape. As the temperature cools according to a predefined cooling schedule, the algorithm becomes increasingly selective, converging toward a low-energy, near-optimal solution. In last-mile delivery, SA is frequently applied to the Vehicle Routing Problem (VRP) to minimize total distance or time.
Key Characteristics of Simulated Annealing
Simulated Annealing (SA) is a probabilistic metaheuristic for global optimization. It is uniquely defined by its ability to escape local optima through a controlled acceptance of inferior solutions, a process directly analogous to the metallurgical annealing of metals.
Metropolis Acceptance Criterion
The core decision rule that determines whether a new candidate solution is accepted. If the new solution is better, it is always accepted. If it is worse, it is accepted with a probability based on the Metropolis-Hastings algorithm:
- Probability Formula:
P(accept) = exp(-ΔE / T) - ΔE: The difference in objective function value (new_cost - current_cost).
- T: The current temperature parameter. This probabilistic acceptance is what allows the algorithm to climb out of local optima, especially at high temperatures.
Cooling Schedule Dynamics
The cooling schedule dictates the rate at which the temperature parameter T decreases over time. It is the most critical factor in balancing exploration versus exploitation:
- Exploration Phase: At high initial temperatures, the algorithm behaves like a random walk, accepting almost all moves to broadly sample the search space.
- Exploitation Phase: As
Tapproaches zero, the algorithm becomes a strict hill-climber, accepting only improving moves. - Common Schedules: Geometric decay (
T_k = α * T_{k-1}), logarithmic, and linear schedules. An improper schedule can cause premature convergence or infinite runtime.
Neighborhood Generation Function
A problem-specific heuristic that defines how to move from the current solution to a new candidate. The structure of the neighborhood directly impacts the algorithm's efficiency:
- VRP/TSP Context: Common operators include 2-opt (reversing a segment), Or-opt (relocating a segment), and swap (exchanging two nodes).
- Granularity: The perturbation size must be tuned. Too small a change leads to slow convergence; too large a change reduces the search to random sampling.
- Feasibility: The function must ensure that generated neighbors respect hard constraints, such as vehicle capacity in a Capacitated VRP.
Global Convergence Properties
Simulated Annealing is theoretically guaranteed to converge to the global optimum under specific conditions, a property known as asymptotic convergence:
- Condition: The cooling schedule must be logarithmic (
T_k = C / log(k+1)), which is computationally impractical for most real-world problems. - Practical Use: In practice, geometric cooling is used, which sacrifices the mathematical guarantee for finite-time execution. The final solution is a high-quality approximation, not a proven global optimum.
- Comparison: Unlike deterministic methods like Mixed Integer Programming (MIP), SA does not provide an optimality gap, but it can find near-optimal solutions for large-scale, non-linear problems where MIP fails to terminate.
Parameter Tuning: Initial Temperature
The starting temperature T_0 must be set high enough to ensure the search space is sufficiently explored. A standard heuristic is to set T_0 such that a defined percentage of worsening moves are initially accepted:
- Method: Perform a preliminary random walk and calculate the average increase in cost
ΔE_avgfor worsening moves. - Calculation: Set
T_0 = -ΔE_avg / ln(χ), whereχis the desired initial acceptance ratio (typically 0.8 to 0.95). - Impact: A
T_0that is too low traps the search in the nearest local basin; aT_0that is too high wastes computation on a pure random walk.
Restart Mechanisms
To mitigate the risk of premature convergence due to an overly aggressive cooling schedule, modern implementations often employ restart strategies:
- Fixed Restart: The algorithm resets to the best-known solution and re-heats the temperature after a set number of non-improving iterations.
- Adaptive Restart: The system monitors the search trajectory and triggers a restart when it detects stagnation in a local basin.
- Benefit: This hybrid approach combines the global search properties of SA with the memory of Tabu Search, ensuring the best-found solution is never lost during the final exploitation phase.
Frequently Asked Questions
Clear, technically precise answers to the most common questions about the Simulated Annealing metaheuristic and its application in solving complex combinatorial optimization problems.
Simulated Annealing (SA) is a probabilistic metaheuristic optimization technique used to find an approximate global optimum for a given function in a large, discrete search space. It works by mimicking the physical process of heating a material and then slowly lowering the temperature to decrease defects. The algorithm starts at a high 'temperature' with a high probability of accepting worse solutions, enabling broad exploration of the search space to escape local optima. As the temperature cools according to a defined cooling schedule, the algorithm becomes increasingly greedy, accepting only better solutions and eventually settling into a low-energy, optimized state. This controlled acceptance of uphill moves is what distinguishes SA from simple hill-climbing algorithms.
Simulated Annealing vs. Other Metaheuristics
Comparative analysis of Simulated Annealing against other common metaheuristics used in last-mile delivery route optimization.
| Feature | Simulated Annealing | Genetic Algorithm | Tabu Search | Large Neighborhood Search |
|---|---|---|---|---|
Core Mechanism | Probabilistic hill-climbing with temperature-controlled acceptance of worse solutions | Population-based evolution via selection, crossover, and mutation | Deterministic local search with short-term memory to forbid revisiting recent solutions | Iterative destruction and repair of large solution segments |
Escapes Local Optima | ||||
Population-Based | ||||
Memory Structure | Implicit via temperature schedule | Implicit via population diversity | Explicit tabu list (short-term memory) | Adaptive operator weights (ALNS variant) |
Convergence Speed | Moderate; depends on cooling schedule | Slow; requires many generations | Fast; aggressive exploitation | Fast; large neighborhood moves |
Parameter Sensitivity | High; cooling rate and initial temperature critical | High; population size, crossover, and mutation rates | Moderate; tabu tenure length | Moderate; destroy/repair operator selection |
Best Suited For | Problems with many local optima and rugged fitness landscapes | Highly constrained multi-objective problems | Combinatorial problems with clear neighborhood structures | Large-scale routing problems with tight time windows |
Typical VRP Application | TSP and small-to-medium VRP instances | Multi-objective HFVRP and DARP | CVRP and VRPTW | Large-scale VRPTW and PDP |
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.
Applications in Last-Mile Delivery Optimization
Simulated Annealing (SA) is a probabilistic metaheuristic that excels at solving complex, constrained routing problems where deterministic methods fail. By accepting worse solutions early in the search, SA escapes local optima to find near-global-optimal delivery schedules.
Escaping Local Optima in Route Planning
In last-mile routing, the solution space is rugged with many local minima. A greedy algorithm might settle on a suboptimal route cluster. Simulated Annealing avoids this by probabilistically accepting a worse route permutation. The acceptance probability is governed by the Metropolis criterion: P = exp(-ΔE / T). Early in the schedule, when the temperature (T) is high, the algorithm freely explores the solution space, accepting cost-increasing moves like crossing routes or adding detours. As T cools, it converges on a highly optimized, low-cost delivery sequence.
Dynamic Time-Window Scheduling (VRPTW)
SA is highly effective for the Vehicle Routing Problem with Time Windows (VRPTW) . The objective function penalizes early arrivals and late deliveries. The cooling schedule is tuned to first resolve capacity violations, then tighten time-window adherence. Key implementation details:
- Neighborhood operators: Relocate, 2-opt*, and Or-opt moves.
- Penalty functions: Soft time windows allow violations at a cost, guiding the search toward feasibility.
- Reheating: Strategic temperature increases prevent premature convergence when the search stagnates.
Multi-Objective Cost Minimization
Last-mile delivery involves conflicting objectives: minimizing total distance traveled, minimizing fleet size, and maximizing on-time percentage. SA handles this through a weighted-sum objective function or by exploring the Pareto frontier directly. The algorithm can dynamically adjust weights during the annealing process. For example, a logistics provider might prioritize distance reduction at high temperatures and shift to time-window adherence as the system cools, producing a set of non-dominated trade-off solutions for the dispatcher.
Real-Time Re-Routing with SA
When a disruption occurs—such as a traffic jam or a failed delivery—the existing route plan must be updated in seconds. SA is well-suited for this because it can start from the current, partially executed solution as a warm start. The initial temperature is set low to perform a localized search around the disrupted route segment. The algorithm rapidly evaluates a limited set of neighborhood moves:
- Inserting a new pickup order into the existing sequence.
- Swapping two remaining stops to avoid a congested zone.
- Re-assigning a failed delivery to a different vehicle.
Cooling Schedule Tuning for Logistics
The cooling schedule dictates how the temperature parameter decreases, directly controlling the exploration-exploitation balance. Common schedules in logistics applications:
- Geometric cooling:
T_k = α * T_{k-1}where α is typically 0.95–0.99. Simple and predictable. - Logarithmic cooling: Guarantees convergence to the global optimum but is impractically slow for real-time use.
- Adaptive cooling: Monitors the acceptance ratio and adjusts the cooling rate dynamically. If too many moves are rejected, the temperature plateaus to allow more exploration.
Hybridization with Local Search
Pure SA can be slow to fine-tune a solution near the global optimum. In practice, it is often hybridized with a deterministic local search (e.g., 2-opt or Or-opt) at each temperature step. This creates a Simulated Annealing with Local Search (SALS) approach:
- SA provides the global diversification to jump between basins of attraction.
- Local search provides the intensification to rapidly descend to the bottom of each basin.
- This combination significantly accelerates convergence on large-scale instances with 500+ stops.

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