Index of /code/genetic

      Name                    Last modified       Size  Description

[DIR] Parent Directory 18-Sep-2004 22:48 - [CMP] genetic.tar.gz 11-Sep-2003 08:43 112k

This is a small example of a genetic algorithm, it "evolves" random
strings into the license of this code (the goal);)
--
Note, it is just more of a "Hello World" in genetic programming,
it is very useless, since we here already know the excact goal
we want.

A brief description:
NR_POPULATION number of "citizen" are initialized, each which holds
as many genes as character in the string we are trying to evolve to.
So, one gene represents one character. The genes/characters are randomly
initialized. A gene is thought to be good/strong depending on how far
away it is from the goal character, that is the character in that position in
the string we try evolving to. e.g. if the goal character is 'c' , then
'b' and 'd' would have a weight of 1 'a' and 'e' would have 2(lesser is good).
So, this "weight" of genes is summed up, which yields the fitness. And the population
is sorted according to its fitness. The top half mates with eachother, the bottom half
dies. Also, some adjustment is done for "inbreeding". That is, if the best fitness remain
the same for 50 generations, which means the genes among the population vary very 
little, we aggresivly mutate alot of the citizens.

With NR_POPULATION = 2048, one usually evolves the solution in 10-12 generations,
with NR_POPULATION = 1024 it can take 100-1500 generations. 


--
Nils Olav Selåsdal <NOS@Utel.no>