The GP.Lab Genetic Programming Kernel

GP.Lab uses a proprietary Genetic Programming implementation written in C++. The representation of individuals is accomplished in a rather 'verbal' way with dedicated program and node classes.

Though systems like TinyGP demonstrate that it's perfectly feasible to implement tree-based GP systems with minimal amounts of code as well as minimal memory footprint at runtime using flattened (linear) representation for trees we prefer the OO approach: Common techniques for object-oriented code allow us to structure the kernel in a way that's easy to understand and to extend (e.g. to adapt to specific problems, add analytics/statistics, etc.).

The GP kernel implements the basic mechanics of the Genetic Programming system, i.e. representation of individual programs, algorithms for initialization and selection as well as the genetic operators.

At this point the three standard initialization mechanisms for new programs are supported:
  • Grow
  • Full and 
  • Ramped Half&Half.
It's probably worth noting that the system uses the actual number of instructions in a program (not just the tree depth) when applying size limits during program initialization and creation of new programs via the genetic operators.

The kernel also provides a range of common instructions:

Program Flow

  • IFGTZ:  If greater than zero (3 parameters: condition, if, else)
  • WHILEGTZ:  A Do-While-Greater-Than-Zero loop

Logic

  • AND:  Logical AND
  • OR:  Logical OR

Math

  • PLUS, MINUS, TIMES, DIV:  Elementary arithmetic (with protected division)
  • SIN, COS, TAN:  Trigonometric functions

Indexed Memory

  • MEMREAD:  Reads the indexed memory content at a specific index
  • MEMWRITE:  Writes to the indexed memory at a specific index
  • MEMSWAP:  Swaps the contents of two indexed memory locations

Specific tasks (problems) require the definition of the function and terminal set for the problem to be solved and subclassing of the program class. The latter contains the logic to initiate evaluation of individual programs and in particular the (entirely problem specific) calculation of fitness values.

Problem specific instructions can be added with a few lines of code by specifying the number of parameters (node fan-in or arity) and logic for evaluating the instruction.


Future posts will cover in more detail the genetic operators and selection mechanisms used by this implementation - both are currently either being refactored or rewritten from scratch as we dust off the project..


Share and Enjoy!

Comments

Popular posts from this blog

GP.Lab: Dark Silicon Update

About GP.Lab

GP.Lab: Public Preview