Hide Comments
Hide Comments

TRSGAGene.SetGeneAsEnumeration(TRSEncodedBits,String) Method

Comments (0)

Writes the value into the Bits chromosome parameter. The function allows write access to the bits as enumerated values. The equivalent    GeneAsEnumeration method provides read access. The SetGeneAsEnumeration function attempts to translate string values into the chromosome bits representing the index of the enumerated value from the    Enumerations property, irregardless of the type specified in GeneType . In other words, the gene does not enforce types, it just helps you to translate bits into a type. You should use the GeneType property to determine the type of the gene before using the accessor functions.

The GeneAsEnumeration/SetGeneAsEnumeration methods translate the enumerated values from their strings into an integer index and encode the index (and vice versa). So if Enumerations contains 4 enumerated values, you only need 2 bits for the encoding. If the Enumerations property is empty or, when writing, the string does not equal a string in the Enumerations property, you will get an exception.

Note: The TRSGAGene class automatically retrieves the appropriate value from the correct place in the Bits chromosome using the    Offset and    Size properties. The overloaded SetGeneAsEnumeration method allows you to change the offset into the bits you want to use.
 

Namespace: RSGeneticAlgorithm

expandingSyntax

Delphi

public 
  procedure SetGeneAsEnumeration(Bits: TRSEncodedBits; const Value: String); overload; 
 

Parameters

Bits

Type: TRSEncodedBits

Value

Type: String

expandingSee Also

Comments (0)