From 96aae74146bed192cedd41deffb4772af0960233 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 17 Jun 2016 17:10:27 -0400 Subject: [PATCH] Fixed knowledge for FGS. --- causal-cmd/causal-cmd.iml | 1 - tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java | 7 +++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/causal-cmd/causal-cmd.iml b/causal-cmd/causal-cmd.iml index 810a18e556..9361361897 100644 --- a/causal-cmd/causal-cmd.iml +++ b/causal-cmd/causal-cmd.iml @@ -16,7 +16,6 @@ - diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java index 3793a6f588..d9e86af705 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java @@ -1315,6 +1315,7 @@ private boolean insert(Node x, Node y, Set T, double bump) { } if (boundGraph != null && !boundGraph.isAdjacentTo(x, y)) return false; + if (knowledge != null && knowledge.isForbidden(x.getName(), y.getName())) return false; graph.addDirectedEdge(x, y); @@ -1339,6 +1340,7 @@ private boolean insert(Node x, Node y, Set T, double bump) { for (Node _t : T) { graph.removeEdge(_t, y); if (boundGraph != null && !boundGraph.isAdjacentTo(_t, y)) continue; + if (knowledge != null && knowledge.isForbidden(y.getName(), _t.getName())) continue; graph.addDirectedEdge(_t, y); @@ -1468,6 +1470,7 @@ private void addRequiredEdges(Graph graph) { Node nodeB = graph.getNode(next.getTo()); if (!graph.isAncestorOf(nodeB, nodeA)) { + if (knowledge != null && knowledge.isForbidden(nodeA.getName(), nodeB.getName())); graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeA, nodeB); TetradLogger.getInstance().log("insertedEdges", "Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB)); @@ -1484,6 +1487,7 @@ private void addRequiredEdges(Graph graph) { if (graph.isAdjacentTo(nodeA, nodeB) && !graph.isChildOf(nodeA, nodeB)) { if (!graph.isAncestorOf(nodeA, nodeB)) { + if (knowledge != null && knowledge.isForbidden(nodeB.getName(), nodeA.getName())); graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); TetradLogger.getInstance().log("insertedEdges", "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); @@ -1492,6 +1496,7 @@ private void addRequiredEdges(Graph graph) { if (!graph.isChildOf(nodeA, nodeB) && getKnowledge().isForbidden(nodeA.getName(), nodeB.getName())) { if (!graph.isAncestorOf(nodeA, nodeB)) { + if (knowledge != null && knowledge.isForbidden(nodeB.getName(), nodeA.getName())); graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); TetradLogger.getInstance().log("insertedEdges", "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); @@ -1504,6 +1509,7 @@ private void addRequiredEdges(Graph graph) { if (graph.isAdjacentTo(nodeA, nodeB) && !graph.isChildOf(nodeA, nodeB)) { if (!graph.isAncestorOf(nodeA, nodeB)) { + if (knowledge != null && knowledge.isForbidden(nodeB.getName(), nodeA.getName())); graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); TetradLogger.getInstance().log("insertedEdges", "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); @@ -1511,6 +1517,7 @@ private void addRequiredEdges(Graph graph) { } if (!graph.isChildOf(nodeA, nodeB) && getKnowledge().isForbidden(nodeA.getName(), nodeB.getName())) { if (!graph.isAncestorOf(nodeA, nodeB)) { + if (knowledge != null && knowledge.isForbidden(nodeA.getName(), nodeB.getName())); graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); TetradLogger.getInstance().log("insertedEdges", "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA));