Executes the genetic program (
GPProgram) using the specified context. The Context provides program state information (including variable values).
The function returns a value of type T
Namespace: RSGenerics.GeneticProgramming
Delphi
|
public
function Execute( const Context: TContext ): T; virtual;
|
Parameters
Context
Type: System.Void
Return Value
Type: T
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 := Executor.Execute(Context);
finally
Context.Free;
end;
end;
|
|