Hide Comments
Hide Comments

Comments (0)

Defines the simple type (e.g., integer, floating point number, etc) for this gene in the population's chromosomes. Use the GeneType property to know how to access the bits of the chromosomes using the AsXXX property accessors (e.g.,  AsInteger for gtInteger GeneType,  AsBoolean for gtBoolean, etc). For the gtEnumeration Gene Type, you also need to define the  Enumerations for the gene before accessing it.

Namespace: RSGeneticAlgorithm

expandingSyntax

Delphi

published
  property GeneType: TGeneType read FGeneType write SetGeneType;
 

Property Value

Type: TGeneType

expandingExamples

The following example prints out the different values of the gene based on its GeneType:

Delphi

function TRSGAGene.AsString(Bits: TRSEncodedBits): String;
 var
    i: Integer;
    f: TGAFloat;
 begin
      case GeneType of
           gtBoolean: if GeneAsBoolean(Bits) then result := 'True' else result := 'False';
           gtInteger:
           begin
                i := GeneAsInteger(Bits);
                result := IntToStr( i );
           end;
           gtFloat:
           begin
                f := GeneAsFloat(Bits);
                result := FloatToStr( f );
           end;
           gtEnumeration: GeneAsEnumeration(Bits);
      else
          result := Bits.AsBitString[Offset, Size];
      end;
 end;

expandingSee Also

Comments (0)