Package edu.cmu.tetrad.search.utils
Class TeyssierScorer
java.lang.Object
edu.cmu.tetrad.search.utils.TeyssierScorer
Implements and extends a scorer extending Teyssier, M., and Koller, D. (2012). 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.
Teyssier, M., & Koller, D. (2012). Ordering-based search: A simple and effective algorithm for learning Bayesian networks. arXiv preprint arXiv:1207.1429.
- Version:
- $Id: $Id
- Author:
- josephramsey, bryanandrews
-
Constructor Summary
ConstructorsConstructorDescriptionTeyssierScorer
(IndependenceTest test, Score score) Constructor that takes both a test or a score. -
Method Summary
Modifier and TypeMethodDescriptionboolean
Returns True iff a is adjacent to b in the current graph.void
bookmark()
Bookmarks the current pi with index Integer.MIN_VALUE.void
bookmark
(int key) Bookmarks the current pi as the index key.void
Clears all bookmarks.boolean
True iff the nodes in W form a clique in the current DAG.boolean
Returns true iff [a, b, c] is a collider.boolean
coveredEdge
(Node x, Node y) Returns true iff x->y or y->x is a covered edge.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) getAncestors.getChildren
(int p) Returns the children of a node v.getChildren
(Node v) Returns the children of a node v.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
getNumEdges.Returns the current permutation without making a copy.getParents
(int p) Returns the parents of the node at index p.getParents
(Node v) Returns the parents of a node v.getPi()
Getter for the fieldpi
.getPrefix
(int i) Retrieves a prefix of the size specified by the parameter.getShuffledVariables.getSkeleton.void
Retries the bookmark with key = Integer.MIN_VALUE and removes the bookmark.void
goToBookmark
(int key) Retrieves the bookmarked state for index 'key' and removes that bookmark.int
Return the index of v in the current permutation.void
Moves v to a new index.boolean
parent.double
score()
score.double
Scores the given permutation.void
setKnowledge
(Knowledge knowledge) Setter for the fieldknowledge
.void
setUseRaskuttiUhler
(boolean useRaskuttiUhler) Setter for the fielduseRaskuttiUhler
.void
setUseScore
(boolean useScore) Setter for the fielduseScore
.int
size()
size.boolean
Swaps m and n in the permutation.boolean
Returns true iff [a, b, c] is a triangle.boolean
Moves j to before k and moves all the ancestors of j betwween k and j to before k.boolean
Moves all j's to before k and moves all the ancestors of all ji's betwween k and ji to before k.boolean
unshieldedCollider
(Node a, Node b, Node c) Returns true iff [a, b, c] is an unshielded collider.boolean
unshieldedTriple
(Node a, Node b, Node c) Returns true iff [a, b, c] is an unshielded triple.
-
Constructor Details
-
TeyssierScorer
Constructor that takes both a test or a score. Only one of these is used, dependent on how the parameters are set.- Parameters:
test
- The test.score
- The score- See Also:
-
-
Method Details
-
setUseScore
public void setUseScore(boolean useScore) Setter for the field
useScore
.- Parameters:
useScore
- True if the score should be used; false if the test should be used.
-
setKnowledge
Setter for the field
knowledge
.- Parameters:
knowledge
- Knowledge of forbidden edges.
-
setUseRaskuttiUhler
public void setUseRaskuttiUhler(boolean useRaskuttiUhler) Setter for the field
useRaskuttiUhler
.- Parameters:
useRaskuttiUhler
- True if Pearl's method for building a DAG should be used.
-
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.
- Throws:
InterruptedException
-
score
score.
- Returns:
- The score of the current permutation.
- Throws:
InterruptedException
-
tuck
-
tuck
-
moveTo
Moves v to a new index.- Parameters:
v
- The variable to move.toIndex
- The index to move v to.
-
swap
-
coveredEdge
-
getPi
-
getOrderShallow
-
index
Return the index of v in the current permutation.- Parameters:
v
- The variable.- Returns:
- Its index.
-
getParents
-
getChildren
-
getParents
-
getChildren
-
getAdjacentNodes
-
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
-
getAncestors
-
getEdges
Returns a list of edges for the current graph as a list of ordered pairs.- Returns:
- This list.
-
getNumEdges
public int getNumEdges()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.
-
bookmark
public void bookmark(int key) Bookmarks the current pi as the index key.- Parameters:
key
- This bookmark may be retrieved using the index 'key', an integer. This bookmark will be stored until it is retrieved and then removed.
-
bookmark
public void bookmark()Bookmarks the current pi with index Integer.MIN_VALUE. -
goToBookmark
public void goToBookmark(int key) Retrieves the bookmarked state for index 'key' and removes that bookmark.- Parameters:
key
- The integer key for this bookmark.
-
goToBookmark
public void goToBookmark()Retries the bookmark with key = Integer.MIN_VALUE and removes the bookmark. -
clearBookmarks
public void clearBookmarks()Clears all bookmarks. -
size
public int size()size.
- Returns:
- The size of pi, the current permutation.
-
getShuffledVariables
-
adjacent
-
collider
-
unshieldedCollider
-
unshieldedTriple
-
triangle
-
clique
-
getPrefix
-
getSkeleton
-
parent
-