Writes the value into the Bits chromosome parameter at the specified Offset. 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 size in the Bits chromosome using the
Size property but allows you to specify where in the bits the gene should be retrieved. The overloaded SetGeneAsEnumeration method will also automatically use the
Offset property.
Namespace: RSGeneticAlgorithm
Delphi |
public |
Parameters
Bits
Type: TRSEncodedBits
Offset
Type: Integer
Value
Type: String
Reference |