ec.gp.koza
Class FullBuilder

java.lang.Object
  |
  +--ec.gp.GPNodeBuilder
        |
        +--ec.gp.koza.FullBuilder
All Implemented Interfaces:
java.lang.Cloneable, Prototype, java.io.Serializable, Setup

public class FullBuilder
extends GPNodeBuilder

FullBuilder is a GPNodeBuilder which implements the FULL tree building method described in Koza I/II.

GROW works by choosing a random integer d between minDepth and maxDepth, inclusive. It then grows a full tree of depth d.

Actually, claiming to implement the Koza I/II approach is a bit of a fib -- Koza's original code is somewhat ad-hoc. In the Koza approach, d is chosen in a kind of round-robin fashion rather than at random, if RAMPED HALF/HALF is used. Also, for all three algorithms (RAMPED HALF/HALF, GROW, FULL), the algorithm will not generate a tree consisting of a single terminal, unless forced to.

This implementation instead follows lil-gp's approach, which is to choose d at random from between minDepth and maxDepth, inclusive, and to allow trees consisting of single terminals.

Determining what various algorithms do is a little confusing, mostly because the source code for lil-gp and Koza don't actually quite do what they claim. The table below lists the depth values actually used (counting nodes, rather than edges, for depth). It's probably not what you had expected!


Koza I Min
Koza I Max
Koza II Min
Koza II Max
lil-gp Min
lil-gp Max
ECJ Min
ECJ Max
GROW (mut)
5
5
5
5
 
 
5
5
GROW (new)
7
7
6? 7?
6? 7?
3
7
5
5
FULL (new)
7
7
6? 7?
6? 7?
3
7
 
 
HALF (new)
2
6
2
5? 6?
3
7
2
6


The table cell is empty when that parameter is not defined by the system by default. Koza II has two values each because of a possible typo in the text -- while page 656 gives one maximum, page 671 gives another. Note the odd fact that in Koza I/II GROW and FULL have effectively one-deeper tree values than HALF does, even though they use the same code parameters! This is because of a quirk in Koza's code.

This algorithm ignores requestedSize, so no pipelines can ask it to grow a tree of a specific fixed size. The algorithm also ignores any user-provided size distributions.

Parameters
base.min-depth
int >= 1
(smallest "maximum" depth the builder may use for building a tree. 2 is the default.)
base.max-depth
int >= base.min-depth
(largest "maximum" depth the builder may use for building a tree. 6 is the default.)

Default Base
gp.koza.full

See Also:
Serialized Form

Field Summary
 int maxDepth
          The largest maximum tree depth FULL can specify.
 int minDepth
          The smallest maximum tree depth FULL can specify.
static java.lang.String P_FULLBUILDER
           
static java.lang.String P_MAXDEPTH
           
static java.lang.String P_MINDEPTH
           
 
Fields inherited from class ec.gp.GPNodeBuilder
CHECK_BOUNDARY, maxSize, minSize, NOSIZEGIVEN, P_MAXSIZE, P_MINSIZE, P_NUMSIZES, P_SIZE, sizeDistribution
 
Constructor Summary
FullBuilder()
           
 
Method Summary
 Parameter defaultBase()
          Returns the default base for this prototype.
 GPNode newRootedTree(EvolutionState state, GPType type, int thread, GPNodeParent parent, GPFunctionSet set, int argposition, int requestedSize)
           
 void setup(EvolutionState state, Parameter base)
          Sets up the object by reading it from the parameters stored in state, built off of the parameter base base.
 
Methods inherited from class ec.gp.GPNodeBuilder
canPick, pickSize, protoClone, protoCloneSimple
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

P_FULLBUILDER

public static final java.lang.String P_FULLBUILDER

P_MAXDEPTH

public static final java.lang.String P_MAXDEPTH

P_MINDEPTH

public static final java.lang.String P_MINDEPTH

maxDepth

public int maxDepth
The largest maximum tree depth FULL can specify.

minDepth

public int minDepth
The smallest maximum tree depth FULL can specify.
Constructor Detail

FullBuilder

public FullBuilder()
Method Detail

defaultBase

public Parameter defaultBase()
Description copied from interface: Prototype
Returns the default base for this prototype. This should generally be implemented by building off of the static base() method on the DefaultsForm object for the prototype's package. This should be callable during setup(...).

setup

public void setup(EvolutionState state,
                  Parameter base)
Description copied from interface: Prototype
Sets up the object by reading it from the parameters stored in state, built off of the parameter base base. If an ancestor implements this method, be sure to call super.setup(state,base); before you do anything else.

For prototypes, setup(...) is typically called once for the prototype instance; cloned instances do not receive the setup(...) call. setup(...) may be called more than once; the only guarantee is that it will get called at least once on an instance or some "parent" object from which it was ultimately cloned.

Overrides:
setup in class GPNodeBuilder

newRootedTree

public GPNode newRootedTree(EvolutionState state,
                            GPType type,
                            int thread,
                            GPNodeParent parent,
                            GPFunctionSet set,
                            int argposition,
                            int requestedSize)
                     throws java.lang.CloneNotSupportedException
Overrides:
newRootedTree in class GPNodeBuilder