Hide Comments
Hide Comments

Comments (0)

Defines one instruction (function, variable, or constant) in the genetic program.

noteNote

When the instruction executes, it needs no information beyond the nodes and the values passed in, so it may be multi-threaded as long as the values are copied and unless the OnExecute event does something unsafe.

alert_noteNotes to Implementers

The TRSGPVariantInstruction class was created so that LoadValueFromXML and SaveValueToXML methods could be defined. In addition, the OnExecute event handler could be declared published using a instantiated generic type that looks non-generic. Unfortunately, when a published property contains a generic, even an instantiated one (e.g., TRSGPInstruction<Variant>), Delphi will not publish the property and make it available at design-time.

Namespace: RSGeneticProgramming

expandingInheritance Hierarchy

TCollectionItem
  RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>
    RSGeneticProgramming.TRSGPVariantInstruction
 

expandingSyntax

Delphi

type
  TRSGPVariantInstruction = class(TRSGPInstruction<Variant>)
  end; 
 

expandingProperties

 

Name

Description

published property

Arity

Specifies the Arity (maximum allowed number of children) for the instruction. If Arity is greater than 0, the instruction must be a function (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public property

Collection

Specifies the set of instructions that this instruction belongs to (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

published property

Comment

Specifies a comment about the instruction. This property is not used by the genetic programming engine (except for reading and writing the comment).

Use this property for describing the instruction and what it does or means

published property

Name

Specifies the name of the instruction (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

published property

OnInitialize

Occurs when the instruction is initialized at the start of evolution. Use this event to seed the initial constant   Value for the instruction. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

published property

Operation

Specifies the type of the instruction: function, variable or constant (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public property

Value

Specifies the initial constant value for this instruction (if it is a constant).

noteNote

Initially, any TRSGPNode<T> created from this instruction will contain the Value constant. However, because of mutation, the node's Value can change. The Instruction Value should never change except at initialization

Top

expandingMethods

 

Name

Description

public method

Assign(TPersistent)

Represents method Assign(TPersistent). (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

AssignEvents(TPersistent)

Copies the event handlers in the Source object to the instructions events (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

protected method

DoExecute(TRSGPNode<T>,TRSGPContext<T>)

Represents method DoExecute(TRSGPNode<T>,TRSGPContext<T>). (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

Execute(TRSGPNode<T>,TRSGPContext<T>)

Executes the node using the specified context. The node provides information about the constant value (if the instruction is a constant) and the subtree program of the node. The Context provides program state information (including variable values).

The function returns a value of type T (which is the result of the OnExecute event, the Node.Value if it is a constant, or the variable value from the Context if is a variable)

protected method

GetDisplayName

Represents method GetDisplayName. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

Initialize

Initializes the instruction at the start of the genetic evolution (not the start of executing a genetic program). The function calls the OnInitialize event.

The intent of the Initialize method is to initialize the instruction for evolution; usually, this means provide an initial constant     Value.

public method

LoadFromXML(IXMLInstructionType)

Loads the instruction from the XML

alert_cautionWarning

If the instruction is a function, the OnExecute event is not loaded or changed

public method

LoadValueFromXML(IXMLInstructionType)

Loads the   Value from the XML (Overrides RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.LoadValueFromXML(IXMLInstructionType).)

protected method

OperationChanged

Represents method OperationChanged. (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

SaveToXML(IXMLConstantInstructionType)

Overloaded. Saves the instruction as a constant to the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

SaveToXML(IXMLFunctionInstructionType)

Overloaded. Saves the instruction as a function to the XML

alert_cautionWarning

If the instruction is a function, the OnExecute event is not saved

public method

SaveToXML(IXMLGPInstructions)

Overloaded. Saves the Instruction to the XML as a function, variable or constant based on its   Operation (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

SaveToXML(IXMLVariableInstructionType)

Overloaded. Saves the instruction as a variable to the XML (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

public method

SaveValueToXML(IXMLInstructionType)

Saves the   Value to the XML (Overrides RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.SaveValueToXML(IXMLInstructionType).)

public method

ToString

Returns string representation of the instruction (Inherited from RSGenerics.GeneticProgramEngine.TRSGPInstruction<T>.)

Top

expandingEvents

 

Name

Description

published event

OnExecute

Occurs when the instruction is executed. Define an OnExecute event handler for every instruction which is a function

Top

expandingSee Also

Comments (0)