next up previous contents
Next: Symbolic regression of sine Up: Demos Previous: Demos   Contents

Subsections


Approximation of pi

Please change directory to 'PERLGP_BASE/demos/pi' and look at the README file before running this demo.

Problem definition

Find a integer arithmetic approximation to $\pi$, for example 3 + 1/7

Arithetic operations allowed: plus, minus, multiply and protected division

Integers allowed: 1,2,3,5,7

Fitness function: absolute error from $\pi$ defined as 2*atan2(2,0) (small is good)

PerlGP approach

In this case the training and testing data structures (TrainingData, TestingData), and the output from evaluateOutput() are simple scalar numbers. Usually, as discussed in Section 2.4, they would be scalar references to larger data structures. There is no input variable in this situation (unlike the more familiar regression problem). There is also no meaningful concept of ``testing''; because no data is sampled, there can also be no out-of-sample data. Hence loadSet() returns just the ``true'' value of pi for both training and testing instances. This value is only accessed by fitnessFunction() of course, not by the evolved code.

There's not much more to explain, except of course that when the fitness reaches around 1e-15 it can go no further because the limit of double precision floating point numbers has been reached.

In this example, self-adapting mutation and crossover probabilities (NodeMutationProb and NodeXoverProb) are used. You can follow the evolution of these attributes with the gnuplot script plot-evparams.gp.


next up previous contents
Next: Symbolic regression of sine Up: Demos Previous: Demos   Contents
Bob MacCallum 2003-02-03