Class PcCommon

java.lang.Object
edu.cmu.tetrad.search.utils.PcCommon
All Implemented Interfaces:
IGraphSearch

public final class PcCommon extends Object implements IGraphSearch
Prodies some common implementation pieces of variaous PC-like algorithms, with options for collider discovery type, FAS type, and conflict rule.
Author:
josephramsey
  • Constructor Details

    • PcCommon

      public PcCommon(IndependenceTest independenceTest)
      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

      public void setFasType(PcCommon.FasType fasType)
      Parameters:
      fasType - The type of FAS to be used.
    • setPcHeuristicType

      public void setPcHeuristicType(PcCommon.PcHeuristicType pcHeuristic)
      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

      public Graph search()
      Runs the search and returns the search graph.
      Specified by:
      search in interface IGraphSearch
      Returns:
      This result graph.
    • search

      public Graph search(List<Node> nodes)
      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

      public void setColliderDiscovery(PcCommon.ColliderDiscovery colliderDiscovery)
      Sets the type of collider discovery to do.
      Parameters:
      colliderDiscovery - This type.
    • setConflictRule

      public void setConflictRule(PcCommon.ConflictRule conflictRule)
      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

      public Knowledge getKnowledge()
      Returns:
      The knowledge specification used in the search. Non-null.
    • setKnowledge

      public void setKnowledge(Knowledge knowledge)
      Sets the knowledge specification used in the search. Non-null.
    • getIndependenceTest

      public IndependenceTest 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

      public Set<Triple> getAmbiguousTriples()
      Returns:
      The set of ambiguous triples found during the most recent run of the algorithm. Non-null after a call to search().
    • getColliderTriples

      public Set<Triple> getColliderTriples()
      Returns:
      The set of collider triples found during the most recent run of the algorithm. Non-null after a call to search().
    • getNoncolliderTriples

      public Set<Triple> getNoncolliderTriples()
      Returns:
      The set of noncollider triples found during the most recent run of the algorithm. Non-null after a call to search().
    • getAdjacencies

      public Set<Edge> getAdjacencies()
      Returns The edges in the search graph.
      Returns:
      These edges.