Module io.jenetics.base
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 type
- C- 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 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();
- Since:
- 6.0
- Version:
- 6.0
- See Also:
- Implementation Note:
- This interceptor is thread-safe and can be used from different threads. No additional synchronization is necessary.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbefore(EvolutionStart<G, C> start) Nullifies the fitness values of the population, if requested.booleanTriggers the nullification of the fitness values of the population for the next generation.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.jenetics.engine.EvolutionInterceptorafter, compose
- 
Constructor Details- 
FitnessNullifierpublic FitnessNullifier()
 
- 
- 
Method Details- 
beforeNullifies 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:
- beforein interface- EvolutionInterceptor<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:
 
- 
nullifyFitnessTriggers the nullification of the fitness values of the population for the next generation.- Returns:
- trueif 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:
 
 
-