Exercise 5: Warm-up Temperature
Hi all, for the answer to Exercise 5 i wrote this piece of code:
import random
import math
def accept_prob(S_old, S_new, T):
# Calculate the probability of accepting a worse solution
prob = math.exp(-(S_old - S_new) / T)
return prob
def accept(S_old, S_new, T):
if random.random() < accept_prob(S_old, S_new, T):
print(True)
else:
print(False)
accept(150, 140, 5)
But i´m receiving this response:
Test Failed: AssertionError: 2.7182818284590455 != 1.0 : The algorithm should greedily select S_new if it is greater that S_old.
I´m lost. I don´t know if it is an error on my code or in the test. Anyone with similar problem or a tip for a solution?