diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pc.java index dd8ccbbd27..eb5a43a62d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pc.java @@ -23,7 +23,7 @@ import java.util.List; /** - * CPC. + * PC. * * @author jdramsey */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcMax.java index 6d77885315..c4940d29d5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcMax.java @@ -23,13 +23,13 @@ import java.util.List; /** - * CPC. + * PC-Max. * * @author jdramsey */ @edu.cmu.tetrad.annotation.Algorithm( name = "PC-Max", - command = "pcmax", + command = "pc-max", algoType = AlgType.forbid_latent_common_causes ) @Bootstrapping @@ -68,9 +68,9 @@ public Graph search(DataModel dataModel, Parameters parameters) { search.setDepth(parameters.getInt(Params.DEPTH)); search.setAggressivelyPreventCycles(true); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); - dataModel.setKnowledge(this.knowledge); + search.setKnowledge(this.knowledge); // search.setConcurrent(parameters.getBoolean(Params.CONCURRENT_FAS)); - search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); + search.setUseMaxP(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); return search.search(); } else { @@ -95,7 +95,7 @@ public Graph getComparisonGraph(Graph graph) { @Override public String getDescription() { - return "PCMAX using " + this.test.getDescription(); + return "PC-Max using " + this.test.getDescription(); } @Override @@ -127,7 +127,7 @@ public Knowledge getKnowledge() { @Override public void setKnowledge(Knowledge knowledge) { - this.knowledge = new Knowledge((Knowledge) knowledge); + this.knowledge = new Knowledge(knowledge); } @Override diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/OrientCollidersMaxP.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/OrientCollidersMaxP.java index 487e68589c..50e576ed36 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/OrientCollidersMaxP.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/OrientCollidersMaxP.java @@ -143,6 +143,11 @@ private void testColliderMaxP(Graph graph, Map scores, Node a, N adja.remove(c); adjc.remove(a); + if (!(PcAll.isArrowpointAllowed(a, b, knowledge) + && (PcAll.isArrowpointAllowed(c, b, knowledge)))) { + return; + } + double p = 0; List S = null; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcAll.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcAll.java index 02adbffd28..4821b08ed7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcAll.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcAll.java @@ -360,6 +360,7 @@ public Graph search(List nodes) { orientCollidersMaxP.setUseHeuristic(this.useHeuristic); orientCollidersMaxP.setMaxPathLength(this.maxPathLength); orientCollidersMaxP.setDepth(this.depth); + orientCollidersMaxP.setKnowledge(this.knowledge); orientCollidersMaxP.orient(this.graph); } else if (this.colliderDiscovery == ColliderDiscovery.CONSERVATIVE) { if (this.verbose) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java index 7752f00a06..d7e7e9b5d9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java @@ -91,8 +91,8 @@ public class PcMax implements GraphSearch { private boolean verbose; private boolean stable; - private boolean concurrent; - private boolean useHeuristic = false; + // private boolean concurrent; + private boolean useMaxP = false; private int maxPPathLength = -1; private PcAll.ConflictRule conflictRule = PcAll.ConflictRule.OVERWRITE; @@ -233,7 +233,7 @@ public Graph search(IFas fas, List nodes) { "be in the domain of the independence test provided."); } - PcAll search = new PcAll(independenceTest); + edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(independenceTest); search.setDepth(depth); search.setHeuristic(1); search.setKnowledge(this.knowledge); @@ -249,14 +249,18 @@ public Graph search(IFas fas, List nodes) { // } else { // search.setConcurrent(PcAll.Concurrent.NO); // } -// + search.setColliderDiscovery(PcAll.ColliderDiscovery.MAX_P); search.setConflictRule(conflictRule); - search.setUseHeuristic(useHeuristic); + search.setUseHeuristic(useMaxP); search.setMaxPathLength(maxPPathLength); // search.setExternalGraph(externalGraph); search.setVerbose(verbose); +// fas.setKnowledge(getKnowledge()); +// fas.setDepth(getDepth()); +// fas.setVerbose(this.verbose); + this.graph = search.search(); this.sepsets = fas.getSepsets(); @@ -315,8 +319,8 @@ public void setStable(boolean stable) { // this.concurrent = concurrent; // } - public void setUseHeuristic(boolean useHeuristic) { - this.useHeuristic = useHeuristic; + public void setUseMaxP(boolean useMaxP) { + this.useMaxP = useMaxP; } public void setMaxPPathLength(int maxPPathLength) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java index 6e1f2aae06..ae6460845a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java @@ -204,6 +204,8 @@ public Graph search(List targets) { this.logger.log("info", "BEGINNING step 1 (prune targets)."); for (Node target : getTargets()) { + if (target == null) throw new NullPointerException("Target not specified"); + graph.addNode(target); constructFan(target, graph);