very simple Genetic Algorithm completed

Paul McGuire ptmcg at austin.rr.com
Fri Feb 1 10:42:30 EST 2008


On Jan 31, 10:43 am, Matthew_WAR... at bnpparibas.com wrote:
> Hi,
>
> I got some help with this from here, and there's been a little bit of
> discussion around GA's recently, so thought I'd post up my likey slow and
> clunky version of a GA that in essence just 'evolves' a solution to 'make a
> sum that evaluates to n using */+-0123456789'  it's a really simple GA that
> would be useful for someone who doesn't quite get GA's to look at.
>
> I think it's simple enough to be fairly self explanatory.
>
> to see it come up with evolved solutions to n=1000
>
> >>>from quickga import *
> >>>evolve()
>
> I like playing with stuff like this. I'm going to use this little toy to
> investigate how mutation rates/crossover gene length, pop size etc.. etc..
> interact with each other. All completely unscientifically and for my own
> bemusement.

Another interesting technique, similar to GA, is SA or Simulated
Annealing.  You should be able to adapt your quickga.py program to an
SA approach without too much trouble, and comparing the two should
tickle your academic bemusement.

-- Paul



More information about the Python-list mailing list