Hide Comments
Hide Comments

Comments (0)

Returns the genetic diversity of the current Population, which is the  AvgFitness /  MaxFitness. In other words, how different (based upon fitness) are the individuals in the population from each other? If the population is not diverse enough, it is hard to breed a solution as everyone is alike. The genetic component can use the Diversity with the  DiversityLimit to automatically abort evolution if the diversity indicates we are in an evolutionary dead-end.
 

Namespace: RSGeneticBase

expandingSyntax

Delphi

public
  property Diversity: TGAFitness read GetDiversity;
 

Property Value

Type: TGAFitness

expandingExamples

The following example uses Diversity, Generation and Fitness to automatically stop evolution:

Delphi

var
    i: Integer;
 begin
      // evolve population for number of generations, until diversity is too
      // low, or best individual meets fitness cutoff and
      // return number of generations executed
      result := Generation;
      for i := 0 to Generations - 1 do
      begin
           Evolve;
           if (UseFitnessCutoff and
               (((FitnessMethod in [fmMaximize, fmWeightedMaximize]) and (FittestIndividual.Fitness >= FitnessCutoff)) or
               ((FitnessMethod in [fmMinimize, fmWeightedMinimize]) and (FittestIndividual.Fitness <= FitnessCutoff)))) or
              (UseDiversityLimit and (Diversity < DiversityLimit)) or
              (UseGenerationLimit and (Generation >= GenerationLimit)) then Break;
      end;
      result := Generation - result;
 end;

expandingSee Also

Comments (0)