Hide Comments
Hide Comments

Comments (0)

Converts the genetic encoding of a RSGeneticAlgorithm.TRSGAIndividual 's Bits into a string representation based on    GeneType. The AsString function extracts the gene's bits (using the Offset and Size properties to specify where) and then converts the bits into a string representation, e.g., for numeric types, you see the decimal representation of the number, for booleans, you see "True" or "False, and for enumerations, you see the correct string from the    Enumerations property.

The Index parameter specifies the index of an individual in the    Population and automatically extracts the RSGeneticAlgorithm.TRSGAIndividual.Bits chromosome property to call the overloaded AsString function.
 

Namespace: RSGeneticAlgorithm

expandingSyntax

Delphi

public 
  function AsString( Index: Integer ): String; overload; 
 

Parameters

Index

Type: Integer

Return Value

Type: String

expandingExamples

The following example prints out the gene representation for every individual in the population:

Delphi

var
   iGene, iPop: Integer;
   Bits: TRSEncodedBits;
 begin
   // for every individual in the population
   for iPop := 0 to RSGeneticAlgorithm1.Population.Count - 1 do
   begin
     // write out the Name for this individual
     Memo1.Lines.Add('Individual #'+IntToStr(iPop)+': '+RSGeneticAlgorithm1.Population[iPop].DisplayName);
     Bits := RSGeneticAlgorithm1.Population[iPop].Bits;
     // for all gene's
     for iGene := 0 to RSGeneticAlgorithm1.Genes.Count - 1 do
       Memo1.Lines.Add(RSGeneticAlgorithm1.Genes[iGene].AsString(Bits));
   end;
 end; 

expandingSee Also

Comments (0)