Hide Comments
Hide Comments

Comments (0)

The TRSGABits class is a descendant class of the TRSEncodedBits class which adds methods useful for genetic operations: CrossOver, Mutate, and Invert. This class is used by the RSGeneticAlgorithm.TRSGAIndividual class to hold the genetic information, or chromosome, of each individual in a genetic algorithm population.
 

Namespace: RSGeneticAlgorithm

expandingInheritance Hierarchy

TRSEncodedBits
  RSGeneticAlgorithm.TRSGABits
 

expandingSyntax

Delphi

type 
  TRSGABits = class(TRSEncodedBits) 
  end;  
 

expandingConstructors

 

Name

Description

public constructor

Create(TRSGAIndividual)

Initializes a new instance of the TRSGABits class.

Top

expandingProperties

 

Name

Description

public property

Owner

Returns the individual that owns the genetic information encoded in the TRSGABits instantiation.
 

Top

expandingMethods

 

Name

Description

public method

Clear

Resets all bits to 0

public method

CrossOver(TRSGABits,TRSGABits)

Overloaded. Modifies the bits of the current object by mixing the bits of the two Source bits, or Parents. The method randomly selects a crossover point and then copies bits from Source1 from the first bit to the crossover bit and then copies bits from Source2 from the crossover bit to the last bit. Thus, the current bits object becomes the child of the two parent bits.

public method

CrossOver(TRSGABits,TRSGABits,Integer)

Overloaded. Modifies the bits of the current object by mixing the bits of the two Source bits, or Parents. The method uses the CrossBit crossover point to copy bits from Source1 from the first bit to the crossover bit and then copy bits from Source2 from the crossover bit to the last bit. Thus, the current bits object becomes the child of the two parent bits.

public method

Invert(Integer,Integer)

Flips the bits in range of bits specified from Offset to Offset + Len. If Offset or Len are -1, the method selects a random number within the range of bits in the object.

public method

Mutate(TGAProbability)

Randomly mutates the bits in the object. The method steps through all of the bits of the object. For each bit, the Mutate method has a chance (based on the MutationProbability) to flip the bit, e.g., from True to False, or from False to True. If any bits are mutated, the method returns True.

public method

Randomize

Randomizes the bits of the class, e.g., it arbitrarily sets bits to True or False.

public method

ToString

Returns a string representation (0s and 1s) of the bits in the object

Top

expandingSee Also

Reference

RSEncodedBits|TRSEncodedBits

Comments (0)