Class FitnessNullifier<G extends Gene<?,G>,C extends Comparable<? super C>>

Type Parameters:
G - the gene type
C - the fitness result type
All Implemented Interfaces:

public final class FitnessNullifier<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements EvolutionInterceptor<G,C>
This class allows forcing a reevaluation of the fitness function. A reevaluation is necessary if the fitness function changes. Changing the fitness function is not the usual use case, but is necessary for some problems, like symbolic regression analyses with changing input data (time series).
final var nullifier = new FitnessNullifier<DoubleGene, Double>(); final Engine<DoubleGene, Double> engine = Engine.builder(problem) .interceptor(nullifier) .build(); // Invalidate fitness value by calling the 'nullifyFitness' method, // possible from a different thread. This forces the reevaluation of // the fitness values at the start of the next generation. nullifier.nullifyFitness();
See Also:
Implementation Note:
This interceptor is thread-safe and can be used from different threads. No additional synchronization is needed.
  • Constructor Details

  • Method Details

    • before

      Nullifies the fitness values of the population, if requested. The nullification flag is reset after this call. Two consecutive calls of this method might lead to two different results.
      Specified by:
      before in interface EvolutionInterceptor<G extends Gene<?,G>,C extends Comparable<? super C>>
      start - the evolution start object
      the evolution start object with the nullified fitness values, if the nullification has been triggered
      See Also:
    • nullifyFitness

      public boolean nullifyFitness()
      Triggers the nullification of the fitness values of the population for the next generation.
      true if the nullification request will trigger a new fitness nullification. @{code false} if the fitness nullification has been requested before, without actually executing it.
      See Also: