Package edu.cmu.tetrad.search.utils
Class PcCommon
java.lang.Object
edu.cmu.tetrad.search.utils.PcCommon
- All Implemented Interfaces:
IGraphSearch
Provides some common implementation pieces of various PC-like algorithms, with options for collider discovery type,
FAS type, and conflict rule.
- Version:
- $Id: $Id
- Author:
- josephramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
Gives the options for the collider discovery algorithm to use--FAS with sepsets reasoning, FAS with conservative reasoning, or FAS with Max P reasoning.static enum
Gives the type of conflict to be used, priority (when there is a conflict, keep the orientation that has already been made), bidirected (when there is a conflict, orient a bidirected edge), or overwrite (when there is a conflict, use the new orientation).static enum
Gives the type of FAS used, regular or stable.static enum
The PC heuristic type, where this is taken from Causation, Prediction, and Search. -
Constructor Summary
ConstructorsConstructorDescriptionPcCommon
(IndependenceTest independenceTest) Constructs a CPC algorithm that uses the given independence test as oracle. -
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
Checks if colliders are allowed based on the given knowledge.Returns The edges in the search graph.Getter for the fieldambiguousTriples
.Getter for the fieldcolliderTriples
.int
getDepth()
Getter for the fielddepth
.long
Getter for the fieldelapsedTime
.Getter for the fieldindependenceTest
.Getter for the fieldknowledge
.Getter for the fieldnoncolliderTriples
.boolean
Checks if the current object guarantees a complete directed acyclic graph (CPDAG).static void
orientCollider
(Node x, Node y, Node z, PcCommon.ConflictRule conflictRule, Graph graph, boolean verbose) Orient a single unshielded triple, x*-*y*-*z, in a graph.search()
Runs the search and returns the search graph.Runs the search over the given list of nodes only, returning the search graph.void
setColliderDiscovery
(PcCommon.ColliderDiscovery colliderDiscovery) Sets the type of collider discovery to do.void
setConflictRule
(PcCommon.ConflictRule conflictRule) Sets the conflict rule to use.void
setDepth
(int depth) Sets the maximum number of variables conditioned on in any conditional independence test.void
setFasType
(PcCommon.FasType fasType) Setter for the fieldfasType
.void
setGuaranteeCpdag
(boolean guaranteeCpdag) Sets to true just in case edges will not be added if they create cycles.void
setKnowledge
(Knowledge knowledge) Sets the knowledge specification used in the search.void
setMaxDiscriminatingPathLength
(int maxDiscriminatingPathLength) Setter for the fieldmaxPathLength
.void
setPcHeuristicType
(PcCommon.PcHeuristicType pcHeuristic) Setter for the fieldpcHeuristicType
.void
setVerbose
(boolean verbose) Sets whether verbose output should be printed.
-
Constructor Details
-
PcCommon
Constructs a CPC algorithm that uses the given independence test as oracle. This does not make a copy of the independence test, for fear of duplicating the data set!- Parameters:
independenceTest
- The independence test to use.
-
-
Method Details
-
orientCollider
public static void orientCollider(Node x, Node y, Node z, PcCommon.ConflictRule conflictRule, Graph graph, boolean verbose) Orient a single unshielded triple, x*-*y*-*z, in a graph. -
colliderAllowed
Checks if colliders are allowed based on the given knowledge.- Parameters:
graph
- The graph containing the nodes.x
- The first node.y
- The second node.z
- The third node.knowledge
- The knowledge object containing the required and forbidden relationships.- Returns:
- True if colliders are allowed based on the given knowledge, false otherwise.
-
setMaxDiscriminatingPathLength
public void setMaxDiscriminatingPathLength(int maxDiscriminatingPathLength) Setter for the field
maxPathLength
.- Parameters:
maxDiscriminatingPathLength
- The max path length for the max p collider orientation heuristic.
-
setFasType
Setter for the field
fasType
.- Parameters:
fasType
- The type of FAS to be used.
-
setPcHeuristicType
Setter for the field
pcHeuristicType
.- Parameters:
pcHeuristic
- Which PC heuristic to use (see Causation, Prediction and Search). Default is PcHeuristicType.NONE.- See Also:
-
isGuaranteeCpdag
public boolean isGuaranteeCpdag()Checks if the current object guarantees a complete directed acyclic graph (CPDAG).- Returns:
true
if the current object guarantees a CPDAG,false
otherwise.
-
setGuaranteeCpdag
public void setGuaranteeCpdag(boolean guaranteeCpdag) Sets to true just in case edges will not be added if they create cycles.- Parameters:
guaranteeCpdag
- True, just in the output will guarantee a CPDAG.
-
search
Runs the search and returns the search graph.- Specified by:
search
in interfaceIGraphSearch
- Returns:
- This result graph.
- Throws:
InterruptedException
- if any.
-
search
Runs the search over the given list of nodes only, returning the search graph.- Parameters:
nodes
- The nodes to search over.- Returns:
- The result graph.
- Throws:
InterruptedException
-
setColliderDiscovery
Sets the type of collider discovery to do.- Parameters:
colliderDiscovery
- This type.
-
setConflictRule
Sets the conflict rule to use.- Parameters:
conflictRule
- This rule.- See Also:
-
getElapsedTime
public long getElapsedTime()Getter for the field
elapsedTime
.- Returns:
- The elapsed time of search in milliseconds, after
search()
has been run.
-
getKnowledge
Getter for the field
knowledge
.- Returns:
- The knowledge specification used in the search. Non-null.
-
setKnowledge
-
getIndependenceTest
Getter for the field
independenceTest
.- Returns:
- the independence test used in the search, set in the constructor. This is not returning a copy, for fear of duplicating the data set!
-
getDepth
public int getDepth()Getter for the field
depth
.- Returns:
- The depth of the search--that is, the maximum number of variables conditioned on in any conditional independence test.
-
setDepth
public void setDepth(int depth) Sets the maximum number of variables conditioned on in any conditional independence test. If set to -1, the value of 1000 will be used. May not be set to Integer.MAX_VALUE due to a Java bug on multicore systems.- Parameters:
depth
- The depth.
-
setVerbose
public void setVerbose(boolean verbose) Sets whether verbose output should be printed.- Parameters:
verbose
- True iff the case.
-
getAmbiguousTriples
-
getColliderTriples
-
getNoncolliderTriples
-
getAdjacencies
-