Package ec.gp.build

# Class PTC1

java.lang.Object
ec.gp.GPNodeBuilder
ec.gp.build.PTC1

All Implemented Interfaces:
  `Prototype`, `Setup`, `Serializable`, `Cloneable`

public class PTC1 extends GPNodeBuilder
PTC1 implements the "Strongly-typed Probabilistic Tree Creation 1 (PTC1)" algorithm described in

Luke, Sean. 2000. Issues in Scaling Genetic Programming: Breeding Strategies, Tree Generation, and Code Bloat. Ph.D. Dissertation, Department of Computer Science, University of Maryland, College Park, Maryland.

...and also in

Luke, Sean. 2000. Two fast tree-creation algorithms for genetic programming. In IEEE Transactions on Evolutionary Computation 4:3 (September 2000), 274-283. IEEE.

Both can be found at http://people.cs.gmu.edu/~sean/papers/

PTC1 requires that your function set to implement PTCFunctionSetForm. The provided function set, PTCFunctionSet, does exactly this.

The Strongly-typed PTC1 algorithm is a derivative of the GROW algorithm used in ec.gp.koza.GrowBuilder. The primary differences are:

- PTC1 guarantees that trees generated will have an expected (mean) tree size, provided by the user. There is no guarantee on variance. This is different from GROW, which doesn't give any user control at all.
- PTC1 does not have a min-depth value. In essence, PTC1's min-depth value is always set to 1.
- PTC1's max-depth value should really only be used to enforce a large memory restriction. Unlike GROW, where it's used to keep GROW from going nuts.
- PTC1 has provisions for picking nonterminals with various probabilities over other nonterminals (and likewise for terminals). To use this, tweak the PTCFunctionSetForm object.

PTC1 assumes that the requested size passed to newRootedTree(...) is the expected size. If the value is NOSIZEGIVEN, then PTC1 will use the expected size defined by the `expected-size` parameter.

Parameters

base.`expected-size` int >= 1 | default expected tree size
base.`max-depth` int >= 1 | maximum allowable tree depth (usually a big value)

Default Base
gp.build.ptc1

See Also:
  - Serialized Form

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `int`
  `expectedSize`
  The default expected tree size for PTC1
  `int`
  `maxDepth`
  The largest maximum tree depth PTC1 can specify -- should be big.
  `static final String`
  `P_EXPECTED`
  `static final String`
  `P_MAXDEPTH`
  `static final String`
  `P_PTC1`

  ### Fields inherited from class ec.gp.GPNodeBuilder

  `CHECK_BOUNDARY, maxSize, minSize, NOSIZEGIVEN, P_MAXSIZE, P_MINSIZE, P_NUMSIZES, P_SIZE, sizeDistribution`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `PTC1()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `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, clone, errorAboutNoNodeWithType, pickSize, warnAboutNonterminal, warnAboutNonTerminalWithType, warnAboutNoTerminalWithType`

  ### Methods inherited from class java.lang.Object

  `equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Field Details

  - ### P_PTC1

    public static final String P_PTC1
    See Also:
      - Constant Field Values

  - ### P_EXPECTED

    public static final String P_EXPECTED
    See Also:
      - Constant Field Values

  - ### P_MAXDEPTH

    public static final String P_MAXDEPTH
    See Also:
      - Constant Field Values

  - ### maxDepth

    public int maxDepth
    The largest maximum tree depth PTC1 can specify -- should be big.

  - ### expectedSize

    public int expectedSize
    The default expected tree size for PTC1

- ## Constructor Details

  - ### PTC1

    public PTC1()

- ## Method Details

  - ### 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.

    Specified by:
      `setup` in interface `Prototype`
    Specified by:
      `setup` in interface `Setup`
    Overrides:
      `setup` in class `GPNodeBuilder`

  - ### newRootedTree

    public GPNode newRootedTree(EvolutionState state, GPType type, int thread, GPNodeParent parent, GPFunctionSet set, int argposition, int requestedSize)
    Specified by:
      `newRootedTree` in class `GPNodeBuilder`