liveBook · Manning

Temperature

As explained in Optimization Algorithms: AI techniques for design, planning, and control problems

A simulated-annealing control value that influences the likelihood of accepting worsening state transitions.

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

How Optimization Algorithms: AI techniques for design, planning, and control problems covers it

How deep it goes
Works through the acceptance calculation and cooling parameters, then illustrates their effects with hand iterations and implementation examples.
Examples
Uses a bounded quadratic minimization with T = 5, a rejected move, and a geometric cooling update.
What it assumes
Assumes basic objective-function minimization while introducing temperature decisions through a small numerical example.
What you can do after
Operate/configure it by selecting a starting temperature, cooling rule, attempts per temperature, and stopping temperature, then tuning their trade-offs.
How it connects
Links temperature to acceptance probability, cooling schedules, local minima, hill climbing, and random search.

Also explained in

Compare how 17 books explain temperature →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Optimization Algorithms: AI techniques for design, planning, and control problems. The section links point to the parts of the book it draws on.