Solution to exercise 6 (intermediate)
In exercise six it wants you to incorporate annealing into the hill climbing algorithm. It says to use the “proper probability” but never specifies what the proper probability is. I have this for the algorithm:
/
if h[x_new] > h[x]:
x = x_new # the new position is higher, go there
elif T!=0 and h[x_new]< h[x]:
prob=x*math.exp(-(h[x]-h[x_new])/T)# add simulated annealing here.
if prob>0.5: #If prob>0.5 let x=x_new
x=x_new
else:
x=x #else x=xthis is with a probability of keeping the downward move at 50% (0.5).
I keep getting this error:
Test Failed: AssertionError: 47 not greater than 70 : Please check your algorithm
Any help is appreciated.