Wrong answer, even though it works? Exercise 6: Simulated AnnealingOctober 21, 2020 at 2:39pm
I got the solution for the advanced level. It seemed to work, it also passed the test (after 70 seconds). However when I submitted my answer I instantly got the feedback that my answer was wrong. Why's that? My code: https://gist.github.com/F1nnM/eaca88485d34fe7187f746d3e5d8b291
(Also I first used a global variable T, which somehow messed up testing. I always got AssertionErrors that 0.4 wasn't greater then 30. Using T only locally fixed that. I'm sure something can be done about that, because that cost me quite some time to figure that out and get my code to pass the test)
October 21, 2020 at 3:11pm
October 31, 2020 at 4:51pm
Hey. A bit late, but in case you haven't sorted this yet: I just had a look at your answer and sometimes the result falls below the minimum required 30. I used the suggested cooling schedule for T, i.e.: T = max(0, ((steps - step)/steps)**3-.005), and created a variable to compare the result of simulated annealing against (instead of random.random() ). This way I could tweak the comparison to the value that gave me the more successful results.
November 3, 2020 at 9:00am
July 7, 2021 at 4:08am
I am currently doing the course, and I am a little bit stuck in Ex. 6 Advanced.
I read your Github notebook about Ex.6 Ad., and my code is similar, except for this line that you have in this way:
if S_new > S_old or (T > 0 and random.random() < math.exp((S_new - S_old)/T)):
I am sure that if I do it like your code, it'll work, but I wanna learn and I can't understand why the probability of acceptance the new solution is compared to
I am doing it like this,
if S_new > S_old or (T > 0 and S_new < math.exp((S_new - S_old)/T)):
July 14, 2021 at 12:22pm