tag:blogger.com,1999:blog-11149365.post1107998403290968238..comments2024-03-23T04:34:59.089+00:00Comments on Go deh!: The Otter AlgorithmPaddy3118http://www.blogger.com/profile/06899509753521482267noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-11149365.post-3456088628464439292009-10-19T08:04:32.422+01:002009-10-19T08:04:32.422+01:00I transmuted the above into this Rosetta Code task...I transmuted the above into <a href="http://rosettacode.org/wiki/Evolutionary_algorithm" rel="nofollow">this Rosetta Code task</a>. Check it out.<br /><br />- Paddy.Paddy3118https://www.blogger.com/profile/06899509753521482267noreply@blogger.comtag:blogger.com,1999:blog-11149365.post-58052574022139573272009-10-04T20:24:58.842+01:002009-10-04T20:24:58.842+01:00Hi Steve,
You're right about the lack of magic...Hi Steve,<br />You're right about the lack of magic. Coding a small example soon dispels any such pretension.<br /><br />Hi Alexander, <br />I took another look and the commented out line 24 should have been deleted as when I was using it, line 28 was the right way around, (I think). But really, writing this I now know that not only was I confused, I was eager to try and get something like line 23 in, so did not give the original enough time.<br /><br />I like to tinker, and sometimes the urge wins out. <br /><br />Thanks for your analysis though.<br /><br />- Paddy.Paddy3118https://www.blogger.com/profile/06899509753521482267noreply@blogger.comtag:blogger.com,1999:blog-11149365.post-36726104526618267892009-10-04T18:47:15.487+01:002009-10-04T18:47:15.487+01:00Your original program didn't converge because ...Your original program didn't converge because your mutation rate is way too high. The expression "(ch if random() <= chance else choice(charset))" where chance = 0.05 means there is 95% chance the character will be mutated. I think what you want is "(choice(charset) if random() < chance else ch)". With this change, the string converges to the solution within a hundred generations; so you don't need to vary the mutation rate.Alexandrehttps://www.blogger.com/profile/10338659962011326420noreply@blogger.comtag:blogger.com,1999:blog-11149365.post-624888053575691822009-10-04T15:55:16.754+01:002009-10-04T15:55:16.754+01:00The thing about evolutionary algorithms is that th...The thing about evolutionary algorithms is that they are basically just a heuristically-directed search through a problem space by gradient descent. For this reason, they are susceptible to hit local minima, and it makes perfect sense that small improvements to the heuristic would make it converge faster or get it to skip over these local minima. In other words, there is really nothing magic about evolutionary algorithms; however they can be an efficient approach to solving a problem.Stevehttp://steve.steve.comnoreply@blogger.comtag:blogger.com,1999:blog-11149365.post-80731244811001044862009-10-03T16:24:37.744+01:002009-10-03T16:24:37.744+01:00Hi Dougal,
Thanks for taking the time.
I just re...Hi Dougal, <br />Thanks for taking the time.<br /><br />I just re-checked and re ran my code. Did you remember that line 24 is commented?<br /><br />I got the following:<br /><br />Python 3.1 (r31:73574, Jun 26 2009, 20:21:35) [MSC v.1500 32 bit (Intel)] on win32<br />Type "copyright", "credits" or "license()" for more information.<br />>>> ================================ RESTART ================================<br />>>> <br />50 11 XCTHINIDJATDIR USKE MVWPLBQK<br />100 12 MTTHINKHVRTHISSLICDVIQUWATPW<br />150 12 MLTHTBGQBITLFEXLIKEWFLWXGSIL<br />200 14 MABHUNKG OTDIUSLNKD NKWSAIEL<br />250 14 MQOHYIJS IT IX LZUS AGWRENGL<br />300 14 AHTHBNKSYIPMIS QULEHABWRADGL<br />350 16 MQKHINKSHIF TS LIXQSY WRHYEL<br />400 16 MWTC DKSSITZJF LIKKYA UGASEL<br />450 17 MVYHQNKSRITQIS LW VJA WIASEH<br />500 17 MJGMQNQS ITIIS LSCOWA WBASEL<br />550 17 MJTMXNQS ITFIS LHEOHA WBCSEL<br />600 18 IEBHMNPS IT IH LMUS A WDASEZ<br />650 19 XRTTINOS IT IS LMMT A WEA ZL<br />700 20 BETHINKS IT IS LILMRAVWTHSYL<br />750 24 METHILKS IT IS LOKESA WOASEL<br />800 27 METHINKS IT IS LEKE A WEASEL<br />816 METHINKS IT IS LIKE A WEASEL<br />>>>Paddy3118https://www.blogger.com/profile/06899509753521482267noreply@blogger.comtag:blogger.com,1999:blog-11149365.post-53342751982148760862009-10-03T13:05:41.630+01:002009-10-03T13:05:41.630+01:00hmm. Well, by running your code exactly as it is. ...hmm. Well, by running your code exactly as it is. I seem to be getting premature convergance to a non-ideal solution.<br /><br />Or basically its getting stuck with a score of 4 (or around that) and not moving.Dougal Matthewshttp://www.dougalmatthews.comnoreply@blogger.com