All problems
Simulated Annealing Acceptance Probability
Problem
Simulated annealing accepts a worse solution with probability exp(-delta / T) where delta > 0 is the objective increase, and always accepts improvements.
Given delta and the temperature T > 0, return the acceptance probability.
Hint
Improvements have unit probability; only uphill moves are tempered.
Test cases
case 1
in: [1,1]
expected: 0.36787944117144233
case 2
in: [-2,0.5]
expected: 1
case 3
in: [4,10]
expected: 0.6703200460356393
Starter codePython
def simulated_annealing_acceptance_probability(delta, temperature):
# Your code here
pass3 test cases · run your code against them in the editor