com.rubecula.darwin.domain.helper
Class FitnessCache
java.lang.Object
com.rubecula.darwin.domain.helper.Cache_<FitnessCacheKey,java.lang.Double>
com.rubecula.darwin.domain.helper.FitnessCache
- All Implemented Interfaces:
- Cache, Cache_MBean, net.sf.tostring0.Identifiable
public class FitnessCache
- extends Cache_<FitnessCacheKey,java.lang.Double>
This cache maintains a set of fitness values indexed by
Signature/FitnessEngine pair. Normally, the trait map object is the phenotype
of an Organism. The purpose is to save time recalculating the fitness when it
is unnecessary.
The signature of a TraitMap is its "cache key".
- Author:
- Robin Hillyard
Fields inherited from class com.rubecula.darwin.domain.helper.Cache_ |
LOG |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
FitnessCache
public FitnessCache()
addFitness
public void addFitness(TraitMap traits,
FitnessEngine fitnessEngine,
Environment environment,
java.lang.Double fitness)
- Parameters:
traits
- the traits being whose fitness has been evaluated.fitnessEngine
- the fitness engine which evaluated the fitness.environment
- the environment the fit object resides in.fitness
- the fitness
flush
public void flush(TraitMap traits,
FitnessEngine engine,
Environment environment)
- Flush the cache for the given combination of traits/engine. Note that you
cannot flush the cache for all fitnesses relating to traits only,
or fitnesses relating to the engine only.
- Parameters:
traits
- the traits being whose fitness has been evaluated.engine
- the fitness engine which evaluated the fitness.environment
- the environment the fit object resides in.
getFitness
public java.lang.Double getFitness(TraitMap traits,
FitnessEngine fitnessEngine,
Environment environment)
- Parameters:
traits
- the traits being whose fitness has been evaluated.fitnessEngine
- the fitness engine which evaluates the fitness.environment
- the environment the fit object resides in.
- Returns:
- the cached phenotype (or null if none) - unless it is not active
in which case always null.
getIdentifier
public java.lang.String getIdentifier()
- Returns:
- "fitness cache"
- See Also:
Identifiable.getIdentifier()
register
public void register(FitnessEngine fitnessEngine)
- register the given fitness engine with this cache. Once done, any fitness
function changes which occur will cause this cache to be completely
flushed.
- Parameters:
fitnessEngine
-
Copyright © 2010 Rubecula Software, LLC. All Rights Reserved.