Complete Guide > Models

Introduction to Models

The key to using EpochX is in the use of models. Models are the programmatic equivalent to the parameter files of many GP systems. A model defines the parameter settings and the fitness function for the evaluation of a candidate solution, as well as providing the means to execute itself.

Control Parameters

The abstract Model class provides facility to handle all the general evolutionary parameters such as population size, or the number of generations to be performed. Representation specific abstract classes inherit from this class to support those parameters that are unique to that representation. For example, the GEModel class includes parameters for limiting the number of codons in a chromosome, which would make little sense for either of the GPModel or GRModel classes.

All components reload parameters from the model at 3 points during execution - at the start of execution, before every run, and before every generation commences. It is an assumption of the framework that changes to a model's settings will not occur any more frequently than this. Each component and operator is responsible for updating its own settings at the necessary times. Therefore, when designing a new plug-in operator it is a choice for the developer to decide whether to implement this feature. All built-in components and operators do support this updating.

Each of the model classes define a range of public mutator methods for setting the value of a parameter and a matching accessor method for retrieving the currently set parameter value. For full listings of these methods see the appropriate JavaDoc.

Fitness Function

In any evolutionary algorithm, the fitness function indirectly defines the problem to be solved by providing a quantifiable measure of how good a solution is towards solving that problem. Each EpochX model must provide a fitness function by implementing the getFitness(CandidateProgram) method. The method must calculate and return a fitness score for the given CandidateProgram. EpochX's evolutionary algorithm relies on standardised fitness scores, so it is important that the method returns a lower value for a good solution than for a bad one. Negative fitness values are perfectly acceptable, and will be considered to be more fit than any positive fitness.

Executing Models

As well as providing all the control parameters, the model is also the entry point for an evolutionary run. Every model inherits a method called 'run' which upon being called on an instance of a model, will transfer the thread of control over to the EpochX framework to perform the evolutionary runs requested. If desired, control can be passed back to your application at specific points of a run (see details of the Life Cycle for information concerning this).

Benchmark Models

A number of models come built-in to EpochX, which allow easy execution of the common benchmark problems. These models do not define 'good' parameters, since it is open to debate what parameters would be the right parameters to set. Instead these models simply define the basic problem, providing the problem specific fitness function, and leaving the choice of the best parameter settings to the user.

The following models are provided for XGP and for both XGR and XGE in each of the Java, Ruby, Groovy and Epox languages.

  • Santa Fe ant trail
  • Los Altos Hills ant trail
  • John Muir ant trail
  • Cubic Regression (x + x2 + x3)
  • Quartic Regression (x + x2 + x3 + x4)
  • Sextic Regression (x6 - 2x4 + x2)
  • Multiplexer (any number of inputs)
  • Majority (any number of inputs)
  • Even Parity (any number of inputs)

Implementing a New Problem Model

If you wish to evolve programs to solve a problem other than one of the benchmark problems that models are provided for, then you must implement a new Model. This is done by writing a new Java class that extends one of GPModel, GRModel or GEModel, depending on which of the representations it is for - STGP, CFG-GP or GE respectively. This process is not difficult but will be described thoroughly in a separate tutorial.


Next: Algorithm
Previous: Overview