on Dec 14, 2001 at 07:15 UTC ( #131891=perlquestion: print w/replies, xml ) Need Help??
I'd think you should have a look at How good is Perl for AI? which has a in depth discussion of perl and artificial intelligence which -I think- is pretty close to your project.
Definitely check out the bioperl project, even though it might be geared toward more "real life" biology than simulations, for your specific case. There are resources for other languages as well, so you'll be able to draw your own conclusions. Have a look at the tutorial to see if it is what you need.
Also CPAN is as usual an authentic gold mine: AI::Gene is an example, besides having the whole bioperl distribution, of course.
As a general consideration, simulation often (if not always) involves modelling, and perl is certainly strong in handling flexible data structures, so even if your roll your own, you will certainly have all the basic language features you need.
AI::Gene (actually, AI::Gene::Sequence and AI::Gene::Simple) is OK as a building block, and it includes functions for mutation, but it lacks the general structure for performing algorithms on it.
That's more or less the same question I asked myself back during Sophmore year in High School, when I was taking my bio class. I wandered into the field of genetic programming; and being a Perl nut even at that tender young age, I wrote myself a Perl library to do it (the first GP library written in Perl, so far as I know) The end result can be found at Perls of evolution. Genetic programming or breeding perls also addresses a similar topic; though not GP according to the canonical sense, there is no way to deny that one is genetically evolving programs. Check both of 'em out.
ObLink to the papers I wrote. Feel free to drop me a line if you're curious and/or want to know more. I found Koza's book to be rather useful, myself.
Koza uses Lisp though right?
And breeds the parse trees directly to produce other programs.
Of course you can play with program text and eval for the same effect.
I did look into using the B:: series of modules, but from what I could see, they were lower-level than would be useful -- dealing with opcodes, not expressions. Of course, if anyone knows more about the B:: modules and can educate me, I'm all ears.
I think Perl would be an excellent choice. If you eventually want your simulation to be super-fast, you can always convert some of it to a more optimizable language.
As for the language for your project, my advice on choosing the language would be the same as that given by wiser monks than I in articles such as Is Perl the right solution... : what language are you most comfortable in.
As to the idea of writing an evolution simulator, I would suggest to you as a resource issues of Scientific American magazine, as I remember seeing a number of issues in the 1980s and early 1990s in which appeared a column called Computer Recreations (and later, if I recall, the column was called Mathematical Recreations) that contained several articles on simulated evolutionary paths (including one, as I recall, concerning a toridal-shaped world called Wa-Tor).
The project sounds quite interesting, and I wish you much luck in undertaking it. I am sure many of the monks here would be likely be interested in it, and would enjoy seeing some of the code you produce in it (if you should decide to post it).
I recently released OPEAL, a library for evolutionary computation AKA simulated evolution. It does evolution using bitstrings and vectors, distributed simulations using SOAP, and will soon do genetic programming; the basic classes are already on the CVS server.
I'd suggest some time spent searching the web for 'Artificial Life' might be of help. Having said that I can think of two possibilities that Perl would be very well suited to indeed.
The match will Perl is because both CAs and L-systems can be implemented using a string rewriting approach. In fact L-systems from the math point of view are string rewriting systems, it's part of the definition of an L-system. And of course, Perl has some of the best string handling available.
Quick Batman, a bibliography!
Lindenmayer Systems, Fractals, and Plants. Przemyslaw Prusinkiewicz and James Hanan, Berlin, Germany: Springer-Verlag, 1980.
The Book of L. G. Rozenberg and A. Salomaa., ed., Berlin, Germany: Springer-Verlag, 1986.
The Computational Beauty of Nature. Gary William Flake, Cambridge, MA: MIT Press, 1999.
Lindenmayer Systems. G. Rozenberg and A. Salomaa., ed., Berlin, Germany: Springer-Verlag, 1992.
A search of CPAN should also be worth the effort, I believe there is L-system code out there, probably CA as well.
There is a beautifull L-system and GD sample code on the Issue 9, Spring 1998 (Volume 3, Issue 1) of TPJ, by Jason Reed.
The text of the article is not available at TPJ, but you can find it here. There is also this page with some realy impressive L-systems, perl code, pictures and rules included.
And if you want to set the bar realy high, you could check disney meets darwin e pro-actively interactive evolution for computer animation.
Someone posted a very neat little genetic algorithm program right here in the monastary. Don't know what sort of scale you are thinking of, but here's a very nice GA implementation.
You know, this is a beautiful question, because this is what ended my academic career. My final class, and exam, was "Scientific Computation", which covered fractals, wavelets, artificial life, genetic algorithms, and a number of modern problems. The final project was to select a problem from the book for the class, so it was pretty open ended. I decided to build an artificial life simulation. I had to build the final project in Maple, and I wrote a graphical UI with little "creatures" with an array of "DNA" that represented movement patterns, which evolved over time in a grid of randomly placed food. The professor was amazed at the resourcefulness regarding the programming language. The moral? The programming language doesn't matter, if you really are interested.
I thought Java was a straight forward programming language that was very fast, handled memory well, has many free libraries, and in no way inihibits your design process? Oh wait...
wouldn't be so fast to rule out Java - could actually be useful in this situation. An OO solution would conceivably be the best one for the job, and typed variables could also be handy. I'd personally want to use Java for this much 'background' ie not I/O coding. Don't really get why everyone keeps dissing on the language - it's not like Microsoft made it or anything.
Microsoft and Shinra are the same. They're both killing the planet.
I have an interesting, related piece of info. I know some guys working on the Human Genome Project and I hear that perl is actually used within the project. Might be worth including that in the project report... If anyone is interested in hearing more about this I can find out more and post an article.
You might be interested in Lincoln Stein's How Perl Saved the Human Genome Project article. Its a bit dated (1996) but still contains some good info.