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.
Notes 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)
|
Note
|
The TRSGPContext<T> is a generic class. Its type will change with the genetic programming type.
|
Namespace: RSGenerics.GeneticProgramEngine
TPersistent
RSGenerics.GeneticProgramEngine.TRSGPContext<T>
|
Delphi
|
type
TRSGPContext<T> = class(TPersistent)
end;
|
Type Parameters
T
|
Name
|
Description
|
|
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
|
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;
|
|