"be consistent" PerlMonks

### Re: JAPH-ing Genetically

 on May 23, 2001 at 14:02 UTC ( #82502=note: print w/replies, xml ) Need Help??

in reply to JAPH-ing Genetically

make a string which, when evaled, gives JAPH! Then you have multiple good answers and a very useful program.

Replies are listed 'Best First'.
Re: Re: JAPH-ing Genetically
by larsen (Parson) on May 23, 2001 at 16:40 UTC
andye is right. Fitness function f must be continuus, so that for two similar individuals x1 and x2, f(x1) is similar to f(x2).

So, small causes (small random mutations) imply small changes (small variations of fitness).

If you want to apply the ideas of GA to evolve programs, you should explore the so-called field of Genetic Programming; a classic reference are Holland's books

You could fuzz hard edges (go - no go) by statistical evaluation (Markov-Chains) with the statistical properties of Perl. Meaning if the program has the same statistical properties as Perl it is slightly fitter than when not, despite it not being valid Perl or if it is valid (which gives a large boost in FITNESS) but doesn't have the statistical properties of Perl it is slightly unfitter.
Re: Re: JAPH-ing Genetically
by Masem (Monsignor) on May 23, 2001 at 17:31 UTC
One of my other examples for Algorithm::Genetic is redoing one of the best nodes, Genetic Programming or breeding Perls, using my module. This node uses bits of legal perl code like "\$x += \$y;" and "\$y=\$x;" to make up a long operation; the bits are breed and mutated such that the operation, when evals to a number, and the GA aims to make code that matched a given number. This is a much better GA example, since with a good operations set, there's numerous ways to calculate a given number.

The reason this JAPH one works is that I upped the mutation rate to 10%, such that when it's close but not at the solution, there's a good chance that that one character pertubation is the right one to lock in the right solution.

Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain
It seems that chemists are using genetic algorithms, too:
Designing new enzymes is a difficult task, but what researchers can do is make thousands of trillions of RNA molecules, with the hope that one or a few of them can catalyze the appropriate reactions.
What's especially weird about this case is that the subject of this particular enzime is genetics!

Now if we could make trillions of little perl interpreters and turn them loose on a problem...

—John
Re: Re: JAPH-ing Genetically
by andye (Curate) on May 23, 2001 at 15:57 UTC
I'd see the problem with that as being the fitness function. One character could make the difference between complete success and complete failure - so how do you evaluate fitness?

If anyone knows an accepted method for this, I'd find it v.interesting.

Andy.

You could evaluate \$@ for instance if it contains "syntax error" that means DWIM gives up it is a very low fitness, if it contains "operator expected" it is better and if it contains "not defined" better yet. You get the picture?
Problem is, an individual that generates a syntax error might only be one character different to an individual that prints the required string. Or it might be total rubbish.

The first should (for this method to work) be fitter than the second, but I don't know a way to quantify that.

Also, p(syntax error) is very high for constructing a valid Perl string randomly. The chances are that all members of a population would generate syntax errors - at which point they'd all have the same fitness.

A better approach would be to create a baby language safe (or safer) from syntax errors and eval that. Like maybe just arithmetic operators and numbers.

Although - it's just occured to me - you'd be on fairly safe ground with a subset of a highly structured language like Logo. And you could evaluate fitness by checking how similar the figure drawn was to your target figure.

Andy.

Create A New User
Node Status?
node history
Node Type: note [id://82502]
help
Chatterbox?
 [stevieb]: Playing around with two DACs to control a single RGB LED (each DAC only has two outputs, LED has 3 inputs), and have realized that each of my IC RPi dists needs a wiring diagram, which is linked to within the documentation

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2017-08-20 19:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Who is your favorite scientist and why?

Results (317 votes). Check out past polls.

Notices?