org.jgap
Class CachedFitnessFunction
java.lang.Object
org.jgap.FitnessFunction
org.jgap.CachedFitnessFunction
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Cloneable, ICloneable
- Direct Known Subclasses:
- MinimizingFitnessFunctionCached
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
Constructor Summary |
CachedFitnessFunction()
Default Constructor ensuring downward compatibility. |
CachedFitnessFunction(java.util.Map<java.lang.String,java.lang.Double> cache)
Constructor that allows to use a custom java.util.Map
implementation as cache. |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
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 custom
java.util.Map
implementation as cache.
E.g. for multi-threaded fitness calculations one could use one instance of
java.util.concurrent.ConcurrentHashMap
for all instances of
the fitness function.
- Parameters:
cache
- java.util.Map
data structure used to cache the
fitness values- Since:
- 3.3.2
getFitnessValue
public final double getFitnessValue(IChromosome a_subject)
- Cached fitness value function.
- Overrides:
getFitnessValue
in class FitnessFunction
- Parameters:
a_subject
- the chromosome to evaluate
- Returns:
- fitness value, from cache if available
- Since:
- 3.2
getBusinessKey
protected java.lang.String getBusinessKey(IChromosome a_subject)
- Retrieves the business key of a chromosome instance.
- Parameters:
a_subject
- the chromosome to retrieve the key for
- Returns:
- the business key of the chromosome
- Since:
- 3.2