Exercise 5, difficulty: Advanced

Hey, I am doing the exercise five of the course in which we have to calculate a probability using simulated annealing, but when I submit my code, it says that the test is failed because “The algorithm should greedily select S_new if it is greater that S_old.”

Nevertheless, I don’t see the problem with my code:


import random import math def accept_prob(S_old, S_new, T): return math.exp(-(S_old-S_new)/T) def accept(S_old, S_new, T): if random.random() < accept_prob(S_old, S_new, T): print(True) else: print(False)