From the GA standpoint, I should point out that you're "cheating" -- both cheating yourself, and the underlying algorithm. There are two problems: first-off, you're not allowing your best individuals to mutate, which is cheating yourself; that is, your better solutions don't get the benefit of genetic mutation. Secondly, you're using the knowledge that none of your "genes" (letters) are related in your mutation criteria, and just mutating those which are "wrong." This makes the process far less random, nearly to the point of eliminating any and all "genetics" from the process. Said another way, your above algorithm will probably go faster with a population size of one, and running for a thousand generations, than with 1000 individuals for one generation. On a similar note, you also only seem to be running one generation.
Those are my nitpicks from my point of view as a meddler in genetic programming. From a perl point of view, you've good solid code. Some of your lines are vaguely C-ish (use of parens in print("foo")), as are your loops, but that's a stylistic thing. You're not using warnings, which might be less forgivable, though. :) In your char_replace function, you're using map when you only need to generate one character -- it looks strange. You also re-evaluate the fitness there, but don't use it.
Update: I now see where you're re-running the generations. I'll point out that the way you're currently going about it is strange -- it means that only the first generation gets the percent that passes through unmodified -- a strange thing to do. I suppose what it boils down to is that I simply don't understand the meta-code that you're using to run your GA. It doesn't agree with the model that I understand, that's all.
perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'
In reply to Re: Genetic Algorithms
by Chmrr
in thread Genetic Algorithms
by illsorted
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |