Exercise 6: Simulated Annealing - Intermediate and Advanced

I managed to cheese a solution for both the intermediate and advanced problems for exercise 6, and was hoping to discuss them with someone.

First the intermediate exercise…
I read, and re-read the text but as far as I can tell, it doesn’t tell you what you should be comparing the value of probability calculated with the given formula with. After printing the values, I guessed I probably needed to compare it with the calculated S_new value, and it seems I guessed correctly, but I’m still not entirely sure why this works, though I’m assuming this is the reason why height values were normalised in the 0-1 range, so it would work with the output of the probability formula, right?

OK now the advanced exercise text gives even less away. I essentially copied the probability logic over from the intermediate exercise, including the temperature cooling formula. Then I added a variable ‘m’ to substitute in the ‘try a new solution near the current one’ section, like so:

x_new = np.random.randint(max(0, x[i]-m), min(N, x[i]+m+1))

I slowly increased the value of M until it passed the test, but I have no idea if this is actually a correct solution, since unlike the earlier (much easier exercises), a model solution wasn’t provided. Could someone advise if this is indeed correct? Thanks

One final comment, I feel like there is a sudden difficulty spike between these, and the previous exercises, perhaps there ought to be something to bridge the gap? But maybe it’s a me problem. Otherwise I am enjoying the course so far, despite having to use python :D Cheers!