Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Simulated Evolution

by narse (Pilgrim)
on Dec 14, 2001 at 07:15 UTC ( [id://131891]=perlquestion: print w/replies, xml ) Need Help??

narse has asked for the wisdom of the Perl Monks concerning the following question:

For a bio class project I am considering writing an evolution simulator (biting off more than i can chew, I know). The question is how to implement this, and what language would be best suited for this sort of project. Perl would be my obvious choice but perhaps someone has a method that is better suited to an alternate language. I have not been able to find much in the way of examples or methods but I have not been looking long. My question is if anyone has experience with this or can point me to a useful resource. -Matt Harrington (If it works, break it!)

Replies are listed 'Best First'.
Re: Simulated Evolution
by stefan k (Curate) on Dec 14, 2001 at 14:21 UTC
    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.

    If I may add this to my post at that time: I am currently very pleased with having chosen ruby for my PhD so far. I dunno what I'll say next week but it has been easy to test new things, produce this or that output, check for what happens when... and similar stuff. I think that this would work well in Perl, too, of course :-)

    Regards... Stefan
    you begin bashing the string with a +42 regexp of confusion

Re: Simulated Evolution
by trantor (Chaplain) on Dec 14, 2001 at 12:50 UTC

    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.

    -- TMTOWTDI

      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.
Re: Simulated Evolution
by Chmrr (Vicar) on Dec 14, 2001 at 16:34 UTC

    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.

    perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

      Koza uses Lisp though right?
      And breeds the parse trees directly to produce other programs.

      I don't think you can do that with Perl, perhaps with some B::* module

      Of course you can play with program text and eval for the same effect.

        That is correct -- Koza does breed actual Lisp S-expressions. I would submit that what he was doing with Lisp is equivilent to playing with "program text and eval" in any other language, such as Perl. Which, incidentally, is what I did. So I can tell you with great certainty that it does indeed work. :)

        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.

        perl -pe '"I lo*`+$^X$\"$]!$/"=~m%(.*)%s;$_=$1;y^`+*^e v^#$&V"+@( NO CARRIER'

Re: Simulated Evolution
by chip (Curate) on Dec 14, 2001 at 09:50 UTC
    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.

    Besides, it seems only fitting to use Perl for evolution research, since its flexibility lets you easily adapt to changing environments and thus outcompete your Python-using rivals. :-)

        -- Chip Salzenberg, Free-Floating Agent of Chaos

Re: Simulated Evolution
by atcroft (Abbot) on Dec 14, 2001 at 14:58 UTC

    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).

Re: Simulated Evolution
by jmerelo (Sexton) on Dec 14, 2001 at 17:43 UTC

    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.

    The released version is a bit outdated, but the CVS snapshots work very well. Please take a look and give me your opinion

Re: Simulated Evolution
by tfrayner (Curate) on Dec 14, 2001 at 19:54 UTC
    Not directly related to Perl, but you might want to take a look at the Tierra project. It's pretty much moribund nowadays, but a few years back (1994-1996) it was a good little example of digital evolution simulation and how one might go about it. The source code is fully available (all in C if I recall correctly). Probably a little dated now, but still worth a look, I think.

    Have fun,

    Tim

    PS. I note that there are a few other resources of potential interest listed on that web site. I've not checked them out though...

Re: Simulated Evolution
by Anonymous Monk on Dec 14, 2001 at 19:43 UTC
    You may want to take a look at O'Reilly's "Beginning Perl for Bioinformatics" by James Tisdall. Chapter 7, in particular, has some code for mutations and randomization. -Doug
Re: Simulated Evolution
by hsmyers (Canon) on Dec 14, 2001 at 23:39 UTC
    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.
    • Cellular Automata
    • Lindenmayer Systems
    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.

    –hsm

    "Never try to teach a pig to sing…it wastes your time and it annoys the pig."
Re: Simulated Evolution
by hawson (Monk) on Dec 15, 2001 at 06:09 UTC
    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.
Re: Simulated Evolution
by Anonymous Monk on Dec 15, 2001 at 13:16 UTC
    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.
Re: Simulated Evolution
by rbc (Curate) on Dec 14, 2001 at 11:02 UTC
    I'd use Java ... maybe Ada95
    just joking about Ada95 :P
      Interesting. I thought you were joking about java ;)
        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...

        ----
        Zak
        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.

        cestus

        Microsoft and Shinra are the same. They're both killing the planet.
Re: Simulated Evolution
by nufsaid (Beadle) on Dec 15, 2001 at 11:43 UTC
    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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://131891]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others pondering the Monastery: (6)
As of 2024-03-19 09:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found