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.
Namespace: RSGeneticAlgorithm
Delphi
|
public
procedure Invert( Offset: Integer = -1; Len: Integer = -1 );
|
Parameters
Offset
Type: Integer
Len
Type: Integer
The following code modifies a child based on CrossOver, Mutation, and Inversion:
Delphi
|
procedure Reproduce(Parent1, Parent2, Child: TRSGAIndividual);
begin
Child.Assign(Parent1);
// crossover
if (goCrossover in Operations) and (Random < CrossoverProbability) then
Child.Crossover( Parent1, Parent2, Random(Child1.Bits.Size) );
// mutate
if goMutate in Operations then
Child.Bits.Mutate(MutationProbability);
// invert
if (goInvert in Operations) and (Random < InversionProbability) then
Child.Bits.Invert;
end;
|
|