org.jgap
Class CachedFitnessFunction
- java.lang.Object
-
- org.jgap.FitnessFunction
-
- org.jgap.CachedFitnessFunction
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ICloneable
public abstract class CachedFitnessFunction extends FitnessFunction
The cached fitness function extends the original FitnessFunction functionality in order to reduce evaluating something twice.- Since:
- 3.2
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from class org.jgap.FitnessFunction
DELTA, NO_FITNESS_VALUE
-
-
Constructor Summary
Constructors Constructor and Description CachedFitnessFunction()Default Constructor ensuring downward compatibility.CachedFitnessFunction(java.util.Map<java.lang.String,java.lang.Double> cache)Constructor that allows to use a customjava.util.Mapimplementation as cache.
E.g.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description doublegetFitnessValue(IChromosome a_subject)Cached fitness value function.-
Methods inherited from class org.jgap.FitnessFunction
clone, getLastComputedFitnessValue
-
-
-
-
Constructor Detail
-
CachedFitnessFunction
public CachedFitnessFunction()
Default Constructor ensuring downward compatibility.- Since:
- 3.3.2
-
CachedFitnessFunction
public CachedFitnessFunction(java.util.Map<java.lang.String,java.lang.Double> cache)
Constructor that allows to use a customjava.util.Mapimplementation as cache.
E.g. for multi-threaded fitness calculations one could use one instance ofjava.util.concurrent.ConcurrentHashMapfor all instances of the fitness function.- Parameters:
cache-java.util.Mapdata structure used to cache the fitness values- Since:
- 3.3.2
-
-
Method Detail
-
getFitnessValue
public final double getFitnessValue(IChromosome a_subject)
Cached fitness value function.- Overrides:
getFitnessValuein classFitnessFunction- Parameters:
a_subject- the chromosome to evaluate- Returns:
- fitness value, from cache if available
- Since:
- 3.2
-
-
DMelt 3.0 © DataMelt by jWork.ORG