Genetic Algorithm
Posted: Tue May 26, 2009 7:38 pm
I am extremely new to lisp but I heard it is good for making genetic algorithms or programs.
I am trying to write a genetic algorithm in lisp, I had attempted it in AHK (autohotkey) if you know what that is, but I hit a road block and it took forever.
I want the basis of my algorithm to act like this:
Make a DNA sequence, the sequence would have x number of digits with the condition that x is divisible by three ( I was thinking about 60 digits long)
The DNA sequence would be split into 3 digit codons, each codon would reference a number between 0 and 9 or and operator (*/-+). For example 000 would correspond to the number 0, 001 would correspond to the number 1 and so on. The reference numbers would then a make a protein sequence. An example would be 016+2*52--46/3. The sequence would have altered so that it could be evaluated in lisp.
The number resulting from the evaluation of the protein sequence would be evaluated for fitness (for simplicities sake i could determine the by how close the number is to 200 or any other number)
This entire process would be executed several times to produce several seeds, lets say 20 times. This way we have 20 DNA sequences to compare for fitness.
Then we have to pick the fittest lines of DNA, as a metaphor I can say that each line of sequence gets a piece of pie in a pie chart. The fitter the DNA sequence the larger the slice. Then we would spin a spinner over the pie chart to determine which DNA sequence move on to the next generation. Fitter DNA sequences have a higher chance of moving on but not a promise. I would spin the spinner 20 times to produce 20 more seeds
The twenty seeds would have to be crossed over at a random point in the DNA sequence.
For example:
Say I have these pieces of DNA
01203110203310
01022301220202
I would chose a random place in the sequence to cut it into two pieces then append each piece to the other two pieces from the other sequences
These:
012|03110203310
010|22301220202
Would become:
012|22301220202
010|03110203310
From here each sequence would have X number of digits mutated (where X ranges from 0 to 60 or how many digits you have in the DNA sequence) The rate of mutation would be determined by how close the sequences are to reaching the goal value. The farther away the higher the mutation rate.
The mutated sequences would then be evaluated for fitness and the process would repeat.
Sorry for all of this information but I just need help starting this off I do not even know how to make the DNA seeds.
If anyone knows how to do any of this or knows of a location on the internet that please tell me. The web sites do not even have to fallow my process, anything will do.
Thank you
All comments are appreciated
I am trying to write a genetic algorithm in lisp, I had attempted it in AHK (autohotkey) if you know what that is, but I hit a road block and it took forever.
I want the basis of my algorithm to act like this:
Make a DNA sequence, the sequence would have x number of digits with the condition that x is divisible by three ( I was thinking about 60 digits long)
The DNA sequence would be split into 3 digit codons, each codon would reference a number between 0 and 9 or and operator (*/-+). For example 000 would correspond to the number 0, 001 would correspond to the number 1 and so on. The reference numbers would then a make a protein sequence. An example would be 016+2*52--46/3. The sequence would have altered so that it could be evaluated in lisp.
The number resulting from the evaluation of the protein sequence would be evaluated for fitness (for simplicities sake i could determine the by how close the number is to 200 or any other number)
This entire process would be executed several times to produce several seeds, lets say 20 times. This way we have 20 DNA sequences to compare for fitness.
Then we have to pick the fittest lines of DNA, as a metaphor I can say that each line of sequence gets a piece of pie in a pie chart. The fitter the DNA sequence the larger the slice. Then we would spin a spinner over the pie chart to determine which DNA sequence move on to the next generation. Fitter DNA sequences have a higher chance of moving on but not a promise. I would spin the spinner 20 times to produce 20 more seeds
The twenty seeds would have to be crossed over at a random point in the DNA sequence.
For example:
Say I have these pieces of DNA
01203110203310
01022301220202
I would chose a random place in the sequence to cut it into two pieces then append each piece to the other two pieces from the other sequences
These:
012|03110203310
010|22301220202
Would become:
012|22301220202
010|03110203310
From here each sequence would have X number of digits mutated (where X ranges from 0 to 60 or how many digits you have in the DNA sequence) The rate of mutation would be determined by how close the sequences are to reaching the goal value. The farther away the higher the mutation rate.
The mutated sequences would then be evaluated for fitness and the process would repeat.
Sorry for all of this information but I just need help starting this off I do not even know how to make the DNA seeds.
If anyone knows how to do any of this or knows of a location on the internet that please tell me. The web sites do not even have to fallow my process, anything will do.
Thank you
All comments are appreciated