Home

APS
Downloads
Buy APS

Support
Register
Contact us

Knowledge Base of APS

Subscribe to the GEPList
 
Visit GEP

 

Choosing the Fitness Function

User Defined Fitness Functions
 
APS 3.0 comes equipped with 11 built-in fitness functions for time series prediction problems and, most probably, you will find among them a suitable fitness function for your problem. But if you want to try other fitness functions to model your data, APS 3.0 allows you to design fitness functions of your own and use them to search the fitness landscape.

You can design your own fitness function using the Custom Fitness Function window.

The code for the custom fitness function must be in JavaScript and can be tested before evolving a model with it. Please remember that APS 3.0 uses fitness proportionate selection and, therefore, fitness must increase with performance and only non-negative values are acceptable. Below is the sample code of a correct fitness function, which is identical to the MSE based fitness function of APS 3.0.


     // All the values of the Target output
     // are accessible through the array:
     // aOutputTarget[0] = 2.549
     // aOutputTarget[1] = 5.215
     // etc.

     // All the values of the output of the Model
     // are accessible through the array:
     // aOutputModel[0] = 78.6945
     // aOutputModel[1] = 12.6421
     // etc.

     // Essential and useful parameters you may use
     // to design your fitness function:
     // aParameters[0] = number of samples
     // aParameters[1] = averaged target output
     // aParameters[2] = variance of the target output

     // Your custom fitness function must return a value, for example:
     // return fitness;

     // Below is an example of a correct fitness function: 
     // the Mean Squared Error (MSE) based fitness function of APS,
     // for which the maximum fitness is equal to 1000:

     // MEAN-SQUARED ERROR
     var nSamples = aParameters[0];
     var fitness = 0.0;
     var modelMinusTargetSquared = 0.0;
     var MSE = 0.0;
     for (var i=0; i<nSamples; i++)
     {
          var temp1 = 0.0;
          temp1 = aOutputModel[i] - aOutputTarget[i]; 
          temp1 *= temp1;
          modelMinusTargetSquared += temp1;
     } 

     MSE = modelMinusTargetSquared / nSamples;

     if (MSE <= 0.000000001)
         MSE = 0;

     fitness = (1/(1+MSE))*1000;

     return fitness;


Obviously, in this case, maximum fitness equals 1000.

Home | Contents | Previous | Next