All problems
Simulated Annealing Accept Test
Problem
Decide whether simulated annealing accepts a move with energy increase delta.
Moves with delta <= 0 are always accepted. Otherwise accept with probability exp(-delta / temperature) after random.seed(seed) followed by random.random(). Return a boolean. If temperature is not positive, reject any positive delta.
Hint
Higher temperature makes uphill moves easier to accept.
Test cases
case 1
in: [1,1,0]
expected: false
case 2
in: [0.5,1,42]
expected: false
case 3
in: [-0.5,1,7]
expected: true
case 4
in: [2,0,3]
expected: false
case 5
in: [0,1,5]
expected: true
Starter codePython
def sa_accept(delta, temperature, seed):
# Your code here
pass5 test cases · run your code against them in the editor