Jump to content

Talk:Evolutionary algorithm: Difference between revisions

Line 149:
:::: Adding them up, we get the chance at step <math>x</math> as: <math>x(x-1)(2n-1)+2x(L-x)\over n^2L^2</math>. Summing the inverse of that should give you the answer of needed total mutations, unfortunately it's non-trivial to do. However, we can examine its tendency: when <math>x</math> is large (many unmatched chars), the expression is roughly <math>2 x^2\over nL^2</math>; recall that the single char mutation had <math>x\over nL</math>, which means double char mutation is initially faster than single char mutation, until <math>x\approx L/2</math>, i.e. half of the letters matched (this shouldn't be surprising).
:::: After that, when <math>x</math> becomes very small, the expression is <math>\approx {2x\over n^2L}</math>, about <math>2/n</math> of the single char mutation speed, meaning it requires about 13 (n=27)times as many mutations when close to perfect match. Since this is the slowest part of the evolution already, mutating two chars is overall probably about an order of magnitude slower. --[[User:Ledrug|Ledrug]] 18:34, 11 October 2011 (UTC)
 
:::: You guys are amazing. You're right - I changed the MUTATE rate and the COPIES to 100 and even with 1000 characters I always get to the target in less than 10,000 iterations (sometimes as low as 5000).
:::: I need a bit of time to get my head around the maths. Very impressive :)
:::: I added the following because I was getting the same random sequence every time. Not sure if there's a more efficient way to do that... <code>srand ( time(NULL) );</code> and included <time.h>
:::: Thank you --[[User:Davidj|Davidj]] 18:45, 11 October 2011 (UTC)
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.