edu.duke.cs.banjo.bayesnet
Class EdgesAsMatrixWithCachedStatistics
java.lang.Object
edu.duke.cs.banjo.bayesnet.EdgesAsMatrix
edu.duke.cs.banjo.bayesnet.EdgesAsMatrixWithCachedStatistics
- All Implemented Interfaces:
- java.lang.Cloneable, EdgesI, EdgesWithCachedStatisticsI
- public class EdgesAsMatrixWithCachedStatistics
- extends EdgesAsMatrix
- implements java.lang.Cloneable, EdgesWithCachedStatisticsI
Contains the data structures built around an adjacency matrix-approach for storing
the network structure.
Details:
- Contains a number of "counts" and other auxilliary variables associated
with the adjacency matrix, for efficient access to matrix data required by the
core objects.
- Example: (3 variables, called 0,1, and 2, of max. Markov lag 1)
0 1 0     0 0 1    
- variable 0 has variable 1 as parent of lag 0,
and variable 2 as parent of lag 1
1 0 1     0 0 0    
- variable 1 has variables 0 and 2 as parents of lag 0,
and no parents of lag 1
0 0 0     0 1 0    
- variable 2 has no parents of lag 0,
and variable 1 as parent of lag 1
- Can (optionally) be loaded from structure file.
Change History:
Created on Mar 3, 2004
2/22/2006 (v1.0.6/v2.0) hjs Correct the computation of the parent counts
in the subtractMatrix method.
<>
3/7/2006 (v2.0) hjs Add regular expression parsing to loading of network structures:
Add additional constructor for extra feedback on a variety of
input errors. New code also supports comments and blank lines
in files.
- Author:
- Jurgen Sladeczek (hjs)
For the latest info, please visit www.cs.duke.edu.
Constructor Summary |
EdgesAsMatrixWithCachedStatistics(EdgesAsMatrix _edgesAsMatrix)
|
EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag)
Basic constructor for creating the initial matrix and its supporting structures. |
EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag,
java.lang.String _directory,
java.lang.String _fileName)
Constructor used for loading a set of nodes (such as the
must-be-absent-parents set) into the matrix structure, using a
minimal amount of validation only. |
EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag,
java.lang.String _directory,
java.lang.String _fileName,
Settings _processData)
Constructor used for loading a network structure (such as the
must-be-present-parents or the initial structure), using an extensive
amount of validation. |
Method Summary |
void |
addParent(int _varIndex,
int _parentVarIndex,
int _lag)
|
void |
adjustForLocalChange(int _nodeToCheck)
|
void |
assignMatrix(EdgesWithCachedStatisticsI _matrixToAssign)
|
void |
computeComplementaryMatrix(EdgesWithCachedStatisticsI _matrix1,
EdgesWithCachedStatisticsI _matrix2)
|
void |
deleteParent(int _varIndex,
int _parentVarIndex,
int _lag)
|
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 _matrix)
|
void |
initMatrix()
|
void |
initMatrix(int valueToInitTo)
|
boolean |
isCyclic()
|
boolean |
isCyclic(BayesNetChangeI bayesNetChange)
|
boolean |
isCyclic(int nodeID,
int[] parentNodeIDs)
|
boolean |
isCyclicBFS(BayesNetChangeI bayesNetChange)
|
boolean |
isParent(int _varIndex,
int _parentVarIndex,
int _lag)
|
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 |
resetCycleAtNode()
|
void |
resetEntireGraph()
|
void |
resetRoundNum()
|
void |
reverseRelation(int _varIndex,
int _lagVar,
int _parentVarIndex,
int _lagParent)
|
void |
setCycleAtNode(int cycleAtNode)
|
void |
setEntry(int _varIndex,
int _parentVarIndex,
int _lag)
|
void |
setEntry(int _varIndex,
int _parentVarIndex,
int _lag,
int _newValue)
|
void |
setToCombinedMatrices(EdgesWithCachedStatisticsI _matrix1,
EdgesWithCachedStatisticsI _matrix2)
|
void |
subtractMatrix(EdgesWithCachedStatisticsI _matrixToSubtract)
|
java.lang.StringBuffer |
toStringWithIDandParentCount()
|
Methods inherited from class edu.duke.cs.banjo.bayesnet.EdgesAsMatrix |
assignMatrix, assignMatrix, assignMatrix, clone, getEntry, getMatrix, hasIdenticalEntries, setMatrix, toString, toStringAsAdjacencyMatrix, toStringAsTest, toStringWithIDs |
Methods inherited from class java.lang.Object |
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
parentCount
private int[] parentCount
combinedParentCount
private int combinedParentCount
parentIDs
private int[] parentIDs
ancestorSet
private int[] ancestorSet
nodesVisited
private int[] nodesVisited
nodesToVisit
private int[] nodesToVisit
cycleAtNode
private int cycleAtNode
EdgesAsMatrixWithCachedStatistics
public EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag)
throws java.lang.Exception
- Basic constructor for creating the initial matrix and its supporting structures.
EdgesAsMatrixWithCachedStatistics
public EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag,
java.lang.String _directory,
java.lang.String _fileName)
throws java.lang.Exception
- Constructor used for loading a set of nodes (such as the
must-be-absent-parents set) into the matrix structure, using a
minimal amount of validation only.
EdgesAsMatrixWithCachedStatistics
public EdgesAsMatrixWithCachedStatistics(int _varCount,
int _minMarkovLag,
int _maxMarkovLag,
java.lang.String _directory,
java.lang.String _fileName,
Settings _processData)
throws java.lang.Exception
- Constructor used for loading a network structure (such as the
must-be-present-parents or the initial structure), using an extensive
amount of validation.
EdgesAsMatrixWithCachedStatistics
public EdgesAsMatrixWithCachedStatistics(EdgesAsMatrix _edgesAsMatrix)
throws java.lang.Exception
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
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 _matrix1,
EdgesWithCachedStatisticsI _matrix2)
throws java.lang.Exception
- Specified by:
setToCombinedMatrices
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
hasOverlap
public boolean hasOverlap(EdgesWithCachedStatisticsI _matrix)
throws java.lang.Exception
- Specified by:
hasOverlap
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
computeComplementaryMatrix
public void computeComplementaryMatrix(EdgesWithCachedStatisticsI _matrix1,
EdgesWithCachedStatisticsI _matrix2)
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 EdgesAsMatrix
parentCount
public int parentCount(int _varIndex)
- Specified by:
parentCount
in interface EdgesWithCachedStatisticsI
isParent
public boolean isParent(int _varIndex,
int _parentVarIndex,
int _lag)
- Specified by:
isParent
in interface EdgesWithCachedStatisticsI
setEntry
public void setEntry(int _varIndex,
int _parentVarIndex,
int _lag)
throws java.lang.Exception
- Specified by:
setEntry
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
setEntry
public void setEntry(int _varIndex,
int _parentVarIndex,
int _lag,
int _newValue)
throws java.lang.Exception
- Specified by:
setEntry
in interface EdgesWithCachedStatisticsI
- Overrides:
setEntry
in class EdgesAsMatrix
- Throws:
java.lang.Exception
addParent
public void addParent(int _varIndex,
int _parentVarIndex,
int _lag)
throws java.lang.Exception
- Specified by:
addParent
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
deleteParent
public void deleteParent(int _varIndex,
int _parentVarIndex,
int _lag)
throws java.lang.Exception
- Specified by:
deleteParent
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
reverseRelation
public void reverseRelation(int _varIndex,
int _lagVar,
int _parentVarIndex,
int _lagParent)
throws java.lang.Exception
- Specified by:
reverseRelation
in interface EdgesWithCachedStatisticsI
- Throws:
java.lang.Exception
resetRoundNum
public void resetRoundNum()
throws java.lang.Exception
- 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
isCyclicBFS
public boolean isCyclicBFS(BayesNetChangeI bayesNetChange)
throws java.lang.Exception
- Throws:
java.lang.Exception
isCyclic
public boolean isCyclic()
- Specified by:
isCyclic
in interface EdgesWithCachedStatisticsI
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 EdgesAsMatrix
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 EdgesAsMatrix
getCycleAtNode
public int getCycleAtNode()
- Specified by:
getCycleAtNode
in interface EdgesWithCachedStatisticsI
- Returns:
- Returns the cycleAtNode.
setCycleAtNode
public void setCycleAtNode(int cycleAtNode)
resetCycleAtNode
public void resetCycleAtNode()
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.