Specifies the maximum number of generations to breed before quitting
Note the
UseGenerationLimit property must be True to use the generation limit.
Namespace: RSGeneticBase
Delphi
|
public
property GenerationLimit: Integer read FGenerationLimit write SetGenerationLimit default 0;
|
Property Value
Type: Integer
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;
|
|