Package edu.cmu.tetrad.search
Class Pc
java.lang.Object
edu.cmu.tetrad.search.Pc
- All Implemented Interfaces:
IGraphSearch
Pc (Unified "Classic PC")
Skeleton via FAS (stable toggle), orient unshielded triples using VANILLA/CPC/MAX_P, then Meek rules to closure. Deterministic: sorted names, canonical (x,y) endpoint ordering. No internal CI cache (wrap your test if desired).
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnum representing the permission to allow or disallow bidirected edges.static enumEnum representing the orientation style used for colliders in a computational context.static final classPublic so callers can use it in results. -
Constructor Summary
ConstructorsConstructorDescriptionPc(IndependenceTest test) Constructs a new instance of the Pc class with a given independence test. -
Method Summary
Modifier and TypeMethodDescriptionIdentifies and returns a list of ambiguous triples from the given graph.Retrieves all colliders from the provided graph based on specific criteria.getFas()Retrieves the Fas object associated with this instance.Identifies and retrieves all noncollider triples from the given graph.getTest()Returns the independence test associated with this instance.search()Performs a search operation based on the test variables associated with the instance.Performs a search to generate a graph structure based on the provided list of nodes.voidSets the allowance for bidirected edges in the structure being analyzed.voidSets the orientation style for handling colliders in the graph.voidsetDepth(int depth) Sets the depth parameter for the instance.voidsetFasStable(boolean fasStable) Sets whether the Fast Adjacency Search (FAS) algorithm will use the "stable" modification.voidsetKnowledge(Knowledge knowledge) Sets the knowledge object for this instance by creating a new instance based on the provided knowledge.voidsetLogMaxPTies(boolean enabled) Sets whether ties in the MAX-P conditional independence tests are logged during execution.voidsetLogStream(PrintStream out) Sets the output stream for logging messages.voidsetMaxPDepthStratified(boolean enabled) Sets whether the MAX-P depth stratification procedure is enabled or disabled.voidsetMaxPGlobalOrder(boolean enabled) Sets the global order-independent MAX-P collider orientation option.voidsetMaxPMargin(double margin) Sets the maximum p-value margin for decision-making in the MAX-P algorithm.voidsetReplicatingGraph(boolean replicatingGraph) Sets the flag indicating whether the graph is in a replicating state.voidsetTest(IndependenceTest test) Sets the independence test for this instance.voidsetTimeoutMs(long timeoutMs) Sets the timeout duration for this instance, specifying the maximum time (in milliseconds) the algorithm or operation is permitted to run.voidsetVerbose(boolean verbose) Sets whether this instance and its associated test will print verbose output.
-
Constructor Details
-
Pc
Constructs a new instance of the Pc class with a given independence test.- Parameters:
test- an IndependenceTest object that defines the test for conditional independence
-
-
Method Details
-
setKnowledge
Sets the knowledge object for this instance by creating a new instance based on the provided knowledge.- Parameters:
knowledge- the Knowledge object to be set, representing constraints or prior information about the graph structure
-
setDepth
public void setDepth(int depth) Sets the depth parameter for the instance. The depth controls the maximum number of conditioning variables used in conditional independence tests.- Parameters:
depth- the maximum number of conditioning variables; a value of -1 typically indicates no limit.
-
setFasStable
public void setFasStable(boolean fasStable) Sets whether the Fast Adjacency Search (FAS) algorithm will use the "stable" modification. The stable version ensures that edge removals during execution do not affect the search process.- Parameters:
fasStable- true to enable the stable FAS modification, false to disable it
-
setColliderOrientationStyle
Sets the orientation style for handling colliders in the graph. The orientation style determines the method used to decide whether a triple forms a collider. Valid styles are defined in thePc.ColliderOrientationStyleenum, such as SEPSETS, CONSERVATIVE, or MAX_P.- Parameters:
rule- thePc.ColliderOrientationStylethat specifies the method used for collider orientation
-
setAllowBidirected
Sets the allowance for bidirected edges in the structure being analyzed. This method determines whether bidirected edges are permitted based on the specified option.- Parameters:
allow- an instance ofPc.AllowBidirectedthat specifies whether bidirected edges are allowed (e.g., ALLOW or DISALLOW)
-
setVerbose
public void setVerbose(boolean verbose) Sets whether this instance and its associated test will print verbose output.- Parameters:
verbose- true to enable verbose output; false to disable it.
-
setTimeoutMs
public void setTimeoutMs(long timeoutMs) Sets the timeout duration for this instance, specifying the maximum time (in milliseconds) the algorithm or operation is permitted to run.- Parameters:
timeoutMs- the timeout duration in milliseconds. A value of 0 or a negative number may indicate no timeout (depending on implementation).
-
setLogMaxPTies
public void setLogMaxPTies(boolean enabled) Sets whether ties in the MAX-P conditional independence tests are logged during execution. If enabled, details about ties that impact decision-making in the algorithm are recorded in the logs.- Parameters:
enabled- true to enable logging for MAX-P ties; false to disable it
-
setLogStream
Sets the output stream for logging messages. The specified PrintStream will be used to capture log outputs generated during the execution of this instance.- Parameters:
out- thePrintStreamobject where the log messages will be directed. Passingnulldisables logging.
-
setMaxPGlobalOrder
public void setMaxPGlobalOrder(boolean enabled) Sets the global order-independent MAX-P collider orientation option. This determines whether the MAX-P algorithm will apply a global ordering that is independent of the sequence of operations.- Parameters:
enabled- true to enable global order-independent orientation, false to disable it
-
setMaxPDepthStratified
public void setMaxPDepthStratified(boolean enabled) Sets whether the MAX-P depth stratification procedure is enabled or disabled. Depth stratification can be used to adjust the way depth constraints are applied during the MAX-P algorithm, based on specific requirements.- Parameters:
enabled- true to enable depth stratification in MAX-P, false to disable it
-
setMaxPMargin
public void setMaxPMargin(double margin) Sets the maximum p-value margin for decision-making in the MAX-P algorithm. The margin is constrained to be non-negative, ensuring that negative values are reset to 0.0.- Parameters:
margin- the maximum p-value margin; if provided value is less than 0.0, it will default to 0.0.
-
search
Performs a search operation based on the test variables associated with the instance. Delegates the search to the method that accepts a list of nodes.- Specified by:
searchin interfaceIGraphSearch- Returns:
- the resulting graph structure after the search operation is completed
- Throws:
InterruptedException- if the thread executing the search is interrupted
-
search
Performs a search to generate a graph structure based on the provided list of nodes. Executes a three-step process: skeleton construction using the Fast Adjacency Search (FAS), orientation of unshielded triples as colliders, and application of Meek rules to ensure proper edge orientations.- Parameters:
nodes- the list of nodes to be used as input for the search algorithm- Returns:
- the resulting graph structure after the search process is completed
- Throws:
InterruptedException- if the thread executing the search is interrupted
-
getTest
Returns the independence test associated with this instance.- Specified by:
getTestin interfaceIGraphSearch- Returns:
- the
IndependenceTestobject representing the test for conditional independence.
-
setTest
Sets the independence test for this instance. The provided test must have the same list of variables as the current test to ensure consistency. Otherwise, an exception will be thrown.- Specified by:
setTestin interfaceIGraphSearch- Parameters:
test- the newIndependenceTestto be set. This test must have the same list of variables as the current test.- Throws:
IllegalArgumentException- if the node lists of the current test and the provided test are not equal.
-
getColliderTriples
Retrieves all colliders from the provided graph based on specific criteria. A collider is an unshielded triple where both parent nodes x and y point to a common child z (i.e., x -> z <- y). The method identifies all such triples in the graph and returns them.- Parameters:
g- the graph from which colliders are identified- Returns:
- a list of triples representing the colliders found in the graph
-
getNoncolliderTriples
Identifies and retrieves all noncollider triples from the given graph. A noncollider triple is a triple where the middle node is not a collider, meaning there are no arrowheads pointing to it from either of the other two nodes.- Parameters:
g- the graph from which noncollider triples are to be extracted- Returns:
- a list of noncollider triples found in the graph
-
getAmbiguousTriples
Identifies and returns a list of ambiguous triples from the given graph. Ambiguous triples are determined based on the structure of the graph and the relationships between nodes in each triple.- Parameters:
g- the graph from which ambiguous triples are to be identified- Returns:
- a list of triples from the graph that are categorized as ambiguous
-
getFas
Retrieves the Fas object associated with this instance.- Returns:
- the Fas object
-
setReplicatingGraph
public void setReplicatingGraph(boolean replicatingGraph) Sets the flag indicating whether the graph is in a replicating state.- Parameters:
replicatingGraph- a boolean value wheretruedenotes that the graph is replicating andfalsedenotes that it is not.
-