[BUG] Building AI Exercise
Hello everyone!
I hope that I posted this in an appropriate section.
I have encountered a small bug with the exercise 5 from the Hill Climbing section (Warm-up Temperature).
For a very specific implementation of the accept_temperature function, the following error will sometimes be thrown:
Error: 0.3678794411714424 != 0.36787944117144233 : Please check your probability calculation.I believe that the difference of these numbers (0.00000000000000011) is way to small to actually cause some real problems. To get this error, I used this code:
import numpy as np
def accept_prob(S_old, S_new, T):
if S_new > S_old:
return 1.0
else:
return np.exp(-1 * (S_old - S_new) / T)By removing the multiplication of -1 with the term and just writing a - instead, the code works perfectly fine:
import numpy as np
def accept_prob(S_old, S_new, T):
if S_new > S_old:
return 1.0
else:
return np.exp(-(S_old - S_new) / T)A straightforward solution to this is formatting the floating point numbers to a specific number of decimals (for example, 10).
However, taking this course is still a quite pleasant experience. Keep up the good work guys!