Hide Comments
Hide Comments

Comments (0)

Converts the genetic encoding in the 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 Bits parameter should be at least of the correct size for this gene and all preceding genes in the Genes collection (e.g., its size should be at least Offset + Size bits). The overloaded    AsString function accepts an index of an individual in the Population and automatically extracts the RSGeneticAlgorithm.TRSGAIndividual.Bits chromosome property.
 

Namespace: RSGeneticAlgorithm

expandingSyntax

Delphi

public 
  function AsString( Bits: TRSEncodedBits ): String; overload; 
 

Parameters

Bits

Type: TRSEncodedBits

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)