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

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

public class EvaluatorBDe
extends Evaluator

Computes the BDe score of a network. This score is simply the sum of the scores of the individual nodes in the network, which lends itself to performance-enhancements using several schemes of caching the node scores.

Details:

Change History:
Created on Jul 11, 2006

9/6/2005 (v1.0.3) hjs Correct defect in constructor, by making use of caching arrays conditional.

10/28/2005 (v2.0) hjs Replace maxValueCount dependency on constant with observed value from data.

hjs (v1.0.6) 12/7/2005 Add condition for checking varCount versus the maxParentCount (will be handled via validation from v2.0.x forward).

hjs (v2.0) Add inner classes for selecting between new compact observations and original ("legacy") observations (which used multi-dim. arrays).
The fast-cache implementations have been improved to be more sensitive to memory use (applies for minMarkovLag>0).
The use of the legacy observations is only provided for illustrative purpose. The corresponding code will be deprecated in future versions of Banjo.

hjs (v2.1) Modifications for execution as a multi-threaded application:
- Observations are now loaded upfront before entering the searcher
- fastCache is shared between threads (regular cache is not)
- logGamma-preCompute cache is shared between threads

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

Nested Class Summary
protected  class EvaluatorBDe.CompactObservationsSelector
           
protected  class EvaluatorBDe.LegacyObservationsSelector
           
private  class EvaluatorBDe.LogGammaArray
           
private  class EvaluatorBDe.LogGammaComputer
           
private  class EvaluatorBDe.LogGammaProvider
           
 
Nested classes inherited from class edu.duke.cs.banjo.learner.components.Evaluator
Evaluator.ObservationsSelector
 
Field Summary
protected  double alpha
           
protected  double checkBestNetworkScore
           
protected  int dimLags
           
protected  int dimObservations
           
protected  int dimVariables
           
protected static double[] fastNodeScoreCacheFor0parents
           
protected static double[][] fastNodeScoreCacheFor1parent
           
protected static double[][][] fastNodeScoreCacheFor2parents
           
protected  EvaluatorBDe.LogGammaProvider logGammaSelector
           
protected static double[][] logGammaValue
           
protected  int maxValueCount
           
protected  int[] N_ij
           
protected  int[] N_ijk
           
protected  int observationCount
           
protected  Evaluator.ObservationsSelector observationsSelector
           
protected  int offsetLags
           
protected  int offsetObservations
           
protected  int offsetVariables
           
protected  double scoreDiff
           
protected  double unreachableBDeScore
           
 
Fields inherited from class edu.duke.cs.banjo.learner.components.Evaluator
b, cachedCurrentNodePreviousScore, cachedNetworkPreviousScore, cachedNetworkScore, cachedNodeScores, cachedParentNodePreviousScore, collisionsInCacheTracker, computedScoreTracker, crossCheckCachedScoreTracker, currentNodeScoreHashItem, fastCacheLevel, feedbackBuffer, fetchedCachedScoreTracker, highestParentCountEncountered, maxMarkovLag, minMarkovLag, nodeScoreHashMap, placedInCacheScoreTracker, processData, retrievedNodeScoreHashItem, useBasicCache, useCache, varCount
 
Constructor Summary
EvaluatorBDe(BayesNetManagerI _initialBayesNet, Settings _processData)
           
 
Method Summary
 void adjustNodeScoresForUndo(BayesNetChangeI suggestedBayesNetChange)
          Adjusts the various internal score containers when a bayesNetChange is not permanently kept.
 void cleanupOnException()
           
 double computeInitialNetworkScore(BayesNetManagerI currentBayesNetManager)
           
private  double computeNodeScore(int nodeID, int[][] parentIDlist)
           
private  int[][] order2Parents(int[][] parentListWith2Nodes)
           
 void testNodeScores(int currentNodeID, int[][] parentIDlist, double nodeScore)
           
 double updateNetworkScore(BayesNetManagerI currentBayesNetManager, BayesNetChangeI currentBayesNetChange)
          Computes the score of the network described by the bayesNetManager, based on the proposed bayesNetChange.
private  boolean validateRequiredData()
          Validates the settings values required for loading the BDe evaluator.
 
Methods inherited from class edu.duke.cs.banjo.learner.components.Evaluator
loggamma, logGamma, provideCollectedStatistics, updateProcessData
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

alpha

protected final double alpha

observationCount

protected final int observationCount

maxValueCount

protected final int maxValueCount

N_ij

protected int[] N_ij

N_ijk

protected int[] N_ijk

scoreDiff

protected final double scoreDiff
See Also:
Constant Field Values

unreachableBDeScore

protected final double unreachableBDeScore
See Also:
Constant Field Values

checkBestNetworkScore

protected double checkBestNetworkScore

logGammaSelector

protected EvaluatorBDe.LogGammaProvider logGammaSelector

observationsSelector

protected Evaluator.ObservationsSelector observationsSelector

dimObservations

protected final int dimObservations

dimVariables

protected final int dimVariables

dimLags

protected final int dimLags

offsetObservations

protected final int offsetObservations

offsetVariables

protected final int offsetVariables

offsetLags

protected final int offsetLags

fastNodeScoreCacheFor0parents

protected static double[] fastNodeScoreCacheFor0parents

fastNodeScoreCacheFor1parent

protected static double[][] fastNodeScoreCacheFor1parent

fastNodeScoreCacheFor2parents

protected static double[][][] fastNodeScoreCacheFor2parents

logGammaValue

protected static double[][] logGammaValue
Constructor Detail

EvaluatorBDe

public EvaluatorBDe(BayesNetManagerI _initialBayesNet,
                    Settings _processData)
             throws java.lang.Exception
Method Detail

validateRequiredData

private boolean validateRequiredData()
                              throws java.lang.Exception
Validates the settings values required for loading the BDe evaluator.

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

computeInitialNetworkScore

public double computeInitialNetworkScore(BayesNetManagerI currentBayesNetManager)
                                  throws java.lang.Exception
Specified by:
computeInitialNetworkScore in interface EvaluatorI
Specified by:
computeInitialNetworkScore in class Evaluator
Throws:
java.lang.Exception

updateNetworkScore

public 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
Specified by:
updateNetworkScore in class Evaluator
Throws:
java.lang.Exception

computeNodeScore

private double computeNodeScore(int nodeID,
                                int[][] parentIDlist)
                         throws java.lang.Exception
Throws:
java.lang.Exception

adjustNodeScoresForUndo

public 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
Specified by:
adjustNodeScoresForUndo in class Evaluator
Throws:
java.lang.Exception

order2Parents

private int[][] order2Parents(int[][] parentListWith2Nodes)

testNodeScores

public void testNodeScores(int currentNodeID,
                           int[][] parentIDlist,
                           double nodeScore)
                    throws java.lang.Exception
Throws:
java.lang.Exception

cleanupOnException

public void cleanupOnException()
                        throws java.lang.Exception
Overrides:
cleanupOnException in class Evaluator
Throws:
java.lang.Exception