Simulated annealing (SA) is an optimization technique used to find an optimal solution to a difficult problem. It mimics the process of annealing in metallurgy, where molten metal is cooled slowly to increase its hardness and strength. Similarly, simulated annealing is used to find a global optimum solution in a large search space.
In simulated annealing, a solution to a problem is represented as a point in a search space (or solution space). A “neighbourhood” around that point is defined, which contains similar solutions. The search moves from one point to another, usually randomly, and at each step, a new point is chosen to move to. The decision of whether to accept a neighbour solution is based on a comparison of the new solution’s cost (or quality) to the current solution’s cost, and a “temperature” parameter.
At the start of the search, the temperature is high and accepting neighbour solutions is easy. This allows the search to explore a wide range of solutions in the neighbourhood of the initial solution. As the search progresses, the temperature is gradually lowered, making it more and more difficult to accept neighbour solutions. This helps the search to gradually focus on the optimal solution and avoid being stuck in a suboptimal local optimum.
The temperature parameter is decreased according to a schedule often referred to as the “cooling function”. This cooling schedule is important for the success of the simulated annealing process. If the schedule is chosen too quickly, the search may not find the global optimum. If it is chosen too slowly, the search may be too slow and may not make meaningful progress.
The success of simulated annealing is often dependent on the choice of an appropriate neighbourhood function. The function should define a neighbourhood that is suitable to the search space and the problem being solved. Ideally, the neighbourhood should be wide enough to allow the search to explore different solutions, but also focused enough to find the optimal solution in a reasonable amount of time.
Simulated annealing is a powerful technique that can be used to solve difficult optimization problems. Its ability to escape local optima, its flexibility in adapting to different search spaces and its simple yet powerful representation of the solution space all make it a powerful tool for a wide range of applications. It is important, however, to properly define the cooling schedule and neighbourhood function in order for the technique to work successfully.