Show/Hide Toolbars

RiverSoftAVG Products Help

Navigation: Code Documentation > GeneticAlgorithm > RSGeneticAlgorithm > Classes > TRSGAGene > Methods

TRSGAGene.GeneAsEnumeration(TRSEncodedBits,Integer) Method

Scroll Prev Top Next More

Extracts this gene's value from the Bits chromosome parameter. The function allows read access to the gene as enumerated values. The equivalent  SetGeneAsEnumeration method provides write access. The GeneAsEnumeration access property will attempt to translate the chromosome bits of this gene to an 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 GeneAsEnumeration method will also automatically use the    Offset property.
 

Namespace: RSGeneticAlgorithm

Parameters

Bits

Type: TRSEncodedBits

Offset

Type: Integer

Return Value

Type: String

RiverSoftAVG Products Help © 1996-2016 Thomas G. Grubb