Hide Comments
Hide Comments

Comments (0)

Executes the individual's genetic program (    DNA) using the specified context. The Context provides program state information (including variable values).

The function returns a value of type T

Namespace: RSGenerics.GeneticProgramming

expandingSyntax

Delphi

public
  function Execute( const Context: TRSGPContext<T> ): T; virtual;
 

Parameters

Context

Type: TRSGPContext<T>

Return Value

Type: T

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)