From welsberr@orca.tamu.edu Thu Jun 26 21:31:45 1997 Newsgroups: talk.origins Subject: Re: "Weasel" Cumulative Selection Demo From: welsberr@orca.tamu.edu (Wesley R. Elsberry) Date: 26 Jun 1997 06:31:45 -0400 I have a Perl script which performs the "weasel" simulation. Features: - Interactive or batch single run - Parameters passed on command line for batch - Can specify files to pick up "pool" and "target" strings from - Produces basic statistics on the run - Sends comma-delimited output to a log file - For the target, can specify a target string length if collecting the target from a file - Follows the Dawkins method of generating an initial seed string from which generation 2 is derived Differences from Delphi Weasel - A mismatch evaluation operator is provided, but not selectable yet - No "curses" type support, strictly a tty-style program The Weasel Perl script is intended to demonstrate the relative advantages of cumulative selection over random search for finding targets in large search spaces. As a simulation of "evolutionary process", this implementation, like Dawkins' original, is "misleading in important ways". Please consult "The Blind Watchmaker" for the complete discussion of what Weasel is intended -- and not intended -- to demonstrate. Using Weasel The files associated with Weasel are weasel.pl -- The Weasel Perl script mkbat.pl -- A script to produce a script for running large batches pool.wsl -- A "pool" string file. Chop is used on the first line of this file, so it had better have a newline at the end. target.wsl -- A "target" string file. Chop is used on the first line of this file, so it had better have a newline at the end. weasel.log -- The Weasel log file, where comma-delimited information about each run is appended. The comma-delimited format is suitable for import into spreadsheets for further analysis. You will need a working Perl interpreter somewhere in your path. Weasel was developed using bigperl on an MS-DOS machine, which naturally led to the use of files rather than simple parameter passing for long target strings. The usage report Typing "weasel.pl help" at the command line displays this message: WEASEL. Copyright 1997 by W.R. Elsberry Usage: WEASEL [popsize mut_rate {pool|file.wsl} {target|[length:]file.wsl}] By running Weasel with no command-line arguments, Weasel interactively asks for parameters for the run. # weasel.pl Population size? (100): Mutation rate? (expressed as %) (6): Target string? : METHINKS Pool? : _ABCDEFGHIJKLMNOPQRSTUVWXYZ Generation 1: VJSKLTCJ 44 Generation 2: MJSKLTCJ 35 Generation 3: MJSKLTKJ 27 Generation 4: MJSKLTKQ 20 Generation 5: MJSILKKQ 15 Generation 6: MJSILKKS 13 Generation 7: MFSILKKS 9 Generation 8: MFSILMKS 7 [...] At each generation, the closest match to the target in the population is displayed, along with its distance from the target. There are two major ways (and several combinations) of using command-line arguments with Weasel. - Passing all values directly - Passing filename information for "pool" and "target" "Passing all values directly" sample # weasel.pl 100 5.5 _ABCDEFGHIJKLMNOPQRSTUVWXYZ METHINKS The above command line sets up a population size of 100, a mutation rate of 5.5%, a pool containing all alphabetic characters plus an underline pressed into duty as a space to avoid problems with brain-dead OS argument handling, and one eight-character target string. "Passing filename information" examples # weasel.pl 100 5.5 pool.wsl target.wsl The above command line sets up a population size of 100, and a mutation rate of 5.5%. The pool string is the first line of text in the file "pool.wsl". The ".wsl" extension is how filenames are distinguished from regular string values. The target string is, unsurprisingly, taken as the first line of text in the file "target.wsl". $ weasel.pl 100 5.5 pool.wsl 8:target.wsl The above command line sets up a population size of 100, and a mutation rate of 5.5%. The pool string is the first line of text in the file "pool.wsl". The target string is the first eight characters from the first line of text in the file "target.wsl". Because of the flexibility afforded by this scheme, you can create batch files to collect data from repeated runs with the same parameters or explore the solution space by varying the parameters. A "mkbat.pl" script is provided as an example of batch mode scripting. The log file format explained Here is an example line from the weasel.log file: "LOG",19683,101,9,0.00045724737082761772585,194.88118811881187753,10,2,"THE","_ABCDEFGHIJKLMNOPQRSTUVWXYZ" Field 1: The initial string was originally intended as a means of extracting the comma-delimited strings from the stream of program output. Field 2: The searchspace size. searchspace = poolsize ** targetlength Field 3: The total number of candidate strings considered. Field 4: The number of unique candidate strings considered. This statistic was frighteningly easy to collect using a Perl associative array, and gives a straightforward quantification of the amount of the searchspace which was explored. Field 5: Proportion of searchspace explored by weasel search. propsearchspace = uniquecandidates / searchspace. Field 6: Relative advantage over random search. reladvantage = searchspace / totalcandidates. Field 7: Population size. Field 8: Mutation rate, in percent. Field 9: Target string, quoted. Field 10: Pool string, quoted. Have fun. I would like to amass a database of the log file output. So if you run this script and collect statistics, please send your log file to me with "WEASEL LOG" in the subject line, or upload via anonymous ftp to inia.tamug.tamu.edu. (Rename the logfile, please, so that none get overwritten.) Wesley -- Wesley R. Elsberry, 6070 Sea Isle, Galveston TX 77554. Information sent to any of my email addresses is my personal property, to be published as I see fit. Student in Wildlife & Fisheries Sciences. http://www.rtis.com/nat/user/elsberry "don t ever tell me insects are any more liberal than humans" - archy