Hide Comments
Hide Comments

Comments (0)

Defines the generics node for tree-based genetic programming which can contain an arbitrary number of children. Each node represents one function or terminal (constant, variable) in a genetic program. It has one  Parent (or nil if root node) and 0 or more  Child nodes (terminals have no children).

noteNote

For the TRSGPTreeNode<T> class, the children are stored in a list. If you restrict your instructions to 2 or less children, it is recommended to use the TRSGPBinaryNode<T> as it uses slightly less memory and is slightly faster.

Namespace: RSGenerics.GeneticProgramEngine

expandingInheritance Hierarchy

TPersistent
  RSGenerics.GeneticProgramEngine.TRSGPNode<T>
    RSGenerics.GeneticProgramEngine.TRSGPTreeNode<T>
      RSGeneticProgramming.TRSGPFloatNode
      RSGeneticProgramming.TRSGPVariantNode
 

expandingSyntax

Delphi

type
  TRSGPTreeNode<T> = class(TRSGPNode<T>)
  end; 
 

Type Parameters

T

expandingConstructors

 

Name

Description

public constructor

Create(TRSGPInstruction<T>,TRSGPNode<T>)

Initializes a new instance of the TRSGPTreeNode<T> class.

public destructor

Destroy

Destroys the node and frees all of its children (Overrides RSGenerics.GeneticProgramEngine.TRSGPNode<T>.Destroy.)

Top

expandingProperties

 

Name

Description

public property

ChildCount

Returns the number of children that the node contains (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected property

Children

Represents property Children.

public property

Child[Integer]

Returns the child node at the specified index (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public property

Instruction

Specifies the Instruction (function, variable or constant) that this node represents in the genetic program (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public property

Parent

Specifies the Parent node of the current node (or nil if there is no parent) (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public property

Value

Specifies the constant value of the node. If the node is not a constant, this value will be ignored (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

Top

expandingMethods

 

Name

Description

public method

AddChild(TRSGPNode<T>)

Represents method AddChild(TRSGPNode<T>).

public method

Assign(TPersistent)

Makes a deep copy (i.e., all children, grandchildren, etc) of the Source to the node (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected method

CalcDepth

Calculate the depth of the tree with this node as the parent (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected method

CalcSize

Calculate the size of the tree with this node as the parent (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

Clear

Empties the node of all information (i.e.,   Instruction equals nil,   Value equals default, and children are deleted and freed) (Overrides RSGenerics.GeneticProgramEngine.TRSGPNode<T>.Clear.)

public method

Clone(TRSGPNode<T>)

Creates a copy of the current node and all of its children. This is a deep copy of the entire subtree. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected method

CreateNode(TRSGPInstruction<T>,TRSGPNode<T>)

Represents method CreateNode(TRSGPInstruction<T>,TRSGPNode<T>).

public method

Depth

Returns the depth (maximum number of levels of children) of the subtree with this node as its root. If the node has no children, the depth is 1. If the node has children, its depth is 2. If at least one of its children has children, the depth is 3, etc. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

Execute(TRSGPContext<T>)

Executes the current node using the specified Context.

Note that it is up to the Instruction to do the actual execution in its     OnExecute event. The instruction is also where the decision to execute children event or not is made.

public method

ExtractChild(TRSGPNode<T>)

Represents method ExtractChild(TRSGPNode<T>).

protected method

GetChild(Integer)

Represents method GetChild(Integer). (Overrides RSGenerics.GeneticProgramEngine.TRSGPNode<T>.GetChild(Integer).)

protected method

GetChildCount

Represents method GetChildCount. (Overrides RSGenerics.GeneticProgramEngine.TRSGPNode<T>.GetChildCount.)

public method

IndexOf(TRSGPNode<T>)

Searchs for the Node as a child of the current node. If the node is found, this method returns the index to access the child. Otherwise, it returns -1. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

InsertChild(Integer,TRSGPNode<T>)

Represents method InsertChild(Integer,TRSGPNode<T>).

public method

IsTerminal

Returns true if the node is a terminal (constant, variable, or function with arity of 0) (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

LoadFromXML(IXMLDnaType)

Loads the node and its children from the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

LoadValueFromXML(IXMLDnaType)

Loads the   Value from the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected method

Modified

Represents method Modified. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

SaveToXML(IXMLDnaType)

Saves the node and its children to the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

SaveValueToXML(IXMLDnaType)

Saves the   Value to the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected method

SetValue(T)

Represents method SetValue(T). (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

Size

Returns the size (how many children, grandchildren, etc) of the subtree with this node as its root. If the node has no children, the depth is 1. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

ToString

Returns a prefix notation version of the node and its children (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

public method

ValueToString

Returns a string representation of the   Value. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

Top

expandingFields

 

Name

Description

protected field

FDepth

Represents field FDepth. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

protected field

FSize

Represents field FSize. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPNode<T>.)

Top

expandingSee Also

Comments (0)