Controls how the genetic component evolves: should it seek to maximize fitness or minimize fitness (or weighted fitness)
Namespace: RSGeneticBase
Delphi
|
public
property FitnessMethod: TGAFitnessMethod read FFitnessMethod write FFitnessMethod default fmMinimize;
|
Property Value
Type: TGAFitnessMethod
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;
|
|