Package io.jenetics.engine
Class FitnessNullifier<G extends Gene<?,G>,C extends Comparable<? super C>>
- java.lang.Object
-
- io.jenetics.engine.FitnessNullifier<G,C>
-
- Type Parameters:
G
- the gene typeC
- the fitness result type
- All Implemented Interfaces:
EvolutionInterceptor<G,C>
public final class FitnessNullifier<G extends Gene<?,G>,C extends Comparable<? super C>> extends Object implements EvolutionInterceptor<G,C>
This class allows to force 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();
- Since:
- 6.0
- Version:
- 6.0
- Author:
- Franz Wilhelmstötter
- See Also:
Phenotype.nullifyFitness()
- Implementation Note:
- This interceptor is thread-safe and can be used from different threads. No additional synchronization is needed.
-
-
Constructor Summary
Constructors Constructor Description FitnessNullifier()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EvolutionStart<G,C>
before(EvolutionStart<G,C> start)
Nullifies the fitness values of the population, if requested.boolean
nullifyFitness()
Triggers the nullification of the fitness values of the population for the next generation.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.jenetics.engine.EvolutionInterceptor
after, compose
-
-
-
-
Constructor Detail
-
FitnessNullifier
public FitnessNullifier()
-
-
Method Detail
-
before
public EvolutionStart<G,C> before(EvolutionStart<G,C> start)
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 interfaceEvolutionInterceptor<G extends Gene<?,G>,C extends Comparable<? super C>>
- Parameters:
start
- the evolution start object- Returns:
- the evolution start object with the nullified fitness values, if the nullification has been triggered
- See Also:
nullifyFitness()
-
nullifyFitness
public boolean nullifyFitness()
Triggers the nullification of the fitness values of the population for the next generation.- Returns:
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:
before(EvolutionStart)
-
-