edu.duke.cs.banjo.bayesnet
Class EdgesAsArrayWithCachedStatistics

java.lang.Object
  extended byedu.duke.cs.banjo.bayesnet.EdgesAsArray
      extended byedu.duke.cs.banjo.bayesnet.EdgesAsArrayWithCachedStatistics
All Implemented Interfaces:
java.lang.Cloneable, EdgesI, EdgesWithCachedStatisticsI

public class EdgesAsArrayWithCachedStatistics
extends EdgesAsArray
implements java.lang.Cloneable, EdgesWithCachedStatisticsI

Contains the data structures built around an adjacency matrix-approach for storing the network structure, using a 1-dimensional array.

Details:

Change History:
Created on June 12, 2006

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

Nested Class Summary
protected  class EdgesAsArrayWithCachedStatistics.CycleFinder
           
protected  class EdgesAsArrayWithCachedStatistics.CycleFinderDFS
           
protected  class EdgesAsArrayWithCachedStatistics.CycleFinderDFSorig
           
protected  class EdgesAsArrayWithCachedStatistics.CycleFinderDFSwithShmueli
           
 
Field Summary
protected  int[] ancestorSet
           
(package private)  java.lang.String associatedDirectory
           
(package private)  java.lang.String associatedFileName
           
protected  BayesNetChangeI bayesNetChange
           
private  int combinedParentCount
           
protected  int cycleAtNode
           
protected  EdgesAsArrayWithCachedStatistics.CycleFinder cycleFinder
           
protected  int[] nodesToVisit
           
protected  int[] nodesVisited
           
private  int[] parentCount
           
protected  int[] parentIDs
           
protected  Settings processData
           
 
Fields inherited from class edu.duke.cs.banjo.bayesnet.EdgesAsArray
currentLagOffset, currentVarOffset, dimLags, dimParents, dimVariables, matrix, maxMarkovLag, minMarkovLag, offsetLags, offsetParents, offsetVariables, varCount
 
Constructor Summary
EdgesAsArrayWithCachedStatistics(EdgesAsArray _edgesAsArray, Settings _processData)
           
EdgesAsArrayWithCachedStatistics(EdgesAsArrayWithCachedStatistics _edgesAsArray)
           
EdgesAsArrayWithCachedStatistics(int _varCount, int _minMarkovLag, int _maxMarkovLag, Settings _processData)
          Basic constructor for creating the initial matrix and its supporting structures.
EdgesAsArrayWithCachedStatistics(int _varCount, int _minMarkovLag, int _maxMarkovLag, Settings _processData, java.lang.String _structureAsString)
           
EdgesAsArrayWithCachedStatistics(int _varCount, int _minMarkovLag, int _maxMarkovLag, java.lang.String _directory, java.lang.String _fileName, Settings _processData, java.lang.String cycleCheckInstructions)
           
 
Method Summary
 void addParent(int _varIndex, int _parentVarIndex, int _lagIndex)
           
 void adjustForLocalChange(int _nodeToCheck)
           
 void assignMatrix(EdgesWithCachedStatisticsI _matrixToAssign)
           
 void computeComplementaryMatrix(EdgesWithCachedStatisticsI _edges1, EdgesWithCachedStatisticsI _edges2)
           
 void deleteParent(int _varIndex, int _parentVarIndex, int _lagIndex)
           
protected  boolean DFSorigForCrossCheck(int nodeToCheck, int parentNodeToCheck, BayesNetChangeI _bayesNetChange)
           
private  int firstParent(int[] _nodesToVisit)
           
 int getCombinedParentCount()
           
 int[][] getCurrentParentIDlist(int _nodeID, int _lag)
           
 int getCycleAtNode()
           
 int[] getParentCount()
           
 int getParentCount(int nodeID)
           
 boolean hasIdenticalEntries(EdgesI _otherMatrix)
           
 boolean hasOverlap(EdgesWithCachedStatisticsI _edges)
           
 void initMatrix()
           
 void initMatrix(int valueToInitTo)
           
 boolean isCyclic()
           
 boolean isCyclic(BayesNetChangeI _bayesNetChange)
           
 boolean isCyclic(int nodeID, int[] parentNodeIDs)
           
 boolean isCyclicDFSorig(BayesNetChangeI _bayesNetChange)
           
 boolean isParent(int _varIndex, int _parentVarIndex, int _parentLag)
           
private  void loadStructure(java.lang.String _structureAsString, Settings _processData)
           
private  void loadStructureAsNodes(java.lang.String _directory, java.lang.String _fileName)
           
private  void loadStructureFile(java.lang.String _directory, java.lang.String _fileName, Settings _processData)
           
 void omitExcludedParents()
           
 void omitNodesAsOwnParents()
           
 int parentCount(int _varIndex)
           
 void reconstructMatrix(java.lang.String _bayesNetStructureString, int _varCount, int _minMarkovLag, int _maxMarkovLag)
           
 void reconstructMatrixStatic(java.lang.String _bayesNetStructureString, int _varCount, int _minMarkovLag, int _maxMarkovLag)
           
 void resetEntireGraph()
           
 void reverseRelation(int _nodeIndex, int _nodeLagIndex, int _parentIndex, int _parentLagIndex)
           
 void setEntry(int _varIndex, int _parentVarIndex, int _lagIndex)
           
 void setEntry(int _varIndex, int _parentVarIndex, int _lagIndex, int _newValue)
           
 void setToCombinedMatrices(EdgesWithCachedStatisticsI _edges1, EdgesWithCachedStatisticsI _edges2)
           
 void subtractMatrix(EdgesWithCachedStatisticsI _matrixToSubtract)
           
 java.lang.StringBuffer toStringWithIDandParentCount()
           
 
Methods inherited from class edu.duke.cs.banjo.bayesnet.EdgesAsArray
assignMatrix, assignMatrix, assignMatrix, clone, getEntry, getMatrix, hasIdenticalEntries, hasIdenticalEntries, setMatrix, toString, toStringAsAdjacencyMatrix, toStringAsTest, toStringWithIDs
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.duke.cs.banjo.bayesnet.EdgesI
assignMatrix, clone, getEntry
 

Field Detail

parentCount

private int[] parentCount

combinedParentCount

private int combinedParentCount

parentIDs

protected int[] parentIDs

ancestorSet

protected int[] ancestorSet

nodesVisited

protected int[] nodesVisited

nodesToVisit

protected int[] nodesToVisit

cycleAtNode

protected int cycleAtNode

associatedDirectory

java.lang.String associatedDirectory

associatedFileName

java.lang.String associatedFileName

processData

protected final Settings processData

cycleFinder

protected EdgesAsArrayWithCachedStatistics.CycleFinder cycleFinder

bayesNetChange

protected BayesNetChangeI bayesNetChange
Constructor Detail

EdgesAsArrayWithCachedStatistics

public EdgesAsArrayWithCachedStatistics(int _varCount,
                                        int _minMarkovLag,
                                        int _maxMarkovLag,
                                        Settings _processData)
                                 throws java.lang.Exception
Basic constructor for creating the initial matrix and its supporting structures.


EdgesAsArrayWithCachedStatistics

public EdgesAsArrayWithCachedStatistics(int _varCount,
                                        int _minMarkovLag,
                                        int _maxMarkovLag,
                                        java.lang.String _directory,
                                        java.lang.String _fileName,
                                        Settings _processData,
                                        java.lang.String cycleCheckInstructions)
                                 throws java.lang.Exception

EdgesAsArrayWithCachedStatistics

public EdgesAsArrayWithCachedStatistics(EdgesAsArray _edgesAsArray,
                                        Settings _processData)
                                 throws java.lang.Exception

EdgesAsArrayWithCachedStatistics

public EdgesAsArrayWithCachedStatistics(EdgesAsArrayWithCachedStatistics _edgesAsArray)
                                 throws java.lang.Exception

EdgesAsArrayWithCachedStatistics

public EdgesAsArrayWithCachedStatistics(int _varCount,
                                        int _minMarkovLag,
                                        int _maxMarkovLag,
                                        Settings _processData,
                                        java.lang.String _structureAsString)
                                 throws java.lang.Exception
Method Detail

initMatrix

public void initMatrix()
Specified by:
initMatrix in interface EdgesWithCachedStatisticsI

initMatrix

public void initMatrix(int valueToInitTo)
Specified by:
initMatrix in interface EdgesWithCachedStatisticsI

assignMatrix

public void assignMatrix(EdgesWithCachedStatisticsI _matrixToAssign)
                  throws java.lang.Exception
Specified by:
assignMatrix in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

subtractMatrix

public void subtractMatrix(EdgesWithCachedStatisticsI _matrixToSubtract)
                    throws java.lang.Exception
Specified by:
subtractMatrix in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

loadStructureAsNodes

private void loadStructureAsNodes(java.lang.String _directory,
                                  java.lang.String _fileName)
                           throws java.lang.Exception
Throws:
java.lang.Exception

loadStructure

private void loadStructure(java.lang.String _structureAsString,
                           Settings _processData)
                    throws java.lang.Exception
Throws:
java.lang.Exception

loadStructureFile

private void loadStructureFile(java.lang.String _directory,
                               java.lang.String _fileName,
                               Settings _processData)
                        throws java.lang.Exception
Throws:
java.lang.Exception

reconstructMatrix

public void reconstructMatrix(java.lang.String _bayesNetStructureString,
                              int _varCount,
                              int _minMarkovLag,
                              int _maxMarkovLag)
                       throws BanjoException
Specified by:
reconstructMatrix in interface EdgesWithCachedStatisticsI
Throws:
BanjoException

reconstructMatrixStatic

public void reconstructMatrixStatic(java.lang.String _bayesNetStructureString,
                                    int _varCount,
                                    int _minMarkovLag,
                                    int _maxMarkovLag)
                             throws BanjoException
Specified by:
reconstructMatrixStatic in interface EdgesWithCachedStatisticsI
Throws:
BanjoException

setToCombinedMatrices

public void setToCombinedMatrices(EdgesWithCachedStatisticsI _edges1,
                                  EdgesWithCachedStatisticsI _edges2)
                           throws java.lang.Exception
Specified by:
setToCombinedMatrices in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

hasOverlap

public boolean hasOverlap(EdgesWithCachedStatisticsI _edges)
                   throws java.lang.Exception
Specified by:
hasOverlap in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

computeComplementaryMatrix

public void computeComplementaryMatrix(EdgesWithCachedStatisticsI _edges1,
                                       EdgesWithCachedStatisticsI _edges2)
                                throws java.lang.Exception
Specified by:
computeComplementaryMatrix in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

getCurrentParentIDlist

public int[][] getCurrentParentIDlist(int _nodeID,
                                      int _lag)
Specified by:
getCurrentParentIDlist in interface EdgesWithCachedStatisticsI
Overrides:
getCurrentParentIDlist in class EdgesAsArray

parentCount

public int parentCount(int _varIndex)
Specified by:
parentCount in interface EdgesWithCachedStatisticsI

isParent

public boolean isParent(int _varIndex,
                        int _parentVarIndex,
                        int _parentLag)
Specified by:
isParent in interface EdgesWithCachedStatisticsI

setEntry

public void setEntry(int _varIndex,
                     int _parentVarIndex,
                     int _lagIndex)
              throws java.lang.Exception
Specified by:
setEntry in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

setEntry

public void setEntry(int _varIndex,
                     int _parentVarIndex,
                     int _lagIndex,
                     int _newValue)
              throws java.lang.Exception
Specified by:
setEntry in interface EdgesWithCachedStatisticsI
Overrides:
setEntry in class EdgesAsArray
Throws:
java.lang.Exception

addParent

public void addParent(int _varIndex,
                      int _parentVarIndex,
                      int _lagIndex)
               throws java.lang.Exception
Specified by:
addParent in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

deleteParent

public void deleteParent(int _varIndex,
                         int _parentVarIndex,
                         int _lagIndex)
                  throws java.lang.Exception
Specified by:
deleteParent in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

reverseRelation

public void reverseRelation(int _nodeIndex,
                            int _nodeLagIndex,
                            int _parentIndex,
                            int _parentLagIndex)
                     throws java.lang.Exception
Specified by:
reverseRelation in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

resetEntireGraph

public void resetEntireGraph()
                      throws java.lang.Exception
Specified by:
resetEntireGraph in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

adjustForLocalChange

public void adjustForLocalChange(int _nodeToCheck)
                          throws java.lang.Exception
Specified by:
adjustForLocalChange in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

isCyclic

public boolean isCyclic(BayesNetChangeI _bayesNetChange)
                 throws java.lang.Exception
Specified by:
isCyclic in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

DFSorigForCrossCheck

protected boolean DFSorigForCrossCheck(int nodeToCheck,
                                       int parentNodeToCheck,
                                       BayesNetChangeI _bayesNetChange)
                                throws java.lang.Exception
Throws:
java.lang.Exception

isCyclicDFSorig

public boolean isCyclicDFSorig(BayesNetChangeI _bayesNetChange)
                        throws java.lang.Exception
Throws:
java.lang.Exception

isCyclic

public boolean isCyclic()
                 throws java.lang.Exception
Specified by:
isCyclic in interface EdgesWithCachedStatisticsI
Throws:
java.lang.Exception

isCyclic

public boolean isCyclic(int nodeID,
                        int[] parentNodeIDs)

firstParent

private int firstParent(int[] _nodesToVisit)

hasIdenticalEntries

public boolean hasIdenticalEntries(EdgesI _otherMatrix)
Specified by:
hasIdenticalEntries in interface EdgesI
Overrides:
hasIdenticalEntries in class EdgesAsArray

omitNodesAsOwnParents

public void omitNodesAsOwnParents()
Specified by:
omitNodesAsOwnParents in interface EdgesWithCachedStatisticsI

omitExcludedParents

public void omitExcludedParents()
Specified by:
omitExcludedParents in interface EdgesWithCachedStatisticsI

getParentCount

public int[] getParentCount()
Specified by:
getParentCount in interface EdgesWithCachedStatisticsI
Returns:
Returns the parentCount.

getParentCount

public int getParentCount(int nodeID)
Specified by:
getParentCount in interface EdgesWithCachedStatisticsI
Overrides:
getParentCount in class EdgesAsArray

getCycleAtNode

public int getCycleAtNode()
Specified by:
getCycleAtNode in interface EdgesWithCachedStatisticsI
Returns:
Returns the cycleAtNode.

toStringWithIDandParentCount

public java.lang.StringBuffer toStringWithIDandParentCount()
Specified by:
toStringWithIDandParentCount in interface EdgesWithCachedStatisticsI

getCombinedParentCount

public int getCombinedParentCount()
Specified by:
getCombinedParentCount in interface EdgesWithCachedStatisticsI
Returns:
Returns the combinedParentCount.