|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.hd.d.pg2k.ai.scorer.AbstractScorerCache
abstract class AbstractScorerCache
Shared abstract base to handle common Scorer cache tasks. Package-visible only for now to support initial cache implementations.
| Field Summary | |
|---|---|
private MemoryTools.SimpleLRUMap<Tuple.Pair<java.lang.String,java.lang.String>,Tuple.Pair<java.lang.Long,ScoreAndConf>> |
_rawScores
Size-limited cache of raw exhibit scores (and when computed); never null. |
protected SimpleExhibitPipelineIF |
dataSource
Live data source for variables, exhibit data and metadata, etc; never null. |
protected SimpleLoggerIF |
log
Logger; never null. |
protected ScorerPopulation |
population
Scorer population (and cache of Scorer "goodness"); never null. |
| Fields inherited from interface org.hd.d.pg2k.ai.scorer.ScorerCacheIF |
|---|
TRIVIAL |
| Constructor Summary | |
|---|---|
protected |
AbstractScorerCache(ScorerPopulation population,
SimpleExhibitPipelineIF dataSource,
SimpleLoggerIF log)
|
| Method Summary | |
|---|---|
boolean |
canAcceptMoreExternalScorers()
Returns true if this cache can accept (many) more external-supplied Scorer values. |
ScoreAndConf |
computeScorerWeighting(java.lang.String scorerNameAndParameters,
boolean allowStale,
java.lang.String source)
ScoreAndConfidence for the given Scorer over all exhibit types; never null but may be (0,0) where the scorer is unknown or untested. |
ScoreAndConf |
computeUnweightedScoreAndConfidence(java.lang.String exhibitName,
ScorerIF scorer,
boolean allowStale)
Computes the raw score [-1,+1] and confidence [0,+1] for the specified exhibit with the specified scorer and parameters; never null but may be (0,0). |
void |
destroy()
Save work-in-progress if possible, and free up resources, ASAP. |
java.util.Set<java.lang.String> |
getCurrentScorersWithParameters(boolean allowStale)
Current set of best-available Scorers with their parameters; never null but may be empty. |
(package private) SimpleExhibitPipelineIF |
getDataSource()
Make internal dataSource available to classes in the same package only; never null. |
(package private) ScorerPopulation |
getPopulation()
Make population available to classes in the same package only; never null. |
ScorerIF |
getScorerInstance(java.lang.String nameAndParameters)
Get Scorer instance given the Scorer{:value=name}* format; null if no such Scorer available. |
boolean |
hasQueuedExternalScorer()
Returns true if at least once external Scorer is queued waiting to be processed. |
boolean |
offerExternalScorer(java.lang.String externalScorerNameAndParameters)
Non-blocking attempt to queue an externally-supplied Scorer value; returns true if accepted. |
int |
size()
Get current population size; non-negative. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Methods inherited from interface org.hd.d.pg2k.ai.scorer.ScorerCacheIF |
|---|
computeCompositeScoreAndConfidence, computeScorerWeighting, extractCalibrationSet, getBaseScorerByName, getBaseScorersWithoutParameters |
| Field Detail |
|---|
protected final SimpleLoggerIF log
protected final ScorerPopulation population
protected final SimpleExhibitPipelineIF dataSource
private final MemoryTools.SimpleLRUMap<Tuple.Pair<java.lang.String,java.lang.String>,Tuple.Pair<java.lang.Long,ScoreAndConf>> _rawScores
This is a thread-safe map, with automatic LRU discarding of stale/unused values.
A lock can be held on this map to make compound operations atomic, though the lock should be held for as little time as possible so as to maximise available concurrency.
| Constructor Detail |
|---|
protected AbstractScorerCache(ScorerPopulation population,
SimpleExhibitPipelineIF dataSource,
SimpleLoggerIF log)
| Method Detail |
|---|
SimpleExhibitPipelineIF getDataSource()
public int size()
size in interface ScorerCacheIFScorerPopulation getPopulation()
public void destroy()
By default does nothing.
public java.util.Set<java.lang.String> getCurrentScorersWithParameters(boolean allowStale)
getCurrentScorersWithParameters in interface ScorerCacheIF
public ScoreAndConf computeUnweightedScoreAndConfidence(java.lang.String exhibitName,
ScorerIF scorer,
boolean allowStale)
throws java.io.IOException
ScorerCacheIF
computeUnweightedScoreAndConfidence in interface ScorerCacheIFexhibitName - valid full exhibit namescorer - instance of the Scorer; never nullallowStale - if true then allow a stale value from cache,
else throw an exception if nothing is currently available
java.io.IOException
public ScoreAndConf computeScorerWeighting(java.lang.String scorerNameAndParameters,
boolean allowStale,
java.lang.String source)
throws java.io.IOException
ScorerCacheIFSome results will be cached (typically those from the base/current Scorer lists) while other may have to be computed each time, which may be slow.
The source parameter can be used to track which mechanisms are most effective at generating improvements in the population, and could, for example, to spend more time on those that are most effective right now.
computeScorerWeighting in interface ScorerCacheIFscorerNameAndParameters - the name and parameters of the scorer; never nullallowStale - if true then allow a stale or low-confidence value from cache,
else throw an exception if nothing is currently available
and we cannot quickly compute enough points to increase our confidencesource - the name of the mechanism used to generate this Scorer value,
or null if none
java.io.IOExceptionpublic ScorerIF getScorerInstance(java.lang.String nameAndParameters)
ScorerCacheIF
getScorerInstance in interface ScorerCacheIFpublic boolean offerExternalScorer(java.lang.String externalScorerNameAndParameters)
offerExternalScorer in interface ScorerCacheIFpublic boolean canAcceptMoreExternalScorers()
canAcceptMoreExternalScorers in interface ScorerCacheIFpublic boolean hasQueuedExternalScorer()
hasQueuedExternalScorer in interface ScorerCacheIF
|
DHD Multimedia Gallery V1.50.55 | ||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||