Explore Library
Code QuizAdvanced

Simulated Annealing Sign Error

The acceptance probability for worse moves is inverted by a missing minus sign.

Codejavascript
// Minimizing energy; accept worse moves with probability exp(-delta/T)
function accept(oldE, newE, T) {
  const delta = newE - oldE;
  if (delta < 0) return true; // improvement
  return Math.random() < Math.exp(delta / T);
}

Worse moves are being accepted far too often, especially large jumps. What is the bug?