Inferensys

Glossary

Simulated Annealing

Simulated Annealing is a probabilistic metaheuristic optimization algorithm that escapes local optima by occasionally accepting worse solutions, inspired by the annealing process in metallurgy.
Performance engineer optimizing AI latency on laptop, latency charts visible, technical optimization session.
METAHEURISTIC OPTIMIZATION

What is Simulated Annealing?

Simulated Annealing is a probabilistic metaheuristic optimization algorithm inspired by the annealing process in metallurgy, which allows occasional moves to worse solutions to escape local optima, gradually 'cooling' the acceptance probability to converge on a good solution.

Simulated Annealing (SA) is a probabilistic technique for approximating the global optimum of a given function, particularly for large-scale NP-hard problems like the Traveling Salesman Problem (TSP) or Vehicle Routing Problem (VRP). The algorithm is a form of local search that, by occasionally accepting worse solutions based on a temperature parameter, can escape local optima and explore a broader solution space, mimicking the physical process of annealing where a material is heated and slowly cooled to reduce defects.

The algorithm's key mechanism is a temperature schedule that controls the probability of accepting inferior moves, defined by the Metropolis criterion. As the virtual temperature decreases according to a cooling schedule, the search becomes more greedy, stabilizing near a high-quality solution. This makes SA highly effective for complex spatial-temporal scheduling tasks where finding a provably optimal solution is computationally intractable, but a robust, near-optimal schedule is required.

ALGORITHM MECHANICS

Key Features of Simulated Annealing

Simulated Annealing is a probabilistic metaheuristic for global optimization, inspired by the physical annealing process in metallurgy. Its core features enable it to escape local optima and find high-quality solutions for complex, NP-hard scheduling and routing problems.

01

Probabilistic Acceptance of Worse Moves

The defining mechanism of Simulated Annealing is its ability to accept worse solutions with a certain probability. This probability is governed by the Metropolis criterion: P(accept) = exp(-ΔE / T), where ΔE is the change in the objective function (e.g., increased makespan or route distance) and T is the current temperature. This stochastic acceptance allows the algorithm to escape local minima by 'jumping' over energy barriers, a critical capability for exploring complex solution landscapes in problems like the Vehicle Routing Problem (VRP) or Job Shop Scheduling.

02

Temperature Schedule (Annealing Schedule)

The algorithm's behavior is controlled by a temperature schedule that systematically reduces the temperature T from a high initial value to near zero. Key components:

  • Initial Temperature: Set high enough so that most moves, including bad ones, are accepted, enabling broad exploration.
  • Cooling Rate: The rate at which T decreases (e.g., T_new = α * T_old, where α = 0.95). A slower cooling rate allows for more thorough exploration but increases computation time.
  • Equilibrium Condition: The number of iterations or accepted moves at each temperature before cooling.
  • Stopping Criterion: Typically when T reaches a minimum value or the solution ceases to improve. This gradual 'cooling' mimics physical annealing, transitioning the search from exploration to exploitation.
03

Solution Neighborhood Structure

Simulated Annealing operates by iteratively moving from the current solution to a neighboring solution. The definition of this neighborhood is problem-specific and crucial for performance. Common moves for scheduling and routing include:

  • Swap: Exchange the positions of two tasks or cities in a sequence.
  • Insertion: Remove a task and insert it at a different position.
  • 2-opt (for TSP/VRP): Reverse a segment of a route.
  • Resource Reassignment: Reassign a job to a different machine or vehicle. The neighborhood operator generates the candidate solutions that are evaluated and potentially accepted, driving the local search component of the algorithm.
04

Asymptotic Convergence to Global Optimum

Under a sufficiently slow cooling schedule, Simulated Annealing can be proven to converge asymptotically to the global optimum. This theoretical guarantee, based on the theory of non-homogeneous Markov chains, distinguishes it from simple Local Search heuristics that get trapped in local optima. In practice, the infinite-time requirement is relaxed, but the principle guides parameter tuning: slower cooling increases the probability of finding a near-optimal solution for NP-hard problems like Mixed-Integer Programming (MIP) formulations of scheduling.

05

Memoryless Search & Minimal State

Simulated Annealing is a memoryless algorithm. It only retains the current solution and the best solution encountered so far. It does not maintain a population (like Genetic Algorithms) or a tabu list. This makes its state management simple and its memory footprint very low. The entire search history is encapsulated in the current temperature and solution state, simplifying implementation and reducing overhead, which is beneficial for large-scale spatial-temporal scheduling problems where evaluating the objective function (e.g., total tardiness) is computationally expensive.

06

Application to Spatial-Temporal Scheduling

In Heterogeneous Fleet Orchestration, Simulated Annealing optimizes complex objectives under multiple constraints:

  • Objective Functions: Minimize makespan, total travel distance, weighted tardiness, or energy consumption.
  • Handling Constraints: It navigates precedence constraints, capacity constraints, and time windows by penalizing infeasible solutions in the objective function or using repair operators.
  • Dynamic Replanning: Can be used within a Model Predictive Control (MPC) loop for real-time replanning, where the initial solution is the incumbent schedule and the algorithm searches for improvements after a disruption.
  • Hybridization: Often combined with other metaheuristics (like Genetic Algorithms for initialization) or Constraint Programming for feasibility checks, creating powerful hybrid solvers for dynamic task allocation and multi-agent path planning.
COMPARISON

Simulated Annealing vs. Other Metaheuristics

A feature comparison of Simulated Annealing against other prominent metaheuristic algorithms used for solving complex spatial-temporal scheduling and combinatorial optimization problems, such as the Vehicle Routing Problem (VRP) and Job Shop Scheduling.

Feature / MechanismSimulated Annealing (SA)Genetic Algorithm (GA)Tabu Search (TS)Greedy Algorithm / Local Search

Core Inspiration

Thermodynamic annealing process in metallurgy

Biological evolution (natural selection)

Human memory and search avoidance

Immediate local improvement

Solution Representation

Single candidate solution (point in search space)

Population of candidate solutions (chromosomes)

Single candidate solution with memory

Single candidate solution

Primary Search Mechanism

Probabilistic hill-climbing with controlled 'bad' moves

Crossover (recombination) and mutation on a population

Deterministic local search guided by a tabu list

Deterministic selection of the best immediate neighbor

Escapes Local Optima?

Memory of Past Search

Implicit via population gene pool

Via current solution only

Key Control Parameter(s)

Temperature schedule (cooling rate)

Population size, crossover & mutation rates

Tabu list size, aspiration criteria

Neighborhood definition

Typical Convergence Behavior

Gradual convergence as temperature cools

Generational improvement, can plateau

Intensive local search with strategic diversifications

Converges to the first local optimum encountered

Handles Constraints

Via penalty functions or modified move operators

Via specialized encoding/repair or penalty functions

Via move operators that preserve feasibility

Often requires feasibility-preserving moves

Best Suited For

Problems with rugged landscapes, moderate dimensionality

Problems with decomposable structure, parameter tuning

Intensive local search around good solutions

Fast baseline, convex or simple landscapes

Computational Overhead per Iteration

Low to moderate

High (evaluates entire population)

Moderate (maintains and checks tabu list)

Very low

SPATIAL-TEMPORAL SCHEDULING

Frequently Asked Questions

Common questions about Simulated Annealing, a probabilistic metaheuristic used to solve complex optimization problems in logistics, scheduling, and fleet orchestration.

Simulated Annealing (SA) is a probabilistic metaheuristic optimization algorithm inspired by the physical annealing process in metallurgy, where a material is heated and slowly cooled to reduce defects and minimize its system energy. In optimization, it searches for a near-optimal solution to complex problems (like the Vehicle Routing Problem or Job Shop Scheduling) by iteratively exploring the solution space, occasionally accepting moves to worse solutions to escape local optima, and gradually reducing this acceptance probability as the search progresses.

Its key components are:

  • Temperature Parameter (T): Controls the probability of accepting worse moves. High initial temperature allows extensive exploration; it is systematically reduced per a cooling schedule.
  • Acceptance Probability: Given by the Metropolis criterion, P = exp(-ΔE / T), where ΔE is the change in the objective function (e.g., makespan or travel distance). A worse solution (ΔE > 0) is accepted with this probability.
  • Cooling Schedule: The rule (e.g., geometric: T_{k+1} = α * T_k) that gradually lowers the temperature, shifting the algorithm's behavior from exploration to exploitation.

SA is particularly valuable for NP-hard combinatorial problems where exact methods like Mixed-Integer Programming (MIP) become intractable at scale, providing a robust framework for finding high-quality solutions in spatial-temporal scheduling and heterogeneous fleet orchestration.

Prasad Kumkar

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.