edu.duke.cs.banjo.learner.components
Class Evaluator

java.lang.Object
  extended byedu.duke.cs.banjo.learner.components.Evaluator
All Implemented Interfaces:
EvaluatorI
Direct Known Subclasses:
EvaluatorBDe

public abstract class Evaluator
extends java.lang.Object
implements EvaluatorI

Combines common code shared by the different evaluator implementations.

Details:

Change History:
Created on Apr 13, 2004

9/6/2005 (v1.0.3) hjs Defect in constructor: Make use of caching arrays conditional, so they are only created when needed

Author:
Jurgen Sladeczek (hjs)
For the latest info, please visit www.cs.duke.edu.

Nested Class Summary
protected  class Evaluator.ObservationsSelector
           
 
Field Summary
(package private) static double[] b
          Used in the log-gamma computation.
protected  double cachedCurrentNodePreviousScore
           
protected  double cachedNetworkPreviousScore
           
protected  double cachedNetworkScore
           
protected  double[] cachedNodeScores
           
protected  double cachedParentNodePreviousScore
           
protected  long[] collisionsInCacheTracker
           
protected  long computedScoreTracker
           
protected  long crossCheckCachedScoreTracker
           
protected  NodeScoreCacheItemI currentNodeScoreHashItem
           
protected  int fastCacheLevel
           
protected  java.lang.StringBuffer feedbackBuffer
           
protected  long[] fetchedCachedScoreTracker
           
protected  int highestParentCountEncountered
           
protected  int maxMarkovLag
           
protected  int minMarkovLag
           
protected  java.util.HashMap nodeScoreHashMap
           
protected  long[] placedInCacheScoreTracker
           
protected  Settings processData
           
protected  NodeScoreCacheItemI retrievedNodeScoreHashItem
           
protected  boolean useBasicCache
           
protected  boolean useCache
           
protected  int varCount
           
 
Constructor Summary
Evaluator(BayesNetManagerI _initialBayesNet, Settings _processData)
          Constructor
 
Method Summary
abstract  void adjustNodeScoresForUndo(BayesNetChangeI suggestedBayesNetChange)
          Adjusts the various internal score containers when a bayesNetChange is not permanently kept.
 void cleanupOnException()
           
abstract  double computeInitialNetworkScore(BayesNetManagerI currentBayesNetManager)
           
protected static double loggamma(double x)
           
protected  double logGamma(double arg)
           
 java.lang.StringBuffer provideCollectedStatistics()
           
abstract  double updateNetworkScore(BayesNetManagerI currentBayesNetManager, BayesNetChangeI currentBayesNetChange)
          Computes the score of the network described by the bayesNetManager, based on the proposed bayesNetChange.
 void updateProcessData(Settings _processData)
          For future use.
private  boolean validateRequiredData()
          Validates the settings values required for loading the evaluator base class (i.e., the cache settings).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

varCount

protected final int varCount

minMarkovLag

protected final int minMarkovLag

maxMarkovLag

protected final int maxMarkovLag

currentNodeScoreHashItem

protected NodeScoreCacheItemI currentNodeScoreHashItem

retrievedNodeScoreHashItem

protected NodeScoreCacheItemI retrievedNodeScoreHashItem

nodeScoreHashMap

protected java.util.HashMap nodeScoreHashMap

feedbackBuffer

protected java.lang.StringBuffer feedbackBuffer

cachedNetworkScore

protected double cachedNetworkScore

cachedNodeScores

protected double[] cachedNodeScores

cachedCurrentNodePreviousScore

protected double cachedCurrentNodePreviousScore

cachedParentNodePreviousScore

protected double cachedParentNodePreviousScore

cachedNetworkPreviousScore

protected double cachedNetworkPreviousScore

computedScoreTracker

protected long computedScoreTracker

fetchedCachedScoreTracker

protected long[] fetchedCachedScoreTracker

placedInCacheScoreTracker

protected long[] placedInCacheScoreTracker

collisionsInCacheTracker

protected long[] collisionsInCacheTracker

crossCheckCachedScoreTracker

protected long crossCheckCachedScoreTracker

highestParentCountEncountered

protected int highestParentCountEncountered

processData

protected Settings processData

useCache

protected boolean useCache

useBasicCache

protected boolean useBasicCache

fastCacheLevel

protected int fastCacheLevel

b

static double[] b
Used in the log-gamma computation. Declared here for optimized performance.

Constructor Detail

Evaluator

public Evaluator(BayesNetManagerI _initialBayesNet,
                 Settings _processData)
          throws java.lang.Exception
Constructor

Method Detail

validateRequiredData

private boolean validateRequiredData()
                              throws java.lang.Exception
Validates the settings values required for loading the evaluator base class (i.e., the cache settings).

Returns:
Returns the boolean flag that indicates whether a crucial setting could not be validated.
Throws:
java.lang.Exception

logGamma

protected double logGamma(double arg)

loggamma

protected static double loggamma(double x)

computeInitialNetworkScore

public abstract double computeInitialNetworkScore(BayesNetManagerI currentBayesNetManager)
                                           throws java.lang.Exception
Specified by:
computeInitialNetworkScore in interface EvaluatorI
Parameters:
currentBayesNetManager - The underlying network.
Returns:
The score for the network described by currentBayesNetManager.
Throws:
java.lang.Exception

updateNetworkScore

public abstract double updateNetworkScore(BayesNetManagerI currentBayesNetManager,
                                          BayesNetChangeI currentBayesNetChange)
                                   throws java.lang.Exception
Description copied from interface: EvaluatorI
Computes the score of the network described by the bayesNetManager, based on the proposed bayesNetChange.

Specified by:
updateNetworkScore in interface EvaluatorI
Parameters:
currentBayesNetManager - The current underlying network.
currentBayesNetChange - The proposed change to the network.
Returns:
Returns the score of the updated network.
Throws:
java.lang.Exception

adjustNodeScoresForUndo

public abstract void adjustNodeScoresForUndo(BayesNetChangeI suggestedBayesNetChange)
                                      throws java.lang.Exception
Description copied from interface: EvaluatorI
Adjusts the various internal score containers when a bayesNetChange is not permanently kept.

Specified by:
adjustNodeScoresForUndo in interface EvaluatorI
Parameters:
suggestedBayesNetChange - The change to the network whose effect needs to be undone.
Throws:
java.lang.Exception

updateProcessData

public void updateProcessData(Settings _processData)
                       throws java.lang.Exception
Description copied from interface: EvaluatorI
For future use. Updates whatever setting within processData that is being changed in the particular evaluator implementation.

Specified by:
updateProcessData in interface EvaluatorI
Parameters:
_processData - The data to be exchanged.
Throws:
java.lang.Exception

provideCollectedStatistics

public java.lang.StringBuffer provideCollectedStatistics()
                                                  throws java.lang.Exception
Specified by:
provideCollectedStatistics in interface EvaluatorI
Returns:
Returns the statistics about the particular evaluator implementation.
Throws:
java.lang.Exception

cleanupOnException

public void cleanupOnException()
                        throws java.lang.Exception
Throws:
java.lang.Exception