From 451f49fb6b0e4477160ad34d970100bebf8bb593 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Tue, 21 Feb 2023 11:20:36 -0500 Subject: [PATCH 001/214] Update README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 84a9e38641..01d1ec3b5e 100644 --- a/README +++ b/README @@ -8,7 +8,7 @@ https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/ The jar to launch the Tetrad GUI is here (please download this one and delete any old ones): -https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.1/tetrad-gui-7.2.1-launch.jar +https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar The application will work on all major platforms once a recent version of the Java JRE is installed. (Corretto 18 is fine, for instance.) You may be able to launch it by double clicking the jar file name, though on a Mac, this presents some security challenges-- From f21a7de2431ddc7ffc7482f1d8452c005e48e5fb Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 2 Mar 2023 12:00:51 -0500 Subject: [PATCH 002/214] Fixed coef range .5 to 1.5 problem. Also put revised knowledge into GRaSP and BOSS. Also switched to a snapshot version. --- data-reader/pom.xml | 2 +- pom.xml | 2 +- tetrad-gui/pom.xml | 2 +- tetrad-lib/pom.xml | 2 +- .../main/java/edu/cmu/tetrad/search/Boss.java | 54 +++++++++++++++ .../java/edu/cmu/tetrad/search/Grasp.java | 66 ++++++++++++++++--- .../main/java/edu/cmu/tetrad/sem/SemIm.java | 4 +- .../java/edu/cmu/tetrad/util/Version.java | 6 +- 8 files changed, 121 insertions(+), 17 deletions(-) diff --git a/data-reader/pom.xml b/data-reader/pom.xml index b7800db80f..705b6a33e7 100644 --- a/data-reader/pom.xml +++ b/data-reader/pom.xml @@ -5,7 +5,7 @@ io.github.cmu-phil tetrad - 7.2.2 + 7.2.4_SNAPSHOT data-reader diff --git a/pom.xml b/pom.xml index d66e1d887f..c7062bbe5d 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.cmu-phil tetrad - 7.2.2 + 7.2.4_SNAPSHOT pom Tetrad Project diff --git a/tetrad-gui/pom.xml b/tetrad-gui/pom.xml index 3bb8e5a0f1..4835b698dc 100644 --- a/tetrad-gui/pom.xml +++ b/tetrad-gui/pom.xml @@ -6,7 +6,7 @@ io.github.cmu-phil tetrad - 7.2.2 + 7.2.4_SNAPSHOT tetrad-gui diff --git a/tetrad-lib/pom.xml b/tetrad-lib/pom.xml index 4a329fa458..0811a65527 100644 --- a/tetrad-lib/pom.xml +++ b/tetrad-lib/pom.xml @@ -6,7 +6,7 @@ io.github.cmu-phil tetrad - 7.2.2 + 7.2.4_SNAPSHOT tetrad-lib diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java index 52073bc8b5..e42beacd5e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java @@ -3,11 +3,13 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.data.KnowledgeEdge; import edu.cmu.tetrad.graph.*; +import edu.cmu.tetrad.util.JOptionUtils; import edu.cmu.tetrad.util.MillisecondTimes; import edu.cmu.tetrad.util.NumberFormatUtil; import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; +import javax.swing.*; import java.text.NumberFormat; import java.util.*; @@ -428,6 +430,26 @@ private void makeValidKnowledgeOrder(List order) { }); } + if (violatesKnowledge(order)) { + Edge edge = violatesForbiddenKnowledge(order); + + if (edge != null) { + JOptionPane.showMessageDialog (JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was in the DAG: " + edge + " in the initial sort,\n" + + "but this edge was forbidden."); + } + + Edge edge2 = violatesRequiredKnowledge(order); + + if (edge2 != null) { + JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was not in the DAG: " + edge2 + " in the initial sorted," + + "but this edge was required."); + } + } + System.out.println("Initial knowledge sort order = " + order); if (violatesKnowledge(order)) { @@ -532,6 +554,38 @@ private boolean violatesKnowledge(List order) { return false; } + private Edge violatesForbiddenKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName()) && scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(i), order.get(j)); + } + } + } + } + + return null; + } + + private Edge violatesRequiredKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName()) && !scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(j), order.get(i)); + } + } + } + } + + return null; + } + public void setUseRaskuttiUhler(boolean useRaskuttiUhler) { this.useRaskuttiUhler = useRaskuttiUhler; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Grasp.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Grasp.java index a0ba229542..ff0e4fd0b0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Grasp.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Grasp.java @@ -2,15 +2,14 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.data.KnowledgeEdge; -import edu.cmu.tetrad.graph.Edge; -import edu.cmu.tetrad.graph.Endpoint; -import edu.cmu.tetrad.graph.Graph; -import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.graph.*; +import edu.cmu.tetrad.util.JOptionUtils; import edu.cmu.tetrad.util.MillisecondTimes; import edu.cmu.tetrad.util.NumberFormatUtil; import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; +import javax.swing.*; import java.text.NumberFormat; import java.util.*; @@ -148,8 +147,23 @@ private void makeValidKnowledgeOrder(List order) { System.out.println("Initial knowledge sort order = " + order); if (violatesKnowledge(order)) { - throw new IllegalArgumentException("The initial sorting procedure could not find a permutation " + - "consistent with that knowledge."); + Edge edge = violatesForbiddenKnowledge(order); + + if (edge != null) { + JOptionPane.showMessageDialog (JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was in the DAG: " + edge + " in the initial sort,\n" + + "but this edge was forbidden."); + } + + Edge edge2 = violatesRequiredKnowledge(order); + + if (edge2 != null) { + JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was not in the DAG: " + edge2 + " in the initial sorted," + + "but this edge was required."); + } } } @@ -211,7 +225,7 @@ private void graspDfs(@NotNull TeyssierScorer scorer, double sOld, int[] depth, if (covered && tucks.contains(tuck)) continue; if (currentDepth > depth[1] && !covered) continue; - int[] idcs = new int[] {scorer.index(x), scorer.index(y)}; + int[] idcs = new int[]{scorer.index(x), scorer.index(y)}; int i = idcs[0]; scorer.bookmark(currentDepth); @@ -333,13 +347,15 @@ public void setUseScore(boolean useScore) { private boolean violatesKnowledge(List order) { if (!this.knowledge.isEmpty()) { + scorer.score(order); + for (int i = 0; i < order.size(); i++) { for (int j = i + 1; j < order.size(); j++) { - if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName())) { + if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName()) && scorer.parent(order.get(i), order.get(j))) { return true; } - if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName())) { + if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName()) && !scorer.parent(order.get(i), order.get(j))) { return true; } } @@ -349,6 +365,38 @@ private boolean violatesKnowledge(List order) { return false; } + private Edge violatesForbiddenKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName()) && scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(i), order.get(j)); + } + } + } + } + + return null; + } + + private Edge violatesRequiredKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName()) && !scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(j), order.get(i)); + } + } + } + } + + return null; + } + public void setOrdered(boolean ordered) { this.ordered = ordered; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemIm.java index 69bf48523a..745f318b47 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemIm.java @@ -1938,8 +1938,8 @@ private double initialValue(Parameter parameter) { if (parameter.isInitializedRandomly()) { if (parameter.getType() == ParamType.COEF) { - double coefLow = getParams().getDouble("coefLow", .5); - double coefHigh = getParams().getDouble("coefHigh", 1.5); + double coefLow = getParams().getDouble("coefLow", 0.0); + double coefHigh = getParams().getDouble("coefHigh", 1.0); double value = new Split(coefLow, coefHigh).nextRandom(); if (getParams().getBoolean("coefSymmetric", true)) { return value; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Version.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Version.java index 9561ffbef0..50bf1ba0ad 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Version.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Version.java @@ -123,8 +123,10 @@ public Version(String spec) { this.minorSubversion = Integer.parseInt(matcher5.group(3)); this.incrementalRelease = Integer.parseInt(matcher5.group(4)); } else { - throw new IllegalArgumentException("Version should be either of the " + - "form a.b.c or a.b.c-d or a.b.c-SNAPSHOT or a.b.c-d.e " + spec); + this.majorVersion = 0;//Integer.parseInt(matcher5.group(1)); + this.minorVersion = 0;//Integer.parseInt(matcher5.group(2)); + this.minorSubversion = 0;//Integer.parseInt(matcher5.group(3)); + this.incrementalRelease = 0;//Integer.parseInt(matcher5.group(4)); } } From 1825b0dc930b6a56554eeef9c87bd9d1ed70e5d2 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 2 Mar 2023 13:05:47 -0500 Subject: [PATCH 003/214] Fixed coef range .5 to 1.5 problem. Also put revised knowledge into GRaSP and BOSS. Also switched to a snapshot version. --- data-reader/pom.xml | 2 +- pom.xml | 2 +- tetrad-gui/pom.xml | 2 +- tetrad-lib/pom.xml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/data-reader/pom.xml b/data-reader/pom.xml index 705b6a33e7..595c6b2a48 100644 --- a/data-reader/pom.xml +++ b/data-reader/pom.xml @@ -5,7 +5,7 @@ io.github.cmu-phil tetrad - 7.2.4_SNAPSHOT + 7.2.4-SNAPSHOT data-reader diff --git a/pom.xml b/pom.xml index c7062bbe5d..7644639ba3 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ 4.0.0 io.github.cmu-phil tetrad - 7.2.4_SNAPSHOT + 7.2.4-SNAPSHOT pom Tetrad Project diff --git a/tetrad-gui/pom.xml b/tetrad-gui/pom.xml index 4835b698dc..c7cdb146db 100644 --- a/tetrad-gui/pom.xml +++ b/tetrad-gui/pom.xml @@ -6,7 +6,7 @@ io.github.cmu-phil tetrad - 7.2.4_SNAPSHOT + 7.2.4-SNAPSHOT tetrad-gui diff --git a/tetrad-lib/pom.xml b/tetrad-lib/pom.xml index 0811a65527..bceefd69c6 100644 --- a/tetrad-lib/pom.xml +++ b/tetrad-lib/pom.xml @@ -6,7 +6,7 @@ io.github.cmu-phil tetrad - 7.2.4_SNAPSHOT + 7.2.4-SNAPSHOT tetrad-lib From 1fa7bd608ce34448cf2a81a342681ad827dfc47b Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 3 Mar 2023 13:25:48 -0500 Subject: [PATCH 004/214] Update README --- README | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README b/README index 01d1ec3b5e..a10ad4db49 100644 --- a/README +++ b/README @@ -2,6 +2,10 @@ The purpose of Tetrad is to make algorithms available to do causal inference. Th https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html +We have a project web page here with all of the current links for artifacts, a list of contributors, and a bit of history here: + +https://sites.google.com/view/tetradcausal + All artifacts are published in the Maven Central Repository here: https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/ @@ -40,10 +44,6 @@ The web page for the Center for Causal Discovery is here: https://www.ccd.pitt.edu/ -We have a project web page here with all of the current links for artifacts, a list of contributors, and a bit of history here: - -https://sites.google.com/view/tetradcausal - A tutorial can be found here: https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html From 647bf4d7fdae9afe9e36e73ee6b632d2f56c437b Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 11:50:29 -0500 Subject: [PATCH 005/214] Update README --- README | 59 +++++++++++++--------------------------------------------- 1 file changed, 13 insertions(+), 46 deletions(-) diff --git a/README b/README index a10ad4db49..8d59145bfa 100644 --- a/README +++ b/README @@ -1,65 +1,32 @@ -The purpose of Tetrad is to make algorithms available to do causal inference. The Dietrich College (Carnegie Mellon University) web page for Tetrad is here: +The purpose of Tetrad is to make algorithms available to do causal inference. Here is the [Dietrich College (Carnegie Mellon University) web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). -https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html +Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. -We have a project web page here with all of the current links for artifacts, a list of contributors, and a bit of history here: +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). -https://sites.google.com/view/tetradcausal +to download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -All artifacts are published in the Maven Central Repository here: +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc))with long term support (LTS) works well cross-platform. -https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/ - -The jar to launch the Tetrad GUI is here (please download this one and delete any old ones): - -https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar - -The application will work on all major platforms once a recent version of the Java JRE is installed. (Corretto 18 is fine, for instance.) You may be able to launch it by double clicking the jar file name, though on a Mac, this presents some security challenges-- - -https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues - -On all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: +You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: java -Xmx[g]G -jar *-launch.jar where 'g' is the maximum number of Gigabytes you wish to allocate to the process. -The link to the causal-cmd repository for Tetrad (which allows Tetrad algorithms to be run at the command line) is here: - -https://github.com/bd2kccd/causal-cmd - -All artifacts for Tetrad and causal-cmd are published in Maven Central, here: - -https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/ - -Please submit issue requests for Tetrad here: - -https://github.com/cmu-phil/tetrad/issues - -Our project URL is here: - -https://github.com/cmu-phil/tetrad - -The web page for the Center for Causal Discovery is here: - -https://www.ccd.pitt.edu/ - -A tutorial can be found here: - -https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html +We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -The manual is here: +All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Javadocs and source code for each release are included in the Maven Central publication for that release. +Here is out [GitHub URL](https://github.com/cmu-phil/tetrad). -For instructions on how to set this project up in IntelliJ IDEA, see: +Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad. -https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA +If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). -Alternatively, you can run the lifecycle package target and launch the "-launch" jar that is -built in the target directory. +Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains fairly well-developed code in these packages: From 64dd3d2d1effb2fb43347ca31c8f39ec1a212175 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 11:51:05 -0500 Subject: [PATCH 006/214] Update README --- README | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README b/README index 8d59145bfa..2dbd07986e 100644 --- a/README +++ b/README @@ -1,4 +1,4 @@ -The purpose of Tetrad is to make algorithms available to do causal inference. Here is the [Dietrich College (Carnegie Mellon University) web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). +The purpose of Tetrad is to make algorithms available to do causal inference. Here is the [Dietrich College Carnegie Mellon University web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 3efd97bf60be4bb84b31f77fe62df93389d8cc37 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:04:03 -0500 Subject: [PATCH 007/214] Update README --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index 2dbd07986e..982c7cd2c2 100644 --- a/README +++ b/README @@ -10,7 +10,9 @@ The application will work on all major platforms once a recent version of the Ja You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: +``` java -Xmx[g]G -jar *-launch.jar +``` where 'g' is the maximum number of Gigabytes you wish to allocate to the process. From f01366e02b677c4b34633039a30447e5e16e4f28 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:08:10 -0500 Subject: [PATCH 008/214] Update README --- README | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/README b/README index 982c7cd2c2..752351e9c5 100644 --- a/README +++ b/README @@ -6,7 +6,7 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so to download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc))with long term support (LTS) works well cross-platform. +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: @@ -14,7 +14,7 @@ You may be able to launch this jar by double clicking the jar file name, though java -Xmx[g]G -jar *-launch.jar ``` -where 'g' is the maximum number of Gigabytes you wish to allocate to the process. +where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. @@ -31,9 +31,8 @@ If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains fairly well-developed code in these packages: +* tetrad +* pitt +* tetradapp -tetrad -pitt -tetradapp - -The tetrad-lib package contains the "model" code; the tetrad-gui package contains the "view" (GUI) code. +The tetrad-lib package contains the model code; the tetrad-gui package contains the view (GUI) code. From d5493db82e2cdc47abe6fe918a9c628edf9b4711 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:12:35 -0500 Subject: [PATCH 009/214] Update README --- README | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README b/README index 752351e9c5..03d8bd006c 100644 --- a/README +++ b/README @@ -1,3 +1,5 @@ +# Tetrad + The purpose of Tetrad is to make algorithms available to do causal inference. Here is the [Dietrich College Carnegie Mellon University web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 98a7d13910ebcba979cd6c5d7f1097cdcdd7e230 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:18:00 -0500 Subject: [PATCH 010/214] Rename README to README.md --- README => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename README => README.md (100%) diff --git a/README b/README.md similarity index 100% rename from README rename to README.md From 89aff3992e92b7b6f06927a1b245a65ef5ca09a6 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:22:44 -0500 Subject: [PATCH 011/214] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 03d8bd006c..fc54535a94 100644 --- a/README.md +++ b/README.md @@ -20,11 +20,13 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. +For Python integration, please see out (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad). Also, please see the [causal-learn package](https://github.com/py-why/causal-learn), now part of the [py-why space](https://github.com/py-why). + All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is out [GitHub URL](https://github.com/cmu-phil/tetrad). +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad. From 40ef93061beb9917ad55a4e3ea2160be96e54575 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:25:36 -0500 Subject: [PATCH 012/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fc54535a94..42beb1a502 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see out (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad). Also, please see the [causal-learn package](https://github.com/py-why/causal-learn), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn package]([https://github.com/py-why/causal-learn](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 9341f93c5562015a452c08f5f1134d7ebe21c0ef Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:26:45 -0500 Subject: [PATCH 013/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 42beb1a502..3b9ece1089 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn package]([https://github.com/py-why/causal-learn](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package][https://github.com/py-why/causal-learn](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From fdc7c381128d615272a256dbd14f0cabf7688246 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:27:48 -0500 Subject: [PATCH 014/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b9ece1089..8b9e2ecf5b 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package][https://github.com/py-why/causal-learn](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From add3111a2631a87162726b92b27ba176a0dae8f6 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:29:06 -0500 Subject: [PATCH 015/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8b9e2ecf5b..e2fb5a6bf4 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 6f169d15799b5c4e1c6ac052b45965679362bd3f Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:29:32 -0500 Subject: [PATCH 016/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2fb5a6bf4..664c17ad05 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 4ac7dbae228fd1151a3ab4fc2689e8b014640037 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:30:41 -0500 Subject: [PATCH 017/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 664c17ad05..8f7c69c49f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 9f5e24c69eba94bd7feed94244a7bb06830d3809 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:31:25 -0500 Subject: [PATCH 018/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f7c69c49f..e4299a6091 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). -to download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. +To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. The application will work on all major platforms once a recent version of the Java JRE/JCK is installed. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. From 9701eda2287d2160949a9158e0360d06e76c53f4 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:32:16 -0500 Subject: [PATCH 019/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e4299a6091..e2bce5995c 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: From 58341402f87c4f5186fc1d047066157bbbadb759 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:34:43 -0500 Subject: [PATCH 020/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e2bce5995c..a7b54022ef 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From c7ac09305d8a0659d97f1a5c6ea18702eb6bfc38 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:36:28 -0500 Subject: [PATCH 021/214] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a7b54022ef..7419fefeaf 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,9 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. + +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From b5e918f838617bfc12ef67aca46401c889cef599 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:41:40 -0500 Subject: [PATCH 022/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7419fefeaf..ac44bc8ffe 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where g is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 818df787701b87c85a84ef4dd9de5b9b168f6597 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:42:21 -0500 Subject: [PATCH 023/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ac44bc8ffe..aaeb650611 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 18b33993952aa0b1dab3da8e3397e6967c94c688 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:44:44 -0500 Subject: [PATCH 024/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aaeb650611..329667c5fb 100644 --- a/README.md +++ b/README.md @@ -30,7 +30,7 @@ Please submit issue requests for Tetrad using our [Issue Tracker](https://github Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. -Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad. +Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). From a2c9eb067022ab6212aac88c8ba66fafd3384cc3 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 12:56:55 -0500 Subject: [PATCH 025/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 329667c5fb..ea4fe4c123 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All artifacts for Tetrad and causal-cmd are published in [Maven Central](https:/ Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here, so don't worry about it. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. From 26222eb9ee7c1b5fb8bdec65c88011923149246d Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:00:52 -0500 Subject: [PATCH 026/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ea4fe4c123..329667c5fb 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All artifacts for Tetrad and causal-cmd are published in [Maven Central](https:/ Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here, so don't worry about it. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. From fdde2233fd95e26436ccbad08699006b510f47f3 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:01:59 -0500 Subject: [PATCH 027/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 329667c5fb..a49997ff2b 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto 18 JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: From f20420b7473f7cf58ccbbc99143972865b2e8eeb Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:02:15 -0500 Subject: [PATCH 028/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a49997ff2b..2ead036395 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto JRK/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: From 67dd4ebc5ab257b92f7dc8ce583071d9e8271dac Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:04:50 -0500 Subject: [PATCH 029/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2ead036395..6b298a6027 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All artifacts for Tetrad and causal-cmd are published in [Maven Central](https:/ Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. From b4eb58048dc93f0c296ffbbf438b925bd7323c6e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:07:30 -0500 Subject: [PATCH 030/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6b298a6027..6ca34116d6 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're al Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). +If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. From d0a022bc64e1d03bef382fb68b0d13f34cb8033c Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:10:23 -0500 Subject: [PATCH 031/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6ca34116d6..d50756b1ec 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ You may be able to launch this jar by double clicking the jar file name, though java -Xmx[g]G -jar *-launch.jar ``` -where g is the maximum number of Gigabytes you wish to allocate to the process. +where [g] is the maximum number of Gigabytes you wish to allocate to the process. We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. From d730125d02781508e1a19724a20c0088b295b113 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:11:41 -0500 Subject: [PATCH 032/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d50756b1ec..4fe1871668 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From 996e52ad643c2b90a1fad98d4d26c2b9ed3085db Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:12:51 -0500 Subject: [PATCH 033/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4fe1871668..76c606de42 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ All artifacts for Tetrad and causal-cmd are published in [Maven Central](https:/ Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. From 1a55f9db3cf253ad34723d1868fd7db243d75b55 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:14:05 -0500 Subject: [PATCH 034/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 76c606de42..f4feb41ce9 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where [g] is the maximum number of Gigabytes you wish to allocate to the process We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in this project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! From da449bd59baa77673500c24fed0efb533ed68371 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:17:39 -0500 Subject: [PATCH 035/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f4feb41ce9..27db2f37fc 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ where [g] is the maximum number of Gigabytes you wish to allocate to the process We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! +For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! From 4be080051605f9adab86fe6d7c896cbc665f9e82 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:29:04 -0500 Subject: [PATCH 036/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 27db2f37fc..ab3d8ab9d7 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly _greater than version 1.8 (version 8)_. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: From b72011ac1a90ea30a520fc3864a578517c7612f5 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:36:30 -0500 Subject: [PATCH 037/214] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index ab3d8ab9d7..6432e9e9e7 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt. If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). +# Install + Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains fairly well-developed code in these packages: From 4fd82e5f8f818a2dc83f49fc91d6c959cc405acc Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:40:23 -0500 Subject: [PATCH 038/214] Update README.md --- README.md | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 6432e9e9e7..22abd02a12 100644 --- a/README.md +++ b/README.md @@ -18,24 +18,31 @@ java -Xmx[g]G -jar *-launch.jar where [g] is the maximum number of Gigabytes you wish to allocate to the process. -We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. - -For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! - -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! - All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. - Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. +# Documentation + If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). +# Command Line + +We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. + +# Python Integration + +For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! + +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! + + # Install +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. + Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains fairly well-developed code in these packages: From 0cd8210a452f57600887a2fe1c98e8d8506d49e5 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:41:06 -0500 Subject: [PATCH 039/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22abd02a12..0f1ed5c95a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tetrad -The purpose of Tetrad is to make algorithms available to do causal inference. Here is the [Dietrich College Carnegie Mellon University web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). +The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Dietrich College Carnegie Mellon University web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 0a3bd7f346cd65e743a93e7313bea883c86c1aeb Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:43:07 -0500 Subject: [PATCH 040/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f1ed5c95a..686f623fa4 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Also, please see the [causal-learn Python package](https://causal-learn.readthed # Install -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Actually you're already here. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. From af6d943c4efdb025a26f47a26373d38aaa0f708a Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:43:57 -0500 Subject: [PATCH 041/214] Update README.md --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 686f623fa4..3366762959 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ Please submit issue requests for Tetrad using our [Issue Tracker](https://github Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. + # Documentation If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). @@ -41,9 +43,7 @@ Also, please see the [causal-learn Python package](https://causal-learn.readthed # Install -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. - -Here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains fairly well-developed code in these packages: * tetrad From 84dbf362690b4c27556d2054e8cca02446875b2c Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:44:12 -0500 Subject: [PATCH 042/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3366762959..90d968dc3e 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Also, please see the [causal-learn Python package](https://causal-learn.readthed Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. -The project contains fairly well-developed code in these packages: +The project contains well-developed code in these packages: * tetrad * pitt * tetradapp From 16400c5c43cae1e351b61aed67b8fda3077f8b1e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:46:36 -0500 Subject: [PATCH 043/214] Update README.md --- README.md | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 90d968dc3e..dc3773ff5e 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,12 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). +Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. + +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. + +# Tetrad GUI Application + To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. @@ -20,11 +26,9 @@ where [g] is the maximum number of Gigabytes you wish to allocate to the process All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). - -Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. +# Bug Reports -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). # Documentation From f40ca045834b7db9fa734e3cda5a3d2ccd66c709 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:47:27 -0500 Subject: [PATCH 044/214] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dc3773ff5e..835009a88d 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. +All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. + # Tetrad GUI Application To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. @@ -24,8 +26,6 @@ java -Xmx[g]G -jar *-launch.jar where [g] is the maximum number of Gigabytes you wish to allocate to the process. -All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. - # Bug Reports Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). From d9af943a61cc961163abf14de43ec5235e060015 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:48:26 -0500 Subject: [PATCH 045/214] Update README.md --- README.md | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 835009a88d..5132bfa083 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,6 @@ java -Xmx[g]G -jar *-launch.jar where [g] is the maximum number of Gigabytes you wish to allocate to the process. -# Bug Reports - -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). - -# Documentation - -If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). - # Command Line We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. @@ -44,6 +36,9 @@ For Python integration, please see our (still new) [py-tetrad Python project](ht Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! +# Documentation + +If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). # Install @@ -55,3 +50,7 @@ The project contains well-developed code in these packages: * tetradapp The tetrad-lib package contains the model code; the tetrad-gui package contains the view (GUI) code. + +# Bug Reports + +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). From d3ac9e906f29e2f0bbbe83b150c83159be43ce92 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:49:06 -0500 Subject: [PATCH 046/214] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5132bfa083..4f1ef19f6e 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ All of our code is public and we welcome suggestions, expecially if you have awe All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -# Tetrad GUI Application +## Tetrad GUI Application To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. @@ -26,21 +26,21 @@ java -Xmx[g]G -jar *-launch.jar where [g] is the maximum number of Gigabytes you wish to allocate to the process. -# Command Line +## Command Line We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that lets you run Tetrad algorithms at the command line. -# Python Integration +## Python Integration For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! -# Documentation +## Documentation If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -# Install +## Install Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. From 4e8d02149611dfa985114e8c8a3bc5324ac3bcd6 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:50:37 -0500 Subject: [PATCH 047/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f1ef19f6e..ceb74d9f46 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). The JPype project is already quite awesome; it is not necessary to use it in the way suggested in py-tetrad, though perhaps py-tetrad can provide a way to get started with it. Have fun exploring! +For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! From 9ad059e9c21d8c385f5390967ece991caba1f1a9 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:52:11 -0500 Subject: [PATCH 048/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ceb74d9f46..4e4f3ff07d 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). Have fun exploring that too! +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). ## Documentation From add05ca9462298e6199d26d53155b44e5ef4b04c Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:53:11 -0500 Subject: [PATCH 049/214] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 4e4f3ff07d..cb0c2224b5 100644 --- a/README.md +++ b/README.md @@ -4,13 +4,11 @@ The purpose of Tetrad is to make algorithms available in Java to do causal infer Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. -All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). - Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -All artifacts for Tetrad and causal-cmd are published in [Maven Central](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. ## Tetrad GUI Application From fe53002b6000118ee3f7cec69226774c2d3cf882 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:54:13 -0500 Subject: [PATCH 050/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb0c2224b5..f844d62233 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,4 @@ The tetrad-lib package contains the model code; the tetrad-gui package contains # Bug Reports -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all issues before publishing new versions of Tetrad. From 7b489c3a738b2c5c51138bb38035ffcb2f062004 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:54:50 -0500 Subject: [PATCH 051/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f844d62233..993b40d41a 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,4 @@ The tetrad-lib package contains the model code; the tetrad-gui package contains # Bug Reports -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all issues before publishing new versions of Tetrad. +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before publishing new versions of Tetrad. From 54fc11ece84cd316a5f37b549285c29cebda1924 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:55:50 -0500 Subject: [PATCH 052/214] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 993b40d41a..422e0575ff 100644 --- a/README.md +++ b/README.md @@ -6,8 +6,6 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. - All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. ## Tetrad GUI Application @@ -40,6 +38,8 @@ If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad ## Install +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. + Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. The project contains well-developed code in these packages: From a83cafde67934609ff62ca1c31e69b16c9b42cf7 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:56:37 -0500 Subject: [PATCH 053/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 422e0575ff..de7d01c6c3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. Performance is everything. This is the Way. ## Tetrad GUI Application From 4b2f7559178f7d19527eb3a6a5d37d200804ea64 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:57:09 -0500 Subject: [PATCH 054/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index de7d01c6c3..cf4a8895e7 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours. Performance is everything. This is the Way. +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. Performance is everything. This is the Way. ## Tetrad GUI Application From 8e569e929f40f5ead1e4d599a65b1dab0bc12aba Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 13:58:03 -0500 Subject: [PATCH 055/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cf4a8895e7..4b72f3a6da 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. Performance is everything. This is the Way. +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. Performance is everything. [This is the Way](https://en.wikipedia.org/wiki/The_Mandalorian). ## Tetrad GUI Application From 2a2f8d4e318eedd61504ca9a1d6e1440ddeb20f1 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 14:01:33 -0500 Subject: [PATCH 056/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b72f3a6da..4b40afe6fc 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,6 @@ The project contains well-developed code in these packages: The tetrad-lib package contains the model code; the tetrad-gui package contains the view (GUI) code. -# Bug Reports +## Bug Reports Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before publishing new versions of Tetrad. From 89ffb177c4ad80a2669e03f350f6c19670be2d88 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 14:05:01 -0500 Subject: [PATCH 057/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4b40afe6fc..8f9e4b8d40 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,4 @@ The tetrad-lib package contains the model code; the tetrad-gui package contains ## Bug Reports -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before publishing new versions of Tetrad. +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before releasing new versions of Tetrad. From c2e873cb0ab5202770c560423eb83b385ffd28d4 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 14:05:51 -0500 Subject: [PATCH 058/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8f9e4b8d40..67039fde7d 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,4 @@ The tetrad-lib package contains the model code; the tetrad-gui package contains ## Bug Reports -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before releasing new versions of Tetrad. +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). From 59cb45f0054f3e8bbcd68d23efbddfdde0c2a703 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 14:09:11 -0500 Subject: [PATCH 059/214] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 67039fde7d..45a3c01c75 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,5 @@ The tetrad-lib package contains the model code; the tetrad-gui package contains ## Bug Reports -Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). +Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List +](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List). From df2e551adb633f9ad8b30ebfc2010f3bc99704b6 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:16:23 -0500 Subject: [PATCH 060/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 45a3c01c75..1e72069ab3 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. Performance is everything. [This is the Way](https://en.wikipedia.org/wiki/The_Mandalorian). +All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. ## Tetrad GUI Application From c0f69d2628b66f49d9da15f6f2b9615c49d4b63b Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:18:01 -0500 Subject: [PATCH 061/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 1e72069ab3..a1fbfa3067 100644 --- a/README.md +++ b/README.md @@ -49,7 +49,7 @@ The project contains well-developed code in these packages: The tetrad-lib package contains the model code; the tetrad-gui package contains the view (GUI) code. -## Bug Reports +## Bug/Issue Reports Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List ](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List). From 2d0367825ce3306cb6c70db0bc24b9772a63144f Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:20:11 -0500 Subject: [PATCH 062/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a1fbfa3067..86ac2b8de3 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using the [JPype Python project](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). From 1e0e56562faefd8bd7aef0a797c24dcd79598a4b Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:22:01 -0500 Subject: [PATCH 063/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 86ac2b8de3..863f6b7552 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our (still new) [py-tetrad Python project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). From cc5b1e4a88ed7b8de0f82765b1846e60a8329ed4 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:26:09 -0500 Subject: [PATCH 064/214] Update README.md --- README.md | 7 ------- 1 file changed, 7 deletions(-) diff --git a/README.md b/README.md index 863f6b7552..a97b31b86b 100644 --- a/README.md +++ b/README.md @@ -42,13 +42,6 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. -The project contains well-developed code in these packages: -* tetrad -* pitt -* tetradapp - -The tetrad-lib package contains the model code; the tetrad-gui package contains the view (GUI) code. - ## Bug/Issue Reports Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List From 42990d78dbbd3cd26331d52deacdad90f8a13ce3 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:41:50 -0500 Subject: [PATCH 065/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a97b31b86b..14bbecaf5f 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). You can run the Tetrad lifecycle package target and launch the "-launch" jar that is built in the target directory. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). ## Bug/Issue Reports From ebdddd755268013fb802a7a0174ff9f9ef5a2325 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:44:59 -0500 Subject: [PATCH 066/214] Update README.md --- README.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 14bbecaf5f..15b2338d33 100644 --- a/README.md +++ b/README.md @@ -8,12 +8,14 @@ Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. +# Java Install + +The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. + ## Tetrad GUI Application To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. - You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: ``` From ba7d5952534c6d6715089bf83a971f477e50567a Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:45:32 -0500 Subject: [PATCH 067/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 15b2338d33..17488613ab 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. -# Java Install +## Java Install The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. From 9b0e76625f61d0c4139caa83630488ba3affa017 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:45:51 -0500 Subject: [PATCH 068/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 17488613ab..1d0c0e0c7a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ All of our code is public and we welcome suggestions, expecially if you have awe ## Java Install -The application will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. ## Tetrad GUI Application From 5fa3a0d65a319f2cb4f0d14faf922d650cf6e3d8 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:46:34 -0500 Subject: [PATCH 069/214] Update README.md --- README.md | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 1d0c0e0c7a..97468a751d 100644 --- a/README.md +++ b/README.md @@ -8,10 +8,14 @@ Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt. All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. -## Java Install +## Install This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. + +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). + ## Tetrad GUI Application To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. @@ -38,12 +42,6 @@ Also, please see the [causal-learn Python package](https://causal-learn.readthed If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -## Install - -All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. - -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). - ## Bug/Issue Reports Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List From 7402b35fb03d708bba12d03188c23083ea768cc0 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:48:12 -0500 Subject: [PATCH 070/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 97468a751d..9126a22dbc 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ This software will work on all major platforms once a recent version of the Java All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA). +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA), if you are interested in Java coding. ## Tetrad GUI Application From f2461e488a08255175cbaa54fae43974125f171a Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:49:09 -0500 Subject: [PATCH 071/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9126a22dbc..4a6c566714 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,7 @@ Also, please see the [causal-learn Python package](https://causal-learn.readthed If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -## Bug/Issue Reports +## Bug Reports/Issue Requests Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List ](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List). From e75824cfdea82008afce022d7305daf76df1ffdf Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:49:55 -0500 Subject: [PATCH 072/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a6c566714..05c6595ec1 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the awesome [py-why space](https://github.com/py-why). +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## Documentation From cb2b74e160d1d9c8548a6427c1e4e26a823ee801 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:50:56 -0500 Subject: [PATCH 073/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 05c6595ec1..d7fdef7736 100644 --- a/README.md +++ b/README.md @@ -45,4 +45,4 @@ If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad ## Bug Reports/Issue Requests Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List -](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List). +](https://github.com/cmu-phil/tetrad/wiki/Current-Wish-List), which we revisit periodically. From 121a55acc6101ac91caa1031bacf916e1caa9a08 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:51:51 -0500 Subject: [PATCH 074/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d7fdef7736..65a5d5e811 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tetrad -The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Dietrich College Carnegie Mellon University web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). +The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Carnegie Mellon University, Dietrich College. web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 5ff62eaa8bb9a068ed3ddd523deba8dafc29601d Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:52:08 -0500 Subject: [PATCH 075/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 65a5d5e811..3693bf3b02 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tetrad -The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Carnegie Mellon University, Dietrich College. web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). +The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Carnegie Mellon University, Dietrich College, web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 9404482f641093ef2df396855d08cc64403e8b36 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:53:00 -0500 Subject: [PATCH 076/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3693bf3b02..4a148ccb8d 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ All of our code is public and we welcome suggestions, expecially if you have awe ## Install -This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well cross-platform. +This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well on all platforms. All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From e4ca1ab1322eed444326f5832914e18a5216cc9d Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:53:26 -0500 Subject: [PATCH 077/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4a148ccb8d..170735273a 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ All of our code is public and we welcome suggestions, expecially if you have awe ## Install -This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well on all platforms. +This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well and consistently on all platforms. All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. From d502b0257b0f231cef41a5628cf2c3c6511ea794 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 17:54:57 -0500 Subject: [PATCH 078/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 170735273a..aff018528e 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are som ## Tetrad GUI Application -To download the current jar you can use to launch the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. +To download the current jar for launching the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: From d0942166251e85cff9a0b77439c3b56f16d3430e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 18:25:57 -0500 Subject: [PATCH 079/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index aff018528e..0903c6180c 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Java code in the Tetrad project into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 5c17d1b2f1c2b7721b0e421aebc2cd88cb4cf96e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 18:27:06 -0500 Subject: [PATCH 080/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0903c6180c..444e9cbff6 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), translating some Tetrad algorithms into Python and adding some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## Documentation From aaae382905e3d6e76fb8a8ba25a007c85d8d5f45 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 18:27:51 -0500 Subject: [PATCH 081/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 444e9cbff6..0695b45ab1 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our (still new) [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From f380c4370a6f61195c1f4707be80bb1c88316d1d Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 18:42:29 -0500 Subject: [PATCH 082/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0695b45ab1..fef1cd618a 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -Also, please see the [causal-learn Python package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## Documentation From 287af0a16b29ee4b9b17a3e65fb378746dbd212b Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 18:43:09 -0500 Subject: [PATCH 083/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fef1cd618a..1b9fa60c90 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds some algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## Documentation From e69b6db4c736387c3cddba67f9b03401aa0389a1 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 19:04:53 -0500 Subject: [PATCH 084/214] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 1b9fa60c90..3455086c28 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,10 @@ For Python integration, please see our [py-tetrad project](https://github.com/cm Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +## Example Data + +We maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated. + ## Documentation If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). From fc50b265d2c5506c7ddd841c47f24ea87ca7d8be Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 19:07:29 -0500 Subject: [PATCH 085/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 3455086c28..ba4cbc3393 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## Example Data -We maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated. +We maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. ## Documentation From ad1b2eb167b38a117d91fc640b7a5f88785a1507 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sun, 5 Mar 2023 19:17:19 -0500 Subject: [PATCH 086/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ba4cbc3393..193fba8e82 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to easily integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 50a0e53e51d8ec0ad727b139058369acc324efb3 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:00:37 -0500 Subject: [PATCH 087/214] Update README.md --- README.md | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 193fba8e82..6eb8e26a2f 100644 --- a/README.md +++ b/README.md @@ -38,14 +38,12 @@ For Python integration, please see our [py-tetrad project](https://github.com/cm Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). -## Example Data - -We maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. - ## Documentation If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). +As an aside, in case you want to try some real data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. + ## Bug Reports/Issue Requests Please submit issue requests for Tetrad using our [Issue Tracker](https://github.com/cmu-phil/tetrad/issues). We will try to the extent possible to resolve all reported issues before [releasing new versions of Tetrad](https://github.com/cmu-phil/tetrad/releases). This may involve moving items to our [Wish List From b888a35e106c13fef2cf85a92d2a23cce1d09624 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:12:55 -0500 Subject: [PATCH 088/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6eb8e26a2f..78656694d0 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Tetrad -The purpose of Tetrad is to make algorithms available in Java to do causal inference. Here is the [Carnegie Mellon University, Dietrich College, web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). +The purpose of Tetrad is to make algorithms available for causal inference. Here is the [Carnegie Mellon University, Dietrich College, web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. From 37ef503f701dcdae38d4ef803547e3353819142f Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:30:54 -0500 Subject: [PATCH 089/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 78656694d0..0ce7c187c6 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to easily integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From b1f47c850ae35a1122f1405804cdf23bdde08a41 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:34:59 -0500 Subject: [PATCH 090/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0ce7c187c6..9470725ca1 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ Here is our [project web page](https://sites.google.com/view/tetradcausal) here Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -All of our code is public and we welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. +Our tools are freeware, and all of our code is public. We welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. ## Install From 510b7bfcc203919830d6333cd1a8cff3a5edd71e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:43:34 -0500 Subject: [PATCH 091/214] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 9470725ca1..60c6b3b919 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,8 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +You can also integrate Tetrad code into Python by making os.sys(..) calls to Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) (in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. + Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## Documentation From 8a31181358b93dd06b08bfb10de85228036e01ef Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:44:15 -0500 Subject: [PATCH 092/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 60c6b3b919..f9c39ccd1c 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -You can also integrate Tetrad code into Python by making os.sys(..) calls to Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) (in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) (in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 317a24748aa4c5481a44f520281f92d7d4d4c8c0 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:45:12 -0500 Subject: [PATCH 093/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f9c39ccd1c..3b3f92a220 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). -You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) (in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 9dfb95a20f7dfe1c2dd1f3ec95f9bedd43ba1953 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:47:00 -0500 Subject: [PATCH 094/214] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b3f92a220..0d6d853c56 100644 --- a/README.md +++ b/README.md @@ -34,9 +34,9 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). -You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 11b11278b22bd59c6105acde1eeb737f73cedada Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:49:39 -0500 Subject: [PATCH 095/214] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0d6d853c56..08d4409122 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,9 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -As an aside, in case you want to try some real data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. +## Example Data + +Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. ## Bug Reports/Issue Requests From 4b051acb2e25cd694691977f6de6ee57803fa354 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:51:16 -0500 Subject: [PATCH 096/214] Update README.md --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 08d4409122..985e68d439 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,10 @@ All artifacts are published in the [Maven Central Repository](https://s01.oss.so Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA), if you are interested in Java coding. +## Documentation + +If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). + ## Tetrad GUI Application To download the current jar for launching the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. @@ -40,10 +44,6 @@ You can also integrate Tetrad code into Python by making os.sys(..) calls to [Ca Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). -## Documentation - -If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). - ## Example Data Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. From e815c80d985d12592ee80e47084c8c6dd8ee0b46 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:52:28 -0500 Subject: [PATCH 097/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 985e68d439..d28f0597d5 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). -You can also integrate Tetrad code into Python by making os.sys(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.system(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 422d801848ecbaa6dea47d92f42152438ecc6dec Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:55:20 -0500 Subject: [PATCH 098/214] Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index d28f0597d5..e564b9fa26 100644 --- a/README.md +++ b/README.md @@ -44,6 +44,10 @@ You can also integrate Tetrad code into Python by making os.system(..) calls to Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +## R Integration + +We have an old project, [r-caussal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad. + ## Example Data Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. From 0f85c743cae313a529dbe092b167f36b8482e052 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:56:47 -0500 Subject: [PATCH 099/214] Update README.md --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index e564b9fa26..e6f5dc8ad1 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,8 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration -We have an old project, [r-caussal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad. +We have an old project, [r-caussal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. +'re ## Example Data From f08f8ab424849fa87fd712363ac5ecd4bcb6184a Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:57:06 -0500 Subject: [PATCH 100/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e6f5dc8ad1..abf250f979 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration -We have an old project, [r-caussal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. +We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. 're ## Example Data From 0b5abdf4c4fd22323cf510e605f0ce1c0bda6f1e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:57:43 -0500 Subject: [PATCH 101/214] Update README.md --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index abf250f979..56e74fbab8 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,6 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. -'re ## Example Data From b680cbcb51c76c44b758c02d994a64ec579322dc Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 09:59:02 -0500 Subject: [PATCH 102/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 56e74fbab8..bbcfe2dc4a 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). This replaces the old [py-causal](https://github.com/bd2kccd/py-causal) package. You can also integrate Tetrad code into Python by making os.system(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. From 8059f1d8c4d9b7c3c93efe6473bf52d6df673d39 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 10:00:42 -0500 Subject: [PATCH 103/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bbcfe2dc4a..c6f49819e0 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). This replaces the old [py-causal](https://github.com/bd2kccd/py-causal) package. -You can also integrate Tetrad code into Python by making os.system(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.system(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing from files the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From ca4509212af478d7276dbb7f919998862ec18dd8 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 15:31:21 -0500 Subject: [PATCH 104/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c6f49819e0..09bab51006 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). This replaces the old [py-causal](https://github.com/bd2kccd/py-causal) package. -You can also integrate Tetrad code into Python by making os.system(..) calls to [Causal Command](https://github.com/bd2kccd/causal-cmd) and parsing from files the results using tools in [causal-learn](https://github.com/py-why/causal-learn). Here are some [now-outdated examples](https://github.com/cmu-phil/algocompy/blob/main/causalcmd/tetrad_cmd_algs.py) of how to do this, which we will soon update. +You can also integrate Tetrad code into Python by making os.system(..) calls; here are some [examples](https://github.com/cmu-phil/algocompy/blob/main/old/causalcmd/tetrad_cmd_algs.py) of how to do it. Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 9b13a671a3b42f11093c5200e83386636b1dc599 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 15:32:18 -0500 Subject: [PATCH 105/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 09bab51006..f995f0d087 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). This allows for integration with [causal-learn](https://github.com/py-why/causal-learn) in the [py-why space](https://github.com/py-why). This replaces the old [py-causal](https://github.com/bd2kccd/py-causal) package. +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). You can also integrate Tetrad code into Python by making os.system(..) calls; here are some [examples](https://github.com/cmu-phil/algocompy/blob/main/old/causalcmd/tetrad_cmd_algs.py) of how to do it. From 18fd0060b91b14b84d2d660a668579633161de35 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 17:03:30 -0500 Subject: [PATCH 106/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f995f0d087..9e1e6f1d37 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which i ## Example Data -Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. This has been formatted in a uniform way to help avoid problems with preprocessing. +Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. These has been formatted in a uniform way to help avoid problems with preprocessing. ## Bug Reports/Issue Requests From 32962e895d78220db66cc07985e956f926826a5e Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Mon, 6 Mar 2023 17:03:43 -0500 Subject: [PATCH 107/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9e1e6f1d37..80bd027e4e 100644 --- a/README.md +++ b/README.md @@ -50,7 +50,7 @@ We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which i ## Example Data -Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. These has been formatted in a uniform way to help avoid problems with preprocessing. +Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. These have been formatted in a uniform way to help avoid problems with preprocessing. ## Bug Reports/Issue Requests From a60c4509a59e3a3d170ee74d1592e26198318da1 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Wed, 8 Mar 2023 11:14:11 -0500 Subject: [PATCH 108/214] Update README.md --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 80bd027e4e..b30832f73c 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/). - -You can also integrate Tetrad code into Python by making os.system(..) calls; here are some [examples](https://github.com/cmu-phil/algocompy/blob/main/old/causalcmd/tetrad_cmd_algs.py) of how to do it. +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/) or [Causal Command](https://github.com/bd2kccd/causal-cmd). Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). From 9acc7155034b6873223670f484151e512344c4bc Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 9 Mar 2023 09:09:47 -0500 Subject: [PATCH 109/214] Added Lee Hastie simulation --- .../java/edu/cmu/tetrad/test/TestGrasp.java | 74 ++++++++++++++++++- 1 file changed, 70 insertions(+), 4 deletions(-) diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java index e2f3d5cb4c..854b84ebf9 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java @@ -39,14 +39,13 @@ import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper; import edu.cmu.tetrad.algcomparison.score.DSeparationScore; import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; -import edu.cmu.tetrad.algcomparison.simulation.SemSimulation; -import edu.cmu.tetrad.algcomparison.simulation.Simulation; -import edu.cmu.tetrad.algcomparison.simulation.Simulations; +import edu.cmu.tetrad.algcomparison.simulation.*; import edu.cmu.tetrad.algcomparison.statistic.*; import edu.cmu.tetrad.bayes.BayesIm; import edu.cmu.tetrad.bayes.BayesPm; import edu.cmu.tetrad.bayes.MlBayesIm; import edu.cmu.tetrad.data.ContinuousVariable; +import edu.cmu.tetrad.data.DataModel; import edu.cmu.tetrad.data.DataSet; import edu.cmu.tetrad.data.IndependenceFacts; import edu.cmu.tetrad.graph.*; @@ -86,9 +85,76 @@ public static void main(String[] args) { // new TestGrasp().wayneCheckDensityClaim2(); // new TestGrasp().bryanCheckDensityClaims(); - new TestGrasp().testLvSwap(); +// new TestGrasp().testLvSwap(); // new TestGrasp().testLvSwapFromDsep(); // new TestGrasp().testDsep(); + + new TestGrasp().testCgScore(); + + } + + private void testExampleBnSim() { + + Parameters params = new Parameters(); + + params.set(Params.NUM_MEASURES, 20); + params.set(Params.NUM_LATENTS, 0); + params.set(Params.AVG_DEGREE, 6); + + params.set(Params.MIN_CATEGORIES, 3); + params.set(Params.MAX_CATEGORIES, 3); + + params.set(Params.RANDOMIZE_COLUMNS, true); + params.set(Params.SAMPLE_SIZE, 500); + params.set(Params.SAVE_LATENT_VARS, false); + params.set(Params.SEED, 29493L); + + params.set(Params.NUM_RUNS, 1); + + BayesNetSimulation sim_ = new BayesNetSimulation(new RandomForward()); + sim_.createData(params, true); + DataModel data_model = sim_.getDataModel(0); + Graph graph = sim_.getTrueGraph(0); + + } + + private void testCgScore() { + + Parameters params = new Parameters(); + + params.set(Params.NUM_MEASURES, 20); + params.set(Params.NUM_LATENTS, 0); + params.set(Params.AVG_DEGREE, 6); + + params.set(Params.MIN_CATEGORIES, 3); + params.set(Params.MAX_CATEGORIES, 3); + params.set(Params.PERCENT_DISCRETE, 50); + params.set(Params.DIFFERENT_GRAPHS, false); + + params.set(Params.RANDOMIZE_COLUMNS, true); + params.set(Params.SAMPLE_SIZE, 500); + params.set(Params.SAVE_LATENT_VARS, false); + params.set(Params.SEED, 29493L); + + params.set(Params.NUM_RUNS, 1); + + LeeHastieSimulation sim_ = new LeeHastieSimulation(new RandomForward()); + sim_.createData(params, true); + DataModel data_model = sim_.getDataModel(0); + Graph graph = sim_.getTrueGraph(0); + + double penaltyDiscount = 2.0; + double structurePrior = 3.0; + boolean discretize = true; + + ConditionalGaussianScore score = new ConditionalGaussianScore((DataSet) data_model, penaltyDiscount, + structurePrior, discretize); + + Fges alg = new Fges(score); + Graph pat = alg.search(); + + System.out.println(pat); + } @NotNull From 4b55e4e825d8f14bb62cfcb65605d6492bad72bb Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 9 Mar 2023 11:02:56 -0500 Subject: [PATCH 110/214] Added Lee Hastie simulation --- .../main/java/edu/cmu/tetrad/util/RandomUtil.java | 2 +- .../test/java/edu/cmu/tetrad/test/TestGrasp.java | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/RandomUtil.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/RandomUtil.java index 4db4d22cef..85f18c3e5c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/RandomUtil.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/RandomUtil.java @@ -66,7 +66,7 @@ private RandomUtil() { */ public static RandomUtil getInstance() { if (!randomUtils.containsKey(Thread.currentThread())) { - System.out.println("new thread"); +// System.out.println("new thread"); randomUtils.put(Thread.currentThread(), new RandomUtil()); } return randomUtils.get(Thread.currentThread()); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java index 854b84ebf9..96229c6664 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java @@ -150,10 +150,22 @@ private void testCgScore() { ConditionalGaussianScore score = new ConditionalGaussianScore((DataSet) data_model, penaltyDiscount, structurePrior, discretize); + IndependenceTest test = new IndTestConditionalGaussianLRT((DataSet) data_model, 0.05, true); + + Fges alg = new Fges(score); Graph pat = alg.search(); - System.out.println(pat); + System.out.println("FGES" + pat); + + + Grasp boss = new Grasp(test, score); + boss.setUseDataOrder(false); + boss.setNumStarts(1); + boss.bestOrder(test.getVariables()); + Graph pat2 = boss.getGraph(true); + + System.out.println("BOSS" + pat2); } From b28217bd3e0c866154809781f548d1bbbb80df60 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 9 Mar 2023 13:49:33 -0500 Subject: [PATCH 111/214] In CG score, move structure prior out of the constructor. --- .../edu/cmu/tetradapp/model/FgesRunner.java | 3 +- .../score/ConditionalGaussianBicScore.java | 2 +- .../search/ConditionalGaussianLikelihood.java | 3 +- .../search/ConditionalGaussianScore.java | 11 ++++--- .../java/edu/cmu/tetrad/search/Cstar.java | 4 +-- .../java/edu/cmu/tetrad/search/GraspFci.java | 6 +++- .../search/IndTestConditionalGaussianLRT.java | 29 +++++++++++------- .../main/java/edu/cmu/tetrad/search/Pc.java | 6 ++-- .../java/edu/cmu/tetrad/test/TestFges.java | 3 +- .../java/edu/cmu/tetrad/test/TestGrasp.java | 30 +++++++++++++------ 10 files changed, 63 insertions(+), 34 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/FgesRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/FgesRunner.java index a6b4c2e2bf..acfe3b4e9d 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/FgesRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/FgesRunner.java @@ -143,8 +143,9 @@ public void execute() { score.setStructurePrior(structurePrior); this.fges = new Fges(score); } else { - ConditionalGaussianScore gesScore = new ConditionalGaussianScore(dataSet, 1, 1, false); + ConditionalGaussianScore gesScore = new ConditionalGaussianScore(dataSet, 1, false); gesScore.setPenaltyDiscount(penaltyDiscount); + gesScore.setStructurePrior(1); this.fges = new Fges(gesScore); } } else if (model instanceof ICovarianceMatrix) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/ConditionalGaussianBicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/ConditionalGaussianBicScore.java index 04e6fc56a2..84b5487bbc 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/ConditionalGaussianBicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/ConditionalGaussianBicScore.java @@ -35,9 +35,9 @@ public Score getScore(DataModel dataSet, Parameters parameters) { ConditionalGaussianScore conditionalGaussianScore = new ConditionalGaussianScore(SimpleDataLoader.getMixedDataSet(dataSet), parameters.getDouble("penaltyDiscount"), - parameters.getDouble("structurePrior"), parameters.getBoolean("discretize")); conditionalGaussianScore.setNumCategoriesToDiscretize(parameters.getInt("numCategoriesToDiscretize")); + conditionalGaussianScore.setStructurePrior(parameters.getDouble("structurePrior")); return conditionalGaussianScore; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianLikelihood.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianLikelihood.java index db0aa82cab..3dbbecda45 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianLikelihood.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianLikelihood.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentSkipListMap; import static edu.cmu.tetrad.data.Discretizer.discretize; import static edu.cmu.tetrad.data.Discretizer.getEqualFrequencyBreakPoints; @@ -133,7 +134,7 @@ public ConditionalGaussianLikelihood(DataSet dataSet) { } } - this.nodesHash = new HashMap<>(); + this.nodesHash = new ConcurrentSkipListMap<>(); for (int j = 0; j < dataSet.getNumColumns(); j++) { Node v = dataSet.getVariable(j); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianScore.java index 2c42503efc..1c81b1a1db 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/ConditionalGaussianScore.java @@ -41,7 +41,7 @@ public class ConditionalGaussianScore implements Score { private final DataSet dataSet; - // The variables of the continuousData set. + // The variables of the dataset. private final List variables; // Likelihood function @@ -49,12 +49,12 @@ public class ConditionalGaussianScore implements Score { private double penaltyDiscount; private int numCategoriesToDiscretize = 3; - private final double structurePrior; + private double structurePrior = 0; /** * Constructs the score using a covariance matrix. */ - public ConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, double structurePrior, boolean discretize) { + public ConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, boolean discretize) { if (dataSet == null) { throw new NullPointerException(); } @@ -62,7 +62,6 @@ public ConditionalGaussianScore(DataSet dataSet, double penaltyDiscount, double this.dataSet = dataSet; this.variables = dataSet.getVariables(); this.penaltyDiscount = penaltyDiscount; - this.structurePrior = structurePrior; this.likelihood = new ConditionalGaussianLikelihood(dataSet); @@ -210,6 +209,10 @@ public String toString() { NumberFormat nf = new DecimalFormat("0.00"); return "Conditional Gaussian Score Penalty " + nf.format(this.penaltyDiscount); } + + public void setStructurePrior(double structurePrior) { + this.structurePrior = structurePrior; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cstar.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cstar.java index dd257f73ea..8807ba8133 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cstar.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cstar.java @@ -631,8 +631,8 @@ private IndependenceTest getIndependenceTest(DataSet sample, IndependenceTest te } else if (test instanceof IndTestScore && ((IndTestScore) test).getWrappedScore() instanceof ConditionalGaussianScore) { ConditionalGaussianScore score = (ConditionalGaussianScore) ((IndTestScore) test).getWrappedScore(); double penaltyDiscount = score.getPenaltyDiscount(); - ConditionalGaussianScore _score = new ConditionalGaussianScore(sample, 1, 0, false); - _score.setPenaltyDiscount(penaltyDiscount); + ConditionalGaussianScore _score = new ConditionalGaussianScore(sample, penaltyDiscount, false); + _score.setStructurePrior(0); return new IndTestScore(_score); } else { throw new IllegalArgumentException("That test is not configured: " + test); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GraspFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GraspFci.java index 35d625153b..70dfc5c798 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GraspFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GraspFci.java @@ -106,12 +106,16 @@ public GraspFci(IndependenceTest test, Score score) { public Graph search() { List nodes = getIndependenceTest().getVariables(); + if (nodes == null) { + throw new NullPointerException("Nodes from test were null."); + } + this.logger.log("info", "Starting FCI algorithm."); this.logger.log("info", "Independence test = " + getIndependenceTest() + "."); this.graph = new EdgeListGraph(nodes); - TeyssierScorer scorer = new TeyssierScorer(independenceTest, score); +// TeyssierScorer scorer = new TeyssierScorer(independenceTest, score); // Run BOSS-tuck to get a CPDAG (like GFCI with FGES)... Grasp alg = new Grasp(independenceTest, score); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java index d59479153d..4aa01b1edc 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java @@ -29,7 +29,6 @@ import edu.cmu.tetrad.graph.Node; import edu.cmu.tetrad.util.Matrix; import edu.cmu.tetrad.util.TetradLogger; -import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.math3.distribution.ChiSquaredDistribution; import java.text.DecimalFormat; @@ -37,6 +36,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; /** * Performs a test of conditional independence X _||_ Y | Z1...Zn where all searchVariables are either continuous or discrete. @@ -48,7 +48,7 @@ */ public class IndTestConditionalGaussianLRT implements IndependenceTest { private final DataSet data; - private final Map nodesHash; + private final Map nodesHash; private double alpha; // Likelihood function @@ -59,15 +59,17 @@ public class IndTestConditionalGaussianLRT implements IndependenceTest { private int numCategoriesToDiscretize = 3; public IndTestConditionalGaussianLRT(DataSet data, double alpha, boolean discretize) { + if (data == null) throw new NullPointerException("Data is null."); + this.data = data; this.likelihood = new ConditionalGaussianLikelihood(data); this.likelihood.setDiscretize(discretize); - this.nodesHash = new HashedMap<>(); + this.nodesHash = new ConcurrentHashMap<>(); List variables = data.getVariables(); for (int i = 0; i < variables.size(); i++) { - this.nodesHash.put(variables.get(i), i); + this.nodesHash.put(variables.get(i).getName(), i); } this.alpha = alpha; @@ -94,8 +96,8 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { this.likelihood.setRows(getRows(allVars, this.nodesHash)); - int _x = this.nodesHash.get(x); - int _y = this.nodesHash.get(y); + int _x = getVariable(x); + int _y = getVariable(y); int[] list0 = new int[z.size() + 1]; int[] list2 = new int[z.size()]; @@ -103,7 +105,7 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { list0[0] = _x; for (int i = 0; i < z.size(); i++) { - int _z = this.nodesHash.get(z.get(i)); + int _z = getVariable(z.get(i)); list0[i + 1] = _z; list2[i] = _z; } @@ -117,7 +119,8 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { if (dof0 <= 0) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); if (this.alpha == 0) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); if (this.alpha == 1) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); - if (lik0 == Double.POSITIVE_INFINITY) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); + if (lik0 == Double.POSITIVE_INFINITY) + return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); double pValue; @@ -141,16 +144,20 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { return new IndependenceResult(new IndependenceFact(x, y, z), independent, pValue); } - private List getRows(List allVars, Map nodesHash) { + private Integer getVariable(Node x) { + return this.nodesHash.get(x.getName()); + } + + private List getRows(List allVars, Map nodesHash) { List rows = new ArrayList<>(); K: for (int k = 0; k < this.data.getNumRows(); k++) { for (Node node : allVars) { if (node instanceof ContinuousVariable) { - if (Double.isNaN(this.data.getDouble(k, nodesHash.get(node)))) continue K; + if (Double.isNaN(this.data.getDouble(k, nodesHash.get(node.getName())))) continue K; } else if (node instanceof DiscreteVariable) { - if (this.data.getInt(k, nodesHash.get(node)) == -99) continue K; + if (this.data.getInt(k, nodesHash.get(node.getName())) == -99) continue K; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java index 571858c3d9..b3cf14706b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java @@ -100,7 +100,7 @@ public class Pc implements GraphSearch { */ public Pc(IndependenceTest independenceTest) { if (independenceTest == null) { - throw new NullPointerException(); + throw new NullPointerException("Independence test is null."); } this.independenceTest = independenceTest; @@ -141,7 +141,7 @@ public Knowledge getKnowledge() { */ public void setKnowledge(Knowledge knowledge) { if (knowledge == null) { - throw new NullPointerException(); + throw new NullPointerException("Knowledge is null."); } this.knowledge = knowledge; @@ -222,7 +222,7 @@ public Graph search(IFas fas, List nodes) { long startTime = MillisecondTimes.timeMillis(); if (getIndependenceTest() == null) { - throw new NullPointerException(); + throw new NullPointerException("Null independence test."); } List allNodes = getIndependenceTest().getVariables(); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestFges.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestFges.java index a597ba48b5..aad940e671 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestFges.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestFges.java @@ -897,8 +897,9 @@ private Graph searchBdeuFges(DataSet Dk, int k) { } private Graph searchMixedFges(DataSet dk) { - ConditionalGaussianScore score = new ConditionalGaussianScore(dk, 2.0, 0.0, true); + ConditionalGaussianScore score = new ConditionalGaussianScore(dk, 2.0, true); score.setPenaltyDiscount(2.0); + score.setStructurePrior(0.0); Fges fges = new Fges(score); return fges.search(); } diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java index 96229c6664..03827bbfbd 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java @@ -34,9 +34,11 @@ import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.LVSWAP_2a; import edu.cmu.tetrad.algcomparison.graph.RandomForward; import edu.cmu.tetrad.algcomparison.graph.SingleGraph; +import edu.cmu.tetrad.algcomparison.independence.ConditionalGaussianLRT; import edu.cmu.tetrad.algcomparison.independence.DSeparationTest; import edu.cmu.tetrad.algcomparison.independence.FisherZ; import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper; +import edu.cmu.tetrad.algcomparison.score.ConditionalGaussianBicScore; import edu.cmu.tetrad.algcomparison.score.DSeparationScore; import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; import edu.cmu.tetrad.algcomparison.simulation.*; @@ -140,17 +142,18 @@ private void testCgScore() { LeeHastieSimulation sim_ = new LeeHastieSimulation(new RandomForward()); sim_.createData(params, true); - DataModel data_model = sim_.getDataModel(0); + DataSet data = (DataSet) sim_.getDataModel(0); Graph graph = sim_.getTrueGraph(0); double penaltyDiscount = 2.0; - double structurePrior = 3.0; + double structurePrior = 1.0; boolean discretize = true; - ConditionalGaussianScore score = new ConditionalGaussianScore((DataSet) data_model, penaltyDiscount, - structurePrior, discretize); + ConditionalGaussianScore score = new ConditionalGaussianScore((DataSet) data, penaltyDiscount, discretize); + score.setStructurePrior(structurePrior); + score.setNumCategoriesToDiscretize(3); - IndependenceTest test = new IndTestConditionalGaussianLRT((DataSet) data_model, 0.05, true); + IndTestConditionalGaussianLRT test = new IndTestConditionalGaussianLRT((DataSet) data, 0.05, true); Fges alg = new Fges(score); @@ -158,14 +161,23 @@ private void testCgScore() { System.out.println("FGES" + pat); + Pc pc = new Pc(test); + Graph pat2 = alg.search(); + + System.out.println("PC" + pat2); + + Parameters parameters = new Parameters(); + +// GRaSP grasp = new GRaSP(new ConditionalGaussianBicScore(), new ConditionalGaussianLRT()); +// Graph pat3 = grasp.search(data, parameters); Grasp boss = new Grasp(test, score); - boss.setUseDataOrder(false); + boss.setUseDataOrder(true); boss.setNumStarts(1); - boss.bestOrder(test.getVariables()); - Graph pat2 = boss.getGraph(true); + boss.bestOrder(score.getVariables()); + Graph pat3 = boss.getGraph(true); - System.out.println("BOSS" + pat2); + System.out.println("GRaSP" + pat3); } From 4c7d6602e954e6210944258c211cd3971613eb9b Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 9 Mar 2023 14:48:39 -0500 Subject: [PATCH 112/214] Fixed structure prior 0 case for BDeu. --- .../src/main/java/edu/cmu/tetrad/search/BDeuScore.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BDeuScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BDeuScore.java index 8fa5df2ece..24760fcdfe 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BDeuScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BDeuScore.java @@ -171,8 +171,11 @@ public double localScore(int node, int[] parents) { private double getPriorForStructure(int numParents, int N) { double e = getStructurePrior(); - int vm = N - 1; - return numParents * FastMath.log(e / (vm)) + (vm - numParents) * FastMath.log(1.0 - (e / (vm))); + if (e == 0) return 0.0; + else { + int vm = N - 1; + return numParents * FastMath.log(e / (vm)) + (vm - numParents) * FastMath.log(1.0 - (e / (vm))); + } } @Override From a5e68487c60fa93d50d4966350ca405fd52baf7c Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 9 Mar 2023 14:50:29 -0500 Subject: [PATCH 113/214] Fixed structure prior 0 case for BDeu. --- tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java | 1 + 1 file changed, 1 insertion(+) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java index 5e90e9010f..9c582abba8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java @@ -169,6 +169,7 @@ public double localScore(int node, int[] parents) { private double getPriorForStructure(int numParents) { double e = getStructurePrior(); + if (e == 0) return 0.0; int vm = this.data.length - 1; return numParents * FastMath.log(e / (vm)) + (vm - numParents) * FastMath.log(1.0 - (e / (vm))); } From 63b8bb35ec3de1f1736118bf2c59e4987e50e235 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Thu, 9 Mar 2023 15:17:03 -0500 Subject: [PATCH 114/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b30832f73c..34dc4f8f59 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration -We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. +We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. There are some comments [here](https://github.com/cmu-phil/py-tetrad/issues) toward a solution. ## Example Data From e3632ff96f19dcdc47012fb023bbcd85afed74ad Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Thu, 9 Mar 2023 15:40:24 -0500 Subject: [PATCH 115/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 34dc4f8f59..22b8be2c1d 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration -We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. There are some comments [here](https://github.com/cmu-phil/py-tetrad/issues) toward a solution. +We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. There are some comments [here](https://github.com/cmu-phil/py-tetrad/issues/1) toward a solution. ## Example Data From 54de93627e9beadaadbc57709ab20319d73d3150 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 10 Mar 2023 10:36:21 -0500 Subject: [PATCH 116/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 22b8be2c1d..b30832f73c 100644 --- a/README.md +++ b/README.md @@ -44,7 +44,7 @@ Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/ ## R Integration -We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. There are some comments [here](https://github.com/cmu-phil/py-tetrad/issues/1) toward a solution. +We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. ## Example Data From 6d9f1d766c59622e7e801018c044c0f6d4acafde Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 10 Mar 2023 13:37:18 -0500 Subject: [PATCH 117/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b30832f73c..f29c477ae1 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Our tools are freeware, and all of our code is public. We welcome suggestions, e This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well and consistently on all platforms. -All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). This includes all downloadable jars and Javadocs. +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). Here are teh [Javadocs for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA), if you are interested in Java coding. From ce43f24120822dc376d652f0a71a1414578675e9 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 10 Mar 2023 13:38:38 -0500 Subject: [PATCH 118/214] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f29c477ae1..f8d7cb2ff9 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ Our tools are freeware, and all of our code is public. We welcome suggestions, e This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well and consistently on all platforms. -All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). Here are teh [Javadocs for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). +All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA), if you are interested in Java coding. @@ -20,6 +20,8 @@ Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are som If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). +Here are the [Javadocs for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). + ## Tetrad GUI Application To download the current jar for launching the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. From 7a59e6ab825192840ffaef108041f401b85a54a5 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 10 Mar 2023 13:39:32 -0500 Subject: [PATCH 119/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f8d7cb2ff9..26670125c6 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are som If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -Here are the [Javadocs for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). +Here are the [Javadocs (that is, API docs) for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). ## Tetrad GUI Application From 96928c97d2a6a2e0b0e190d60956c5dee952b916 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Fri, 10 Mar 2023 14:04:42 -0500 Subject: [PATCH 120/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 26670125c6..50e5866882 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are som If you're new to Tetrad, here is a [Tutorial](https://rawgit.com/cmu-phil/tetrad/development/tetrad-gui/src/main/resources/resources/javahelp/manual/tetrad_tutorial.html). Also, here is our [Manual](https://htmlpreview.github.io/?https:///github.com/cmu-phil/tetrad/blob/development/docs/manual/index.html). If you like to watch thought-provoking lectures, here are some [lectures on the Center for Causal Discovery site](https://www.ccd.pitt.edu/video-tutorials/). -Here are the [Javadocs (that is, API docs) for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/). +Here are the [Javadocs (that is, API docs) for Tetrad](https://www.phil.cmu.edu/tetrad-javadocs/7.2.2/lib). ## Tetrad GUI Application From de34c862f9b589f07f9fa4b1ad60b307dc269994 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sat, 11 Mar 2023 00:15:35 -0500 Subject: [PATCH 121/214] Update README.md --- README.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 50e5866882..ffbdef738d 100644 --- a/README.md +++ b/README.md @@ -2,19 +2,19 @@ The purpose of Tetrad is to make algorithms available for causal inference. Here is the [Carnegie Mellon University, Dietrich College, web page for Tetrad](https://www.cmu.edu/dietrich/news/news-stories/2020/august/tetrad-sail.html). Here is the [Simon Initiative page for Tetrad](https://www.cmu.edu/simon/open-simon/toolkit/tools/learning-tools/tetrad.html). -Here is our [project web page](https://sites.google.com/view/tetradcausal) here with current links for artifacts, a list of contributors, and a bit of history. +Here is our [project web page](https://sites.google.com/view/tetradcausal) with current links for artifacts, a list of contributors, and some history. Here is the web page for the [Center for Causal Discovery](https://www.ccd.pitt.edu/), which also supports the latest version of Tetrad and Causal Command. -Our tools are freeware, and all of our code is public. We welcome suggestions, expecially if you have awesome algorithms that outperform ours or know how to improve performance of our algorithms. +Our tools are freeware, and all of our code is public. We welcome suggestions, especially if you have awesome algorithms that outperform ours or know how to improve the performance of our algorithms. ## Install -This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long term support (LTS) works well and consistently on all platforms. +This software will work on all major platforms once a recent version of the Java JRE/JCK is installed, certainly **_greater than version 1.8 (version 8)_**. We find that the most recent [Corretto JRE/JDK](https://aws.amazon.com/corretto/?filtered-posts.sort-by=item.additionalFields.createdDate&filtered-posts.sort-order=desc) with long-term support (LTS) works well and consistently on all platforms. All artifacts are published in the [Maven Central Repository](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/). -Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on how to set this project up in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA), if you are interested in Java coding. +Here is our [GitHub URL](https://github.com/cmu-phil/tetrad). Also, here are some [instructions on setting up this project in IntelliJ IDEA](https://github.com/cmu-phil/tetrad/wiki/Setting-up-Tetrad-in-IntelliJ-IDEA) if you are interested in Java coding. ## Documentation @@ -26,7 +26,7 @@ Here are the [Javadocs (that is, API docs) for Tetrad](https://www.phil.cmu.edu/ To download the current jar for launching the Tetrad GUI, click [here](https://s01.oss.sonatype.org/content/repositories/releases/io/github/cmu-phil/tetrad-gui/7.2.2/tetrad-gui-7.2.2-launch.jar). Please delete any old ones you're not using. -You may be able to launch this jar by double clicking the jar file name, though on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: +You may be able to launch this jar by double-clicking the jar file name. However, on a Mac, this presents some [security challenges](https://github.com/cmu-phil/tetrad/wiki/Dealing-with-Tetrad-on-a-Mac:--Security-Issues). In any case, on all platforms, the jar may be launched at the command line (with a specification of the amount of RAM you will allow it to use) using this command: ``` java -Xmx[g]G -jar *-launch.jar @@ -42,15 +42,15 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/) or [Causal Command](https://github.com/bd2kccd/causal-cmd). -Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms not in Tetrad, now part of the [py-why space](https://github.com/py-why). +Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms, not in Tetrad, now part of the [py-why space](https://github.com/py-why). ## R Integration -We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will make an effort to provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. +We have an old project, [r-causal](https://github.com/bd2kccd/r-causal), which integrates R with an old version of Tetrad. We will provide updated advice for doing this with a more recent version of Tetrad, as we've done with Python. ## Example Data -Tetrad has robust facilities for simulating data, but if you'd like to try your hand at real data, or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both real and simulated, with ground truth where known or strongly suggested. These have been formatted in a uniform way to help avoid problems with preprocessing. +Tetrad has robust facilities for simulating data, but if you'd like to try your hand at actual or realistically simulated data, we maintain a [repository of example datasets](https://github.com/cmu-phil/example-causal-datasets), both actual and simulated, with ground truth where known or strongly suggested. These have been formatted uniformly to help avoid problems with preprocessing. ## Bug Reports/Issue Requests From 4d3c7c709a1cd5b196763b02c26e93eb2c155345 Mon Sep 17 00:00:00 2001 From: Joseph Ramsey Date: Sat, 11 Mar 2023 07:52:48 -0500 Subject: [PATCH 122/214] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ffbdef738d..01aea04f34 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ We have a tool, [Causal Command](https://github.com/bd2kccd/causal-cmd), that le ## Python Integration -For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary Tetrad code into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/) or [Causal Command](https://github.com/bd2kccd/causal-cmd). +For Python integration, please see our [py-tetrad project](https://github.com/cmu-phil/py-tetrad), which shows how to integrate arbitrary (Java) Tetrad code easily into a Python workflow using [JPype](https://jpype.readthedocs.io/en/latest/) or [Causal Command](https://github.com/bd2kccd/causal-cmd). Also, please see the [causal-learn package](https://causal-learn.readthedocs.io/en/latest/), which translates some Tetrad algorithms into Python and adds several algorithms, not in Tetrad, now part of the [py-why space](https://github.com/py-why). From fec7ef821b2e139910bae9f04d715fcf71e06497 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sat, 11 Mar 2023 12:30:19 -0500 Subject: [PATCH 123/214] Consolidated two versions of PC to use the better one. --- pom.xml | 2 +- .../algorithm/oracle/cpdag/PC.java | 95 ++++++++++-------- .../examples/ExampleCompareSimulation.java | 6 +- .../independence/DiscreteBicTest.java | 4 +- .../algcomparison/score/DiscreteBicScore.java | 4 +- .../{BicScore.java => DiscreteBicScore.java} | 6 +- .../main/java/edu/cmu/tetrad/search/Pc.java | 97 ++++++++++++------- ...r.java => TestBayesDiscreteBicScorer.java} | 2 +- .../test/java/edu/cmu/tetrad/test/TestPc.java | 2 +- .../edu/cmu/tetrad/test/TestPcStableMax.java | 2 +- 10 files changed, 126 insertions(+), 94 deletions(-) rename tetrad-lib/src/main/java/edu/cmu/tetrad/search/{BicScore.java => DiscreteBicScore.java} (97%) rename tetrad-lib/src/test/java/edu/cmu/tetrad/test/{TestBayesBicScorer.java => TestBayesDiscreteBicScorer.java} (98%) diff --git a/pom.xml b/pom.xml index 7644639ba3..afb93c9904 100644 --- a/pom.xml +++ b/pom.xml @@ -137,7 +137,7 @@ org.apache.velocity velocity - 1.5 + 1.7 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 c8e5a8def9..39dc54d1ec 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 @@ -12,6 +12,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; +import edu.cmu.tetrad.search.Pc; import edu.cmu.tetrad.search.PcAll; import edu.cmu.tetrad.search.SearchGraphUtils; import edu.cmu.tetrad.search.TimeSeriesUtils; @@ -61,51 +62,59 @@ public Graph search(DataModel dataModel, Parameters parameters) { knowledge = timeSeries.getKnowledge(); } - final PcAll.ColliderDiscovery colliderDiscovery - = PcAll.ColliderDiscovery.FAS_SEPSETS; - - PcAll.ConflictRule conflictRule; - - switch (parameters.getInt(Params.CONFLICT_RULE)) { - case 1: - conflictRule = PcAll.ConflictRule.OVERWRITE; - break; - case 2: - conflictRule = PcAll.ConflictRule.BIDIRECTED; - break; - case 3: - conflictRule = PcAll.ConflictRule.PRIORITY; - break; - default: - throw new IllegalArgumentException("Not a choice."); - } - - edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(this.test.getTest(dataModel, parameters)); + Pc search = new Pc(getIndependenceWrapper().getTest(dataModel, parameters)); search.setDepth(parameters.getInt(Params.DEPTH)); - search.setHeuristic(parameters.getInt(Params.FAS_HEURISTIC)); - search.setKnowledge(this.knowledge); - - if (parameters.getBoolean(Params.STABLE_FAS)) { - search.setFasType(PcAll.FasType.STABLE); - } else { - search.setFasType(PcAll.FasType.REGULAR); - } - - if (parameters.getBoolean(Params.CONCURRENT_FAS)) { - search.setConcurrent(PcAll.Concurrent.YES); - } else { - search.setConcurrent(PcAll.Concurrent.NO); - } - - search.setColliderDiscovery(colliderDiscovery); - search.setConflictRule(conflictRule); - search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); - search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); - search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); - search.setExternalGraph(externalGraph); + search.setAggressivelyPreventCycles(true); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); - + search.setConcurrent(parameters.getBoolean(Params.CONCURRENT_FAS)); + search.setUseMaxP(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); + search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); return search.search(); + +// final PcAll.ColliderDiscovery colliderDiscovery +// = PcAll.ColliderDiscovery.FAS_SEPSETS; +// +// PcAll.ConflictRule conflictRule; +// +// switch (parameters.getInt(Params.CONFLICT_RULE)) { +// case 1: +// conflictRule = PcAll.ConflictRule.OVERWRITE; +// break; +// case 2: +// conflictRule = PcAll.ConflictRule.BIDIRECTED; +// break; +// case 3: +// conflictRule = PcAll.ConflictRule.PRIORITY; +// break; +// default: +// throw new IllegalArgumentException("Not a choice."); +// } +// +// edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(this.test.getTest(dataModel, parameters)); +// search.setDepth(parameters.getInt(Params.DEPTH)); +// search.setHeuristic(parameters.getInt(Params.FAS_HEURISTIC)); +// search.setKnowledge(this.knowledge); +// +// if (parameters.getBoolean(Params.STABLE_FAS)) { +// search.setFasType(PcAll.FasType.STABLE); +// } else { +// search.setFasType(PcAll.FasType.REGULAR); +// } +// +// if (parameters.getBoolean(Params.CONCURRENT_FAS)) { +// search.setConcurrent(PcAll.Concurrent.YES); +// } else { +// search.setConcurrent(PcAll.Concurrent.NO); +// } +// +// search.setColliderDiscovery(colliderDiscovery); +// search.setConflictRule(conflictRule); +// search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); +// search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); +// search.setExternalGraph(externalGraph); +// search.setVerbose(parameters.getBoolean(Params.VERBOSE)); +// +// return search.search(); } else { PC pcAll = new PC(this.test); @@ -142,7 +151,7 @@ public List getParameters() { // parameters.add(Params.COLLIDER_DISCOVERY_RULE); parameters.add(Params.CONFLICT_RULE); parameters.add(Params.DEPTH); - parameters.add(Params.FAS_HEURISTIC); +// parameters.add(Params.FAS_HEURISTIC); parameters.add(Params.USE_MAX_P_ORIENTATION_HEURISTIC); parameters.add(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH); parameters.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation.java index 4156e71bbb..08a4f54d8f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation.java @@ -42,9 +42,9 @@ public static void main(String... args) { Parameters parameters = new Parameters(); //https:arxiv.org/abs/1607.08110 parameters.set("numRuns", 10); - parameters.set("numMeasures", 10); - parameters.set("avgDegree", 2); - parameters.set("sampleSize", 500); + parameters.set("numMeasures", 20); + parameters.set("avgDegree", 4); + parameters.set("sampleSize", 1000); parameters.set("alpha", 1e-2); Statistics statistics = new Statistics(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/independence/DiscreteBicTest.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/independence/DiscreteBicTest.java index 6fa4e3f887..031d51310b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/independence/DiscreteBicTest.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/independence/DiscreteBicTest.java @@ -5,7 +5,7 @@ import edu.cmu.tetrad.data.DataModel; import edu.cmu.tetrad.data.DataType; import edu.cmu.tetrad.data.SimpleDataLoader; -import edu.cmu.tetrad.search.BicScore; +import edu.cmu.tetrad.search.DiscreteBicScore; import edu.cmu.tetrad.search.IndTestScore; import edu.cmu.tetrad.search.IndependenceTest; import edu.cmu.tetrad.util.Parameters; @@ -31,7 +31,7 @@ public class DiscreteBicTest implements IndependenceWrapper { @Override public IndependenceTest getTest(DataModel dataSet, Parameters parameters) { - BicScore score = new BicScore(SimpleDataLoader.getDiscreteDataSet(dataSet)); + DiscreteBicScore score = new DiscreteBicScore(SimpleDataLoader.getDiscreteDataSet(dataSet)); score.setPenaltyDiscount(parameters.getDouble(Params.PENALTY_DISCOUNT)); score.setStructurePrior(parameters.getDouble(Params.STRUCTURE_PRIOR)); return new IndTestScore(score); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DiscreteBicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DiscreteBicScore.java index d72a83b387..d055a56630 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DiscreteBicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DiscreteBicScore.java @@ -29,8 +29,8 @@ public class DiscreteBicScore implements ScoreWrapper { @Override public Score getScore(DataModel dataSet, Parameters parameters) { this.dataSet = dataSet; - edu.cmu.tetrad.search.BicScore score - = new edu.cmu.tetrad.search.BicScore(SimpleDataLoader.getDiscreteDataSet(dataSet)); + edu.cmu.tetrad.search.DiscreteBicScore score + = new edu.cmu.tetrad.search.DiscreteBicScore(SimpleDataLoader.getDiscreteDataSet(dataSet)); score.setPenaltyDiscount(parameters.getDouble(Params.PENALTY_DISCOUNT)); score.setStructurePrior(parameters.getDouble(Params.STRUCTURE_PRIOR)); return score; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java similarity index 97% rename from tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java rename to tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java index 9c582abba8..fb27af2929 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java @@ -30,7 +30,7 @@ /** * Calculates the discrete BIC score. */ -public class BicScore implements LocalDiscreteScore, IBDeuScore { +public class DiscreteBicScore implements LocalDiscreteScore, IBDeuScore { private List variables; private final int[][] data; private final int sampleSize; @@ -40,7 +40,7 @@ public class BicScore implements LocalDiscreteScore, IBDeuScore { private final int[] numCategories; private double structurePrior = 1; - public BicScore(DataSet dataSet) { + public DiscreteBicScore(DataSet dataSet) { if (dataSet == null) { throw new NullPointerException("Data was not provided."); } @@ -136,7 +136,7 @@ public double localScore(int node, int[] parents) { continue; } - int rowIndex = BicScore.getRowIndex(dims, parentValues); + int rowIndex = DiscreteBicScore.getRowIndex(dims, parentValues); n_jk[rowIndex][childValue]++; n_j[rowIndex]++; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java index b3cf14706b..61786d8f37 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java @@ -24,6 +24,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.*; import edu.cmu.tetrad.util.MillisecondTimes; +import edu.cmu.tetrad.util.Params; import edu.cmu.tetrad.util.TetradLogger; import java.util.ArrayList; @@ -87,8 +88,11 @@ public class Pc implements GraphSearch { private int numIndependenceTests; private boolean verbose; - - private boolean fdr; + private boolean stable; + private boolean concurrent; + private boolean useMaxP = false; + private int maxPPathLength = -1; + private PcAll.ConflictRule conflictRule = PcAll.ConflictRule.OVERWRITE; //=============================CONSTRUCTORS==========================// @@ -206,9 +210,7 @@ public Graph search() { public Graph search(List nodes) { nodes = new ArrayList<>(nodes); - IFas fas; - - fas = new Fas(getIndependenceTest()); + IFas fas = new Fas(getIndependenceTest()); fas.setVerbose(this.verbose); return search(fas, nodes); } @@ -217,8 +219,6 @@ public Graph search(IFas fas, List nodes) { this.logger.log("info", "Starting PC algorithm"); this.logger.log("info", "Independence test = " + getIndependenceTest() + "."); -// this.logger.log("info", "Variables " + independenceTest.getVariable()); - long startTime = MillisecondTimes.timeMillis(); if (getIndependenceTest() == null) { @@ -226,35 +226,57 @@ public Graph search(IFas fas, List nodes) { } List allNodes = getIndependenceTest().getVariables(); - if (!allNodes.containsAll(nodes)) { + if (!new HashSet<>(allNodes).containsAll(nodes)) { throw new IllegalArgumentException("All of the given nodes must " + "be in the domain of the independence test provided."); } - fas.setKnowledge(getKnowledge()); - fas.setDepth(getDepth()); - fas.setVerbose(this.verbose); + edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(independenceTest); + search.setDepth(depth); + search.setHeuristic(1); + search.setKnowledge(this.knowledge); + + if (stable) { + search.setFasType(PcAll.FasType.STABLE); + } else { + search.setFasType(PcAll.FasType.REGULAR); + } - this.graph = fas.search(); + if (concurrent) { + search.setConcurrent(PcAll.Concurrent.YES); + } else { + search.setConcurrent(PcAll.Concurrent.NO); + } + + search.setColliderDiscovery(PcAll.ColliderDiscovery.FAS_SEPSETS); + search.setConflictRule(conflictRule); + 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(); this.numIndependenceTests = fas.getNumIndependenceTests(); -// enumerateTriples(); - SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, nodes); SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); - for (Edge edge : this.graph.getEdges()) { - if (Edges.isBidirectedEdge(edge)) { - this.graph.removeEdge(edge.getNode1(), edge.getNode2()); - this.graph.addUndirectedEdge(edge.getNode1(), edge.getNode2()); - } - } +// for (Edge edge : this.graph.getEdges()) { +// if (Edges.isBidirectedEdge(edge)) { +// this.graph.removeEdge(edge.getNode1(), edge.getNode2()); +// this.graph.addUndirectedEdge(edge.getNode1(), edge.getNode2()); +// } +// } - MeekRules rules = new MeekRules(); - rules.setKnowledge(this.knowledge); - rules.orientImplied(this.graph); +// MeekRules rules = new MeekRules(); +// rules.setKnowledge(this.knowledge); +// rules.orientImplied(this.graph); this.logger.log("graph", "\nReturning this graph: " + this.graph); @@ -286,33 +308,34 @@ public Set getNonadjacencies() { return new HashSet<>(nonAdjacencies); } - //===============================PRIVATE METHODS=======================// - public int getNumIndependenceTests() { return this.numIndependenceTests; } - public List getNodes() { return this.graph.getNodes(); } + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } - public boolean isVerbose() { - return this.verbose; + public void setStable(boolean stable) { + this.stable = stable; } - public void setVerbose(boolean verbose) { - this.verbose = verbose; + public void setConcurrent(boolean concurrent) { + this.concurrent = concurrent; } - /** - * True iff the algorithm should be run with False Discovery Rate tests. - */ - public boolean isFdr() { - return this.fdr; + public void setUseMaxP(boolean useMaxP) { + this.useMaxP = useMaxP; + } + + public void setMaxPPathLength(int maxPPathLength) { + this.maxPPathLength = maxPPathLength; } - public void setFdr(boolean fdr) { - this.fdr = fdr; + public void setConflictRule(PcAll.ConflictRule conflictRule) { + this.conflictRule = conflictRule; } } diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesBicScorer.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesDiscreteBicScorer.java similarity index 98% rename from tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesBicScorer.java rename to tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesDiscreteBicScorer.java index d8ffa4b900..23191306ba 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesBicScorer.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestBayesDiscreteBicScorer.java @@ -38,7 +38,7 @@ /** * @author Joseph Ramsey */ -public final class TestBayesBicScorer { +public final class TestBayesDiscreteBicScorer { @Test public void testPValue() { diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPc.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPc.java index 5c15857558..2eee231d1d 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPc.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPc.java @@ -164,7 +164,7 @@ private void checkSearch(String inputGraph, String outputGraph) { // Run search // Graph resultGraph = pc.search(); - Graph resultGraph = pc.search(new Fas(independence), independence.getVariables()); + Graph resultGraph = pc.search(); // Build comparison graph. Graph trueGraph = GraphUtils.convert(outputGraph); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPcStableMax.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPcStableMax.java index a22d3c5bc9..6200431995 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPcStableMax.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestPcStableMax.java @@ -149,7 +149,7 @@ private void checkSearch(String inputGraph, String outputGraph) { // Run search // Graph resultGraph = pc.search(); - Graph resultGraph = pc.search(new Fas(independence), independence.getVariables()); + Graph resultGraph = pc.search(); // Build comparison graph. Graph trueGraph = GraphUtils.convert(outputGraph); From baa0efae2fb40ce2f8c07ba6d5df863c8206019a Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sat, 11 Mar 2023 13:01:47 -0500 Subject: [PATCH 124/214] Consolidated two versions of CPC, PCMAX to use the better one. --- .../algorithm/oracle/cpdag/CPC.java | 53 +-- .../algorithm/oracle/cpdag/PC.java | 45 --- .../algorithm/oracle/cpdag/PCMAX.java | 57 +-- .../main/java/edu/cmu/tetrad/search/Cpc.java | 138 ++++++-- .../main/java/edu/cmu/tetrad/search/Pc.java | 11 - .../java/edu/cmu/tetrad/search/PcMax.java | 331 ++++++++++++++++++ 6 files changed, 454 insertions(+), 181 deletions(-) create mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java index b21dec9615..255829f067 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java @@ -12,9 +12,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; -import edu.cmu.tetrad.search.PcAll; -import edu.cmu.tetrad.search.SearchGraphUtils; -import edu.cmu.tetrad.search.TimeSeriesUtils; +import edu.cmu.tetrad.search.*; import edu.cmu.tetrad.util.Parameters; import edu.cmu.tetrad.util.Params; import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest; @@ -59,48 +57,13 @@ public Graph search(DataModel dataModel, Parameters parameters) { knowledge = timeSeries.getKnowledge(); } - final PcAll.ColliderDiscovery colliderDiscovery - = PcAll.ColliderDiscovery.CONSERVATIVE; - - PcAll.ConflictRule conflictRule; - - switch (parameters.getInt(Params.CONFLICT_RULE)) { - case 1: - conflictRule = PcAll.ConflictRule.OVERWRITE; - break; - case 2: - conflictRule = PcAll.ConflictRule.BIDIRECTED; - break; - case 3: - conflictRule = PcAll.ConflictRule.PRIORITY; - break; - default: - throw new IllegalArgumentException("Not a choice."); - } - - PcAll search = new PcAll(this.test.getTest(dataModel, parameters)); + Cpc search = new Cpc(getIndependenceWrapper().getTest(dataModel, parameters)); search.setDepth(parameters.getInt(Params.DEPTH)); - search.setHeuristic(parameters.getInt(Params.FAS_HEURISTIC)); - search.setKnowledge(this.knowledge); - - if (parameters.getBoolean(Params.STABLE_FAS)) { - search.setFasType(PcAll.FasType.STABLE); - } else { - search.setFasType(PcAll.FasType.REGULAR); - } - - if (parameters.getBoolean(Params.CONCURRENT_FAS)) { - search.setConcurrent(PcAll.Concurrent.YES); - } else { - search.setConcurrent(PcAll.Concurrent.NO); - } - - search.setColliderDiscovery(colliderDiscovery); - search.setConflictRule(conflictRule); - search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); - search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); + search.setAggressivelyPreventCycles(true); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); - + search.setConcurrent(parameters.getBoolean(Params.CONCURRENT_FAS)); + search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); + search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); return search.search(); } else { CPC pcAll = new CPC(this.test); @@ -122,7 +85,7 @@ public Graph getComparisonGraph(Graph graph) { @Override public String getDescription() { - return "PC using " + this.test.getDescription(); + return "CPC using " + this.test.getDescription(); } @Override @@ -138,7 +101,7 @@ public List getParameters() { // parameters.add(Params.COLLIDER_DISCOVERY_RULE); parameters.add(Params.CONFLICT_RULE); parameters.add(Params.DEPTH); - parameters.add(Params.FAS_HEURISTIC); +// parameters.add(Params.FAS_HEURISTIC); parameters.add(Params.USE_MAX_P_ORIENTATION_HEURISTIC); parameters.add(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH); parameters.add(Params.TIME_LAG); 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 39dc54d1ec..a35c59830a 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 @@ -70,51 +70,6 @@ public Graph search(DataModel dataModel, Parameters parameters) { search.setUseMaxP(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); return search.search(); - -// final PcAll.ColliderDiscovery colliderDiscovery -// = PcAll.ColliderDiscovery.FAS_SEPSETS; -// -// PcAll.ConflictRule conflictRule; -// -// switch (parameters.getInt(Params.CONFLICT_RULE)) { -// case 1: -// conflictRule = PcAll.ConflictRule.OVERWRITE; -// break; -// case 2: -// conflictRule = PcAll.ConflictRule.BIDIRECTED; -// break; -// case 3: -// conflictRule = PcAll.ConflictRule.PRIORITY; -// break; -// default: -// throw new IllegalArgumentException("Not a choice."); -// } -// -// edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(this.test.getTest(dataModel, parameters)); -// search.setDepth(parameters.getInt(Params.DEPTH)); -// search.setHeuristic(parameters.getInt(Params.FAS_HEURISTIC)); -// search.setKnowledge(this.knowledge); -// -// if (parameters.getBoolean(Params.STABLE_FAS)) { -// search.setFasType(PcAll.FasType.STABLE); -// } else { -// search.setFasType(PcAll.FasType.REGULAR); -// } -// -// if (parameters.getBoolean(Params.CONCURRENT_FAS)) { -// search.setConcurrent(PcAll.Concurrent.YES); -// } else { -// search.setConcurrent(PcAll.Concurrent.NO); -// } -// -// search.setColliderDiscovery(colliderDiscovery); -// search.setConflictRule(conflictRule); -// search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); -// search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); -// search.setExternalGraph(externalGraph); -// search.setVerbose(parameters.getBoolean(Params.VERBOSE)); -// -// return search.search(); } else { PC pcAll = new PC(this.test); 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 ac4086e170..5832d67ae2 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 @@ -12,7 +12,8 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; -import edu.cmu.tetrad.search.PcAll; +import edu.cmu.tetrad.search.Pc; +import edu.cmu.tetrad.search.PcMax; import edu.cmu.tetrad.search.SearchGraphUtils; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; @@ -39,6 +40,8 @@ public class PCMAX implements Algorithm, HasKnowledge, TakesIndependenceWrapper private IndependenceWrapper test; private Knowledge knowledge = new Knowledge(); + private Graph externalGraph = null; + public PCMAX() { } @@ -59,48 +62,13 @@ public Graph search(DataModel dataModel, Parameters parameters) { knowledge = timeSeries.getKnowledge(); } - final PcAll.ColliderDiscovery colliderDiscovery - = PcAll.ColliderDiscovery.MAX_P; - - PcAll.ConflictRule conflictRule; - - switch (parameters.getInt(Params.CONFLICT_RULE)) { - case 1: - conflictRule = PcAll.ConflictRule.OVERWRITE; - break; - case 2: - conflictRule = PcAll.ConflictRule.BIDIRECTED; - break; - case 3: - conflictRule = PcAll.ConflictRule.PRIORITY; - break; - default: - throw new IllegalArgumentException("Not a choice."); - } - - edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(this.test.getTest(dataModel, parameters)); + PcMax search = new PcMax(getIndependenceWrapper().getTest(dataModel, parameters)); search.setDepth(parameters.getInt(Params.DEPTH)); - search.setHeuristic(parameters.getInt(Params.FAS_HEURISTIC)); - search.setKnowledge(this.knowledge); - - if (parameters.getBoolean(Params.STABLE_FAS)) { - search.setFasType(PcAll.FasType.STABLE); - } else { - search.setFasType(PcAll.FasType.REGULAR); - } - - if (parameters.getBoolean(Params.CONCURRENT_FAS)) { - search.setConcurrent(PcAll.Concurrent.YES); - } else { - search.setConcurrent(PcAll.Concurrent.NO); - } - - search.setColliderDiscovery(colliderDiscovery); - search.setConflictRule(conflictRule); - search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); - search.setMaxPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); + search.setAggressivelyPreventCycles(true); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); - + search.setConcurrent(parameters.getBoolean(Params.CONCURRENT_FAS)); + search.setUseHeuristic(parameters.getBoolean(Params.USE_MAX_P_ORIENTATION_HEURISTIC)); + search.setMaxPPathLength(parameters.getInt(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH)); return search.search(); } else { PCMAX pcAll = new PCMAX(this.test); @@ -122,7 +90,7 @@ public Graph getComparisonGraph(Graph graph) { @Override public String getDescription() { - return "PC using " + this.test.getDescription(); + return "PCMAX using " + this.test.getDescription(); } @Override @@ -138,7 +106,7 @@ public List getParameters() { // parameters.add(Params.COLLIDER_DISCOVERY_RULE); parameters.add(Params.CONFLICT_RULE); parameters.add(Params.DEPTH); - parameters.add(Params.FAS_HEURISTIC); +// parameters.add(Params.FAS_HEURISTIC); parameters.add(Params.USE_MAX_P_ORIENTATION_HEURISTIC); parameters.add(Params.MAX_P_ORIENTATION_MAX_PATH_LENGTH); parameters.add(Params.TIME_LAG); @@ -167,4 +135,7 @@ public void setIndependenceWrapper(IndependenceWrapper test) { this.test = test; } + public void setExternalGraph(Graph externalGraph) { + this.externalGraph = externalGraph; + } } \ No newline at end of file diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java index f87aa8ce64..8a27591cdf 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java @@ -104,6 +104,12 @@ public final class Cpc implements GraphSearch { */ private boolean verbose; + private boolean stable; + private boolean concurrent; + private boolean useHeuristic = false; + private int maxPPathLength = -1; + private PcAll.ConflictRule conflictRule = PcAll.ConflictRule.OVERWRITE; + //=============================CONSTRUCTORS==========================// /** @@ -229,31 +235,33 @@ public Set getNonadjacencies() { * See PC for caveats. The number of possible cycles and bidirected edges is far less with CPC than with PC. */ public Graph search() { - return search(this.independenceTest.getVariables()); - } - - public Graph search(List nodes) { - nodes = new ArrayList<>(nodes); - return search(new Fas(getIndependenceTest()), nodes); - } - - public Graph search(IFas fas, List nodes) { this.logger.log("info", "Starting CPC algorithm"); this.logger.log("info", "Independence test = " + getIndependenceTest() + "."); this.ambiguousTriples = new HashSet<>(); this.colliderTriples = new HashSet<>(); this.noncolliderTriples = new HashSet<>(); + Fas fas = new Fas(getIndependenceTest()); + +// SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, getIndependenceTest().getVariables()); +// SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); + +// for (Edge edge : this.graph.getEdges()) { +// if (Edges.isBidirectedEdge(edge)) { +// this.graph.removeEdge(edge.getNode1(), edge.getNode2()); +// this.graph.addUndirectedEdge(edge.getNode1(), edge.getNode2()); +// } +// } + +// MeekRules rules = new MeekRules(); +// rules.setKnowledge(this.knowledge); +// rules.orientImplied(this.graph); + + // this.logger.log("info", "Variables " + independenceTest.getVariable()); long startTime = MillisecondTimes.timeMillis(); - List allNodes = getIndependenceTest().getVariables(); - if (!allNodes.containsAll(nodes)) { - throw new IllegalArgumentException("All of the given nodes must " + - "be in the domain of the independence test provided."); - } - fas.setKnowledge(getKnowledge()); fas.setDepth(getDepth()); fas.setVerbose(this.verbose); @@ -263,35 +271,70 @@ public Graph search(IFas fas, List nodes) { this.graph = fas.search(); this.sepsets = fas.getSepsets(); - if (this.verbose) { - System.out.println("CPC orientation..."); + edu.cmu.tetrad.search.PcAll search = new edu.cmu.tetrad.search.PcAll(independenceTest); + search.setDepth(depth); + search.setHeuristic(1); + search.setKnowledge(this.knowledge); + + if (stable) { + search.setFasType(PcAll.FasType.STABLE); + } else { + search.setFasType(PcAll.FasType.REGULAR); } - SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, nodes); - orientUnshieldedTriples(this.knowledge); -// orientUnshieldedTriplesConcurrent(knowledge, getIndependenceTest(), getMaxIndegree()); - MeekRules meekRules = new MeekRules(); - meekRules.setAggressivelyPreventCycles(this.aggressivelyPreventCycles); - meekRules.setKnowledge(this.knowledge); + if (concurrent) { + search.setConcurrent(PcAll.Concurrent.YES); + } else { + search.setConcurrent(PcAll.Concurrent.NO); + } - meekRules.orientImplied(this.graph); + search.setColliderDiscovery(PcAll.ColliderDiscovery.CONSERVATIVE); + search.setConflictRule(conflictRule); + search.setUseHeuristic(useHeuristic); + search.setMaxPathLength(maxPPathLength); +// search.setExternalGraph(externalGraph); + search.setVerbose(verbose); - // Remove ambiguities whose status have been determined. - Set ambiguities = this.graph.underlines().getAmbiguousTriples(); +// fas.setKnowledge(getKnowledge()); +// fas.setDepth(getDepth()); +// fas.setVerbose(this.verbose); - for (Triple triple : new HashSet<>(ambiguities)) { - Node x = triple.getX(); - Node y = triple.getY(); - Node z = triple.getZ(); + this.graph = search.search(); + this.sepsets = fas.getSepsets(); - if (this.graph.isDefCollider(x, y, z)) { - this.graph.underlines().removeAmbiguousTriple(x, y, z); - } + SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, independenceTest.getVariables()); + SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); - if (this.graph.getEdge(x, y).pointsTowards(x) || this.graph.getEdge(y, z).pointsTowards(z)) { - this.graph.underlines().removeAmbiguousTriple(x, y, z); - } - } + +// if (this.verbose) { +// System.out.println("CPC orientation..."); +// } +// SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, independenceTest.getVariables()); +// orientUnshieldedTriples(this.knowledge); +//// orientUnshieldedTriplesConcurrent(knowledge, getIndependenceTest(), getMaxIndegree()); +// MeekRules meekRules = new MeekRules(); +// +// meekRules.setAggressivelyPreventCycles(this.aggressivelyPreventCycles); +// meekRules.setKnowledge(this.knowledge); +// +// meekRules.orientImplied(this.graph); +// +// // Remove ambiguities whose status have been determined. +// Set ambiguities = this.graph.underlines().getAmbiguousTriples(); +// +// for (Triple triple : new HashSet<>(ambiguities)) { +// Node x = triple.getX(); +// Node y = triple.getY(); +// Node z = triple.getZ(); +// +// if (this.graph.isDefCollider(x, y, z)) { +// this.graph.underlines().removeAmbiguousTriple(x, y, z); +// } +// +// if (this.graph.getEdge(x, y).pointsTowards(x) || this.graph.getEdge(y, z).pointsTowards(z)) { +// this.graph.underlines().removeAmbiguousTriple(x, y, z); +// } +// } TetradLogger.getInstance().log("graph", "\nReturning this graph: " + this.graph); @@ -497,6 +540,27 @@ public Graph getExternalGraph() { public void setExternalGraph(Graph externalGraph) { this.externalGraph = externalGraph; } + + public void setStable(boolean stable) { + this.stable = stable; + } + + public void setConcurrent(boolean concurrent) { + this.concurrent = concurrent; + } + + public void setUseHeuristic(boolean useHeuristic) { + this.useHeuristic = useHeuristic; + } + + public void setMaxPPathLength(int maxPPathLength) { + this.maxPPathLength = maxPPathLength; + } + + public void setConflictRule(PcAll.ConflictRule conflictRule) { + this.conflictRule = conflictRule; + } + } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java index 61786d8f37..e5a90d7001 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pc.java @@ -267,17 +267,6 @@ public Graph search(IFas fas, List nodes) { SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, nodes); SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); -// for (Edge edge : this.graph.getEdges()) { -// if (Edges.isBidirectedEdge(edge)) { -// this.graph.removeEdge(edge.getNode1(), edge.getNode2()); -// this.graph.addUndirectedEdge(edge.getNode1(), edge.getNode2()); -// } -// } - -// MeekRules rules = new MeekRules(); -// rules.setKnowledge(this.knowledge); -// rules.orientImplied(this.graph); - this.logger.log("graph", "\nReturning this graph: " + this.graph); this.elapsedTime = MillisecondTimes.timeMillis() - startTime; 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 new file mode 100644 index 0000000000..2589b71b28 --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMax.java @@ -0,0 +1,331 @@ +/////////////////////////////////////////////////////////////////////////////// +// For information as to what this class does, see the Javadoc, below. // +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // +// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard // +// Scheines, Joseph Ramsey, and Clark Glymour. // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +/////////////////////////////////////////////////////////////////////////////// + +package edu.cmu.tetrad.search; + +import edu.cmu.tetrad.data.Knowledge; +import edu.cmu.tetrad.graph.Edge; +import edu.cmu.tetrad.graph.Graph; +import edu.cmu.tetrad.graph.GraphUtils; +import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.util.MillisecondTimes; +import edu.cmu.tetrad.util.TetradLogger; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +/** + * Implements the PC ("Peter/Clark") algorithm, as specified in Chapter 6 of Spirtes, Glymour, and Scheines, "Causation, + * Prediction, and Search," 2nd edition, with a modified rule set in step D due to Chris Meek. For the modified rule + * set, see Chris Meek (1995), "Causal inference and causal explanation with background knowledge." + * + * @author Joseph Ramsey. + */ +public class PcMax implements GraphSearch { + + /** + * The independence test used for the PC search.g + */ + private final IndependenceTest independenceTest; + + /** + * Forbidden and required edges for the search. + */ + private Knowledge knowledge = new Knowledge(); + + /** + * Sepset information accumulated in the search. + */ + private SepsetMap sepsets; + + /** + * The maximum number of nodes conditioned on in the search. The default it 1000. + */ + private int depth = 1000; + + /** + * The graph that's constructed during the search. + */ + private Graph graph; + + /** + * Elapsed time of the most recent search. + */ + private long elapsedTime; + + /** + * True if cycles are to be aggressively prevented. May be expensive for large graphs (but also useful for large + * graphs). + */ + private boolean aggressivelyPreventCycles; + + /** + * The logger for this class. The config needs to be set. + */ + private final TetradLogger logger = TetradLogger.getInstance(); + + /** + * The number of indepdendence tests in the last search. + */ + private int numIndependenceTests; + + private boolean verbose; + private boolean stable; + private boolean concurrent; + private boolean useHeuristic = false; + private int maxPPathLength = -1; + private PcAll.ConflictRule conflictRule = PcAll.ConflictRule.OVERWRITE; + + //=============================CONSTRUCTORS==========================// + + /** + * Constructs a new PC search using the given independence test as oracle. + * + * @param independenceTest The oracle for conditional independence facts. This does not make a copy of the + * independence test, for fear of duplicating the data set! + */ + public PcMax(IndependenceTest independenceTest) { + if (independenceTest == null) { + throw new NullPointerException("Independence test is null."); + } + + this.independenceTest = independenceTest; + } + + //==============================PUBLIC METHODS========================// + + /** + * @return true iff edges will not be added if they would create cycles. + */ + public boolean isAggressivelyPreventCycles() { + return this.aggressivelyPreventCycles; + } + + /** + * @param aggressivelyPreventCycles Set to true just in case edges will not be addeds if they would create cycles. + */ + public void setAggressivelyPreventCycles(boolean aggressivelyPreventCycles) { + this.aggressivelyPreventCycles = aggressivelyPreventCycles; + } + + /** + * @return the independence test being used in the search. + */ + public IndependenceTest getIndependenceTest() { + return this.independenceTest; + } + + /** + * @return the knowledge specification used in the search. Non-null. + */ + public Knowledge getKnowledge() { + return this.knowledge; + } + + /** + * Sets the knowledge specification to be used in the search. May not be null. + */ + public void setKnowledge(Knowledge knowledge) { + if (knowledge == null) { + throw new NullPointerException("Knowledge is null."); + } + + this.knowledge = knowledge; + } + + /** + * @return the sepset map from the most recent search. Non-null after the first call to search(). + */ + public SepsetMap getSepsets() { + return this.sepsets; + } + + /** + * @return the current depth of search--that is, the maximum number of conditioning nodes for any conditional + * independence checked. + */ + public int getDepth() { + return this.depth; + } + + /** + * Sets the depth of the search--that is, the maximum number of conditioning nodes for any conditional independence + * checked. + * + * @param depth The depth of the search. The default is 1000. A value of -1 may be used to indicate that the depth + * should be high (1000). A value of Integer.MAX_VALUE may not be used, due to a bug on multi-core + * machines. + */ + public void setDepth(int depth) { + if (depth < -1) { + throw new IllegalArgumentException("Depth must be -1 or >= 0: " + depth); + } + + if (depth > 1000) { + throw new IllegalArgumentException("Depth must be <= 1000."); + } + + this.depth = depth; + } + + /** + * Runs PC starting with a complete graph over all nodes of the given conditional independence test, using the given + * independence test and knowledge and returns the resultant graph. The returned graph will be a CPDAG if the + * independence information is consistent with the hypothesis that there are no latent common causes. It may, + * however, contain cycles or bidirected edges if this assumption is not born out, either due to the actual presence + * of latent common causes, or due to statistical errors in conditional independence judgments. + */ + @Override + public Graph search() { + return search(this.independenceTest.getVariables()); + } + + /** + * Runs PC starting with a commplete graph over the given list of nodes, using the given independence test and + * knowledge and returns the resultant graph. The returned graph will be a CPDAG if the independence information + * is consistent with the hypothesis that there are no latent common causes. It may, however, contain cycles or + * bidirected edges if this assumption is not born out, either due to the actual presence of latent common causes, + * or due to statistical errors in conditional independence judgments. + *

+ * All of the given nodes must be in the domatein of the given conditional independence test. + */ + public Graph search(List nodes) { + nodes = new ArrayList<>(nodes); + + IFas fas = new Fas(getIndependenceTest()); + fas.setVerbose(this.verbose); + return search(fas, nodes); + } + + public Graph search(IFas fas, List nodes) { + this.logger.log("info", "Starting PC algorithm"); + this.logger.log("info", "Independence test = " + getIndependenceTest() + "."); + + long startTime = MillisecondTimes.timeMillis(); + + if (getIndependenceTest() == null) { + throw new NullPointerException("Null independence test."); + } + + List allNodes = getIndependenceTest().getVariables(); + if (!new HashSet<>(allNodes).containsAll(nodes)) { + throw new IllegalArgumentException("All of the given nodes must " + + "be in the domain of the independence test provided."); + } + + PcAll search = new PcAll(independenceTest); + search.setDepth(depth); + search.setHeuristic(1); + search.setKnowledge(this.knowledge); + + if (stable) { + search.setFasType(PcAll.FasType.STABLE); + } else { + search.setFasType(PcAll.FasType.REGULAR); + } + + if (concurrent) { + search.setConcurrent(PcAll.Concurrent.YES); + } else { + search.setConcurrent(PcAll.Concurrent.NO); + } + + search.setColliderDiscovery(PcAll.ColliderDiscovery.MAX_P); + search.setConflictRule(conflictRule); + search.setUseHeuristic(useHeuristic); + search.setMaxPathLength(maxPPathLength); +// search.setExternalGraph(externalGraph); + search.setVerbose(verbose); + + this.graph = search.search(); + this.sepsets = fas.getSepsets(); + + this.numIndependenceTests = fas.getNumIndependenceTests(); + + SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, nodes); + SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); + + this.logger.log("graph", "\nReturning this graph: " + this.graph); + + this.elapsedTime = MillisecondTimes.timeMillis() - startTime; + + this.logger.log("info", "Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + this.logger.log("info", "Finishing PC Algorithm."); + this.logger.flush(); + + return this.graph; + } + + /** + * @return the elapsed time of the search, in milliseconds. + */ + public long getElapsedTime() { + return this.elapsedTime; + } + + public Set getAdjacencies() { + return new HashSet<>(this.graph.getEdges()); + } + + public Set getNonadjacencies() { + Graph complete = GraphUtils.completeGraph(this.graph); + Set nonAdjacencies = complete.getEdges(); + Graph undirected = GraphUtils.undirectedGraph(this.graph); + nonAdjacencies.removeAll(undirected.getEdges()); + return new HashSet<>(nonAdjacencies); + } + + public int getNumIndependenceTests() { + return this.numIndependenceTests; + } + public List getNodes() { + return this.graph.getNodes(); + } + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public void setStable(boolean stable) { + this.stable = stable; + } + + public void setConcurrent(boolean concurrent) { + this.concurrent = concurrent; + } + + public void setUseHeuristic(boolean useHeuristic) { + this.useHeuristic = useHeuristic; + } + + public void setMaxPPathLength(int maxPPathLength) { + this.maxPPathLength = maxPPathLength; + } + + public void setConflictRule(PcAll.ConflictRule conflictRule) { + this.conflictRule = conflictRule; + } +} + + + + From 10108b48a5a782c38ccf2950e2cff2a5cc353d24 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sat, 11 Mar 2023 13:17:01 -0500 Subject: [PATCH 125/214] Consolidated two versions of CPC, PCMAX to use the better one. --- .../algorithm/oracle/cpdag/CPC.java | 2 +- .../algorithm/oracle/cpdag/PC.java | 3 +- .../main/java/edu/cmu/tetrad/search/Cpc.java | 183 ------------------ 3 files changed, 2 insertions(+), 186 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java index 255829f067..228568dac1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java @@ -117,7 +117,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/algcomparison/algorithm/oracle/cpdag/PC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC.java index a35c59830a..06ce9f26a8 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 @@ -13,7 +13,6 @@ import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.search.Pc; -import edu.cmu.tetrad.search.PcAll; import edu.cmu.tetrad.search.SearchGraphUtils; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; @@ -122,7 +121,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/Cpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java index 8a27591cdf..4b1d5f137f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cpc.java @@ -243,23 +243,6 @@ public Graph search() { Fas fas = new Fas(getIndependenceTest()); -// SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, getIndependenceTest().getVariables()); -// SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); - -// for (Edge edge : this.graph.getEdges()) { -// if (Edges.isBidirectedEdge(edge)) { -// this.graph.removeEdge(edge.getNode1(), edge.getNode2()); -// this.graph.addUndirectedEdge(edge.getNode1(), edge.getNode2()); -// } -// } - -// MeekRules rules = new MeekRules(); -// rules.setKnowledge(this.knowledge); -// rules.orientImplied(this.graph); - - -// this.logger.log("info", "Variables " + independenceTest.getVariable()); - long startTime = MillisecondTimes.timeMillis(); fas.setKnowledge(getKnowledge()); @@ -305,37 +288,6 @@ public Graph search() { SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, independenceTest.getVariables()); SearchGraphUtils.orientCollidersUsingSepsets(this.sepsets, this.knowledge, this.graph, this.verbose, false); - -// if (this.verbose) { -// System.out.println("CPC orientation..."); -// } -// SearchGraphUtils.pcOrientbk(this.knowledge, this.graph, independenceTest.getVariables()); -// orientUnshieldedTriples(this.knowledge); -//// orientUnshieldedTriplesConcurrent(knowledge, getIndependenceTest(), getMaxIndegree()); -// MeekRules meekRules = new MeekRules(); -// -// meekRules.setAggressivelyPreventCycles(this.aggressivelyPreventCycles); -// meekRules.setKnowledge(this.knowledge); -// -// meekRules.orientImplied(this.graph); -// -// // Remove ambiguities whose status have been determined. -// Set ambiguities = this.graph.underlines().getAmbiguousTriples(); -// -// for (Triple triple : new HashSet<>(ambiguities)) { -// Node x = triple.getX(); -// Node y = triple.getY(); -// Node z = triple.getZ(); -// -// if (this.graph.isDefCollider(x, y, z)) { -// this.graph.underlines().removeAmbiguousTriple(x, y, z); -// } -// -// if (this.graph.getEdge(x, y).pointsTowards(x) || this.graph.getEdge(y, z).pointsTowards(z)) { -// this.graph.underlines().removeAmbiguousTriple(x, y, z); -// } -// } - TetradLogger.getInstance().log("graph", "\nReturning this graph: " + this.graph); long endTime = MillisecondTimes.timeMillis(); @@ -347,37 +299,9 @@ public Graph search() { logTriples(); TetradLogger.getInstance().flush(); -// SearchGraphUtils.verifySepsetIntegrity(sepsetMap, graph); return this.graph; } -// /** -// * Orients the given graph using CPC orientation with the conditional independence test provided in the -// * constructor. -// */ -// public final Graph orientationForGraph(Dag trueGraph) { -// Graph graph = new EdgeListGraph(independenceTest.getVariable()); -// -// for (Edge edge : trueGraph.getEdges()) { -// Node nodeA = edge.getNode1(); -// Node nodeB = edge.getNode2(); -// -// Node _nodeA = independenceTest.getVariable(nodeA.getNode()); -// Node _nodeB = independenceTest.getVariable(nodeB.getNode()); -// -// graph.addUndirectedEdge(_nodeA, _nodeB); -// } -// -// SearchGraphUtils.pcOrientbk(knowledge, graph, graph.getNodes()); -// orientUnshieldedTriples(knowledge, getIndependenceTest(), depth); -// MeekRules meekRules = new MeekRules(); -// meekRules.setAggressivelyPreventCycles(this.aggressivelyPreventCycles); -// meekRules.setKnowledge(knowledge); -// meekRules.orientImplied(graph); -// -// return graph; -// } - //==========================PRIVATE METHODS===========================// private void logTriples() { @@ -401,113 +325,6 @@ private void logTriples() { } } - private void orientUnshieldedTriples(Knowledge knowledge) { - TetradLogger.getInstance().log("info", "Starting Collider Orientation:"); - - this.colliderTriples = new HashSet<>(); - this.noncolliderTriples = new HashSet<>(); - this.ambiguousTriples = new HashSet<>(); - List nodes = this.graph.getNodes(); - - for (Node y : nodes) { - List adjacentNodes = this.graph.getAdjacentNodes(y); - - if (adjacentNodes.size() < 2) { - continue; - } - - ChoiceGenerator cg = new ChoiceGenerator(adjacentNodes.size(), 2); - int[] combination; - - while ((combination = cg.next()) != null) { - Node x = adjacentNodes.get(combination[0]); - Node z = adjacentNodes.get(combination[1]); - - if (this.graph.isAdjacentTo(x, z)) { - continue; - } - - List> sepsetsxz = getSepsets(x, z, this.graph); - - if (isColliderSepset(y, sepsetsxz)) { - if (colliderAllowed(x, y, z, knowledge)) { - this.graph.removeEdge(x, y); - this.graph.removeEdge(z, y); - this.graph.addDirectedEdge(x, y); - this.graph.addDirectedEdge(z, y); - - TetradLogger.getInstance().log("colliderOrientations", SearchLogUtils.colliderOrientedMsg(x, y, z)); - } - - this.colliderTriples.add(new Triple(x, y, z)); - } else if (isNoncolliderSepset(y, sepsetsxz)) { - this.noncolliderTriples.add(new Triple(x, y, z)); - } else { - Triple triple = new Triple(x, y, z); - this.ambiguousTriples.add(triple); - this.graph.underlines().addAmbiguousTriple(triple.getX(), triple.getY(), triple.getZ()); - } - } - } - - TetradLogger.getInstance().log("info", "Finishing Collider Orientation."); - } - - private List> getSepsets(Node i, Node k, Graph g) { - List adji = g.getAdjacentNodes(i); - List adjk = g.getAdjacentNodes(k); - List> sepsets = new ArrayList<>(); - - for (int d = 0; d <= FastMath.max(adji.size(), adjk.size()); d++) { - if (adji.size() >= 2 && d <= adji.size()) { - ChoiceGenerator gen = new ChoiceGenerator(adji.size(), d); - int[] choice; - - while ((choice = gen.next()) != null) { - List v = GraphUtils.asList(choice, adji); - if (getIndependenceTest().checkIndependence(i, k, v).independent()) sepsets.add(v); - } - } - - if (adjk.size() >= 2 && d <= adjk.size()) { - ChoiceGenerator gen = new ChoiceGenerator(adjk.size(), d); - int[] choice; - - while ((choice = gen.next()) != null) { - List v = GraphUtils.asList(choice, adjk); - if (getIndependenceTest().checkIndependence(i, k, v).independent()) sepsets.add(v); - } - } - } - - return sepsets; - } - - private boolean isColliderSepset(Node j, List> sepsets) { - if (sepsets.isEmpty()) return false; - - for (List sepset : sepsets) { - if (sepset.contains(j)) return false; - } - - return true; - } - - private boolean isNoncolliderSepset(Node j, List> sepsets) { - if (sepsets.isEmpty()) return false; - - for (List sepset : sepsets) { - if (!sepset.contains(j)) return false; - } - - return true; - } - - private boolean colliderAllowed(Node x, Node y, Node z, Knowledge knowledge) { - return Cpc.isArrowpointAllowed1(x, y, knowledge) && - Cpc.isArrowpointAllowed1(z, y, knowledge); - } - public static boolean isArrowpointAllowed1(Node from, Node to, Knowledge knowledge) { return knowledge == null || !knowledge.isRequired(to.toString(), from.toString()) && From f39735aa3c9a130686f75835e3d25b0e657fd6fd Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 13 Mar 2023 01:27:01 -0400 Subject: [PATCH 126/214] Consolidated two versions of CPC, PCMAX to use the better one. --- .../score/DegenerateGaussianBicScore.java | 7 +- .../search/DegenerateGaussianScore.java | 191 ++------- .../search/DegenerateGaussianScoreOld.java | 361 ++++++++++++++++++ .../tetrad/search/SemBicScoreDGWrapper.java | 225 ----------- .../java/edu/cmu/tetrad/test/TestGrasp.java | 6 +- 5 files changed, 396 insertions(+), 394 deletions(-) mode change 100755 => 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java create mode 100755 tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScoreOld.java delete mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/search/SemBicScoreDGWrapper.java diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DegenerateGaussianBicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DegenerateGaussianBicScore.java index 742486f88c..18b648a443 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DegenerateGaussianBicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/score/DegenerateGaussianBicScore.java @@ -5,8 +5,9 @@ import edu.cmu.tetrad.data.DataType; import edu.cmu.tetrad.data.SimpleDataLoader; import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.search.DegenerateGaussianScoreOld; import edu.cmu.tetrad.search.Score; -import edu.cmu.tetrad.search.SemBicScoreDGWrapper; +import edu.cmu.tetrad.search.DegenerateGaussianScore; import edu.cmu.tetrad.util.Parameters; import java.util.ArrayList; @@ -31,8 +32,8 @@ public class DegenerateGaussianBicScore implements ScoreWrapper { @Override public Score getScore(DataModel dataSet, Parameters parameters) { this.dataSet = dataSet; -// DegenerateGaussianScore degenerateGaussianScore = new DegenerateGaussianScore(DataUtils.getMixedDataSet(dataSet)); - SemBicScoreDGWrapper degenerateGaussianScore = new SemBicScoreDGWrapper(SimpleDataLoader.getMixedDataSet(dataSet)); +// DegenerateGaussianScoreOld degenerateGaussianScore = new DegenerateGaussianScoreOld(DataUtils.getMixedDataSet(dataSet)); + DegenerateGaussianScore degenerateGaussianScore = new DegenerateGaussianScore(SimpleDataLoader.getMixedDataSet(dataSet)); degenerateGaussianScore.setPenaltyDiscount(parameters.getDouble("penaltyDiscount")); degenerateGaussianScore.setStructurePrior(parameters.getDouble("structurePrior")); return degenerateGaussianScore; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java old mode 100755 new mode 100644 index 1666481f19..b774d87b56 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java @@ -1,30 +1,7 @@ -/////////////////////////////////////////////////////////////////////////////// -// For information as to what this class does, see the Javadoc, below. // -// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // -// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard // -// Scheines, Joseph Ramsey, and Clark Glymour. // -// // -// This program is free software; you can redistribute it and/or modify // -// it under the terms of the GNU General Public License as published by // -// the Free Software Foundation; either version 2 of the License, or // -// (at your option) any later version. // -// // -// This program is distributed in the hope that it will be useful, // -// but WITHOUT ANY WARRANTY; without even the implied warranty of // -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // -// GNU General Public License for more details. // -// // -// You should have received a copy of the GNU General Public License // -// along with this program; if not, write to the Free Software // -// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // -/////////////////////////////////////////////////////////////////////////////// - package edu.cmu.tetrad.search; import edu.cmu.tetrad.data.*; import edu.cmu.tetrad.graph.Node; -import edu.cmu.tetrad.util.Matrix; -import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.math3.linear.BlockRealMatrix; import org.apache.commons.math3.linear.RealMatrix; import org.apache.commons.math3.util.FastMath; @@ -45,32 +22,22 @@ * * @author Bryan Andrews */ + public class DegenerateGaussianScore implements Score { - private final BoxDataSet ddata; private final DataSet dataSet; // The mixed variables of the original dataset. private final List variables; - // The penalty discount. - private double penaltyDiscount = 1.0; - // The structure prior. private double structurePrior; // The embedding map. private final Map> embedding; - // A constant. - private static final double L2PE = log(2.0 * FastMath.PI * FastMath.E); - - private final Map nodesHash; - + private final SemBicScore bic; - /** - * Constructs the score using a covariance matrix. - */ public DegenerateGaussianScore(DataSet dataSet) { if (dataSet == null) { throw new NullPointerException(); @@ -111,9 +78,7 @@ public DegenerateGaussianScore(DataSet dataSet) { B.get(keys.get(key))[j] = 1; } - /* - * Remove a degenerate dimension. - */ + // Remove a degenerate dimension. i--; keys.remove(keysReverse.get(i)); A.remove(i); @@ -145,67 +110,36 @@ public DegenerateGaussianScore(DataSet dataSet) { } } - // The continuous variables of the post-embedding dataset. RealMatrix D = new BlockRealMatrix(B_); - this.ddata = new BoxDataSet(new DoubleDataBox(D.getData()), A); - this.nodesHash = new HashedMap<>(); - - List variables = dataSet.getVariables(); - - for (int j = 0; j < variables.size(); j++) { - this.nodesHash.put(variables.get(j), j); - } - + this.bic = new SemBicScore(new BoxDataSet(new DoubleDataBox(D.getData()), A)); + this.bic.setStructurePrior(0); } /** * Calculates the sample likelihood and BIC score for i given its parents in a simple SEM model */ public double localScore(int i, int... parents) { + double score = 0; - List rows = getRows(i, parents); - int N = rows.size(); - - List B = new ArrayList<>(); List A = new ArrayList<>(this.embedding.get(i)); + List B = new ArrayList<>(); for (int i_ : parents) { B.addAll(this.embedding.get(i_)); } - int[] A_ = new int[A.size() + B.size()]; - int[] B_ = new int[B.size()]; - for (int i_ = 0; i_ < A.size(); i_++) { - A_[i_] = A.get(i_); - } + int[] parents_ = new int[B.size()]; for (int i_ = 0; i_ < B.size(); i_++) { - A_[A.size() + i_] = B.get(i_); - B_[i_] = B.get(i_); + parents_[i_] = B.get(i_); } - int dof = (A_.length * (A_.length + 1) - B_.length * (B_.length + 1)) / 2; - double ldetA = log(getCov(rows, A_).det()); - double ldetB = log(getCov(rows, B_).det()); - - double lik = N * (ldetB - ldetA + DegenerateGaussianScore.L2PE * (B_.length - A_.length)); - double score = 2 * lik + 2 * calculateStructurePrior(parents.length) - dof * getPenaltyDiscount() * log(N); - - if (Double.isNaN(score) || Double.isInfinite(score)) { - return Double.NaN; - } else { - return score; + for (Integer i_ : A) { + score += this.bic.localScore(i_, parents_); } - } - private double calculateStructurePrior(int k) { - if (this.structurePrior <= 0) { - return 0; - } else { - double n = this.variables.size() - 1; - double p = this.structurePrior / n; - return k * log(p) + (n - k) * log(1.0 - p); - } - } + // NOTE: STRUCTURE PRIOR IS NOT CURRENTLY IMPLEMENTED! + return score; + } public double localScoreDiff(int x, int y, int[] z) { return localScore(y, append(z, x)) - localScore(y, z); @@ -237,8 +171,9 @@ public double localScore(int i) { return localScore(i, new int[0]); } - public int getSampleSize() { - return this.dataSet.getNumRows(); + @Override + public List getVariables() { + return this.variables; } @Override @@ -247,18 +182,12 @@ public boolean isEffectEdge(double bump) { } @Override - public List getVariables() { - return this.variables; + public int getSampleSize() { + return 0; } @Override public Node getVariable(String targetName) { - for (Node node : this.variables) { - if (node.getName().equals(targetName)) { - return node; - } - } - return null; } @@ -272,89 +201,25 @@ public boolean determines(List z, Node y) { return false; } + @Override + public String toString() { + NumberFormat nf = new DecimalFormat("0.00"); + return "Degenerate Gaussian Score Penalty " + nf.format(this.bic.getPenaltyDiscount()); + } + public double getPenaltyDiscount() { - return this.penaltyDiscount; + return this.bic.getPenaltyDiscount(); } public void setPenaltyDiscount(double penaltyDiscount) { - this.penaltyDiscount = penaltyDiscount; + this.bic.setPenaltyDiscount(penaltyDiscount); } public double getStructurePrior() { - return this.structurePrior; + return structurePrior; } public void setStructurePrior(double structurePrior) { this.structurePrior = structurePrior; } - - @Override - public String toString() { - NumberFormat nf = new DecimalFormat("0.00"); - return "Degenerate Gaussian Score Penalty " + nf.format(this.penaltyDiscount); - } - - // Subsample of the continuous mixedVariables conditioning on the given cols. - private Matrix getCov(List rows, int[] cols) { - if (rows.isEmpty()) return new Matrix(0, 0); - Matrix cov = new Matrix(cols.length, cols.length); - - for (int i = 0; i < cols.length; i++) { - for (int j = 0; j < cols.length; j++) { - double mui = 0.0; - double muj = 0.0; - - for (int k : rows) { - mui += this.ddata.getDouble(k, cols[i]); - muj += this.ddata.getDouble(k, cols[j]); - } - - mui /= rows.size() - 1; - muj /= rows.size() - 1; - - double _cov = 0.0; - - for (int k : rows) { - _cov += (this.ddata.getDouble(k, cols[i]) - mui) * (this.ddata.getDouble(k, cols[j]) - muj); - } - - double mean = _cov / (rows.size()); - cov.set(i, j, mean); - } - } - - return cov; - } - - private List getRows(int i, int[] parents) { - List rows = new ArrayList<>(); - - K: - for (int k = 0; k < this.dataSet.getNumRows(); k++) { - Node ii = this.variables.get(i); - - List A = new ArrayList<>(this.embedding.get(this.nodesHash.get(ii))); - - for (int j : A) { - if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; - } - - for (int ignored : parents) { - Node pp = this.variables.get(i); - - List AA = new ArrayList<>(this.embedding.get(this.nodesHash.get(pp))); - - for (int j : AA) { - if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; - } - } - - rows.add(k); - } - - return rows; - } } - - - diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScoreOld.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScoreOld.java new file mode 100755 index 0000000000..1c4c807545 --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScoreOld.java @@ -0,0 +1,361 @@ +/////////////////////////////////////////////////////////////////////////////// +// For information as to what this class does, see the Javadoc, below. // +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // +// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard // +// Scheines, Joseph Ramsey, and Clark Glymour. // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +/////////////////////////////////////////////////////////////////////////////// + +package edu.cmu.tetrad.search; + +import edu.cmu.tetrad.data.*; +import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.util.Matrix; +import org.apache.commons.collections4.map.HashedMap; +import org.apache.commons.math3.linear.BlockRealMatrix; +import org.apache.commons.math3.linear.RealMatrix; +import org.apache.commons.math3.util.FastMath; + +import java.text.DecimalFormat; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import static org.apache.commons.math3.util.FastMath.log; + +/** + * Implements a degenerate Gaussian BIC score for FGES. + *

+ * http://proceedings.mlr.press/v104/andrews19a/andrews19a.pdf + * + * @author Bryan Andrews + * @deprecated Use DegenerateGaussianScore + */ +public class DegenerateGaussianScoreOld implements Score { + + private final BoxDataSet ddata; + private final DataSet dataSet; + + // The mixed variables of the original dataset. + private final List variables; + + // The penalty discount. + private double penaltyDiscount = 1.0; + + // The structure prior. + private double structurePrior; + + // The embedding map. + private final Map> embedding; + + // A constant. + private static final double L2PE = log(2.0 * FastMath.PI * FastMath.E); + + private final Map nodesHash; + + + /** + * Constructs the score using a covariance matrix. + */ + public DegenerateGaussianScoreOld(DataSet dataSet) { + if (dataSet == null) { + throw new NullPointerException(); + } + + this.dataSet = dataSet; + this.variables = dataSet.getVariables(); + // The number of instances. + int n = dataSet.getNumRows(); + this.embedding = new HashMap<>(); + + List A = new ArrayList<>(); + List B = new ArrayList<>(); + + int index = 0; + + int i = 0; + int i_ = 0; + while (i_ < this.variables.size()) { + + Node v = this.variables.get(i_); + + if (v instanceof DiscreteVariable) { + + Map, Integer> keys = new HashMap<>(); + Map> keysReverse = new HashMap<>(); + for (int j = 0; j < n; j++) { + List key = new ArrayList<>(); + key.add(this.dataSet.getInt(j, i_)); + if (!keys.containsKey(key)) { + keys.put(key, i); + keysReverse.put(i, key); + Node v_ = new ContinuousVariable("V__" + ++index); + A.add(v_); + B.add(new double[n]); + i++; + } + B.get(keys.get(key))[j] = 1; + } + + /* + * Remove a degenerate dimension. + */ + i--; + keys.remove(keysReverse.get(i)); + A.remove(i); + B.remove(i); + + this.embedding.put(i_, new ArrayList<>(keys.values())); + + } else { + + A.add(v); + double[] b = new double[n]; + for (int j = 0; j < n; j++) { + b[j] = this.dataSet.getDouble(j, i_); + } + + B.add(b); + List index2 = new ArrayList<>(); + index2.add(i); + this.embedding.put(i_, index2); + i++; + + } + i_++; + } + double[][] B_ = new double[n][B.size()]; + for (int j = 0; j < B.size(); j++) { + for (int k = 0; k < n; k++) { + B_[k][j] = B.get(j)[k]; + } + } + + // The continuous variables of the post-embedding dataset. + RealMatrix D = new BlockRealMatrix(B_); + this.ddata = new BoxDataSet(new DoubleDataBox(D.getData()), A); + this.nodesHash = new HashedMap<>(); + + List variables = dataSet.getVariables(); + + for (int j = 0; j < variables.size(); j++) { + this.nodesHash.put(variables.get(j), j); + } + + } + + /** + * Calculates the sample likelihood and BIC score for i given its parents in a simple SEM model + */ + public double localScore(int i, int... parents) { + + List rows = getRows(i, parents); + int N = dataSet.getNumRows();// rows.size(); + + List B = new ArrayList<>(); + List A = new ArrayList<>(this.embedding.get(i)); + for (int i_ : parents) { + B.addAll(this.embedding.get(i_)); + } + + int[] A_ = new int[A.size() + B.size()]; + int[] B_ = new int[B.size()]; + for (int i_ = 0; i_ < A.size(); i_++) { + A_[i_] = A.get(i_); + } + for (int i_ = 0; i_ < B.size(); i_++) { + A_[A.size() + i_] = B.get(i_); + B_[i_] = B.get(i_); + } + + int dof = (A_.length * (A_.length + 1) - B_.length * (B_.length + 1)) / 2; + double ldetA = log(getCov(rows, A_).det()); + double ldetB = log(getCov(rows, B_).det()); + + double lik = N * (ldetB - ldetA + DegenerateGaussianScoreOld.L2PE * (B_.length - A_.length)); + double score = 2 * lik + 2 * calculateStructurePrior(parents.length) - dof * getPenaltyDiscount() * log(N); + + if (Double.isNaN(score) || Double.isInfinite(score)) { + return Double.NaN; + } else { + return score; + } + } + + private double calculateStructurePrior(int k) { + if (this.structurePrior <= 0) { + return 0; + } else { + double n = this.variables.size() - 1; + double p = this.structurePrior / n; + return k * log(p) + (n - k) * log(1.0 - p); + } + } + + + public double localScoreDiff(int x, int y, int[] z) { + return localScore(y, append(z, x)) - localScore(y, z); + } + + @Override + public double localScoreDiff(int x, int y) { + return localScore(y, x) - localScore(y); + } + + private int[] append(int[] parents, int extra) { + int[] all = new int[parents.length + 1]; + System.arraycopy(parents, 0, all, 0, parents.length); + all[parents.length] = extra; + return all; + } + + /** + * Specialized scoring method for a single parent. Used to speed up the effect edges search. + */ + public double localScore(int i, int parent) { + return localScore(i, new int[]{parent}); + } + + /** + * Specialized scoring method for no parents. Used to speed up the effect edges search. + */ + public double localScore(int i) { + return localScore(i, new int[0]); + } + + public int getSampleSize() { + return this.dataSet.getNumRows(); + } + + @Override + public boolean isEffectEdge(double bump) { + return bump > 0; + } + + @Override + public List getVariables() { + return this.variables; + } + + @Override + public Node getVariable(String targetName) { + for (Node node : this.variables) { + if (node.getName().equals(targetName)) { + return node; + } + } + + return null; + } + + @Override + public int getMaxDegree() { + return (int) FastMath.ceil(log(this.dataSet.getNumRows())); + } + + @Override + public boolean determines(List z, Node y) { + return false; + } + + public double getPenaltyDiscount() { + return this.penaltyDiscount; + } + + public void setPenaltyDiscount(double penaltyDiscount) { + this.penaltyDiscount = penaltyDiscount; + } + + public double getStructurePrior() { + return this.structurePrior; + } + + public void setStructurePrior(double structurePrior) { + this.structurePrior = structurePrior; + } + + @Override + public String toString() { + NumberFormat nf = new DecimalFormat("0.00"); + return "Degenerate Gaussian Score Penalty " + nf.format(this.penaltyDiscount); + } + + // Subsample of the continuous mixedVariables conditioning on the given cols. + private Matrix getCov(List rows, int[] cols) { + if (rows.isEmpty()) return new Matrix(0, 0); + Matrix cov = new Matrix(cols.length, cols.length); + + for (int i = 0; i < cols.length; i++) { + for (int j = 0; j < cols.length; j++) { + double mui = 0.0; + double muj = 0.0; + + for (int k : rows) { + mui += this.ddata.getDouble(k, cols[i]); + muj += this.ddata.getDouble(k, cols[j]); + } + + mui /= rows.size() - 1; + muj /= rows.size() - 1; + + double _cov = 0.0; + + for (int k : rows) { + _cov += (this.ddata.getDouble(k, cols[i]) - mui) * (this.ddata.getDouble(k, cols[j]) - muj); + } + + double mean = _cov / (rows.size()); + cov.set(i, j, mean); + } + } + + return cov; + } + + private List getRows(int i, int[] parents) { + List rows = new ArrayList<>(); + + K: + for (int k = 0; k < this.dataSet.getNumRows(); k++) { + Node ii = this.variables.get(i); + + List A = new ArrayList<>(this.embedding.get(this.nodesHash.get(ii))); + + for (int j : A) { + if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; + } + + for (int ignored : parents) { + Node pp = this.variables.get(i); + + List AA = new ArrayList<>(this.embedding.get(this.nodesHash.get(pp))); + + for (int j : AA) { + if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; + } + } + + rows.add(k); + } + + return rows; + } +} + + + diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SemBicScoreDGWrapper.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SemBicScoreDGWrapper.java deleted file mode 100644 index d1adf2366c..0000000000 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SemBicScoreDGWrapper.java +++ /dev/null @@ -1,225 +0,0 @@ -package edu.cmu.tetrad.search; - -import edu.cmu.tetrad.data.*; -import edu.cmu.tetrad.graph.Node; -import org.apache.commons.math3.linear.BlockRealMatrix; -import org.apache.commons.math3.linear.RealMatrix; -import org.apache.commons.math3.util.FastMath; - -import java.text.DecimalFormat; -import java.text.NumberFormat; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static org.apache.commons.math3.util.FastMath.log; - -/** - * Implements a degenerate Gaussian BIC score for FGES. - *

- * http://proceedings.mlr.press/v104/andrews19a/andrews19a.pdf - * - * @author Bryan Andrews - */ - -public class SemBicScoreDGWrapper implements Score { - - private final DataSet dataSet; - - // The mixed variables of the original dataset. - private final List variables; - - // The structure prior. - private double structurePrior; - - // The embedding map. - private final Map> embedding; - - private final SemBicScore bic; - - public SemBicScoreDGWrapper(DataSet dataSet) { - if (dataSet == null) { - throw new NullPointerException(); - } - - this.dataSet = dataSet; - this.variables = dataSet.getVariables(); - // The number of instances. - int n = dataSet.getNumRows(); - this.embedding = new HashMap<>(); - - List A = new ArrayList<>(); - List B = new ArrayList<>(); - - int index = 0; - - int i = 0; - int i_ = 0; - while (i_ < this.variables.size()) { - - Node v = this.variables.get(i_); - - if (v instanceof DiscreteVariable) { - - Map, Integer> keys = new HashMap<>(); - Map> keysReverse = new HashMap<>(); - for (int j = 0; j < n; j++) { - List key = new ArrayList<>(); - key.add(this.dataSet.getInt(j, i_)); - if (!keys.containsKey(key)) { - keys.put(key, i); - keysReverse.put(i, key); - Node v_ = new ContinuousVariable("V__" + ++index); - A.add(v_); - B.add(new double[n]); - i++; - } - B.get(keys.get(key))[j] = 1; - } - - // Remove a degenerate dimension. - i--; - keys.remove(keysReverse.get(i)); - A.remove(i); - B.remove(i); - - this.embedding.put(i_, new ArrayList<>(keys.values())); - - } else { - - A.add(v); - double[] b = new double[n]; - for (int j = 0; j < n; j++) { - b[j] = this.dataSet.getDouble(j, i_); - } - - B.add(b); - List index2 = new ArrayList<>(); - index2.add(i); - this.embedding.put(i_, index2); - i++; - - } - i_++; - } - double[][] B_ = new double[n][B.size()]; - for (int j = 0; j < B.size(); j++) { - for (int k = 0; k < n; k++) { - B_[k][j] = B.get(j)[k]; - } - } - - RealMatrix D = new BlockRealMatrix(B_); - this.bic = new SemBicScore(new BoxDataSet(new DoubleDataBox(D.getData()), A)); - this.bic.setStructurePrior(0); - } - - /** - * Calculates the sample likelihood and BIC score for i given its parents in a simple SEM model - */ - public double localScore(int i, int... parents) { - double score = 0; - - List A = new ArrayList<>(this.embedding.get(i)); - List B = new ArrayList<>(); - for (int i_ : parents) { - B.addAll(this.embedding.get(i_)); - } - - int[] parents_ = new int[B.size()]; - for (int i_ = 0; i_ < B.size(); i_++) { - parents_[i_] = B.get(i_); - } - - for (Integer i_ : A) { - score += this.bic.localScore(i_, parents_); - } - - // NOTE: STRUCTURE PRIOR IS NOT CURRENTLY IMPLEMENTED! - - return score; - } - - public double localScoreDiff(int x, int y, int[] z) { - return localScore(y, append(z, x)) - localScore(y, z); - } - - @Override - public double localScoreDiff(int x, int y) { - return localScore(y, x) - localScore(y); - } - - private int[] append(int[] parents, int extra) { - int[] all = new int[parents.length + 1]; - System.arraycopy(parents, 0, all, 0, parents.length); - all[parents.length] = extra; - return all; - } - - /** - * Specialized scoring method for a single parent. Used to speed up the effect edges search. - */ - public double localScore(int i, int parent) { - return localScore(i, new int[]{parent}); - } - - /** - * Specialized scoring method for no parents. Used to speed up the effect edges search. - */ - public double localScore(int i) { - return localScore(i, new int[0]); - } - - @Override - public List getVariables() { - return this.variables; - } - - @Override - public boolean isEffectEdge(double bump) { - return bump > 0; - } - - @Override - public int getSampleSize() { - return 0; - } - - @Override - public Node getVariable(String targetName) { - return null; - } - - @Override - public int getMaxDegree() { - return (int) FastMath.ceil(log(this.dataSet.getNumRows())); - } - - @Override - public boolean determines(List z, Node y) { - return false; - } - - @Override - public String toString() { - NumberFormat nf = new DecimalFormat("0.00"); - return "Degenerate Gaussian Score Penalty " + nf.format(this.bic.getPenaltyDiscount()); - } - - public double getPenaltyDiscount() { - return this.bic.getPenaltyDiscount(); - } - - public void setPenaltyDiscount(double penaltyDiscount) { - this.bic.setPenaltyDiscount(penaltyDiscount); - } - - public double getStructurePrior() { - return structurePrior; - } - - public void setStructurePrior(double structurePrior) { - this.structurePrior = structurePrior; - } -} diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java index 03827bbfbd..0f6218377c 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java @@ -149,11 +149,11 @@ private void testCgScore() { double structurePrior = 1.0; boolean discretize = true; - ConditionalGaussianScore score = new ConditionalGaussianScore((DataSet) data, penaltyDiscount, discretize); + DegenerateGaussianScore score = new DegenerateGaussianScore((DataSet) data); score.setStructurePrior(structurePrior); - score.setNumCategoriesToDiscretize(3); - IndTestConditionalGaussianLRT test = new IndTestConditionalGaussianLRT((DataSet) data, 0.05, true); + IndTestDegenerateGaussianLRT test = new IndTestDegenerateGaussianLRT((DataSet) data); + test.setAlpha(0.01); Fges alg = new Fges(score); From 0222209eaeee2775c9f1fd281cb0430c2c93307a Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 13 Mar 2023 13:23:53 -0400 Subject: [PATCH 127/214] Moved Boss to BossOld and imported BossNew as Boss. --- .../algcomparison/algorithm/multi/Images.java | 4 +- .../algorithm/oracle/cpdag/BOSS.java | 118 +--- .../algorithm/oracle/cpdag/BOSSDC.java | 9 +- .../algorithm/oracle/cpdag/BOSSOLD.java | 188 ++++++ .../algorithm/oracle/pag/BFCI.java | 8 +- .../oracle/pag/BFCIFinalOrientationOnly.java | 6 +- .../algorithm/oracle/pag/BFCITR.java | 8 +- .../algorithm/oracle/pag/LVSWAP_1.java | 8 +- .../algorithm/oracle/pag/LVSWAP_2a.java | 8 +- .../algorithm/oracle/pag/LVSWAP_2b.java | 8 +- .../algcomparison/examples/TestBoss.java | 8 +- .../main/java/edu/cmu/tetrad/search/BFci.java | 6 +- .../java/edu/cmu/tetrad/search/BfciFoo.java | 24 +- .../java/edu/cmu/tetrad/search/BfciTr.java | 26 +- .../main/java/edu/cmu/tetrad/search/Boss.java | 625 +++--------------- .../java/edu/cmu/tetrad/search/BossDC.java | 11 +- .../java/edu/cmu/tetrad/search/BossOld.java | 606 +++++++++++++++++ .../search/DegenerateGaussianScore.java | 191 +++++- .../cmu/tetrad/search/DiscreteBicScore.java | 1 - .../edu/cmu/tetrad/search/GrowShrinkTree.java | 39 +- .../search/IndTestConditionalGaussianLRT.java | 29 +- .../cmu/tetrad/search/IndTestTeyssier.java | 8 +- .../java/edu/cmu/tetrad/search/LvSwap.java | 12 +- .../cmu/tetrad/search/SepsetsTeyssier.java | 6 +- .../edu/cmu/tetrad/search/SimpleDemoGA.java | 8 +- .../java/edu/cmu/tetrad/search/SpFci.java | 4 +- .../edu/cmu/tetrad/search/TeyssierScorer.java | 2 +- .../cmu/tetrad/search/TeyssierScorer3.java | 2 +- .../cmu/tetrad/test/TestAnneAnalysis3.java | 6 +- .../java/edu/cmu/tetrad/test/TestGrasp.java | 20 +- 30 files changed, 1192 insertions(+), 807 deletions(-) create mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSOLD.java create mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossOld.java diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java index d8c1ca60a9..5b03aa5763 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java @@ -94,8 +94,8 @@ public Graph search(List dataSets, Parameters parameters) { // return search.getGraph(true); // } else if (meta == 2) { - Boss search = new Boss(score); - search.setAlgType(Boss.AlgType.BOSS1); + BossOld search = new BossOld(score); + search.setAlgType(BossOld.AlgType.BOSS1); search.setKnowledge(new Knowledge((Knowledge) knowledge)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.bestOrder(score.getVariables()); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java index 7a234aa2be..920c9e0b24 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java @@ -1,34 +1,25 @@ package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag; import edu.cmu.tetrad.algcomparison.algorithm.Algorithm; -import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper; import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; -import edu.cmu.tetrad.algcomparison.utils.HasKnowledge; -import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper; import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper; import edu.cmu.tetrad.annotation.AlgType; import edu.cmu.tetrad.annotation.Bootstrapping; import edu.cmu.tetrad.annotation.Experimental; import edu.cmu.tetrad.data.DataModel; -import edu.cmu.tetrad.data.DataSet; import edu.cmu.tetrad.data.DataType; -import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; -import edu.cmu.tetrad.graph.Node; import edu.cmu.tetrad.search.Boss; -import edu.cmu.tetrad.search.IndependenceTest; import edu.cmu.tetrad.search.Score; -import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; import edu.cmu.tetrad.util.Params; -import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest; import java.util.ArrayList; import java.util.List; /** - * BOSS (Best Order Score Search) + * BOSS-DC (Best Order Score Search Divide and Conquer) * * @author bryanandrews * @author josephramsey @@ -40,83 +31,29 @@ ) @Bootstrapping @Experimental -public class BOSS implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, HasKnowledge { +public class BOSS implements Algorithm, UsesScoreWrapper { static final long serialVersionUID = 23L; private ScoreWrapper score; - private IndependenceWrapper test; - private Knowledge knowledge = new Knowledge(); public BOSS() { // Used in reflection; do not delete. } -// public BOSS(ScoreWrapper score) { -// this.score = score; -// } - - public BOSS(IndependenceWrapper test, ScoreWrapper score) { - this.test = test; + public BOSS(ScoreWrapper score) { this.score = score; } + @Override public Graph search(DataModel dataModel, Parameters parameters) { - if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) { - if (parameters.getInt(Params.TIME_LAG) > 0) { - DataSet dataSet = (DataSet) dataModel; - DataSet timeSeries = TimeSeriesUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG)); - if (dataSet.getName() != null) { - timeSeries.setName(dataSet.getName()); - } - dataModel = timeSeries; - knowledge = timeSeries.getKnowledge(); - } - - Score score = this.score.getScore(dataModel, parameters); - IndependenceTest test = this.test.getTest(dataModel, parameters); - - Boss boss = new Boss(test, score); - - if (parameters.getInt(Params.BOSS_ALG) == 1) { - boss.setAlgType(Boss.AlgType.BOSS1); - } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - boss.setAlgType(Boss.AlgType.BOSS2); - } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - boss.setAlgType(Boss.AlgType.BOSS3); - } else { - throw new IllegalArgumentException("Unrecognized boss algorithm type."); - } - - boss.setDepth(parameters.getInt(Params.DEPTH)); - boss.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER)); - boss.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE)); - boss.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER)); - boss.setVerbose(parameters.getBoolean(Params.VERBOSE)); - boss.setNumStarts(parameters.getInt(Params.NUM_STARTS)); - boss.setCaching(parameters.getBoolean(Params.CACHE_SCORES)); - - boss.setKnowledge(this.knowledge); - - boss.bestOrder(new ArrayList(score.getVariables())); - return boss.getGraph(true); - } else { - BOSS algorithm = new BOSS(this.test, this.score); - - DataSet data = (DataSet) dataModel; - GeneralResamplingTest search = new GeneralResamplingTest( - data, - algorithm, - parameters.getInt(Params.NUMBER_RESAMPLING), - parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), - parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), - parameters.getInt(Params.RESAMPLING_ENSEMBLE), - parameters.getBoolean(Params.ADD_ORIGINAL_DATASET)); - search.setKnowledge(this.knowledge); - - search.setParameters(parameters); - search.setVerbose(parameters.getBoolean(Params.VERBOSE)); - return search.search(); - } + Score score = this.score.getScore(dataModel, parameters); + Boss boss = new Boss(score); + + boss.setDepth(parameters.getInt(Params.DEPTH)); + boss.setVerbose(parameters.getBoolean(Params.VERBOSE)); + boss.setNumStarts(parameters.getInt(Params.NUM_STARTS)); + + return boss.search(); } @Override @@ -126,7 +63,7 @@ public Graph getComparisonGraph(Graph graph) { @Override public String getDescription() { - return "BOSS (Best Order Score Search) using " + this.score.getDescription(); + return "BOSSNEW (Best Order Score Search) using " + this.score.getDescription(); } @Override @@ -139,18 +76,12 @@ public List getParameters() { ArrayList params = new ArrayList<>(); // Flags - params.add(Params.BOSS_ALG); - params.add(Params.DEPTH); - params.add(Params.GRASP_USE_SCORE); - params.add(Params.GRASP_USE_RASKUTTI_UHLER); - params.add(Params.GRASP_USE_DATA_ORDER); - params.add(Params.TIME_LAG); - params.add(Params.CACHE_SCORES); params.add(Params.VERBOSE); // Parameters + params.add(Params.BOSS_ALG); params.add(Params.NUM_STARTS); - + params.add(Params.DEPTH); return params; } @@ -165,23 +96,4 @@ public void setScoreWrapper(ScoreWrapper score) { this.score = score; } - @Override - public Knowledge getKnowledge() { - return this.knowledge.copy(); - } - - @Override - public void setKnowledge(Knowledge knowledge) { - this.knowledge = new Knowledge((Knowledge) knowledge); - } - - @Override - public void setIndependenceWrapper(IndependenceWrapper test) { - this.test = test; - } - - @Override - public IndependenceWrapper getIndependenceWrapper() { - return this.test; - } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSDC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSDC.java index 323bf7a746..d157a3f0b5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSDC.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSDC.java @@ -3,14 +3,13 @@ import edu.cmu.tetrad.algcomparison.algorithm.Algorithm; import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper; -import edu.cmu.tetrad.annotation.AlgType; import edu.cmu.tetrad.annotation.Bootstrapping; import edu.cmu.tetrad.annotation.Experimental; import edu.cmu.tetrad.data.DataModel; import edu.cmu.tetrad.data.DataType; import edu.cmu.tetrad.graph.EdgeListGraph; import edu.cmu.tetrad.graph.Graph; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.BossDC; import edu.cmu.tetrad.search.Score; import edu.cmu.tetrad.util.Parameters; @@ -51,11 +50,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { BossDC boss = new BossDC(score); if (parameters.getInt(Params.BOSS_ALG) == 1) { - boss.setAlgType(Boss.AlgType.BOSS1); + boss.setAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - boss.setAlgType(Boss.AlgType.BOSS2); + boss.setAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - boss.setAlgType(Boss.AlgType.BOSS3); + boss.setAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSOLD.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSOLD.java new file mode 100644 index 0000000000..80d8dbfec8 --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSOLD.java @@ -0,0 +1,188 @@ +package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag; + +import edu.cmu.tetrad.algcomparison.algorithm.Algorithm; +import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper; +import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; +import edu.cmu.tetrad.algcomparison.utils.HasKnowledge; +import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper; +import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper; +import edu.cmu.tetrad.annotation.AlgType; +import edu.cmu.tetrad.annotation.Bootstrapping; +import edu.cmu.tetrad.annotation.Experimental; +import edu.cmu.tetrad.data.DataModel; +import edu.cmu.tetrad.data.DataSet; +import edu.cmu.tetrad.data.DataType; +import edu.cmu.tetrad.data.Knowledge; +import edu.cmu.tetrad.graph.EdgeListGraph; +import edu.cmu.tetrad.graph.Graph; +import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.search.BossOld; +import edu.cmu.tetrad.search.IndependenceTest; +import edu.cmu.tetrad.search.Score; +import edu.cmu.tetrad.search.TimeSeriesUtils; +import edu.cmu.tetrad.util.Parameters; +import edu.cmu.tetrad.util.Params; +import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest; + +import java.util.ArrayList; +import java.util.List; + +/** + * BOSS (Best Order Score Search) + * + * @author bryanandrews + * @author josephramsey + */ +//@edu.cmu.tetrad.annotation.Algorithm( +// name = "BOSS-OLD", +// command = "boss-old", +// algoType = AlgType.forbid_latent_common_causes +//) +@Bootstrapping +@Experimental +@Deprecated +public class BOSSOLD implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, HasKnowledge { + static final long serialVersionUID = 23L; + private ScoreWrapper score; + private IndependenceWrapper test; + private Knowledge knowledge = new Knowledge(); + + public BOSSOLD() { + // Used in reflection; do not delete. + } + +// public BOSS(ScoreWrapper score) { +// this.score = score; +// } + + public BOSSOLD(IndependenceWrapper test, ScoreWrapper score) { + this.test = test; + this.score = score; + } + + @Override + public Graph search(DataModel dataModel, Parameters parameters) { + if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) { + if (parameters.getInt(Params.TIME_LAG) > 0) { + DataSet dataSet = (DataSet) dataModel; + DataSet timeSeries = TimeSeriesUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG)); + if (dataSet.getName() != null) { + timeSeries.setName(dataSet.getName()); + } + dataModel = timeSeries; + knowledge = timeSeries.getKnowledge(); + } + + Score score = this.score.getScore(dataModel, parameters); + IndependenceTest test = this.test.getTest(dataModel, parameters); + + BossOld bossOld = new BossOld(test, score); + + if (parameters.getInt(Params.BOSS_ALG) == 1) { + bossOld.setAlgType(BossOld.AlgType.BOSS1); + } else if (parameters.getInt(Params.BOSS_ALG) == 2) { + bossOld.setAlgType(BossOld.AlgType.BOSS2); + } else if (parameters.getInt(Params.BOSS_ALG) == 3) { + bossOld.setAlgType(BossOld.AlgType.BOSS3); + } else { + throw new IllegalArgumentException("Unrecognized boss algorithm type."); + } + + bossOld.setDepth(parameters.getInt(Params.DEPTH)); + bossOld.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER)); + bossOld.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE)); + bossOld.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER)); + bossOld.setVerbose(parameters.getBoolean(Params.VERBOSE)); + bossOld.setNumStarts(parameters.getInt(Params.NUM_STARTS)); + bossOld.setCaching(parameters.getBoolean(Params.CACHE_SCORES)); + + bossOld.setKnowledge(this.knowledge); + + bossOld.bestOrder(new ArrayList(score.getVariables())); + return bossOld.getGraph(true); + } else { + BOSSOLD algorithm = new BOSSOLD(this.test, this.score); + + DataSet data = (DataSet) dataModel; + GeneralResamplingTest search = new GeneralResamplingTest( + data, + algorithm, + parameters.getInt(Params.NUMBER_RESAMPLING), + parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), + parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), + parameters.getInt(Params.RESAMPLING_ENSEMBLE), + parameters.getBoolean(Params.ADD_ORIGINAL_DATASET)); + search.setKnowledge(this.knowledge); + + search.setParameters(parameters); + search.setVerbose(parameters.getBoolean(Params.VERBOSE)); + return search.search(); + } + } + + @Override + public Graph getComparisonGraph(Graph graph) { + return new EdgeListGraph(graph); + } + + @Override + public String getDescription() { + return "BOSS (Best Order Score Search) using " + this.score.getDescription(); + } + + @Override + public DataType getDataType() { + return this.score.getDataType(); + } + + @Override + public List getParameters() { + ArrayList params = new ArrayList<>(); + + // Flags + params.add(Params.BOSS_ALG); + params.add(Params.DEPTH); + params.add(Params.GRASP_USE_SCORE); + params.add(Params.GRASP_USE_RASKUTTI_UHLER); + params.add(Params.GRASP_USE_DATA_ORDER); + params.add(Params.TIME_LAG); + params.add(Params.CACHE_SCORES); + params.add(Params.VERBOSE); + + // Parameters + params.add(Params.NUM_STARTS); + + + return params; + } + + @Override + public ScoreWrapper getScoreWrapper() { + return this.score; + } + + @Override + public void setScoreWrapper(ScoreWrapper score) { + this.score = score; + } + + @Override + public Knowledge getKnowledge() { + return this.knowledge.copy(); + } + + @Override + public void setKnowledge(Knowledge knowledge) { + this.knowledge = new Knowledge((Knowledge) knowledge); + } + + @Override + public void setIndependenceWrapper(IndependenceWrapper test) { + this.test = test; + } + + @Override + public IndependenceWrapper getIndependenceWrapper() { + return this.test; + } +} diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCI.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCI.java index 6f1b194dd7..d1ec14e462 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCI.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCI.java @@ -15,7 +15,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.search.BFci; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; import edu.cmu.tetrad.util.Params; @@ -78,11 +78,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { BFci search = new BFci(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setAlgType(Boss.AlgType.BOSS1); + search.setAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setAlgType(Boss.AlgType.BOSS2); + search.setAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - search.setAlgType(Boss.AlgType.BOSS3); + search.setAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCIFinalOrientationOnly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCIFinalOrientationOnly.java index 2fc07d768c..5866f24cc8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCIFinalOrientationOnly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCIFinalOrientationOnly.java @@ -12,7 +12,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.search.BfciFoo; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; import edu.cmu.tetrad.util.Params; @@ -75,9 +75,9 @@ public Graph search(DataModel dataModel, Parameters parameters) { BfciFoo search = new BfciFoo(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setAlgType(Boss.AlgType.BOSS1); + search.setAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setAlgType(Boss.AlgType.BOSS2); + search.setAlgType(BossOld.AlgType.BOSS2); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCITR.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCITR.java index f8f3ed6c36..156fcfde5e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCITR.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BFCITR.java @@ -12,7 +12,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.search.BfciTr; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; import edu.cmu.tetrad.util.Params; @@ -75,11 +75,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { BfciTr search = new BfciTr(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setAlgType(Boss.AlgType.BOSS1); + search.setAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setAlgType(Boss.AlgType.BOSS2); + search.setAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - search.setAlgType(Boss.AlgType.BOSS3); + search.setAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_1.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_1.java index 42806ca57d..a744f6161d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_1.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_1.java @@ -15,7 +15,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.graph.LayoutUtil; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.LvSwap; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; @@ -73,11 +73,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { LvSwap search = new LvSwap(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setBossAlgType(Boss.AlgType.BOSS1); + search.setBossAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setBossAlgType(Boss.AlgType.BOSS2); + search.setBossAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - search.setBossAlgType(Boss.AlgType.BOSS3); + search.setBossAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2a.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2a.java index 8f6a768641..95113cf7cd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2a.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2a.java @@ -15,7 +15,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.graph.LayoutUtil; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.LvSwap; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; @@ -73,11 +73,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { LvSwap search = new LvSwap(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setBossAlgType(Boss.AlgType.BOSS1); + search.setBossAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setBossAlgType(Boss.AlgType.BOSS2); + search.setBossAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - search.setBossAlgType(Boss.AlgType.BOSS3); + search.setBossAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2b.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2b.java index b6045f6e6a..f78360769f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2b.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LVSWAP_2b.java @@ -15,7 +15,7 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.graph.LayoutUtil; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import edu.cmu.tetrad.search.LvSwap; import edu.cmu.tetrad.search.TimeSeriesUtils; import edu.cmu.tetrad.util.Parameters; @@ -73,11 +73,11 @@ public Graph search(DataModel dataModel, Parameters parameters) { LvSwap search = new LvSwap(this.test.getTest(dataModel, parameters), this.score.getScore(dataModel, parameters)); if (parameters.getInt(Params.BOSS_ALG) == 1) { - search.setBossAlgType(Boss.AlgType.BOSS1); + search.setBossAlgType(BossOld.AlgType.BOSS1); } else if (parameters.getInt(Params.BOSS_ALG) == 2) { - search.setBossAlgType(Boss.AlgType.BOSS2); + search.setBossAlgType(BossOld.AlgType.BOSS2); } else if (parameters.getInt(Params.BOSS_ALG) == 3) { - search.setBossAlgType(Boss.AlgType.BOSS3); + search.setBossAlgType(BossOld.AlgType.BOSS3); } else { throw new IllegalArgumentException("Unrecognized boss algorithm type."); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestBoss.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestBoss.java index 11911cdae2..a891a0704e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestBoss.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestBoss.java @@ -23,14 +23,10 @@ import edu.cmu.tetrad.algcomparison.Comparison; import edu.cmu.tetrad.algcomparison.algorithm.Algorithms; -import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BDCE; -import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BOSS; -import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BOSSDC; -import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges; +import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BOSSOLD; import edu.cmu.tetrad.algcomparison.graph.RandomForward; import edu.cmu.tetrad.algcomparison.independence.FisherZ; import edu.cmu.tetrad.algcomparison.score.SemBicScore; -import edu.cmu.tetrad.algcomparison.score.ZhangShenBoundScore; import edu.cmu.tetrad.algcomparison.simulation.SemSimulation; import edu.cmu.tetrad.algcomparison.simulation.Simulations; import edu.cmu.tetrad.algcomparison.statistic.*; @@ -70,7 +66,7 @@ public static void main(String... args) { Algorithms algorithms = new Algorithms(); // algorithms.add(new Fges(new SemBicScore())); - algorithms.add(new BOSS(new FisherZ(), new SemBicScore())); + algorithms.add(new BOSSOLD(new FisherZ(), new SemBicScore())); // algorithms.add(new BDCE(new SemBicScore())); // algorithms.add(new BOSSDC(new SemBicScore())); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BFci.java index cfcf69d427..478222366c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BFci.java @@ -88,7 +88,7 @@ public final class BFci implements GraphSearch { private boolean useScore = true; private boolean doDiscriminatingPathRule = true; private boolean possibleDsepSearchDone = true; - private Boss.AlgType bossType = Boss.AlgType.BOSS1; + private BossOld.AlgType bossType = BossOld.AlgType.BOSS1; //============================CONSTRUCTORS============================// public BFci(IndependenceTest test, Score score) { @@ -112,7 +112,7 @@ public Graph search() { TeyssierScorer scorer = new TeyssierScorer(independenceTest, score); // Run BOSS-tuck to get a CPDAG (like GFCI with FGES)... - Boss alg = new Boss(scorer); + BossOld alg = new BossOld(scorer); alg.setAlgType(bossType); alg.setUseScore(useScore); alg.setUseRaskuttiUhler(useRaskuttiUhler); @@ -411,7 +411,7 @@ public void setPossibleDsepSearchDone(boolean possibleDsepSearchDone) { this.possibleDsepSearchDone = possibleDsepSearchDone; } - public void setAlgType(Boss.AlgType type) { + public void setAlgType(BossOld.AlgType type) { this.bossType = type; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciFoo.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciFoo.java index 53fe102fcb..2a931ffd80 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciFoo.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciFoo.java @@ -72,7 +72,7 @@ public final class BfciFoo implements GraphSearch { private boolean useScore = true; private boolean doDiscriminatingPathRule = true; private Knowledge knowledge = new Knowledge(); - private Boss.AlgType algType = Boss.AlgType.BOSS1; + private BossOld.AlgType algType = BossOld.AlgType.BOSS1; //============================CONSTRUCTORS============================// public BfciFoo(IndependenceTest test, Score score) { @@ -88,20 +88,20 @@ public Graph search() { TeyssierScorer scorer = new TeyssierScorer(test, score); // Run BOSS-tuck to get a CPDAG (like GFCI with FGES)... - Boss boss = new Boss(scorer); - boss.setAlgType(algType); - boss.setUseScore(useScore); - boss.setUseRaskuttiUhler(useRaskuttiUhler); - boss.setUseDataOrder(useDataOrder); - boss.setDepth(depth); - boss.setNumStarts(numStarts); - boss.setVerbose(false); + BossOld bossOld = new BossOld(scorer); + bossOld.setAlgType(algType); + bossOld.setUseScore(useScore); + bossOld.setUseRaskuttiUhler(useRaskuttiUhler); + bossOld.setUseDataOrder(useDataOrder); + bossOld.setDepth(depth); + bossOld.setNumStarts(numStarts); + bossOld.setVerbose(false); List variables = this.score.getVariables(); assert variables != null; - boss.bestOrder(variables); - Graph graph = boss.getGraph(false); // Get the DAG + bossOld.bestOrder(variables); + Graph graph = bossOld.getGraph(false); // Get the DAG if (score instanceof edu.cmu.tetrad.search.MagSemBicScore) { ((edu.cmu.tetrad.search.MagSemBicScore) score).setMag(graph); @@ -436,7 +436,7 @@ public void setKnowledge(Knowledge knowledge) { this.knowledge = new Knowledge((Knowledge) knowledge); } - public void setAlgType(Boss.AlgType algType) { + public void setAlgType(BossOld.AlgType algType) { this.algType = algType; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciTr.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciTr.java index e11afd0af0..167b8630e7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciTr.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BfciTr.java @@ -77,7 +77,7 @@ public final class BfciTr implements GraphSearch { private boolean doDiscriminatingPathRule = true; private boolean possibleDsepSearchDone = true; private Knowledge knowledge = new Knowledge(); - private Boss.AlgType algType = Boss.AlgType.BOSS1; + private BossOld.AlgType algType = BossOld.AlgType.BOSS1; //============================CONSTRUCTORS============================// public BfciTr(IndependenceTest test, Score score) { @@ -93,21 +93,21 @@ public Graph search() { TeyssierScorer scorer = new TeyssierScorer(test, score); // Run BOSS-tuck to get a CPDAG (like GFCI with FGES)... - Boss boss = new Boss(scorer); - boss.setAlgType(algType); - boss.setUseScore(useScore); - boss.setUseRaskuttiUhler(useRaskuttiUhler); - boss.setUseDataOrder(useDataOrder); - boss.setDepth(depth); - boss.setNumStarts(numStarts); - boss.setCaching(true); - boss.setVerbose(false); // Get the DAG + BossOld bossOld = new BossOld(scorer); + bossOld.setAlgType(algType); + bossOld.setUseScore(useScore); + bossOld.setUseRaskuttiUhler(useRaskuttiUhler); + bossOld.setUseDataOrder(useDataOrder); + bossOld.setDepth(depth); + bossOld.setNumStarts(numStarts); + bossOld.setCaching(true); + bossOld.setVerbose(false); // Get the DAG List variables = this.score.getVariables(); assert variables != null; - boss.bestOrder(variables); - Graph graph = boss.getGraph(false); + bossOld.bestOrder(variables); + Graph graph = bossOld.getGraph(false); // if (true) return graph; @@ -350,7 +350,7 @@ public void setKnowledge(Knowledge knowledge) { this.knowledge = new Knowledge((Knowledge) knowledge); } - public void setAlgType(Boss.AlgType algType) { + public void setAlgType(BossOld.AlgType algType) { this.algType = algType; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java index e42beacd5e..6510c22ab1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Boss.java @@ -1,20 +1,10 @@ package edu.cmu.tetrad.search; -import edu.cmu.tetrad.data.Knowledge; -import edu.cmu.tetrad.data.KnowledgeEdge; -import edu.cmu.tetrad.graph.*; -import edu.cmu.tetrad.util.JOptionUtils; -import edu.cmu.tetrad.util.MillisecondTimes; -import edu.cmu.tetrad.util.NumberFormatUtil; -import edu.cmu.tetrad.util.TetradLogger; -import org.jetbrains.annotations.NotNull; - -import javax.swing.*; -import java.text.NumberFormat; -import java.util.*; +import edu.cmu.tetrad.graph.EdgeListGraph; +import edu.cmu.tetrad.graph.Graph; +import edu.cmu.tetrad.graph.Node; -import static edu.cmu.tetrad.util.RandomUtil.shuffle; -import static java.lang.Double.NEGATIVE_INFINITY; +import java.util.*; /** * Implements the BOSS algorithm. @@ -23,496 +13,139 @@ * @author josephramsey */ public class Boss { + private List order; private final List variables; - private final Score score; - private IndependenceTest test; - private Knowledge knowledge = new Knowledge(); - private final TeyssierScorer scorer; - private long start; - long stop; - private boolean useScore = true; - private boolean useRaskuttiUhler; - private boolean useDataOrder = true; - private boolean verbose = true; + private final Map> parents; + private final Map scores; + private final GrowShrinkTree gst; + private final Bes bes; private int depth = -1; private int numStarts = 1; - private AlgType algType = AlgType.BOSS1; - private boolean caching = true; - private double epsilon = 1e-10; - - public Boss(@NotNull IndependenceTest test, Score score) { - this.test = test; - this.score = score; - this.variables = new ArrayList<>(score.getVariables()); - this.useScore = true; - this.scorer = new TeyssierScorer(this.test, this.score); - } - - public Boss(Score score) { - this.test = null; - this.score = score; - this.variables = new ArrayList<>(score.getVariables()); - this.useScore = true; - this.scorer = new TeyssierScorer(null, this.score); - } - - public Boss(TeyssierScorer scorer) { - this.scorer = scorer; - this.score = scorer.getScoreObject(); - this.variables = new ArrayList<>(scorer.getPi()); - } - - public List bestOrder(@NotNull List order) { - - scorer.setCachingScores(caching); - scorer.setKnowledge(knowledge); - - List bestPerm; - long start = MillisecondTimes.timeMillis(); - order = new ArrayList<>(order); - - this.scorer.setUseRaskuttiUhler(this.useRaskuttiUhler); - - if (this.useRaskuttiUhler) { - this.scorer.setUseScore(false); - } else { - this.scorer.setUseScore(this.useScore && !(this.score instanceof GraphScore)); - } - - this.scorer.setKnowledge(this.knowledge); - this.scorer.clearBookmarks(); - - bestPerm = null; - double best = NEGATIVE_INFINITY; - - this.scorer.score(order); - - for (int r = 0; r < this.numStarts; r++) { - if ((r == 0 && !this.useDataOrder) || r > 0) { - shuffle(order); - } - - this.start = MillisecondTimes.timeMillis(); - - makeValidKnowledgeOrder(order); - - double s1, s2; - - int count = 0; -// boolean ensureMinimumCount = score instanceof ZhangShenBoundScore; - - if (algType == AlgType.BOSS1) { - betterMutation1(scorer); - } else if (algType == AlgType.BOSS2) { - betterMutation2(scorer); - } else if (algType == AlgType.BOSS3) { - betterMutationBryan(scorer); - } - - do { - s1 = scorer.score(); - - if (algType == AlgType.BOSS1) { - besMutation(scorer); - betterMutation1(scorer); - } else if (algType == AlgType.BOSS2) { - besMutation(scorer); - betterMutation2(scorer); - } else if (algType == AlgType.BOSS3) { - besMutation(scorer); - betterMutationBryan(scorer); - } - - s2 = scorer.score(); - } while (s2 > s1); - - if (this.scorer.score() > best) { - best = this.scorer.score(); - bestPerm = scorer.getPi(); - } - } - - this.scorer.score(bestPerm); - - this.stop = MillisecondTimes.timeMillis(); + private boolean verbose = true; + private BossOld.AlgType algType = BossOld.AlgType.BOSS1; +// private double epsilon = 1e-10; - if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("\nFinal " + algType + " order = " + this.scorer.getPi()); - TetradLogger.getInstance().forceLogMessage("Final score = " + this.scorer.score()); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (stop - start) / 1000.0 + " s"); - } - return bestPerm; - } + public Boss(Score score) { + this.order = new LinkedList<>(score.getVariables()); + this.variables = score.getVariables(); + this.parents = new HashMap<>(); + this.scores = new HashMap<>(); + this.gst = new GrowShrinkTree(score); + this.bes = new Bes(score); + this.bes.setDepth(this.depth); + this.bes.setVerbose(false); -// public void betterMutation1(@NotNull TeyssierScorer scorer) { -// double bestScore = scorer.score(); -// scorer.bookmark(); -// double s1, s2; -// -// Set introns1; -// Set introns2; -// -// introns2 = new HashSet<>(scorer.getPi()); -// -// int[] range = new int[2]; -// -// do { -// s1 = scorer.score(); -// -// introns1 = introns2; -// introns2 = new HashSet<>(); -// -// for (int i = 1; i < scorer.size(); i++) { -// Node x = scorer.get(i); -// if (!introns1.contains(x)) continue; -// -// scorer.bookmark(1); -// -// for (int j = i - 1; j >= 0; j--) { -// if (!scorer.adjacent(scorer.get(j), x)) continue; -// -// tuck(x, j, scorer, range); -// -// if (scorer.score() < bestScore || violatesKnowledge(scorer.getPi())) { -// scorer.goToBookmark(); -// } else { -// bestScore = scorer.score(); -// -// for (int l = range[0]; l <= range[1]; l++) { -// introns2.add(scorer.get(l)); -// } -// } -// -// scorer.bookmark(); -// -// if (verbose) { -// System.out.print("\rIndex = " + (i + 1) + " Score = " + scorer.score() + " (betterMutation1)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); -// } -// } -// } -// -// if (verbose) { -// System.out.println(); -// } -// -// s2 = scorer.score(); -// } while (s2 > s1); -// -// scorer.goToBookmark(1); -// } - - public void betterMutation1(@NotNull TeyssierScorer scorer) { - double bestScore = scorer.score(); - double originalScore; - scorer.bookmark(); - - Set introns1; - Set introns2; - - introns2 = new HashSet<>(scorer.getPi()); - int[] range = new int[2]; - - do { - originalScore = bestScore; - - introns1 = introns2; - introns2 = new HashSet<>(); - - for (int i = 1; i < scorer.size(); i++) { - Node x = scorer.get(i); - if (!introns1.contains(x)) continue; - - for (int j = i - 1; j >= 0; j--) { - if (!scorer.adjacent(scorer.get(j), x)) continue; - - tuck(x, j, scorer, range); - - if (scorer.score() > bestScore + epsilon || violatesKnowledge(scorer.getPi())) { - for (int l = range[0]; l <= range[1]; l++) { - introns2.add(scorer.get(l)); - } - bestScore = scorer.score(); - scorer.bookmark(); - } else { - scorer.goToBookmark(); - } - - if (verbose) { - System.out.print("\rIndex = " + (i + 1) + " Score = " + scorer.score() + " (betterMutationTuck)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); - System.out.print("\r# Edges = " + scorer.getNumEdges() + " Index = " + (i + 1) + " Score = " + scorer.score() + " (betterMutationTuck)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); - } - } - } - if (verbose) { - System.out.println(); - } - } while (bestScore > originalScore + epsilon); + for (Node x : this.order) this.parents.put(x, new HashSet<>()); } + public Graph search() { +// shuffle(this.order); - public void betterMutation2(@NotNull TeyssierScorer scorer) { - scorer.bookmark(); - double s1, s2; - - do { - s1 = scorer.score(); - scorer.bookmark(1); - - for (Node k : scorer.getPi()) { - double _sp = NEGATIVE_INFINITY; - scorer.bookmark(); - - for (int j = 0; j < scorer.size(); j++) { - scorer.moveTo(k, j); - - if (scorer.score() >= _sp + epsilon) { - if (!violatesKnowledge(scorer.getPi())) { - _sp = scorer.score(); - scorer.bookmark(); - - if (verbose) { - System.out.print("\rIndex = " + (scorer.index(k) + 1) + " Score = " + scorer.score() + " (betterMutation2)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); - } - } - } + double s1, s2, s3; + s1 = this.update(); + do { s2 = s1; + do { s3 = s1; + for (Node x : new ArrayList<>(this.order)) { + if (betterMutation(x)) s1 = update(); } + } while(s1 > s3); - scorer.goToBookmark(); - } - - if (verbose) { - System.out.println(); - } + do { s3 = s1; + Graph graph = this.getGraph(true); + this.bes.bes(graph, this.variables); + this.order = new LinkedList<>(graph.paths().validOrder(this.order, true)); + s1 = update(); + } while(s1 > s3); - s2 = scorer.score(); - } while (s2 > s1 + epsilon); + } while(s1 > s2); - scorer.goToBookmark(1); + return this.getGraph(true); } - public void betterMutationBryan(@NotNull TeyssierScorer scorer) { - double bestScore = scorer.score(); - scorer.bookmark(); - double s1, s2; - - Set introns1; - Set introns2; - - introns2 = new HashSet<>(scorer.getPi()); + public boolean betterMutation(Node x) { + ListIterator itr = this.order.listIterator(); + double[] scores = new double[this.order.size() + 1]; + int i = 0; - int[] range = new int[2]; + Set Z = new HashSet<>(); + double score = 0; + int curr = 0; - do { - s1 = scorer.score(); - - introns1 = introns2; - introns2 = new HashSet<>(); - - List> edges = scorer.getEdges(); - int m = 0; - int all = edges.size(); - - for (OrderedPair edge : edges) { - m++; - Node x = edge.getFirst(); - Node y = edge.getSecond(); - if (scorer.index(x) > scorer.index(y)) continue; - if (!scorer.adjacent(y, x)) continue; - if (!introns1.contains(y) && !introns1.contains(x)) continue; - - tuck(y, scorer.index(x), scorer, range); - - if (scorer.score() < bestScore || violatesKnowledge(scorer.getPi())) { - scorer.goToBookmark(); - } else { - bestScore = scorer.score(); - - for (int l = range[0]; l <= range[1]; l++) { - introns2.add(scorer.get(l)); - } - - if (verbose) { - System.out.print("\r Score " + m + " / " + all + " = " + scorer.score() + " (boss)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); - } - } - - scorer.bookmark(); + while (itr.hasNext()) { + Node z = itr.next(); + scores[i++] = this.gst.growShrink(x, new HashSet<>(Z), new HashSet<>()) + score; + if (z != x) { + score += this.gst.growShrink(z, new HashSet<>(Z), new HashSet<>()); + Z.add(z); + } else curr = i - 1; + } + scores[i] = this.gst.growShrink(x, new HashSet<>(Z), new HashSet<>()) + score; - if (verbose) { - System.out.print("\r Score " + m + " / " + all + " = " + scorer.score() + " (boss)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); - } - } + Z.add(x); + score = 0; + int best = i; - if (verbose) { - System.out.println(); + while (itr.hasPrevious()) { + Node z = itr.previous(); + if (z != x) { + Z.remove(z); + score += this.gst.growShrink(z, new HashSet<>(Z), new HashSet<>()); } + scores[--i] += score; + if (scores[i] > scores[best]) best = i; + } - s2 = scorer.score(); - } while (s2 > s1); - } - - - public void tubes(@NotNull TeyssierScorer scorer) { - double s; - - do { - s = scorer.score(); - - for (NodePair edge : scorer.getAdjacencies()) { - Node x = edge.getFirst(); - Node y = edge.getSecond(); - if (!scorer.adjacent(x, y)) continue; - - scorer.bookmark(); - - tuck(y, scorer.index(x), scorer, new int[2]); +// if (scores[best] > scores[curr] + this.epsilon) return false; + if (best == curr) return false; + else if (best > curr) best--; - if (scorer.score() >= s) { - besMutation(scorer); - } else { - scorer.goToBookmark(); - } - } + this.order.remove(curr); + this.order.add(best, x); - } while (scorer.score() > s); + return true; } + private double update() { + double score = 0; - private void tuck(Node k, int j, TeyssierScorer scorer, int[] range) { - if (scorer.index(k) < j) return; - Set ancestors = scorer.getAncestors(k); - - int minIndex = j; - - for (int i = j + 1; i <= scorer.index(k); i++) { - if (ancestors.contains(scorer.get(i))) { - scorer.moveTo(scorer.get(i), j++); - } + Iterator itr = this.order.iterator(); + Set Z = new HashSet<>(); + while (itr.hasNext()) { + Node x = itr.next(); + this.parents.get(x).clear(); + this.scores.put(x, this.gst.growShrink(x, new HashSet<>(Z), this.parents.get(x))); + score += this.scores.get(x); + Z.add(x); } - range[0] = minIndex; - range[1] = scorer.index(k); + return score; } - public void besMutation(TeyssierScorer scorer) { - Graph graph = scorer.getGraph(true); - Bes bes = new Bes(score); - bes.setDepth(depth); - bes.setVerbose(false); - bes.setKnowledge(knowledge); - bes.bes(graph, scorer.getPi()); - List pi = graph.paths().validOrder(scorer.getPi(), true); - scorer.score(pi); - } - - public int getNumEdges() { - return this.scorer.getNumEdges(); - } - - private void makeValidKnowledgeOrder(List order) { - if (!this.knowledge.isEmpty()) { - order.sort((o1, o2) -> { - if (o1.getName().equals(o2.getName())) { - return 0; - } else if (this.knowledge.isRequired(o1.getName(), o2.getName())) { - return -1; - } else if (this.knowledge.isRequired(o2.getName(), o1.getName())) { - return 1; - } else if (this.knowledge.isForbidden(o1.getName(), o2.getName())) { - return 1; - } else if (this.knowledge.isForbidden(o2.getName(), o1.getName())) { - return -1; - } else { - return 0; - } - }); - } - - if (violatesKnowledge(order)) { - Edge edge = violatesForbiddenKnowledge(order); - - if (edge != null) { - JOptionPane.showMessageDialog (JOptionUtils.centeringComp(), - "The initial sorting procedure could not find a permutation consistent with that \n" + - "knowledge; this edge was in the DAG: " + edge + " in the initial sort,\n" + - "but this edge was forbidden."); - } - - Edge edge2 = violatesRequiredKnowledge(order); + private Graph getGraph(boolean cpDag) { + Graph graph = new EdgeListGraph(this.order); - if (edge2 != null) { - JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), - "The initial sorting procedure could not find a permutation consistent with that \n" + - "knowledge; this edge was not in the DAG: " + edge2 + " in the initial sorted," + - "but this edge was required."); + for (Node a : this.order) { + for (Node b : this.parents.get(a)) { + graph.addDirectedEdge(b, a); } } - System.out.println("Initial knowledge sort order = " + order); - - if (violatesKnowledge(order)) { - throw new IllegalArgumentException("The initial sorting procedure could not find a permutation " + - "consistent with that knowledge."); + if (cpDag) { + MeekRules rules = new MeekRules(); + rules.orientImplied(graph); } - } - public Graph getGraph(boolean cpDag) { - if (this.scorer == null) throw new IllegalArgumentException("Please run algorithm first."); - Graph graph = this.scorer.getGraph(cpDag); - - NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); - graph.addAttribute("score ", nf.format(this.scorer.score())); return graph; } - public void orientbk(Knowledge bk, Graph graph, List variables) { - for (Iterator it = bk.forbiddenEdgesIterator(); it.hasNext(); ) { - KnowledgeEdge edge = it.next(); - - //match strings to variables in the graph. - Node from = SearchGraphUtils.translate(edge.getFrom(), variables); - Node to = SearchGraphUtils.translate(edge.getTo(), variables); - - if (from == null || to == null) { - continue; - } - - if (graph.getEdge(from, to) == null) { - continue; - } - - // Orient to*->from - graph.setEndpoint(to, from, Endpoint.ARROW); - } - - for (Iterator it = bk.requiredEdgesIterator(); it.hasNext(); ) { - KnowledgeEdge edge = it.next(); - - //match strings to variables in the graph. - Node from = SearchGraphUtils.translate(edge.getFrom(), variables); - Node to = SearchGraphUtils.translate(edge.getTo(), variables); - - if (from == null || to == null) { - continue; - } - - if (graph.getEdge(from, to) == null) { - continue; - } - - // Orient to*->from - graph.setEndpoint(from, to, Endpoint.ARROW); - } - } - public void setNumStarts(int numStarts) { this.numStarts = numStarts; } public List getVariables() { - return this.variables; + return new ArrayList<>(this.variables); } public boolean isVerbose() { @@ -523,84 +156,14 @@ public void setVerbose(boolean verbose) { this.verbose = verbose; } - public void setKnowledge(Knowledge knowledge) { - this.knowledge = new Knowledge((Knowledge) knowledge); - } - public void setDepth(int depth) { if (depth < -1) throw new IllegalArgumentException("Depth should be >= -1."); this.depth = depth; } - public void setUseScore(boolean useScore) { - this.useScore = useScore; - } - - private boolean violatesKnowledge(List order) { - if (!this.knowledge.isEmpty()) { - for (int i = 0; i < order.size(); i++) { - for (int j = i + 1; j < order.size(); j++) { - if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName())) { - return true; - } - - if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName())) { - return true; - } - } - } - } - - return false; - } - - private Edge violatesForbiddenKnowledge(List order) { - if (!this.knowledge.isEmpty()) { - scorer.score(order); - - for (int i = 0; i < order.size(); i++) { - for (int j = i + 1; j < order.size(); j++) { - if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName()) && scorer.parent(order.get(i), order.get(j))) { - return Edges.directedEdge(order.get(i), order.get(j)); - } - } - } - } - - return null; - } - - private Edge violatesRequiredKnowledge(List order) { - if (!this.knowledge.isEmpty()) { - scorer.score(order); - - for (int i = 0; i < order.size(); i++) { - for (int j = i + 1; j < order.size(); j++) { - if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName()) && !scorer.parent(order.get(i), order.get(j))) { - return Edges.directedEdge(order.get(j), order.get(i)); - } - } - } - } - - return null; - } - - public void setUseRaskuttiUhler(boolean useRaskuttiUhler) { - this.useRaskuttiUhler = useRaskuttiUhler; - } - - public void setUseDataOrder(boolean useDataOrder) { - this.useDataOrder = useDataOrder; - } - - public void setAlgType(AlgType algType) { + public void setAlgType(BossOld.AlgType algType) { this.algType = algType; } - public void setCaching(boolean caching) { - this.caching = caching; - } - - public enum AlgType {BOSS1, BOSS2, BOSS3} + public enum AlgType {BOSS1} } \ No newline at end of file diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossDC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossDC.java index f9f3c7d1e7..8e70f3fbe9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossDC.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossDC.java @@ -7,7 +7,6 @@ import java.text.NumberFormat; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.Set; @@ -28,7 +27,7 @@ public class BossDC { private boolean verbose = true; private int depth = -1; private int numStarts = 1; - private Boss.AlgType algType = Boss.AlgType.BOSS1; + private BossOld.AlgType algType = BossOld.AlgType.BOSS1; private boolean caching = true; @@ -93,11 +92,11 @@ public void divide(@NotNull TeyssierScorer scorer, int a, int b, int c) { if (b < (c - 1)) { divide(scorer, b, (b + c) / 2, c); } - if (algType == Boss.AlgType.BOSS1) { + if (algType == BossOld.AlgType.BOSS1) { conquerRTL(scorer, a, b, c); - } else if (algType == Boss.AlgType.BOSS2){ + } else if (algType == BossOld.AlgType.BOSS2){ conquerLTR(scorer, a, b, c); - } else if (algType == Boss.AlgType.BOSS3){ + } else if (algType == BossOld.AlgType.BOSS3){ conquerMT(scorer, a, b, c); } } @@ -260,7 +259,7 @@ public void setUseDataOrder(boolean useDataOrder) { this.useDataOrder = useDataOrder; } - public void setAlgType(Boss.AlgType algType) { + public void setAlgType(BossOld.AlgType algType) { this.algType = algType; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossOld.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossOld.java new file mode 100644 index 0000000000..2995a9ab5e --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossOld.java @@ -0,0 +1,606 @@ +package edu.cmu.tetrad.search; + +import edu.cmu.tetrad.data.Knowledge; +import edu.cmu.tetrad.data.KnowledgeEdge; +import edu.cmu.tetrad.graph.*; +import edu.cmu.tetrad.util.JOptionUtils; +import edu.cmu.tetrad.util.MillisecondTimes; +import edu.cmu.tetrad.util.NumberFormatUtil; +import edu.cmu.tetrad.util.TetradLogger; +import org.jetbrains.annotations.NotNull; + +import javax.swing.*; +import java.text.NumberFormat; +import java.util.*; + +import static edu.cmu.tetrad.util.RandomUtil.shuffle; +import static java.lang.Double.NEGATIVE_INFINITY; + +/** + * Implements the BOSS algorithm. + * + * @author bryanandrews + * @author josephramsey + */ +public class BossOld { + private final List variables; + private final Score score; + private IndependenceTest test; + private Knowledge knowledge = new Knowledge(); + private final TeyssierScorer scorer; + private long start; + long stop; + private boolean useScore = true; + private boolean useRaskuttiUhler; + private boolean useDataOrder = true; + private boolean verbose = true; + private int depth = -1; + private int numStarts = 1; + private AlgType algType = AlgType.BOSS1; + private boolean caching = true; + private double epsilon = 1e-10; + + public BossOld(@NotNull IndependenceTest test, Score score) { + this.test = test; + this.score = score; + this.variables = new ArrayList<>(score.getVariables()); + this.useScore = true; + this.scorer = new TeyssierScorer(this.test, this.score); + } + + public BossOld(Score score) { + this.test = null; + this.score = score; + this.variables = new ArrayList<>(score.getVariables()); + this.useScore = true; + this.scorer = new TeyssierScorer(null, this.score); + } + + public BossOld(TeyssierScorer scorer) { + this.scorer = scorer; + this.score = scorer.getScoreObject(); + this.variables = new ArrayList<>(scorer.getPi()); + } + + public List bestOrder(@NotNull List order) { + + scorer.setCachingScores(caching); + scorer.setKnowledge(knowledge); + + List bestPerm; + long start = MillisecondTimes.timeMillis(); + order = new ArrayList<>(order); + + this.scorer.setUseRaskuttiUhler(this.useRaskuttiUhler); + + if (this.useRaskuttiUhler) { + this.scorer.setUseScore(false); + } else { + this.scorer.setUseScore(this.useScore && !(this.score instanceof GraphScore)); + } + + this.scorer.setKnowledge(this.knowledge); + this.scorer.clearBookmarks(); + + bestPerm = null; + double best = NEGATIVE_INFINITY; + + this.scorer.score(order); + + for (int r = 0; r < this.numStarts; r++) { + if ((r == 0 && !this.useDataOrder) || r > 0) { + shuffle(order); + } + + this.start = MillisecondTimes.timeMillis(); + + makeValidKnowledgeOrder(order); + + double s1, s2; + + int count = 0; +// boolean ensureMinimumCount = score instanceof ZhangShenBoundScore; + + if (algType == AlgType.BOSS1) { + betterMutation1(scorer); + } else if (algType == AlgType.BOSS2) { + betterMutation2(scorer); + } else if (algType == AlgType.BOSS3) { + betterMutationBryan(scorer); + } + + do { + s1 = scorer.score(); + + if (algType == AlgType.BOSS1) { + besMutation(scorer); + betterMutation1(scorer); + } else if (algType == AlgType.BOSS2) { + besMutation(scorer); + betterMutation2(scorer); + } else if (algType == AlgType.BOSS3) { + besMutation(scorer); + betterMutationBryan(scorer); + } + + s2 = scorer.score(); + } while (s2 > s1); + + if (this.scorer.score() > best) { + best = this.scorer.score(); + bestPerm = scorer.getPi(); + } + } + + this.scorer.score(bestPerm); + + this.stop = MillisecondTimes.timeMillis(); + + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage("\nFinal " + algType + " order = " + this.scorer.getPi()); + TetradLogger.getInstance().forceLogMessage("Final score = " + this.scorer.score()); + TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (stop - start) / 1000.0 + " s"); + } + + return bestPerm; + } + +// public void betterMutation1(@NotNull TeyssierScorer scorer) { +// double bestScore = scorer.score(); +// scorer.bookmark(); +// double s1, s2; +// +// Set introns1; +// Set introns2; +// +// introns2 = new HashSet<>(scorer.getPi()); +// +// int[] range = new int[2]; +// +// do { +// s1 = scorer.score(); +// +// introns1 = introns2; +// introns2 = new HashSet<>(); +// +// for (int i = 1; i < scorer.size(); i++) { +// Node x = scorer.get(i); +// if (!introns1.contains(x)) continue; +// +// scorer.bookmark(1); +// +// for (int j = i - 1; j >= 0; j--) { +// if (!scorer.adjacent(scorer.get(j), x)) continue; +// +// tuck(x, j, scorer, range); +// +// if (scorer.score() < bestScore || violatesKnowledge(scorer.getPi())) { +// scorer.goToBookmark(); +// } else { +// bestScore = scorer.score(); +// +// for (int l = range[0]; l <= range[1]; l++) { +// introns2.add(scorer.get(l)); +// } +// } +// +// scorer.bookmark(); +// +// if (verbose) { +// System.out.print("\rIndex = " + (i + 1) + " Score = " + scorer.score() + " (betterMutation1)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); +// } +// } +// } +// +// if (verbose) { +// System.out.println(); +// } +// +// s2 = scorer.score(); +// } while (s2 > s1); +// +// scorer.goToBookmark(1); +// } + + public void betterMutation1(@NotNull TeyssierScorer scorer) { + double bestScore = scorer.score(); + double originalScore; + scorer.bookmark(); + + Set introns1; + Set introns2; + + introns2 = new HashSet<>(scorer.getPi()); + int[] range = new int[2]; + + do { + originalScore = bestScore; + + introns1 = introns2; + introns2 = new HashSet<>(); + + for (int i = 1; i < scorer.size(); i++) { + Node x = scorer.get(i); + if (!introns1.contains(x)) continue; + + for (int j = i - 1; j >= 0; j--) { + if (!scorer.adjacent(scorer.get(j), x)) continue; + + tuck(x, j, scorer, range); + + if (scorer.score() > bestScore + epsilon || violatesKnowledge(scorer.getPi())) { + for (int l = range[0]; l <= range[1]; l++) { + introns2.add(scorer.get(l)); + } + bestScore = scorer.score(); + scorer.bookmark(); + } else { + scorer.goToBookmark(); + } + + if (verbose) { + System.out.print("\rIndex = " + (i + 1) + " Score = " + scorer.score() + " (betterMutationTuck)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); + System.out.print("\r# Edges = " + scorer.getNumEdges() + " Index = " + (i + 1) + " Score = " + scorer.score() + " (betterMutationTuck)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); + } + } + } + if (verbose) { + System.out.println(); + } + } while (bestScore > originalScore + epsilon); + } + + + public void betterMutation2(@NotNull TeyssierScorer scorer) { + scorer.bookmark(); + double s1, s2; + + do { + s1 = scorer.score(); + scorer.bookmark(1); + + for (Node k : scorer.getPi()) { + double _sp = NEGATIVE_INFINITY; + scorer.bookmark(); + + for (int j = 0; j < scorer.size(); j++) { + scorer.moveTo(k, j); + + if (scorer.score() >= _sp + epsilon) { + if (!violatesKnowledge(scorer.getPi())) { + _sp = scorer.score(); + scorer.bookmark(); + + if (verbose) { + System.out.print("\rIndex = " + (scorer.index(k) + 1) + " Score = " + scorer.score() + " (betterMutation2)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); + } + } + } + + } + + scorer.goToBookmark(); + } + + if (verbose) { + System.out.println(); + } + + s2 = scorer.score(); + } while (s2 > s1 + epsilon); + + scorer.goToBookmark(1); + } + + public void betterMutationBryan(@NotNull TeyssierScorer scorer) { + double bestScore = scorer.score(); + scorer.bookmark(); + double s1, s2; + + Set introns1; + Set introns2; + + introns2 = new HashSet<>(scorer.getPi()); + + int[] range = new int[2]; + + do { + s1 = scorer.score(); + + introns1 = introns2; + introns2 = new HashSet<>(); + + List> edges = scorer.getEdges(); + int m = 0; + int all = edges.size(); + + for (OrderedPair edge : edges) { + m++; + Node x = edge.getFirst(); + Node y = edge.getSecond(); + if (scorer.index(x) > scorer.index(y)) continue; + if (!scorer.adjacent(y, x)) continue; + if (!introns1.contains(y) && !introns1.contains(x)) continue; + + tuck(y, scorer.index(x), scorer, range); + + if (scorer.score() < bestScore || violatesKnowledge(scorer.getPi())) { + scorer.goToBookmark(); + } else { + bestScore = scorer.score(); + + for (int l = range[0]; l <= range[1]; l++) { + introns2.add(scorer.get(l)); + } + + if (verbose) { + System.out.print("\r Score " + m + " / " + all + " = " + scorer.score() + " (boss)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); + } + } + + scorer.bookmark(); + + if (verbose) { + System.out.print("\r Score " + m + " / " + all + " = " + scorer.score() + " (boss)" + " Elapsed " + ((MillisecondTimes.timeMillis() - start) / 1000.0 + " s")); + } + } + + if (verbose) { + System.out.println(); + } + + s2 = scorer.score(); + } while (s2 > s1); + } + + + public void tubes(@NotNull TeyssierScorer scorer) { + double s; + + do { + s = scorer.score(); + + for (NodePair edge : scorer.getAdjacencies()) { + Node x = edge.getFirst(); + Node y = edge.getSecond(); + if (!scorer.adjacent(x, y)) continue; + + scorer.bookmark(); + + tuck(y, scorer.index(x), scorer, new int[2]); + + if (scorer.score() >= s) { + besMutation(scorer); + } else { + scorer.goToBookmark(); + } + } + + } while (scorer.score() > s); + } + + + private void tuck(Node k, int j, TeyssierScorer scorer, int[] range) { + if (scorer.index(k) < j) return; + Set ancestors = scorer.getAncestors(k); + + int minIndex = j; + + for (int i = j + 1; i <= scorer.index(k); i++) { + if (ancestors.contains(scorer.get(i))) { + scorer.moveTo(scorer.get(i), j++); + } + } + + range[0] = minIndex; + range[1] = scorer.index(k); + } + + public void besMutation(TeyssierScorer scorer) { + Graph graph = scorer.getGraph(true); + Bes bes = new Bes(score); + bes.setDepth(depth); + bes.setVerbose(false); + bes.setKnowledge(knowledge); + bes.bes(graph, scorer.getPi()); + List pi = graph.paths().validOrder(scorer.getPi(), true); + scorer.score(pi); + } + + public int getNumEdges() { + return this.scorer.getNumEdges(); + } + + private void makeValidKnowledgeOrder(List order) { + if (!this.knowledge.isEmpty()) { + order.sort((o1, o2) -> { + if (o1.getName().equals(o2.getName())) { + return 0; + } else if (this.knowledge.isRequired(o1.getName(), o2.getName())) { + return -1; + } else if (this.knowledge.isRequired(o2.getName(), o1.getName())) { + return 1; + } else if (this.knowledge.isForbidden(o1.getName(), o2.getName())) { + return 1; + } else if (this.knowledge.isForbidden(o2.getName(), o1.getName())) { + return -1; + } else { + return 0; + } + }); + } + + if (violatesKnowledge(order)) { + Edge edge = violatesForbiddenKnowledge(order); + + if (edge != null) { + JOptionPane.showMessageDialog (JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was in the DAG: " + edge + " in the initial sort,\n" + + "but this edge was forbidden."); + } + + Edge edge2 = violatesRequiredKnowledge(order); + + if (edge2 != null) { + JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), + "The initial sorting procedure could not find a permutation consistent with that \n" + + "knowledge; this edge was not in the DAG: " + edge2 + " in the initial sorted," + + "but this edge was required."); + } + } + + System.out.println("Initial knowledge sort order = " + order); + + if (violatesKnowledge(order)) { + throw new IllegalArgumentException("The initial sorting procedure could not find a permutation " + + "consistent with that knowledge."); + } + } + + public Graph getGraph(boolean cpDag) { + if (this.scorer == null) throw new IllegalArgumentException("Please run algorithm first."); + Graph graph = this.scorer.getGraph(cpDag); + + NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); + graph.addAttribute("score ", nf.format(this.scorer.score())); + return graph; + } + + public void orientbk(Knowledge bk, Graph graph, List variables) { + for (Iterator it = bk.forbiddenEdgesIterator(); it.hasNext(); ) { + KnowledgeEdge edge = it.next(); + + //match strings to variables in the graph. + Node from = SearchGraphUtils.translate(edge.getFrom(), variables); + Node to = SearchGraphUtils.translate(edge.getTo(), variables); + + if (from == null || to == null) { + continue; + } + + if (graph.getEdge(from, to) == null) { + continue; + } + + // Orient to*->from + graph.setEndpoint(to, from, Endpoint.ARROW); + } + + for (Iterator it = bk.requiredEdgesIterator(); it.hasNext(); ) { + KnowledgeEdge edge = it.next(); + + //match strings to variables in the graph. + Node from = SearchGraphUtils.translate(edge.getFrom(), variables); + Node to = SearchGraphUtils.translate(edge.getTo(), variables); + + if (from == null || to == null) { + continue; + } + + if (graph.getEdge(from, to) == null) { + continue; + } + + // Orient to*->from + graph.setEndpoint(from, to, Endpoint.ARROW); + } + } + + public void setNumStarts(int numStarts) { + this.numStarts = numStarts; + } + + public List getVariables() { + return this.variables; + } + + public boolean isVerbose() { + return this.verbose; + } + + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + public void setKnowledge(Knowledge knowledge) { + this.knowledge = new Knowledge((Knowledge) knowledge); + } + + public void setDepth(int depth) { + if (depth < -1) throw new IllegalArgumentException("Depth should be >= -1."); + this.depth = depth; + } + + public void setUseScore(boolean useScore) { + this.useScore = useScore; + } + + private boolean violatesKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName())) { + return true; + } + + if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName())) { + return true; + } + } + } + } + + return false; + } + + private Edge violatesForbiddenKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isForbidden(order.get(i).getName(), order.get(j).getName()) && scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(i), order.get(j)); + } + } + } + } + + return null; + } + + private Edge violatesRequiredKnowledge(List order) { + if (!this.knowledge.isEmpty()) { + scorer.score(order); + + for (int i = 0; i < order.size(); i++) { + for (int j = i + 1; j < order.size(); j++) { + if (this.knowledge.isRequired(order.get(j).getName(), order.get(i).getName()) && !scorer.parent(order.get(i), order.get(j))) { + return Edges.directedEdge(order.get(j), order.get(i)); + } + } + } + } + + return null; + } + + public void setUseRaskuttiUhler(boolean useRaskuttiUhler) { + this.useRaskuttiUhler = useRaskuttiUhler; + } + + public void setUseDataOrder(boolean useDataOrder) { + this.useDataOrder = useDataOrder; + } + + public void setAlgType(AlgType algType) { + this.algType = algType; + } + + public void setCaching(boolean caching) { + this.caching = caching; + } + + public enum AlgType {BOSS1, BOSS2, BOSS3} +} \ No newline at end of file diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java index b774d87b56..1666481f19 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DegenerateGaussianScore.java @@ -1,7 +1,30 @@ +/////////////////////////////////////////////////////////////////////////////// +// For information as to what this class does, see the Javadoc, below. // +// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, // +// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard // +// Scheines, Joseph Ramsey, and Clark Glymour. // +// // +// This program is free software; you can redistribute it and/or modify // +// it under the terms of the GNU General Public License as published by // +// the Free Software Foundation; either version 2 of the License, or // +// (at your option) any later version. // +// // +// This program is distributed in the hope that it will be useful, // +// but WITHOUT ANY WARRANTY; without even the implied warranty of // +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // +// GNU General Public License for more details. // +// // +// You should have received a copy of the GNU General Public License // +// along with this program; if not, write to the Free Software // +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // +/////////////////////////////////////////////////////////////////////////////// + package edu.cmu.tetrad.search; import edu.cmu.tetrad.data.*; import edu.cmu.tetrad.graph.Node; +import edu.cmu.tetrad.util.Matrix; +import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.math3.linear.BlockRealMatrix; import org.apache.commons.math3.linear.RealMatrix; import org.apache.commons.math3.util.FastMath; @@ -22,22 +45,32 @@ * * @author Bryan Andrews */ - public class DegenerateGaussianScore implements Score { + private final BoxDataSet ddata; private final DataSet dataSet; // The mixed variables of the original dataset. private final List variables; + // The penalty discount. + private double penaltyDiscount = 1.0; + // The structure prior. private double structurePrior; // The embedding map. private final Map> embedding; - private final SemBicScore bic; + // A constant. + private static final double L2PE = log(2.0 * FastMath.PI * FastMath.E); + + private final Map nodesHash; + + /** + * Constructs the score using a covariance matrix. + */ public DegenerateGaussianScore(DataSet dataSet) { if (dataSet == null) { throw new NullPointerException(); @@ -78,7 +111,9 @@ public DegenerateGaussianScore(DataSet dataSet) { B.get(keys.get(key))[j] = 1; } - // Remove a degenerate dimension. + /* + * Remove a degenerate dimension. + */ i--; keys.remove(keysReverse.get(i)); A.remove(i); @@ -110,37 +145,68 @@ public DegenerateGaussianScore(DataSet dataSet) { } } + // The continuous variables of the post-embedding dataset. RealMatrix D = new BlockRealMatrix(B_); - this.bic = new SemBicScore(new BoxDataSet(new DoubleDataBox(D.getData()), A)); - this.bic.setStructurePrior(0); + this.ddata = new BoxDataSet(new DoubleDataBox(D.getData()), A); + this.nodesHash = new HashedMap<>(); + + List variables = dataSet.getVariables(); + + for (int j = 0; j < variables.size(); j++) { + this.nodesHash.put(variables.get(j), j); + } + } /** * Calculates the sample likelihood and BIC score for i given its parents in a simple SEM model */ public double localScore(int i, int... parents) { - double score = 0; - List A = new ArrayList<>(this.embedding.get(i)); + List rows = getRows(i, parents); + int N = rows.size(); + List B = new ArrayList<>(); + List A = new ArrayList<>(this.embedding.get(i)); for (int i_ : parents) { B.addAll(this.embedding.get(i_)); } - int[] parents_ = new int[B.size()]; + int[] A_ = new int[A.size() + B.size()]; + int[] B_ = new int[B.size()]; + for (int i_ = 0; i_ < A.size(); i_++) { + A_[i_] = A.get(i_); + } for (int i_ = 0; i_ < B.size(); i_++) { - parents_[i_] = B.get(i_); + A_[A.size() + i_] = B.get(i_); + B_[i_] = B.get(i_); } - for (Integer i_ : A) { - score += this.bic.localScore(i_, parents_); - } + int dof = (A_.length * (A_.length + 1) - B_.length * (B_.length + 1)) / 2; + double ldetA = log(getCov(rows, A_).det()); + double ldetB = log(getCov(rows, B_).det()); - // NOTE: STRUCTURE PRIOR IS NOT CURRENTLY IMPLEMENTED! + double lik = N * (ldetB - ldetA + DegenerateGaussianScore.L2PE * (B_.length - A_.length)); + double score = 2 * lik + 2 * calculateStructurePrior(parents.length) - dof * getPenaltyDiscount() * log(N); + + if (Double.isNaN(score) || Double.isInfinite(score)) { + return Double.NaN; + } else { + return score; + } + } - return score; + private double calculateStructurePrior(int k) { + if (this.structurePrior <= 0) { + return 0; + } else { + double n = this.variables.size() - 1; + double p = this.structurePrior / n; + return k * log(p) + (n - k) * log(1.0 - p); + } } + public double localScoreDiff(int x, int y, int[] z) { return localScore(y, append(z, x)) - localScore(y, z); } @@ -171,9 +237,8 @@ public double localScore(int i) { return localScore(i, new int[0]); } - @Override - public List getVariables() { - return this.variables; + public int getSampleSize() { + return this.dataSet.getNumRows(); } @Override @@ -182,12 +247,18 @@ public boolean isEffectEdge(double bump) { } @Override - public int getSampleSize() { - return 0; + public List getVariables() { + return this.variables; } @Override public Node getVariable(String targetName) { + for (Node node : this.variables) { + if (node.getName().equals(targetName)) { + return node; + } + } + return null; } @@ -201,25 +272,89 @@ public boolean determines(List z, Node y) { return false; } - @Override - public String toString() { - NumberFormat nf = new DecimalFormat("0.00"); - return "Degenerate Gaussian Score Penalty " + nf.format(this.bic.getPenaltyDiscount()); - } - public double getPenaltyDiscount() { - return this.bic.getPenaltyDiscount(); + return this.penaltyDiscount; } public void setPenaltyDiscount(double penaltyDiscount) { - this.bic.setPenaltyDiscount(penaltyDiscount); + this.penaltyDiscount = penaltyDiscount; } public double getStructurePrior() { - return structurePrior; + return this.structurePrior; } public void setStructurePrior(double structurePrior) { this.structurePrior = structurePrior; } + + @Override + public String toString() { + NumberFormat nf = new DecimalFormat("0.00"); + return "Degenerate Gaussian Score Penalty " + nf.format(this.penaltyDiscount); + } + + // Subsample of the continuous mixedVariables conditioning on the given cols. + private Matrix getCov(List rows, int[] cols) { + if (rows.isEmpty()) return new Matrix(0, 0); + Matrix cov = new Matrix(cols.length, cols.length); + + for (int i = 0; i < cols.length; i++) { + for (int j = 0; j < cols.length; j++) { + double mui = 0.0; + double muj = 0.0; + + for (int k : rows) { + mui += this.ddata.getDouble(k, cols[i]); + muj += this.ddata.getDouble(k, cols[j]); + } + + mui /= rows.size() - 1; + muj /= rows.size() - 1; + + double _cov = 0.0; + + for (int k : rows) { + _cov += (this.ddata.getDouble(k, cols[i]) - mui) * (this.ddata.getDouble(k, cols[j]) - muj); + } + + double mean = _cov / (rows.size()); + cov.set(i, j, mean); + } + } + + return cov; + } + + private List getRows(int i, int[] parents) { + List rows = new ArrayList<>(); + + K: + for (int k = 0; k < this.dataSet.getNumRows(); k++) { + Node ii = this.variables.get(i); + + List A = new ArrayList<>(this.embedding.get(this.nodesHash.get(ii))); + + for (int j : A) { + if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; + } + + for (int ignored : parents) { + Node pp = this.variables.get(i); + + List AA = new ArrayList<>(this.embedding.get(this.nodesHash.get(pp))); + + for (int j : AA) { + if (Double.isNaN(this.ddata.getDouble(k, j))) continue K; + } + } + + rows.add(k); + } + + return rows; + } } + + + diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java index fb27af2929..a524cb9e29 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/DiscreteBicScore.java @@ -169,7 +169,6 @@ public double localScore(int node, int[] parents) { private double getPriorForStructure(int numParents) { double e = getStructurePrior(); - if (e == 0) return 0.0; int vm = this.data.length - 1; return numParents * FastMath.log(e / (vm)) + (vm - numParents) * FastMath.log(1.0 - (e / (vm))); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GrowShrinkTree.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GrowShrinkTree.java index ab56d1b1de..f1e8b3002b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GrowShrinkTree.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GrowShrinkTree.java @@ -23,8 +23,8 @@ public GrowShrinkTree(Score score) { } } - public double GrowShrink(Node node, Set prefix, LinkedHashSet parents) { - return this.roots.get(node).GrowShrink(node, prefix, parents); + public double growShrink(Node node, Set prefix, Set parents) { + return this.roots.get(node).growShrink(node, prefix, parents); } private static class GSTNode implements Comparable { @@ -60,7 +60,7 @@ private GSTNode(Node node, Node add, Set parents) { this.growScore = GrowShrinkTree.score.localScore(y, X); } - public double GrowShrink(Node node, Set prefix, LinkedHashSet parents) { + public double growShrink(Node node, Set prefix, Set parents) { if (!this.grow) { this.grow = true; @@ -69,7 +69,7 @@ public double GrowShrink(Node node, Set prefix, LinkedHashSet parent for (Node add : GrowShrinkTree.score.getVariables()) { if (parents.contains(add) || add == node) continue; GSTNode branch = new GSTNode(node, add, parents); - if (this.compareTo(branch) < 0) this.branches.add(branch); + if (branch.getGrowScore() >= this.growScore) this.branches.add(branch); } this.branches.sort(Collections.reverseOrder()); } @@ -79,7 +79,7 @@ public double GrowShrink(Node node, Set prefix, LinkedHashSet parent if (prefix.contains(add)) { prefix.remove(add); parents.add(add); - return branch.GrowShrink(node, prefix, parents); + return branch.growShrink(node, prefix, parents); } } @@ -90,40 +90,37 @@ public double GrowShrink(Node node, Set prefix, LinkedHashSet parent if (parents.isEmpty()) return this.shrinkScore; - int y = GrowShrinkTree.index.get(node); Node best; + int y = GrowShrinkTree.index.get(node); do { + + best = null; int[] X = new int[parents.size() - 1]; - int i = 0; - Iterator itr = parents.iterator(); - itr.next(); - while (itr.hasNext()) X[i++] = GrowShrinkTree.index.get(itr.next()); + for (Node remove : new HashSet<>(parents)) { - itr = parents.iterator(); - Node remove = itr.next(); - best = null; + int i = 0; + parents.remove(remove); + for (Node parent : parents) X[i++] = GrowShrinkTree.index.get(parent); + parents.add(remove); + + double s = score.localScore(y, X); - do { - double s = GrowShrinkTree.score.localScore(y, X); if (s > this.shrinkScore) { this.shrinkScore = s; best = remove; } - if (i < parents.size() - 1) { - remove = itr.next(); - X[i++] = GrowShrinkTree.index.get(remove); - } - } while (i < parents.size() - 1); + } if (best != null) { parents.remove(best); this.remove.add(best); } - } while (best != null); + } while(best != null); + } parents.removeAll(this.remove); return this.shrinkScore; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java index 4aa01b1edc..d59479153d 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestConditionalGaussianLRT.java @@ -29,6 +29,7 @@ import edu.cmu.tetrad.graph.Node; import edu.cmu.tetrad.util.Matrix; import edu.cmu.tetrad.util.TetradLogger; +import org.apache.commons.collections4.map.HashedMap; import org.apache.commons.math3.distribution.ChiSquaredDistribution; import java.text.DecimalFormat; @@ -36,7 +37,6 @@ import java.util.ArrayList; import java.util.List; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; /** * Performs a test of conditional independence X _||_ Y | Z1...Zn where all searchVariables are either continuous or discrete. @@ -48,7 +48,7 @@ */ public class IndTestConditionalGaussianLRT implements IndependenceTest { private final DataSet data; - private final Map nodesHash; + private final Map nodesHash; private double alpha; // Likelihood function @@ -59,17 +59,15 @@ public class IndTestConditionalGaussianLRT implements IndependenceTest { private int numCategoriesToDiscretize = 3; public IndTestConditionalGaussianLRT(DataSet data, double alpha, boolean discretize) { - if (data == null) throw new NullPointerException("Data is null."); - this.data = data; this.likelihood = new ConditionalGaussianLikelihood(data); this.likelihood.setDiscretize(discretize); - this.nodesHash = new ConcurrentHashMap<>(); + this.nodesHash = new HashedMap<>(); List variables = data.getVariables(); for (int i = 0; i < variables.size(); i++) { - this.nodesHash.put(variables.get(i).getName(), i); + this.nodesHash.put(variables.get(i), i); } this.alpha = alpha; @@ -96,8 +94,8 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { this.likelihood.setRows(getRows(allVars, this.nodesHash)); - int _x = getVariable(x); - int _y = getVariable(y); + int _x = this.nodesHash.get(x); + int _y = this.nodesHash.get(y); int[] list0 = new int[z.size() + 1]; int[] list2 = new int[z.size()]; @@ -105,7 +103,7 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { list0[0] = _x; for (int i = 0; i < z.size(); i++) { - int _z = getVariable(z.get(i)); + int _z = this.nodesHash.get(z.get(i)); list0[i + 1] = _z; list2[i] = _z; } @@ -119,8 +117,7 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { if (dof0 <= 0) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); if (this.alpha == 0) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); if (this.alpha == 1) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); - if (lik0 == Double.POSITIVE_INFINITY) - return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); + if (lik0 == Double.POSITIVE_INFINITY) return new IndependenceResult(new IndependenceFact(x, y, z), false, Double.NaN); double pValue; @@ -144,20 +141,16 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { return new IndependenceResult(new IndependenceFact(x, y, z), independent, pValue); } - private Integer getVariable(Node x) { - return this.nodesHash.get(x.getName()); - } - - private List getRows(List allVars, Map nodesHash) { + private List getRows(List allVars, Map nodesHash) { List rows = new ArrayList<>(); K: for (int k = 0; k < this.data.getNumRows(); k++) { for (Node node : allVars) { if (node instanceof ContinuousVariable) { - if (Double.isNaN(this.data.getDouble(k, nodesHash.get(node.getName())))) continue K; + if (Double.isNaN(this.data.getDouble(k, nodesHash.get(node)))) continue K; } else if (node instanceof DiscreteVariable) { - if (this.data.getInt(k, nodesHash.get(node.getName())) == -99) continue K; + if (this.data.getInt(k, nodesHash.get(node)) == -99) continue K; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestTeyssier.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestTeyssier.java index a0cf0825cf..b54a0eeeef 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestTeyssier.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IndTestTeyssier.java @@ -77,7 +77,7 @@ public final class IndTestTeyssier implements IndependenceTest { private double p = NaN; private double r = NaN; - private Boss boss; + private BossOld bossOld; //==========================CONSTRUCTORS=============================// @@ -138,7 +138,7 @@ public IndTestTeyssier(DataSet dataSet, double penaltyDiscount) { score.setPenaltyDiscount(penaltyDiscount); this.scorer = new TeyssierScorer(null, score); this.scorer.score(variables); - this.boss = new Boss(scorer); + this.bossOld = new BossOld(scorer); } /** @@ -164,7 +164,7 @@ public IndTestTeyssier(ICovarianceMatrix covMatrix, double penaltyDiscount) { score.setPenaltyDiscount(penaltyDiscount); this.scorer = new TeyssierScorer(null, score); scorer.score(variables); - this.boss = new Boss(scorer); + this.bossOld = new BossOld(scorer); } @@ -212,7 +212,7 @@ public IndependenceResult checkIndependence(Node x, Node y, List z) { perm.add(x); perm.add(y); - boss.bestOrder(perm); + bossOld.bestOrder(perm); // scorer.score(perm); // boss.betterMutationTuck(scorer); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvSwap.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvSwap.java index 2fe8d04f18..74998f1be8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvSwap.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvSwap.java @@ -64,7 +64,7 @@ public enum AlgType {LVSwap1, LVSwap2a, LVSwap2b} private AlgType algType = AlgType.LVSwap1; - private Boss.AlgType bossAlgType = Boss.AlgType.BOSS1; + private BossOld.AlgType bossAlgType = BossOld.AlgType.BOSS1; // The score used, if GS is used to build DAGs. private final Score score; @@ -114,7 +114,7 @@ public Graph search() { public Graph lvswap1() { TeyssierScorer scorer = new TeyssierScorer(test, score); - Boss alg = new Boss(scorer); + BossOld alg = new BossOld(scorer); alg.setAlgType(bossAlgType); alg.setUseScore(useScore); alg.setUseRaskuttiUhler(useRaskuttiUhler); @@ -190,7 +190,7 @@ public Graph lvswap1() { public Graph lvswap2a() { TeyssierScorer scorer = new TeyssierScorer(test, score); - Boss alg = new Boss(scorer); + BossOld alg = new BossOld(scorer); alg.setAlgType(bossAlgType); alg.setUseScore(useScore); alg.setUseRaskuttiUhler(useRaskuttiUhler); @@ -265,7 +265,7 @@ public Graph lvswap2a() { public Graph lvswap2b() { TeyssierScorer scorer = new TeyssierScorer(test, score); - Boss alg = new Boss(scorer); + BossOld alg = new BossOld(scorer); alg.setAlgType(bossAlgType); alg.setUseScore(useScore); alg.setUseRaskuttiUhler(useRaskuttiUhler); @@ -348,7 +348,7 @@ public Graph lvswap2b() { public Graph lvswap3() { TeyssierScorer scorer = new TeyssierScorer(test, score); - Boss alg = new Boss(scorer); + BossOld alg = new BossOld(scorer); alg.setAlgType(bossAlgType); alg.setUseScore(useScore); alg.setUseRaskuttiUhler(useRaskuttiUhler); @@ -621,7 +621,7 @@ public void setAlgType(AlgType bossAlgType) { this.algType = bossAlgType; } - public void setBossAlgType(Boss.AlgType algType) { + public void setBossAlgType(BossOld.AlgType algType) { this.bossAlgType = algType; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SepsetsTeyssier.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SepsetsTeyssier.java index 360be78343..066869493e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SepsetsTeyssier.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SepsetsTeyssier.java @@ -116,9 +116,9 @@ public boolean isIndependent(Node a, Node b, List c) { nodes.add(a); nodes.add(b); - Boss boss = new Boss(scorer); - boss.setAlgType(Boss.AlgType.BOSS1); - boss.bestOrder(nodes); + BossOld bossOld = new BossOld(scorer); + bossOld.setAlgType(BossOld.AlgType.BOSS1); + bossOld.bestOrder(nodes); // this.scorer.score(nodes); boolean adjacent = this.scorer.adjacent(a, b); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SimpleDemoGA.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SimpleDemoGA.java index b289d8c0f8..5e1895aab1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SimpleDemoGA.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SimpleDemoGA.java @@ -81,10 +81,10 @@ private Individual bossContiguous(Individual individual, int start, int chunk) { Score score2 = ((SemBicScore) score).subset(pi2); // Run BOSS on pi2. - Boss boss = new Boss(score2); - boss.setAlgType(Boss.AlgType.BOSS1); - boss.setVerbose(true); - List pi3 = boss.bestOrder(pi2); + BossOld bossOld = new BossOld(score2); + bossOld.setAlgType(BossOld.AlgType.BOSS1); + bossOld.setVerbose(true); + List pi3 = bossOld.bestOrder(pi2); List pi4 = new ArrayList<>(pi); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SpFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SpFci.java index 71d6cd8cc9..a046428a8f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SpFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SpFci.java @@ -89,7 +89,7 @@ public final class SpFci implements GraphSearch { private boolean useScore = true; private boolean doDiscriminatingPathRule = true; private boolean possibleDsepSearchDone = true; - private Boss.AlgType bossType = Boss.AlgType.BOSS1; + private BossOld.AlgType bossType = BossOld.AlgType.BOSS1; //============================CONSTRUCTORS============================// public SpFci(IndependenceTest test, Score score) { @@ -432,7 +432,7 @@ public void setPossibleDsepSearchDone(boolean possibleDsepSearchDone) { this.possibleDsepSearchDone = possibleDsepSearchDone; } - public void setAlgType(Boss.AlgType type) { + public void setAlgType(BossOld.AlgType type) { this.bossType = type; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer.java index 2f49c3dd3d..cefabf7713 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer.java @@ -1114,7 +1114,7 @@ private Pair getGrowShrinkScore(int p) { Set prefix = new HashSet<>(getPrefix(p)); LinkedHashSet parents = new LinkedHashSet<>(); - double sMax = GST.GrowShrink(n, prefix, parents); + double sMax = GST.growShrink(n, prefix, parents); return new Pair(parents, Double.isNaN(sMax) ? Double.NEGATIVE_INFINITY : sMax); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer3.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer3.java index b6c6bd25c1..ca71184ba2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer3.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/TeyssierScorer3.java @@ -1114,7 +1114,7 @@ private Pair getGrowShrinkScore(int p) { Set prefix = new HashSet<>(getPrefix(p)); LinkedHashSet parents = new LinkedHashSet<>(); - double sMax = GST.GrowShrink(n, prefix, parents); + double sMax = GST.growShrink(n, prefix, parents); return new Pair(parents, Double.isNaN(sMax) ? Double.NEGATIVE_INFINITY : sMax); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestAnneAnalysis3.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestAnneAnalysis3.java index 1cd76159a2..f11a214a30 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestAnneAnalysis3.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestAnneAnalysis3.java @@ -6,7 +6,7 @@ import edu.cmu.tetrad.graph.Edges; import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.graph.Node; -import edu.cmu.tetrad.search.Boss; +import edu.cmu.tetrad.search.BossOld; import org.jetbrains.annotations.NotNull; import org.junit.Test; @@ -97,8 +97,8 @@ private void run1() { score.setLambda(vars.size() / 2.); // Grasp alg = new Grasp(score); - Boss alg = new Boss(score); - alg.setAlgType(Boss.AlgType.BOSS2); + BossOld alg = new BossOld(score); + alg.setAlgType(BossOld.AlgType.BOSS2); List nodes = alg.bestOrder(score.getVariables()); Graph estCpdag = alg.getGraph(true); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java index 0f6218377c..6b456e2c67 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGrasp.java @@ -24,7 +24,7 @@ import edu.cmu.tetrad.algcomparison.Comparison; import edu.cmu.tetrad.algcomparison.algorithm.Algorithm; import edu.cmu.tetrad.algcomparison.algorithm.Algorithms; -import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BOSS; +import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BOSSOLD; import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.BRIDGES_OLD; import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.GRaSP; import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.PC; @@ -34,11 +34,9 @@ import edu.cmu.tetrad.algcomparison.algorithm.oracle.pag.LVSWAP_2a; import edu.cmu.tetrad.algcomparison.graph.RandomForward; import edu.cmu.tetrad.algcomparison.graph.SingleGraph; -import edu.cmu.tetrad.algcomparison.independence.ConditionalGaussianLRT; import edu.cmu.tetrad.algcomparison.independence.DSeparationTest; import edu.cmu.tetrad.algcomparison.independence.FisherZ; import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper; -import edu.cmu.tetrad.algcomparison.score.ConditionalGaussianBicScore; import edu.cmu.tetrad.algcomparison.score.DSeparationScore; import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; import edu.cmu.tetrad.algcomparison.simulation.*; @@ -637,7 +635,7 @@ public void newAlgsHeadToHead() { public void doNewAgsHeadToHead(Parameters params, String dataPath, String resultsPath, boolean doPcFges) { Algorithms algorithms = new Algorithms(); // algorithms.add(new GRaSP(new edu.cmu.tetrad.algcomparison.score.SemBicScore(), new FisherZ())); - algorithms.add(new BOSS(new FisherZ(), new edu.cmu.tetrad.algcomparison.score.SemBicScore())); + algorithms.add(new BOSSOLD(new FisherZ(), new edu.cmu.tetrad.algcomparison.score.SemBicScore())); // algorithms.add(new BRIDGES(new edu.cmu.tetrad.algcomparison.score.SemBicScore())); // if (doPcFges) { @@ -1263,7 +1261,7 @@ public void wayneCheckDensityClaim2() { while ((perm = gen.next()) != null) { List pi = GraphUtils.asList(perm, variables); - Boss grasp = new Boss(new GraphScore(facts.getFacts())); + BossOld grasp = new BossOld(new GraphScore(facts.getFacts())); grasp.setUseRaskuttiUhler(true); grasp.setDepth(100); @@ -2942,11 +2940,11 @@ public void testScores() { IndependenceWrapper test = new FisherZ(); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.SemBicScore())); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.PoissonPriorScore())); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.EbicScore())); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.KimEtAlScores())); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.ZhangShenBoundScore())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.SemBicScore())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.PoissonPriorScore())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.EbicScore())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.KimEtAlScores())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.ZhangShenBoundScore())); Simulations simulations = new Simulations(); simulations.add(new SemSimulation(new RandomForward())); @@ -3011,7 +3009,7 @@ public void testScores2() { IndependenceWrapper test = new FisherZ(); - algorithms.add(new BOSS(test, new edu.cmu.tetrad.algcomparison.score.ZhangShenBoundScore())); + algorithms.add(new BOSSOLD(test, new edu.cmu.tetrad.algcomparison.score.ZhangShenBoundScore())); Simulations simulations = new Simulations(); simulations.add(new SemSimulation(new RandomForward())); From 313535d7a96738ce4afcd05df6768d10e4fd2923 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 13 Mar 2023 13:26:55 -0400 Subject: [PATCH 128/214] Removing the t-depth parameter from tha manual. --- docs/manual/index.html | 21 --------------------- 1 file changed, 21 deletions(-) diff --git a/docs/manual/index.html b/docs/manual/index.html index d4b3744f0e..604a10c340 100755 --- a/docs/manual/index.html +++ b/docs/manual/index.html @@ -8080,27 +8080,6 @@

targetName

id="targetName_value_type">String -

tDepth

-
    -
  • Short Description: "T-Depth", the maximum number of neighbors - considered in power set calculations
  • -
  • Long - Description: For FGES, this is the - maximum number of T-neighbors or H-complement-neights that are - considered in any scoring step. Default is -1 (unlimited). -
  • -
  • Default Value: -1
  • -
  • Lower Bound: -1
  • -
  • Upper Bound: 2147483647
  • -
  • Value Type: Integer
  • -
-

thr