What is simulated annealing?

Stephen M. Walker II · Co-Founder / CEO

What is simulated annealing?

Simulated annealing is an optimization technique inspired by annealing in metallurgy, where a metal is heated and then cooled slowly to reduce its brittleness. In the same way, simulated annealing searches for good solutions to optimization problems by starting with a candidate solution and gradually making smaller, more constrained changes to it as the algorithm progresses.

The advantage of simulated annealing over simpler local-search methods is that it is less likely to get stuck in a local optimum, a solution that looks best in its immediate neighborhood but isn't the best overall. Early on, the algorithm accepts some moves that make the solution temporarily worse, which lets it escape local optima; as the "temperature" cools, it accepts fewer worsening moves and converges on a solution.

Simulated annealing does not guarantee the best possible solution, but it is a practical tool for finding good solutions to problems that are too large to search exhaustively.

What are the benefits and drawbacks of simulated annealing?

Simulated annealing is well-suited to problems with many local optima that are difficult to solve with traditional methods. Its benefits include:

  1. Reduced risk of getting stuck in local optima, compared to simple hill-climbing.

  2. Applicability to both discrete/combinatorial problems and continuous ones.

  3. Straightforward handling of constraints by rejecting or penalizing infeasible moves.

  4. Simplicity to implement, since it only requires a way to generate neighboring solutions and evaluate their quality.

Its main drawbacks are that it can be slow to converge, offers no guarantee of finding the global optimum, and its performance depends heavily on tuning the cooling schedule and other parameters.

How does simulated annealing work?

The algorithm starts with a random (or otherwise chosen) candidate solution and repeatedly generates a nearby candidate by making a small change to it. If the new candidate is better, it is accepted. If it is worse, it may still be accepted with a probability that depends on how much worse it is and on a "temperature" parameter that decreases over the course of the run. High temperature early on makes the search more willing to accept worse solutions, which helps it explore the space and avoid getting trapped; as the temperature drops, the search becomes more selective and settles into a solution.

What are some applications of simulated annealing?

Simulated annealing has been used to solve a variety of optimization problems, including the traveling salesman problem, the knapsack problem, and the satisfiability problem — all discrete, combinatorial problems where it is valued precisely because it doesn't require the objective function to be continuous or differentiable. It has also been applied to circuit and layout design, scheduling, image recognition, and other areas of AI and machine learning.

More terms

Continue exploring the glossary.

Learn how teams define, measure, and improve LLM systems.

Glossary term

What is systems neuroscience?

Systems neuroscience in the context of artificial intelligence (AI) refers to an interdisciplinary approach that combines insights from neuroscience—the study of the nervous system and the brain—with AI development. The goal is to create AI models that can perceive, learn, and adapt in complex and dynamic environments by emulating the functions of neural assemblies and various subsystems found in biological organisms.
Read term

Glossary term

What is brute-force search?

Brute-force search, also known as exhaustive search or generate and test, is a general problem-solving technique and algorithmic paradigm that systematically enumerates all possible candidates for a solution and checks each one for validity. This approach is straightforward and relies on sheer computing power to solve a problem.
Read term

It's time to build

Collaborate with your team on reliable Generative AI features.
Want expert guidance? Book a 1:1 onboarding session from your dashboard.

Talk to sales