Hide Comments
Hide Comments

Comments (0)

Defines the context (state of the program, i.e., variables and world) for executing or evaluating a genetic program. Every function node OnExecute in a genetic program can read and write to this context. Every variable terminal node will read from this context OnExecute.

alert_noteNotes to Inheritors

By default, a genetic programming context contains a list of variables and their values in the base type specified. Extend the TRSGPContext class to add other context such as world properties (e.g., the map for the ant trail problem)

noteNote

The TRSGPContext<T> is a generic class. Its type will change with the genetic programming type.

Namespace: RSGenerics.GeneticProgramEngine

expandingInheritance Hierarchy

TPersistent
  RSGenerics.GeneticProgramEngine.TRSGPContext<T>
 

expandingSyntax

Delphi

type 
  TRSGPContext<T> = class(TPersistent) 
  end;  
 

Type Parameters

T

expandingConstructors

 

Name

Description

public constructor

Create

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

public destructor

Destroy

Represents the destructor of the TRSGPContext<T> class.

Top

expandingProperties

 

Name

Description

public property

Values

Specifies the variables of type T in the context. For every variable in your genetic programming problem, define a variable in this list.

Top

expandingMethods

 

Name

Description

public method

Assign(TPersistent)

Represents method Assign(TPersistent).

Top

expandingExamples

The following example sets up the world state for the cart centering problem and then executes the genetic program that has been evolved for it:

Delphi

var
   Context: TRSGeneticProgramming.TContext;
   Velocity, Position: TGAFloat;
   Direction: TGAFloat;
 begin
   Context := TRSGeneticProgramming.TContext.Create;
   try
     // velocity -0.75 m/s and 0.75 m/s
     Velocity := 1.5 * Random - 0.75;
     // position  -0.75 m through 0.75 m
     Position := 1.5 * Random - 0.75;
     Context.Values.AddOrSetValue('Position', Position);
     Context.Values.AddOrSetValue('Velocity', Velocity);
     Direction := Item.Execute(Context);
   finally
     Context.Free;
   end;
 end;

expandingSee Also

Comments (0)