SA Simulated Annealing

Simulated Annealing (SA) is a metaheuristic optimization algorithm inspired by the annealing process in metallurgy. It is commonly used to solve combinatorial optimization problems, where the goal is to find the best solution from a large set of possible solutions.

The basic idea behind SA is to mimic the annealing process of slowly cooling a material to reduce defects and find the most stable state. In the context of optimization, SA starts with an initial solution and iteratively explores the search space to find better solutions.

Here's a detailed explanation of the SA algorithm:

Initialization:

  • Define the problem: Clearly define the optimization problem, including the objective function to be minimized or maximized, the decision variables, and any constraints.
  • Set the initial temperature (T) and cooling rate (α): The temperature determines the probability of accepting worse solutions initially, and the cooling rate controls how fast the temperature decreases.

Generate an initial solution:

  • Create an initial solution randomly or using some heuristic method. This solution serves as the starting point for the algorithm.

Main loop:

  • Repeat the following steps until a termination condition is met (e.g., a maximum number of iterations or reaching a desired solution quality):
  • Perturbation: Modify the current solution to generate a neighboring solution. This perturbation can be performed by changing one or more decision variables randomly or using a specific neighborhood structure.
  • Evaluation: Calculate the objective function value for the new solution.
  • Acceptance criteria: Decide whether to accept the new solution based on its objective function value and the current temperature.
  • If the new solution is better (i.e., it improves the objective function value), accept it unconditionally.
  • If the new solution is worse, calculate the acceptance probability using a probabilistic function that depends on the current temperature and the magnitude of the objective function change. A commonly used acceptance probability function is the Boltzmann probability function.
  • Update: Update the current solution if the new solution is accepted.
  • Cool down: Reduce the temperature according to the cooling rate.

Termination:

  • Define a termination criterion, such as reaching a maximum number of iterations, finding a satisfactory solution, or when the temperature drops below a certain threshold.

The key element in SA is the acceptance probability function, which determines the probability of accepting worse solutions. In the beginning, when the temperature is high, the algorithm is more likely to accept worse solutions, allowing for exploration of the search space and avoiding being trapped in local optima. As the temperature decreases, the acceptance probability becomes lower, and the algorithm becomes more exploitative, focusing on improving the solution.

The cooling schedule, determined by the initial temperature and cooling rate, plays a crucial role in SA. A slow cooling schedule allows the algorithm to explore the search space extensively, while a fast cooling schedule makes it converge quickly but may lead to premature convergence.

SA has been successfully applied to various optimization problems, such as the traveling salesman problem, the job shop scheduling problem, and the graph coloring problem. It is known for its ability to find good solutions in complex search spaces, although it does not guarantee finding the global optimum.

Overall, SA is a flexible and robust optimization algorithm that can handle a wide range of combinatorial optimization problems by leveraging the principles of simulated annealing.