Package edu.cmu.tetrad.search
Class TeyssierScorerOpt
java.lang.Object
edu.cmu.tetrad.search.TeyssierScorerOpt
Implements a scorer extending Teyssier, M., and Koller, D. (2012). Ordering-based search: A simple and effective
algorithm for learning Bayesian networks. arXiv preprint arXiv:1207.1429. You give it a score function
and a variable ordering, and it computes the score. You can move any variable left or right, and it will
keep track of the score using the Teyssier and Kohler method. You can move a variable to a new position,
and you can bookmark a state and come back to it.
- Author:
- josephramsey, bryanandrews
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns True iff a is adjacent to b in the current graph.boolean
True iff the nodes in W form a clique in the current DAG.boolean
Returns true iff [a, b, c] is a collider.void
get
(int j) Returns the node at index j in pi.Returns a list of adjacent node pairs in the current graph.Returns the nodes adjacent to v.getAncestors
(Node node) getEdges()
Returns a list of edges for the current graph as a list of ordered pairs.getGraph
(boolean cpDag) Returns the DAG build for the current permutation, or its CPDAG.int
getParents
(int p) Returns the parents of the node at index p.getParents
(Node v) Returns the parents of a node v.getPi()
int
Return the index of v in the current permutation.void
Moves v to a new index.float
score()
float
Scores the given permutation.void
setKnowledge
(Knowledge knowledge) int
size()
boolean
Swaps m and n in the permutation.boolean
Returns true iff [a, b, c] is a triangle.void
updateScores
(int i1, int i2)
-
Constructor Details
-
TeyssierScorerOpt
-
-
Method Details
-
setKnowledge
- Parameters:
knowledge
- Knowledge of forbidden edges.
-
score
Scores the given permutation. This needs to be done initially before any move or tuck operations are performed.- Parameters:
order
- The permutation to score.- Returns:
- The score of it.
-
score
public float score()- Returns:
- The score of the current permutation.
-
moveTo
Moves v to a new index.- Parameters:
v
- The variable to move.toIndex
- The index to move v to.
-
demote
-
swap
Swaps m and n in the permutation.- Parameters:
m
- The first variable.n
- The second variable.- Returns:
- True iff the swap was done.
-
getPi
- Returns:
- A copy of the current permutation.
-
index
Return the index of v in the current permutation.- Parameters:
v
- The variable.- Returns:
- Its index.
-
getParents
Returns the parents of the node at index p.- Parameters:
p
- The index of the node.- Returns:
- Its parents.
-
getParents
Returns the parents of a node v.- Parameters:
v
- The variable.- Returns:
- Its parents.
-
getAdjacentNodes
Returns the nodes adjacent to v.- Parameters:
v
- The variable.- Returns:
- Its adjacent nodes.
-
getGraph
Returns the DAG build for the current permutation, or its CPDAG.- Parameters:
cpDag
- True iff the CPDAG should be returned, False if the DAG.- Returns:
- This graph.
-
getAdjacencies
Returns a list of adjacent node pairs in the current graph.- Returns:
- This list.
-
getAncestors
-
getEdges
Returns a list of edges for the current graph as a list of ordered pairs.- Returns:
- This list.
-
getNumEdges
public int getNumEdges()- Returns:
- The number of edges in the current graph.
-
get
Returns the node at index j in pi.- Parameters:
j
- The index.- Returns:
- The node at that index.
-
size
public int size()- Returns:
- The size of pi, the current permutation.
-
adjacent
Returns True iff a is adjacent to b in the current graph.- Parameters:
a
- The first node.b
- The second node.- Returns:
- True iff adj(a, b).
-
collider
Returns true iff [a, b, c] is a collider.- Parameters:
a
- The first node.b
- The second node.c
- The third node.- Returns:
- True iff a->b<-c in the current DAG.
-
triangle
Returns true iff [a, b, c] is a triangle.- Parameters:
a
- The first node.b
- The second node.c
- The third node.- Returns:
- True iff adj(a, b) and adj(b, c) and adj(a, c).
-
clique
True iff the nodes in W form a clique in the current DAG.- Parameters:
W
- The nodes.- Returns:
- True iff these nodes form a clique.
-
updateScores
public void updateScores(int i1, int i2)
-