Package edu.cmu.tetrad.search.utils
Class PcCommon
java.lang.Object
edu.cmu.tetrad.search.utils.PcCommon
- All Implemented Interfaces:
IGraphSearch
Prodies some common implementation pieces of variaous PC-like algorithms, with options for collider discovery type,
FAS type, and conflict rule.
- Author:
- josephramsey
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumGive the options for the collider discovery algroithm to use--FAS with sepsets reasoning, FAS with conservative reasoning, or FAS with Max P reasoning.static enumGives 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 enumGives the type of FAS used, regular or stable.static enumNONE = no heuristic, PC-1 = sort nodes alphabetically; PC-1 = sort edges by p-value; PC-3 = additionally sort edges in reverse order using p-values of associated independence facts. -
Constructor Summary
ConstructorsConstructorDescriptionPcCommon(IndependenceTest independenceTest) Constructs a CPC algorithm that uses the given independence test as oracle. -
Method Summary
Modifier and TypeMethodDescriptionReturns The edges in the search graph.intgetDepth()longbooleanstatic voidorientCollider(Node x, Node y, Node z, PcCommon.ConflictRule conflictRule, Graph graph) 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 serach graph.voidsetColliderDiscovery(PcCommon.ColliderDiscovery colliderDiscovery) Sets the type of collider discovery to do.voidsetConflictRule(PcCommon.ConflictRule conflictRule) Sets the conflict rule to use.voidsetDepth(int depth) Sets the maximum number of variables conditioned on in any conditional independence test.voidsetFasType(PcCommon.FasType fasType) voidsetKnowledge(Knowledge knowledge) Sets the knowledge specification used in the search.voidsetMaxPathLength(int maxPathLength) voidsetMeekPreventCycles(boolean meekPreventCycles) Sets to true just in case edges will not be added if they would create cycles.voidsetPcHeuristicType(PcCommon.PcHeuristicType pcHeuristic) voidsetVerbose(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) Orient a single unshielded triple, x*-*y*-*z, in a graph.- Parameters:
conflictRule- The conflict rule to use.graph- The graph to orient.- See Also:
-
setMaxPathLength
public void setMaxPathLength(int maxPathLength) - Parameters:
maxPathLength- The max path length for the max p collider orientation heuristic.
-
setFasType
- Parameters:
fasType- The type of FAS to be used.
-
setPcHeuristicType
- Parameters:
pcHeuristic- Which PC heuristic to use (see Causation, Prediction and Search). Default is PcHeuristicType.NONE.- See Also:
-
isMeekPreventCycles
public boolean isMeekPreventCycles()- Returns:
- true just in case edges will not be added if they would create cycles.
-
setMeekPreventCycles
public void setMeekPreventCycles(boolean meekPreventCycles) Sets to true just in case edges will not be added if they would create cycles.- Parameters:
meekPreventCycles- True just in case edges will not be added if they would create cycles.
-
search
Runs the search and returns the search graph.- Specified by:
searchin interfaceIGraphSearch- Returns:
- This result graph.
-
search
Runs the search over the given list of nodes only, returning the serach graph.- Parameters:
nodes- The nodes to search over.- Returns:
- The result graph.
-
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()- Returns:
- The elapsed time of search in milliseconds, after
search()has been run.
-
getKnowledge
- Returns:
- The knowledge specification used in the search. Non-null.
-
setKnowledge
Sets the knowledge specification used in the search. Non-null. -
getIndependenceTest
- 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()- 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 multi-core 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
- Returns:
- The set of ambiguous triples found during the most recent run of the algorithm. Non-null after a call to
search().
-
getColliderTriples
- Returns:
- The set of collider triples found during the most recent run of the algorithm. Non-null after a call to
search().
-
getNoncolliderTriples
- Returns:
- The set of noncollider triples found during the most recent run of the algorithm. Non-null after a call
to
search().
-
getAdjacencies
Returns The edges in the search graph.- Returns:
- These edges.
-