Skip to content

Commit

Permalink
Merge pull request #215 from cmu-phil/autistics
Browse files Browse the repository at this point in the history
Fixed knowledge for FGS.
  • Loading branch information
jdramsey authored Jun 17, 2016
2 parents 849fc1f + 96aae74 commit 221e33c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
1 change: 0 additions & 1 deletion causal-cmd/causal-cmd.iml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
<excludeFolder url="file://$MODULE_DIR$/target/maven-archiver" />
<excludeFolder url="file://$MODULE_DIR$/target/maven-status" />
<excludeFolder url="file://$MODULE_DIR$/target/site" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire" />
<excludeFolder url="file://$MODULE_DIR$/target/surefire-reports" />
</content>
<orderEntry type="inheritedJdk" />
Expand Down
7 changes: 7 additions & 0 deletions tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fgs.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,7 @@ private boolean insert(Node x, Node y, Set<Node> 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);

Expand All @@ -1339,6 +1340,7 @@ private boolean insert(Node x, Node y, Set<Node> 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);

Expand Down Expand Up @@ -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));
Expand All @@ -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));
Expand All @@ -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));
Expand All @@ -1504,13 +1509,15 @@ 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));
}
}
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));
Expand Down

0 comments on commit 221e33c

Please sign in to comment.