Temperature T controls how readily simulated annealing accepts a worse solution. Accepting some worse moves can help a search escape a local minimum: early on, a high temperature favors exploration; as T falls, the search becomes more selective. Improving moves are always accepted. section 5.2.2 section 5.2.5
For minimization, let Δf be the candidate’s objective value minus the current value. If Δf is positive, accept the worse candidate when a random number r between 0 and 1 is less than p = exp(−Δf/T). A larger setback lowers p; a higher temperature raises it. At very low temperatures, the search resembles hill climbing. At very high temperatures, it approaches random search. section 5.2.3 section 5.2.4
A rejected move at T = 5
Minimize f(x) = (x − 6)². From x = 2.25, with f(x) = 14.06, a proposed move to x = 1.18 has f(x) = 23.23. Its acceptance probability is exp(−(23.23 − 14.06)/5) = 0.1597. With r = 0.37, reject the move. After two attempts at T = 5, geometric cooling with factor 0.85 sets T to 4.25. section 5.3
Temperature is one part of an annealing schedule:
- Choose a starting temperature. If the scale of objective changes is unknown, start high, cool quickly until roughly 50–60% of inferior moves are accepted, then use that temperature to begin slower cooling. section 5.2.4
- Set the cooling rule, attempts per temperature, and final temperature. Generate and test neighboring solutions at the current temperature, then update T according to the schedule. section 5.2.2 section 5.2.4
- Experiment with starting values and schedules: excessive heat accepts nearly every change, while too little heat can leave the search trapped. Reheating is an option when progress stalls. section 5.2.4 section 5.2.5
Figure 5.5 Change of acceptance probability with the temperature and the change in the objective function. The objective function change is the difference in the objective function’s value between the current solution and a candidate solution. In minimization problems, a positive objective function change indicates that the candidate solution is worse than the current solution. The acceptance probability gets lower as the objective function change increases. At high temperatures, SA tends to explore more by accepting non-improving moves. As the temperature gets lower, the algorithm restricts exploration, favoring exploitation.
Compare temperature and objective-value change to see why a large worsening move is less likely to be accepted, especially after cooling. section 5.2.3
For a Python implementation, a continuous-function example uses scipy.optimize.dual_annealing; scipy.optimize.anneal is deprecated. Temperature settings still need problem-dependent tuning, and simulated annealing does not guarantee an optimal or feasible result. section 5.3 section 5.7
















