From 41b97c3fefe8a64653f4f838eb68dad896bc3ba6 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sat, 1 Jun 2024 05:29:11 -0400 Subject: [PATCH 01/29] Correct typo and clean imports in graph package The commit corrects a spelling mistake in a error message in the PoissonPriorScore class and streamlines the import statements in the NodeType class within the graph package. Removed unused imports to enhance code cleanliness. --- .../src/main/java/edu/cmu/tetrad/graph/NodeType.java | 8 ++------ .../edu/cmu/tetrad/search/score/PoissonPriorScore.java | 2 +- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/NodeType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/NodeType.java index 4d52e4dec8..7300c6edfa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/NodeType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/NodeType.java @@ -21,11 +21,6 @@ package edu.cmu.tetrad.graph; -import edu.cmu.tetrad.util.TetradLogger; -import edu.cmu.tetrad.util.TetradSerializable; - -import java.io.*; - /** * An enum of the node types in a graph (MEASURED, LATENT, ERROR). * @@ -40,7 +35,8 @@ public enum NodeType { /** * Constant LATENT */ - LATENT,/** + LATENT, + /** * Constant ERROR */ ERROR, diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/PoissonPriorScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/PoissonPriorScore.java index 11a7e159c9..994b52652c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/PoissonPriorScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/PoissonPriorScore.java @@ -257,7 +257,7 @@ public DataModel getData() { * @param lambda The lambda parameter. */ public void setLambda(double lambda) { - if (lambda < 1.0) throw new IllegalArgumentException("Poisso lambda can't be < 1: " + lambda); + if (lambda < 1.0) throw new IllegalArgumentException("Poisson lambda can't be < 1: " + lambda); this.lambda = lambda; } From b69cf822dba8245e4db0756752aa02460785ce25 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 3 Jun 2024 00:40:36 -0400 Subject: [PATCH 02/29] Refactor LvLite search and update GraphEditor The LvLite search algorithm was refactored for optimization and clarity. A new class, 'LvLiteDsepFriendly', was also added. The 'GraphEditor' now has a shortcut for creating a random graph. --- .../editor/EdgewiseComparisonEditor.java | 7 + .../edu/cmu/tetradapp/editor/GraphEditor.java | 3 + .../algorithm/oracle/pag/Gfci.java | 3 + .../algorithm/oracle/pag/GraspFci.java | 2 + .../algorithm/oracle/pag/LvLite.java | 4 +- .../oracle/pag/LvLiteDsepFriendly.java | 267 ++++++ .../java/edu/cmu/tetrad/graph/GraphUtils.java | 34 +- .../main/java/edu/cmu/tetrad/search/GFci.java | 15 +- .../java/edu/cmu/tetrad/search/GraspFci.java | 15 +- .../java/edu/cmu/tetrad/search/LvLite.java | 277 +++--- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 898 ++++++++++++++++++ .../cmu/tetrad/search/utils/DagSepsets.java | 2 +- .../cmu/tetrad/search/utils/FciOrient.java | 122 ++- 13 files changed, 1451 insertions(+), 198 deletions(-) create mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java create mode 100644 tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/EdgewiseComparisonEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/EdgewiseComparisonEditor.java index 4270057b71..14e81e2f20 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/EdgewiseComparisonEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/EdgewiseComparisonEditor.java @@ -78,6 +78,13 @@ private void setup() { area.setFont(font); + int position = area.getText().indexOf("True graph"); + + // If the word is found, scroll to it + if (position >= 0) { + area.setCaretPosition(position); + } + JScrollPane scrollTextPane = new JScrollPane(area); scrollTextPane.setPreferredSize(new Dimension(500, 600)); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GraphEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GraphEditor.java index 621bfb63a1..33a42cb03f 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GraphEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GraphEditor.java @@ -511,6 +511,9 @@ private JMenu createGraphMenu() { JMenuItem randomGraph = new JMenuItem("Random Graph"); graph.add(randomGraph); + randomGraph.setAccelerator( + KeyStroke.getKeyStroke(KeyEvent.VK_R, InputEvent.META_DOWN_MASK)); + graph.addSeparator(); graph.add(new GraphPropertiesAction(getWorkbench())); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java index 74f7ba19fa..cebab5493c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java @@ -103,6 +103,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setNumThreads(parameters.getInt(Params.NUM_THREADS)); Object obj = parameters.get(Params.PRINT_STREAM); @@ -161,6 +163,7 @@ public List getParameters() { parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.COMPLETE_RULE_SET_USED); parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.POSSIBLE_MSEP_DONE); parameters.add(Params.TIME_LAG); parameters.add(Params.NUM_THREADS); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java index cff9016d4b..f4dc2bae29 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java @@ -127,6 +127,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); // General search.setVerbose(parameters.getBoolean(Params.VERBOSE)); @@ -191,6 +192,7 @@ public List getParameters() { params.add(Params.MAX_PATH_LENGTH); params.add(Params.COMPLETE_RULE_SET_USED); params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); params.add(Params.POSSIBLE_MSEP_DONE); // General diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java index f2a10b100e..6401cdaad5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java @@ -125,7 +125,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); // LV-Lite - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setAllowTucks(parameters.getBoolean(Params.ALLOW_TUCKS)); @@ -184,7 +184,7 @@ public List getParameters() { // FCI-ORIENT params.add(Params.COMPLETE_RULE_SET_USED); - params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); // LV-Lite diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java new file mode 100644 index 0000000000..07d55f70f2 --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -0,0 +1,267 @@ +package edu.cmu.tetrad.algcomparison.algorithm.oracle.pag; + +import edu.cmu.tetrad.algcomparison.algorithm.AbstractBootstrapAlgorithm; +import edu.cmu.tetrad.algcomparison.algorithm.Algorithm; +import edu.cmu.tetrad.algcomparison.algorithm.ReturnsBootstrapGraphs; +import edu.cmu.tetrad.algcomparison.algorithm.TakesCovarianceMatrix; +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.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.Graph; +import edu.cmu.tetrad.graph.GraphTransforms; +import edu.cmu.tetrad.search.IndependenceTest; +import edu.cmu.tetrad.search.score.Score; +import edu.cmu.tetrad.search.utils.TsUtils; +import edu.cmu.tetrad.util.Parameters; +import edu.cmu.tetrad.util.Params; + +import java.io.Serial; +import java.util.ArrayList; +import java.util.List; + + +/** + * Adjusts GFCI to use a permutation algorithm (such as BOSS-Tuck) to do the initial steps of finding adjacencies and + * unshielded colliders. + *

+ * GFCI reference is this: + *

+ * J.M. Ogarrio and P. Spirtes and J. Ramsey, "A Hybrid Causal Search Algorithm for Latent Variable Models," JMLR 2016. + * + * @author josephramsey + * @version $Id: $Id + */ +@edu.cmu.tetrad.annotation.Algorithm( + name = "LV-Lite-Dsep-Friendly", + command = "lv-lite-dsep-friendly", + algoType = AlgType.allow_latent_common_causes +) +@Bootstrapping +public class LvLiteDsepFriendly extends AbstractBootstrapAlgorithm implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, + HasKnowledge, ReturnsBootstrapGraphs, TakesCovarianceMatrix { + + @Serial + private static final long serialVersionUID = 23L; + + /** + * The independence test to use. + */ + private IndependenceWrapper test; + + /** + * The score to use. + */ + private ScoreWrapper score; + + /** + * The knowledge. + */ + private Knowledge knowledge = new Knowledge(); + + /** + *

Constructor for GraspFci.

+ */ + public LvLiteDsepFriendly() { + // Used for reflection; do not delete. + } + + /** + *

Constructor for GraspFci.

+ * + * @param test a {@link IndependenceWrapper} object + * @param score a {@link ScoreWrapper} object + */ + public LvLiteDsepFriendly(IndependenceWrapper test, ScoreWrapper score) { + this.test = test; + this.score = score; + } + + /** + * Runs a search algorithm to find a graph structure based on a given data set and parameters. + * + * @param dataModel the data set to be used for the search algorithm + * @param parameters the parameters for the search algorithm + * @return the graph structure found by the search algorithm + */ + @Override + public Graph runSearch(DataModel dataModel, Parameters parameters) { + if (parameters.getInt(Params.TIME_LAG) > 0) { + if (!(dataModel instanceof DataSet dataSet)) { + throw new IllegalArgumentException("Expecting a dataset for time lagging."); + } + + DataSet timeSeries = TsUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG)); + if (dataSet.getName() != null) { + timeSeries.setName(dataSet.getName()); + } + dataModel = timeSeries; + knowledge = timeSeries.getKnowledge(); + } + + IndependenceTest test = this.test.getTest(dataModel, parameters); + Score score = this.score.getScore(dataModel, parameters); + + test.setVerbose(parameters.getBoolean(Params.VERBOSE)); + edu.cmu.tetrad.search.LvLiteDsepFriendly search = new edu.cmu.tetrad.search.LvLiteDsepFriendly(test, score); + + // GRaSP + search.setSeed(parameters.getLong(Params.SEED)); + search.setSingularDepth(parameters.getInt(Params.GRASP_SINGULAR_DEPTH)); + search.setNonSingularDepth(parameters.getInt(Params.GRASP_NONSINGULAR_DEPTH)); + search.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG)); + search.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE)); + search.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER)); + search.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER)); + search.setNumStarts(parameters.getInt(Params.NUM_STARTS)); + + // FCI + search.setDepth(parameters.getInt(Params.DEPTH)); + search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); + search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + + // Gene + search.setVerbose(parameters.getBoolean(Params.VERBOSE)); + search.setKnowledge(this.knowledge); + + return search.search(); + } + + /** + * Retrieves a comparison graph by transforming a true directed graph into a partially directed graph (PAG). + * + * @param graph The true directed graph, if there is one. + * @return The comparison graph. + */ + @Override + public Graph getComparisonGraph(Graph graph) { + return GraphTransforms.dagToPag(graph); + } + + /** + * Returns a short, one-line description of this algorithm. The description is generated by concatenating the + * descriptions of the test and score objects associated with this algorithm. + * + * @return The description of this algorithm. + */ + @Override + public String getDescription() { + return "LV-Lite-Dsep-Friendly (LV-Lite that can be used from a d-separation oracle--uses GRaSP) using " + this.test.getDescription() + + " and " + this.score.getDescription(); + } + + /** + * Retrieves the data type required by the search algorithm. + * + * @return The data type required by the search algorithm. + */ + @Override + public DataType getDataType() { + return this.test.getDataType(); + } + + /** + * Retrieves the list of parameters used by the algorithm. + * + * @return The list of parameters used by the algorithm. + */ + @Override + public List getParameters() { + List params = new ArrayList<>(); + + // GRaSP + params.add(Params.GRASP_DEPTH); + params.add(Params.GRASP_SINGULAR_DEPTH); + params.add(Params.GRASP_NONSINGULAR_DEPTH); + params.add(Params.GRASP_ORDERED_ALG); + params.add(Params.GRASP_USE_RASKUTTI_UHLER); + params.add(Params.USE_DATA_ORDER); + params.add(Params.NUM_STARTS); + + // FCI + params.add(Params.DEPTH); + params.add(Params.MAX_PATH_LENGTH); + params.add(Params.COMPLETE_RULE_SET_USED); + params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + + // General + params.add(Params.TIME_LAG); + params.add(Params.SEED); + params.add(Params.VERBOSE); + + return params; + } + + + /** + * Retrieves the knowledge object associated with this method. + * + * @return The knowledge object. + */ + @Override + public Knowledge getKnowledge() { + return this.knowledge; + } + + /** + * Sets the knowledge object associated with this method. + * + * @param knowledge the knowledge object to be set + */ + @Override + public void setKnowledge(Knowledge knowledge) { + this.knowledge = new Knowledge(knowledge); + } + + /** + * Retrieves the IndependenceWrapper object associated with this method. The IndependenceWrapper object contains an + * IndependenceTest that checks the independence of two variables conditional on a set of variables using a given + * dataset and parameters . + * + * @return The IndependenceWrapper object associated with this method. + */ + @Override + public IndependenceWrapper getIndependenceWrapper() { + return this.test; + } + + /** + * Sets the independence wrapper. + * + * @param test the independence wrapper. + */ + @Override + public void setIndependenceWrapper(IndependenceWrapper test) { + this.test = test; + } + + /** + * Retrieves the ScoreWrapper object associated with this method. + * + * @return The ScoreWrapper object associated with this method. + */ + @Override + public ScoreWrapper getScoreWrapper() { + return this.score; + } + + /** + * Sets the score wrapper for the algorithm. + * + * @param score the score wrapper. + */ + @Override + public void setScoreWrapper(ScoreWrapper score) { + this.score = score; + } +} diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java index 424b708fba..fc65ba2a9f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java @@ -1753,7 +1753,7 @@ public static TwoCycleErrors getTwoCycleErrors(Graph trueGraph, Graph estGraph) if (!edge.isDirected()) { continue; } - + Node node1 = edge.getNode1(); Node node2 = edge.getNode2(); @@ -2517,26 +2517,28 @@ public static void gfciR0(Graph graph, Graph referenceCpdag, SepsetProducer seps } else if (referenceCpdag.isAdjacentTo(a, c)) { Set sepset = sepsets.getSepset(a, c); - if (graph.isAdjacentTo(a, c)) { - graph.removeEdge(a, c); - } + if (sepset != null && graph.isAdjacentTo(a, c)) { + if (graph.isAdjacentTo(a, c)) { + graph.removeEdge(a, c); + } - if (sepset != null && !sepset.contains(b) && FciOrient.isArrowheadAllowed(a, b, graph, knowledge) && FciOrient.isArrowheadAllowed(c, b, graph, knowledge)) { - graph.setEndpoint(a, b, Endpoint.ARROW); - graph.setEndpoint(c, b, Endpoint.ARROW); + if (!sepset.contains(b) && FciOrient.isArrowheadAllowed(a, b, graph, knowledge) && FciOrient.isArrowheadAllowed(c, b, graph, knowledge)) { + graph.setEndpoint(a, b, Endpoint.ARROW); + graph.setEndpoint(c, b, Endpoint.ARROW); - if (verbose) { - double p = sepsets.getPValue(a, c, sepset); - String _p = p < 0.0001 ? "< 0.0001" : String.format("%.4f", p); + if (verbose) { + double p = sepsets.getPValue(a, c, sepset); + String _p = p < 0.0001 ? "< 0.0001" : String.format("%.4f", p); - TetradLogger.getInstance().forceLogMessage("Oriented collider " + a + " *-> " + b + " <-* " + c + " (from test)), p = " + _p + "."); + TetradLogger.getInstance().forceLogMessage("Oriented collider " + a + " *-> " + b + " <-* " + c + " (from test)), p = " + _p + "."); - if (Edges.isBidirectedEdge(graph.getEdge(a, b))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(a, b)); - } + if (Edges.isBidirectedEdge(graph.getEdge(a, b))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(a, b)); + } - if (Edges.isBidirectedEdge(graph.getEdge(b, c))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(b, c)); + if (Edges.isBidirectedEdge(graph.getEdge(b, c))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(b, c)); + } } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index ebb3cd994e..3116cd5f88 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -114,6 +114,10 @@ public final class GFci implements IGraphSearch { * Whether verbose output should be printed. */ private boolean verbose; + /** + * Whether the discriminating path collider rule should be used. + */ + private boolean doDiscriminatingPathColliderRule = true; /** * Constructs a new GFci algorithm with the given independence test and score. @@ -168,7 +172,7 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); @@ -303,4 +307,13 @@ public void setNumThreads(int numThreads) { } this.numThreads = numThreads; } + + /** + * Sets whether the discriminating path collider rules should be used. + * + * @param doDiscriminatingPathColliderRule True, if the discriminating path collider rules should be used. False, otherwise. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } } 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 4aeed95fca..3a32af8d76 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 @@ -125,6 +125,10 @@ public final class GraspFci implements IGraphSearch { * True iff verbose output should be printed. */ private boolean verbose; + /** + * Indicates whether the discriminating path collider rule should be used in GRaSP. + */ + private boolean setDoDiscriminatingPathColliderRule = true; /** * Constructs a new GraspFci object. @@ -192,7 +196,7 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathColliderRule(setDoDiscriminatingPathColliderRule); fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); @@ -335,4 +339,13 @@ public void setSeed(long seed) { public void setDepth(int depth) { this.depth = depth; } + + /** + * Sets whether to use the discriminating path collider rule for GRaSP. + * + * @param doDiscriminatingPathColliderRule True, if so. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.setDoDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 94833cc37c..1d5497a025 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -75,12 +75,12 @@ public final class LvLite implements IGraphSearch { *

* By default, the value of this variable is set to true, indicating that the discriminating path rule is used. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; /** * Indicates whether the discriminating path collider rule is turned on or off. - * - * If set to true, the discriminating path collider rule is enabled. - * If set to false, the discriminating path collider rule is disabled. + *

+ * If set to true, the discriminating path collider rule is enabled. If set to false, the discriminating path + * collider rule is disabled. */ private boolean doDiscriminatingPathColliderRule = true; /** @@ -172,7 +172,8 @@ public Graph search() { var pag = new EdgeListGraph(cpdag); scorer.score(best); - var fciOrient = new FciOrient(null); + FciOrient fciOrient = new FciOrient(null); + fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(false); fciOrient.setDoDiscriminatingPathTailRule(false); @@ -192,32 +193,7 @@ public Graph search() { orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag); } while (!unshieldedColliders.equals(_unshieldedColliders)); - finalOrientation(fciOrient, pag, scorer, doDiscriminatingPathColliderRule); - -// boolean changed; -// int count = 0; -// -// do { -// changed = false; -// -// for (int i = 0; i < nodes.size(); i++) { -// for (int j = i + 1; j < nodes.size(); j++) { -// Node n1 = nodes.get(i); -// Node n2 = nodes.get(j); -// if (!pag.isAdjacentTo(n1, n2)) { -// List inducingPath = pag.paths().getInducingPath(n1, n2); -// -// if (inducingPath != null) { -// pag.addNondirectedEdge(n1, n2); -// changed = true; -// } -// } -// } -// } -// -// } while (changed && count++ <= 2); - -// finalOrientation(fciOrient, pag, scorer); + finalOrientation(fciOrient, pag, scorer); return GraphUtils.replaceNodes(pag, this.score.getVariables()); } @@ -269,21 +245,21 @@ public void setUseDataOrder(boolean useDataOrder) { } /** - * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. + * Sets whether the search algorithm should use the Discriminating Path Rule. * - * @param useBes true to use the BES algorithm, false otherwise + * @param doDiscriminatingPathTailRule true if the Discriminating Path Rule should be used, false otherwise */ - public void setUseBes(boolean useBes) { - this.useBes = useBes; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } /** - * Sets whether the search algorithm should use the Discriminating Path Rule. + * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. * - * @param doDiscriminatingPathRule true if the Discriminating Path Rule should be used, false otherwise + * @param useBes true to use the BES algorithm, false otherwise */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setUseBes(boolean useBes) { + this.useBes = useBes; } /** @@ -313,6 +289,8 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var reverse = new ArrayList<>(best); Collections.reverse(reverse); + Set toRemove = new HashSet<>(); + // Copy al the unshielded triples from the old PAG to the new PAG where adjacencies still exist. for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -325,14 +303,18 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); +// if (pag.isAdjacentTo(x, y)) { if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { - if (copyUnshieldedCollider(x, b, y, scorer, pag, null, true, cpdag)) { - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); - } + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + pag.removeEdge(x, y); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } +// } } } } @@ -344,78 +326,84 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< adj.sort(Comparator.comparingInt(reverse::indexOf)); for (int i = 0; i < adj.size(); i++) { - for (int j = i + 1; j < adj.size(); j++) { + for (int j = 0; j < adj.size(); j++) { + if (i == j) continue; + var x = adj.get(i); var y = adj.get(j); // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - if (unshieldedCollider(cpdag, x, b, y) && unshieldedTriple(pag, x, b, y)) { - if (copyUnshieldedCollider(x, b, y, scorer, pag, unshieldedColliders, true, cpdag)) { - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + if (unshieldedTriple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + unshieldedColliders.add(new Triple(x, b, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } else if (allowTucks && pag.isAdjacentTo(x, y)) { scorer.goToBookmark(); scorer.tuck(b, x); - scorer.tuck(b, y); - if (copyUnshieldedCollider(x, b, y, scorer, pag, unshieldedColliders, false, cpdag)) { + boolean scorerUnshieldedCollider = scorer.unshieldedCollider(x, b, y); + boolean pagTriple = triple(pag, x, b, y); + boolean colliderAllowed = colliderAllowed(pag, x, b, y); + + if (pagTriple && scorerUnshieldedCollider && colliderAllowed) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + if (verbose) { TetradLogger.getInstance().forceLogMessage( - "TUCKING: Oriented " + x + " *-> " + b + " <-* " + y + "."); + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); + + List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); + commonAdj.retainAll(pag.getAdjacentNodes(y)); + + List commonChildren = new ArrayList<>(pag.getChildren(x)); + commonChildren.retainAll(pag.getChildren(y)); + + commonAdj.removeAll(commonChildren); + + for (Node a : commonAdj) { + if (a == b) continue; + + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "### Also oriented " + x + " *-> " + b + " <-* " + y + "."); + } } } } } } } - } - /** - * Copies the content of node x to node b and removes the edge between node x and node y, based on the specified - * scorer and graph. If the triple is already an unshielded collider, the method returns false, and if the triple is - * not a collider in the scorer or is not a triple in the PAG, the method returns false. If orienting the triple as - * a collider is not allowed, the method returns false. Otherwise, true is returned. - * - * @param x The source node to copy from. - * @param b The target node to copy to. - * @param y The node to remove the edge between x and y. - * @param scorer The scorer to evaluate the conditions for copying and removing. - * @param pag The PAG to perform the copying and removing operations on. - * @return true if the removal/orientation code was performed, false otherwise. - */ - private boolean copyUnshieldedCollider(Node x, Node b, Node y, TeyssierScorer scorer, Graph pag, - Set unshieldedColliders, boolean checkCpdag, Graph cpdag) { - if (unshieldedCollider(pag, x, b, y)) { - return false; - } + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); - boolean unshieldedCollider = checkCpdag ? unshieldedCollider(cpdag, x, b, y) : scorer.unshieldedCollider(x, b, y); - - if (unshieldedCollider && triple(pag, x, b, y) && colliderAllowed(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - boolean adj = pag.isAdjacentTo(x, y); + boolean _adj = pag.isAdjacentTo(x, y); if (pag.removeEdge(x, y)) { - if (verbose && adj && !pag.isAdjacentTo(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { TetradLogger.getInstance().forceLogMessage( "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); } } - - if (unshieldedColliders != null) { - unshieldedColliders.add(new Triple(x, b, y)); - } - - return true; } - - return false; } /** @@ -494,7 +482,7 @@ private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { * @param pag The Graph object for which the final orientation is determined. * @param scorer The scorer object used in the score-based discriminating path rule. */ - private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer, boolean doDiscriminatingPathColliderRule) { + private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { if (verbose) { TetradLogger.getInstance().forceLogMessage("Final Orientation:"); } @@ -505,7 +493,7 @@ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer sco } else { fciOrient.spirtesFinalOrientation(pag); } - } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathColliderRule)); // Score-based discriminating path rule + } while (discriminatingPathRule(pag, scorer)); // Score-based discriminating path rule } /** @@ -523,11 +511,10 @@ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer sco *

* This is Zhang's rule R4, discriminating paths. * - * @param graph a {@link Graph} object - * @param doDiscriminatingPathColliderRule + * @param graph a {@link Graph} object */ - private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer, boolean doDiscriminatingPathColliderRule) { - if (!doDiscriminatingPathRule) return false; + private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { + if (!doDiscriminatingPathTailRule) return false; List nodes = graph.getNodes(); boolean oriented = false; @@ -562,7 +549,7 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer, boole continue; } - boolean _oriented = ddpOrient(a, b, c, graph, scorer, doDiscriminatingPathColliderRule); + boolean _oriented = ddpOrient(a, b, c, graph, scorer); if (_oriented) oriented = true; } @@ -577,13 +564,12 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer, boole * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP * consists of colliders that are parents of c. * - * @param a a {@link Node} object - * @param b a {@link Node} object - * @param c a {@link Node} object - * @param graph a {@link Graph} object - * @param doDiscriminatingPathColliderRule + * @param a a {@link Node} object + * @param b a {@link Node} object + * @param c a {@link Node} object + * @param graph a {@link Graph} object */ - private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer, boolean doDiscriminatingPathColliderRule) { + private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { Queue Q = new ArrayDeque<>(20); Set V = new HashSet<>(); @@ -591,7 +577,6 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc Map previous = new HashMap<>(); List path = new ArrayList<>(); - path.add(a); List cParents = graph.getParents(c); @@ -622,7 +607,6 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc continue; } - previous.put(d, t); Node p = previous.get(t); if (!graph.isDefCollider(d, t, p)) { @@ -636,7 +620,7 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc } if (!graph.isAdjacentTo(d, c)) { - if (doDdpOrientation(d, a, b, c, path, graph, scorer, doDiscriminatingPathColliderRule)) { + if (doDdpOrientation(d, a, b, c, path, graph, scorer)) { return true; } } @@ -672,71 +656,80 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc * at B; otherwise, there should be a noncollider at B. * * - * @param e the 'e' node - * @param a the 'a' node - * @param b the 'b' node - * @param c the 'c' node - * @param graph the graph representation - * @param doDiscriminatingPathColliderRule whether to apply the collider rule. + * @param e the 'e' node + * @param a the 'a' node + * @param b the 'b' node + * @param c the 'c' node + * @param graph the graph representation * @return true if the orientation is determined, false otherwise * @throws IllegalArgumentException if 'e' is adjacent to 'c' */ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph - graph, TeyssierScorer scorer, boolean doDiscriminatingPathColliderRule) { + graph, TeyssierScorer scorer) { + + if (graph.getEndpoint(b, c) != Endpoint.ARROW) { + return false; + } if (graph.getEndpoint(c, b) != Endpoint.CIRCLE) { return false; } - for (Node n : path) { - if (!graph.isParentOf(n, c)) { - throw new IllegalArgumentException("Node " + n + " is not a parent of " + c); - } + if (graph.getEndpoint(a, c) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(b, a) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(c, a) != Endpoint.TAIL) { + return false; } if (!path.contains(a)) { throw new IllegalArgumentException("Path does not contain a"); } + for (Node n : path) { + if (!graph.isParentOf(n, c)) { + throw new IllegalArgumentException("Node " + n + " is not a parent of " + c); + } + } + scorer.goToBookmark(); scorer.tuck(b, c); scorer.tuck(b, e); scorer.tuck(c, e); -// -// for (Node node : path) { -// scorer.tuck(e, node); -// } -// -// scorer.tuck(a, e); -// scorer.tuck(b, e); + boolean collider = !scorer.adjacent(e, c); - boolean collider = !scorer.parent(e, c); + if (collider) { + if (doDiscriminatingPathColliderRule) { + graph.setEndpoint(a, b, Endpoint.ARROW); + graph.setEndpoint(c, b, Endpoint.ARROW); - if (collider && doDiscriminatingPathColliderRule) { - if (!colliderAllowed(graph, a, b, c)) { - return false; - } - - graph.setEndpoint(a, b, Endpoint.ARROW); - graph.setEndpoint(c, b, Endpoint.ARROW); + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } - if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( - "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + return true; } - - return true; } else { - graph.setEndpoint(c, b, Endpoint.TAIL); + if (doDiscriminatingPathTailRule) { + graph.setEndpoint(c, b, Endpoint.TAIL); - if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( - "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); - } + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } - return true; + return true; + } } + + return false; } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java new file mode 100644 index 0000000000..cca968ef53 --- /dev/null +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -0,0 +1,898 @@ +/////////////////////////////////////////////////////////////////////////////// +// For information as to what this class does, see the Javadoc, below. //i +// 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.*; +import edu.cmu.tetrad.search.score.Score; +import edu.cmu.tetrad.search.test.MsepTest; +import edu.cmu.tetrad.search.utils.DagSepsets; +import edu.cmu.tetrad.search.utils.FciOrient; +import edu.cmu.tetrad.search.utils.TeyssierScorer; +import edu.cmu.tetrad.util.TetradLogger; +import org.jetbrains.annotations.NotNull; + +import java.util.*; + +/** + * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the + * structure of a graphical model from observational data. + *

+ * This class provides methods for running the search algorithm and getting the learned pattern as a PAG (Partially + * Annotated Graph). + * + * @author josephramsey + */ +public final class LvLiteDsepFriendly implements IGraphSearch { + private final ArrayList variables; + private boolean useRaskuttiUhler; + private IndependenceTest test; + /** + * The score. + */ + private Score score; + private boolean useScore; + /** + * The background knowledge. + */ + private Knowledge knowledge = new Knowledge(); + /** + * Flag for the complete rule set, true if one should use the complete rule set, false otherwise. + */ + private boolean completeRuleSetUsed = true; + /** + * The number of starts for GRaSP. + */ + private int numStarts = 1; + /** + * Whether to use data order. + */ + private boolean useDataOrder = true; + /** + * This flag represents whether the Bes algorithm should be used in the search. + *

+ * If set to true, the Bes algorithm will be used. If set to false, the Bes algorithm will not be used. + *

+ * By default, the value of this flag is false. + */ + private boolean useBes = false; + /** + * This variable represents whether the discriminating path rule is used in the LV-Lite class. + *

+ * The discriminating path rule is a rule used in the search algorithm. It determines whether the algorithm + * considers discriminating paths when searching for patterns in the data. + *

+ * By default, the value of this variable is set to true, indicating that the discriminating path rule is used. + */ + private boolean doDiscriminatingPathTailRule = true; + /** + * Indicates whether the discriminating path collider rule is turned on or off. + *

+ * If set to true, the discriminating path collider rule is enabled. If set to false, the discriminating path + * collider rule is disabled. + */ + private boolean doDiscriminatingPathColliderRule = true; + /** + * True iff verbose output should be printed. + */ + private boolean verbose; + /** + * Represents a variable that determines whether tucks are allowed. The value of this variable determines whether + * tucks are enabled or disabled. + */ + private boolean allowTucks = true; + /** + * The scorer to be used. + */ + private TeyssierScorer scorer; + /** + * The time at which the algorithm started. + */ + private long start; + /** + * Whether to impose an ordering on the three GRaSP algorithms. + */ + private boolean ordered = false; + /** + * The maximum depth of the depth-first search for tucks. + */ + private int uncoveredDepth = 1; + /** + * The maximum depth of the depth-first search for uncovered tucks. + */ + private int nonSingularDepth = 1; + /** + * The maximum depth of the depth-first search for singular tucks. + */ + private int depth = 3; + /** + * Whether to allow internal randomness in the algorithm. + */ + private boolean allowInternalRandomness = false; + /** + * Represents the seed used for random number generation or shuffling. + */ + private long seed = -1; + /** + * The maximum path length. + */ + private int maxPathLength = -1; + + /** + * Constructor for a score. + * + * @param score The score to use. + */ + public LvLiteDsepFriendly(@NotNull Score score) { + this.score = score; + this.variables = new ArrayList<>(score.getVariables()); + this.useScore = true; + } + + /** + * Constructor for a test. + * + * @param test The test to use. + */ + public LvLiteDsepFriendly(@NotNull IndependenceTest test) { + this.test = test; + this.variables = new ArrayList<>(test.getVariables()); + this.useScore = false; + this.useRaskuttiUhler = true; + } + + /** + * Constructor that takes both a test and a score; only one is used-- the parameter setting will decide which. + * + * @param test The test to use. + * @param score The score to use. + */ + public LvLiteDsepFriendly(@NotNull IndependenceTest test, Score score) { + this.test = test; + this.score = score; + this.variables = new ArrayList<>(score.getVariables()); + } + + /** + * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given + * Graph following the PAG (Partially Ancestral Graph) structure. + * + * @param pag The Graph to be reoriented. + */ + private void reorientWithCircles(Graph pag) { + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Orient all edges in PAG as o-o:"); + } + pag.reorientAllWith(Endpoint.CIRCLE); + } + + /** + * Run the search and return s a PAG. + * + * @return The PAG. + */ + public Graph search() { + List nodes = this.score.getVariables(); + + if (nodes == null) { + throw new NullPointerException("Nodes from test were null."); + } + + if (verbose) { + TetradLogger.getInstance().forceLogMessage("===Starting LV-Lite==="); + } + + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Running BOSS to get CPDAG and best order."); + } + + test.setVerbose(verbose); + edu.cmu.tetrad.search.Grasp grasp = new edu.cmu.tetrad.search.Grasp(test, score); + + grasp.setSeed(seed); + grasp.setDepth(depth); + grasp.setUncoveredDepth(uncoveredDepth); + grasp.setNonSingularDepth(nonSingularDepth); + grasp.setOrdered(ordered); + grasp.setUseScore(useScore); + grasp.setUseRaskuttiUhler(useRaskuttiUhler); + grasp.setUseDataOrder(useDataOrder); + grasp.setAllowInternalRandomness(allowInternalRandomness); + grasp.setVerbose(verbose); + + grasp.setNumStarts(numStarts); + grasp.setKnowledge(this.knowledge); + List best = grasp.bestOrder(variables); + grasp.getGraph(true); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Best order: " + best); + } + + var scorer = new TeyssierScorer(test, score); + scorer.setUseScore(useScore); + scorer.score(best); + scorer.bookmark(); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().forceLogMessage("Initializing scorer with BOSS best order."); + } + + var cpdag = scorer.getGraph(true); + var pag = new EdgeListGraph(cpdag); + scorer.score(best); + + FciOrient fciOrient; + + if (test instanceof MsepTest) { + fciOrient = new FciOrient(new DagSepsets(((MsepTest) test).getGraph())); + } else { + fciOrient = new FciOrient(null); + } + + fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); + fciOrient.setDoDiscriminatingPathColliderRule(false); + fciOrient.setDoDiscriminatingPathTailRule(false); + fciOrient.setKnowledge(knowledge); + fciOrient.setVerbose(verbose); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Collider orientation and edge removal."); + } + + // The main procedure. + Set unshieldedColliders = new HashSet<>(); + Set _unshieldedColliders; + + do { + _unshieldedColliders = new HashSet<>(unshieldedColliders); + orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag); + } while (!unshieldedColliders.equals(_unshieldedColliders)); + + finalOrientation(fciOrient, pag, scorer); + + return GraphUtils.replaceNodes(pag, this.score.getVariables()); + } + + /** + * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. + * + * @param useBes true to use the BES algorithm, false otherwise + */ + public void setUseBes(boolean useBes) { + this.useBes = useBes; + } + + /** + * Sets the value of the doDiscriminatingPathColliderRule property. + * + * @param doDiscriminatingPathColliderRule the new value for the doDiscriminatingPathColliderRule property + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } + + /** + * Orients and removes edges in a graph according to specified rules. Edges are removed in the course of the + * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the + * possibility that the removal of an edge may allow for further removals or orientations. + * + * @param pag The original graph. + * @param fciOrient The orientation rules to be applied. + * @param best The list of best nodes. + * @param scorer The scorer used to evaluate edge orientations. + */ + private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, + Set unshieldedColliders, Graph cpdag) { + reorientWithCircles(pag); + doRequiredOrientations(fciOrient, pag, best); + + var reverse = new ArrayList<>(best); + Collections.reverse(reverse); + + Set toRemove = new HashSet<>(); + + // Copy al the unshielded triples from the old PAG to the new PAG where adjacencies still exist. + for (Node b : reverse) { + var adj = pag.getAdjacentNodes(b); + + // Sort adj in the order of reverse + adj.sort(Comparator.comparingInt(reverse::indexOf)); + + for (int i = 0; i < adj.size(); i++) { + for (int j = i + 1; j < adj.size(); j++) { + var x = adj.get(i); + var y = adj.get(j); + +// if (pag.isAdjacentTo(x, y)) { + if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + pag.removeEdge(x, y); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); + } + } +// } + } + } + } + + for (Node b : reverse) { + var adj = pag.getAdjacentNodes(b); + + // Sort adj in the order of reverse + adj.sort(Comparator.comparingInt(reverse::indexOf)); + + for (int i = 0; i < adj.size(); i++) { + for (int j = 0; j < adj.size(); j++) { + if (i == j) continue; + + var x = adj.get(i); + var y = adj.get(j); + + // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, + // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. + if (unshieldedTriple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + unshieldedColliders.add(new Triple(x, b, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } + } else if (allowTucks && pag.isAdjacentTo(x, y)) { + scorer.goToBookmark(); + scorer.tuck(b, x); + + boolean scorerUnshieldedCollider = scorer.unshieldedCollider(x, b, y); + boolean pagTriple = triple(pag, x, b, y); + boolean colliderAllowed = colliderAllowed(pag, x, b, y); + + if (pagTriple && scorerUnshieldedCollider && colliderAllowed) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); + + List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); + commonAdj.retainAll(pag.getAdjacentNodes(y)); + + List commonChildren = new ArrayList<>(pag.getChildren(x)); + commonChildren.retainAll(pag.getChildren(y)); + + commonAdj.removeAll(commonChildren); + + for (Node a : commonAdj) { + if (a == b) continue; + + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "### Also oriented " + x + " *-> " + b + " <-* " + y + "."); + } + } + } + } + } + } + } + + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); + + boolean _adj = pag.isAdjacentTo(x, y); + + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().forceLogMessage( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } + } + + /** + * Determines if the collider is allowed. + * + * @param pag The Graph representing the PAG. + * @param x The Node object representing the first node. + * @param b The Node object representing the second node. + * @param y The Node object representing the third node. + * @return true if the collider is allowed, false otherwise. + */ + private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { + return FciOrient.isArrowheadAllowed(x, b, pag, knowledge) + && FciOrient.isArrowheadAllowed(y, b, pag, knowledge); + } + + /** + * Orient required edges in PAG. + * + * @param fciOrient The FciOrient object used for orienting the edges. + * @param pag The Graph representing the PAG. + * @param best The list of Node objects representing the best nodes. + */ + private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best) { + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Orient required edges in PAG:"); + } + + fciOrient.fciOrientbk(knowledge, pag, best); + } + + /** + * Checks if three nodes in a graph form an unshielded triple. An unshielded triple is a configuration where node a + * is adjacent to node b, node b is adjacent to node c, but node a is not adjacent to node c. + * + * @param graph The graph in which the nodes reside. + * @param a The first node in the triple. + * @param b The second node in the triple. + * @param c The third node in the triple. + * @return {@code true} if the nodes form an unshielded triple, {@code false} otherwise. + */ + private boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); + } + + /** + * Checks if three nodes are connected in a graph. + * + * @param graph the graph to check for connectivity + * @param a the first node + * @param b the second node + * @param c the third node + * @return {@code true} if all three nodes are connected, {@code false} otherwise + */ + private boolean triple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + } + + /** + * Checks if the given nodes are unshielded colliders when considering the given graph. + * + * @param graph the graph to consider + * @param a the first node + * @param b the second node + * @param c the third node + * @return true if the nodes are unshielded colliders, false otherwise + */ + private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { + return a != c && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); + } + + /** + * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. + * + * @param fciOrient The FciOrient object used to determine the final orientation. + * @param pag The Graph object for which the final orientation is determined. + * @param scorer The scorer object used in the score-based discriminating path rule. + */ + private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Final Orientation:"); + } + + do { + if (completeRuleSetUsed) { + fciOrient.zhangFinalOrientation(pag); + } else { + fciOrient.spirtesFinalOrientation(pag); + } + } while (discriminatingPathRule(pag, scorer)); // Score-based discriminating path rule + } + + /** + * This is a score-based discriminating path rule. + *

+ * The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where + * the dots are a collider path from E to A with each node on the path (except L) a parent of C. + *

+     *          B
+     *         xo           x is either an arrowhead or a circle
+     *        /  \
+     *       v    v
+     * E....A --> C
+     * 
+ *

+ * This is Zhang's rule R4, discriminating paths. + * + * @param graph a {@link Graph} object + */ + private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { + if (!doDiscriminatingPathTailRule) return false; + + List nodes = graph.getNodes(); + boolean oriented = false; + + for (Node b : nodes) { + if (Thread.currentThread().isInterrupted()) { + break; + } + + // potential A and C candidate pairs are only those + // that look like this: A<-*Bo-*C + List possA = graph.getNodesOutTo(b, Endpoint.ARROW); + List possC = graph.getNodesInTo(b, Endpoint.CIRCLE); + + for (Node a : possA) { + if (Thread.currentThread().isInterrupted()) { + break; + } + + for (Node c : possC) { + if (Thread.currentThread().isInterrupted()) { + break; + } + + if (a == c) continue; + + if (!graph.isParentOf(a, c)) { + continue; + } + + if (graph.getEndpoint(b, c) != Endpoint.ARROW) { + continue; + } + + boolean _oriented = ddpOrient(a, b, c, graph, scorer); + + if (_oriented) oriented = true; + } + } + } + + return oriented; + } + + /** + * A method to search "back from a" to find a DDP. It is called with a reachability list (first consisting only of + * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP + * consists of colliders that are parents of c. + * + * @param a a {@link Node} object + * @param b a {@link Node} object + * @param c a {@link Node} object + * @param graph a {@link Graph} object + */ + private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { + Queue Q = new ArrayDeque<>(20); + Set V = new HashSet<>(); + + Node e = null; + + Map previous = new HashMap<>(); + List path = new ArrayList<>(); + + List cParents = graph.getParents(c); + + Q.offer(a); + V.add(a); + V.add(b); + previous.put(a, b); + + while (!Q.isEmpty()) { + if (Thread.currentThread().isInterrupted()) { + break; + } + + Node t = Q.poll(); + + if (e == null || e == t) { + e = t; + } + + List nodesInTo = graph.getNodesInTo(t, Endpoint.ARROW); + + for (Node d : nodesInTo) { + if (Thread.currentThread().isInterrupted()) { + break; + } + + if (V.contains(d)) { + continue; + } + + Node p = previous.get(t); + + if (!graph.isDefCollider(d, t, p)) { + continue; + } + + previous.put(d, t); + + if (!path.contains(t)) { + path.add(t); + } + + if (!graph.isAdjacentTo(d, c)) { + if (doDdpOrientation(d, a, b, c, path, graph, scorer)) { + return true; + } + } + + if (cParents.contains(d)) { + Q.offer(d); + V.add(d); + } + } + } + + return false; + } + + /** + * Determines the orientation for the nodes in a Directed Acyclic Graph (DAG) based on the Discriminating Path Rule + * Here, we insist that the sepset for D and B contain all the nodes along the collider path. + *

+ * Reminder: + *

+     *      The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where
+     *      the dots are a collider path from E to A with each node on the path (except L) a parent of C.
+     *      
+     *               B
+     *              xo           x is either an arrowhead or a circle
+     *             /  \
+     *            v    v
+     *      E....A --> C
+     *
+     *      This is Zhang's rule R4, discriminating paths. The "collider path" here is all of the collider nodes
+     *      along the E...A path (all parents of C), including A. The idea is that is we know that E is independent
+     *      of C given all of nodes on the collider path plus perhaps some other nodes, then there should be a collider
+     *      at B; otherwise, there should be a noncollider at B.
+     * 
+ * + * @param e the 'e' node + * @param a the 'a' node + * @param b the 'b' node + * @param c the 'c' node + * @param graph the graph representation + * @return true if the orientation is determined, false otherwise + * @throws IllegalArgumentException if 'e' is adjacent to 'c' + */ + private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph + graph, TeyssierScorer scorer) { + + if (graph.getEndpoint(b, c) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(c, b) != Endpoint.CIRCLE) { + return false; + } + + if (graph.getEndpoint(a, c) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(b, a) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(c, a) != Endpoint.TAIL) { + return false; + } + + if (!path.contains(a)) { + throw new IllegalArgumentException("Path does not contain a"); + } + + for (Node n : path) { + if (!graph.isParentOf(n, c)) { + throw new IllegalArgumentException("Node " + n + " is not a parent of " + c); + } + } + + scorer.goToBookmark(); + scorer.tuck(b, c); + scorer.tuck(b, e); + scorer.tuck(c, e); + + boolean collider = !scorer.adjacent(e, c); + + if (collider) { + if (doDiscriminatingPathColliderRule) { + graph.setEndpoint(a, b, Endpoint.ARROW); + graph.setEndpoint(c, b, Endpoint.ARROW); + + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } + + return true; + } + } else { + if (doDiscriminatingPathTailRule) { + graph.setEndpoint(c, b, Endpoint.TAIL); + + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } + + return true; + } + } + + return false; + } + + /** + * Sets the allowTucks flag to the specified value. + * + * @param allowTucks the boolean value indicating whether tucks are allowed + */ + public void setAllowTucks(boolean allowTucks) { + this.allowTucks = allowTucks; + } + + + /** + * Sets the knowledge used in search. + * + * @param knowledge This knowledge. + */ + public void setKnowledge(Knowledge knowledge) { + this.knowledge = new Knowledge(knowledge); + } + + /** + * Sets whether Zhang's complete rules set is used. + * + * @param completeRuleSetUsed set to true if Zhang's complete rule set should be used, false if only R1-R4 (the rule + * set of the original FCI) should be used. False by default. + */ + public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { + this.completeRuleSetUsed = completeRuleSetUsed; + } + + /** + * Sets whether verbose output should be printed. + * + * @param verbose True, if so. + */ + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + /** + * Sets the number of starts for GRaSP. + * + * @param numStarts The number of starts. + */ + public void setNumStarts(int numStarts) { + this.numStarts = numStarts; + } + + /** + * Sets whether to use Raskutti and Uhler's modification of GRaSP. + * + * @param useRaskuttiUhler True, if so. + */ + public void setUseRaskuttiUhler(boolean useRaskuttiUhler) { + this.useRaskuttiUhler = useRaskuttiUhler; + } + + /** + * Sets whether to use data order for GRaSP (as opposed to random order) for the first step of GRaSP + * + * @param useDataOrder True, if so. + */ + public void setUseDataOrder(boolean useDataOrder) { + this.useDataOrder = useDataOrder; + } + + /** + * Sets whether to use score for GRaSP (as opposed to independence test) for GRaSP. + * + * @param useScore True, if so. + */ + public void setUseScore(boolean useScore) { + this.useScore = useScore; + } + + /** + * Sets whether to use the discriminating path rule for GRaSP. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets depth for singular tucks. + * + * @param uncoveredDepth The depth for singular tucks. + */ + public void setSingularDepth(int uncoveredDepth) { + if (uncoveredDepth < -1) throw new IllegalArgumentException("Uncovered depth should be >= -1."); + this.uncoveredDepth = uncoveredDepth; + } + + /** + * Sets depth for non-singular tucks. + * + * @param nonSingularDepth The depth for non-singular tucks. + */ + public void setNonSingularDepth(int nonSingularDepth) { + if (nonSingularDepth < -1) throw new IllegalArgumentException("Non-singular depth should be >= -1."); + this.nonSingularDepth = nonSingularDepth; + } + + /** + * Sets whether to use the ordered version of GRaSP. + * + * @param ordered True, if so. + */ + public void setOrdered(boolean ordered) { + this.ordered = ordered; + } + + /** + *

Setter for the field seed.

+ * + * @param seed a long + */ + public void setSeed(long seed) { + this.seed = seed; + } + + /** + * Sets the depth for the search algorithm. + * + * @param depth The depth value to set for the search algorithm. + */ + public void setDepth(int depth) { + this.depth = depth; + } + + + /** + * Sets the maximum length of any discriminating path searched. + * + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. + */ + public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + + this.maxPathLength = maxPathLength; + } +} diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagSepsets.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagSepsets.java index 5b833dfcc4..172f167575 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagSepsets.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagSepsets.java @@ -119,7 +119,7 @@ public boolean isIndependent(Node a, Node b, Set sepset) { */ @Override public double getPValue(Node a, Node b, Set sepset) { - throw new UnsupportedOperationException("This makes no sense for this subclass."); + return dag.paths().isMSeparatedFrom(a, b, sepset, false) ? 1.0 : 0.0; } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java index 177a529d76..cb0248e04c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java @@ -672,24 +672,22 @@ public void ruleR4B(Graph graph) { /** * A method to search "back from a" to find a DDP. It is called with a reachability list (first consisting only of - * a). This is breadth-first, utilizing "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP + * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP * consists of colliders that are parents of c. * - * @param a a {@link edu.cmu.tetrad.graph.Node} object - * @param b a {@link edu.cmu.tetrad.graph.Node} object - * @param c a {@link edu.cmu.tetrad.graph.Node} object - * @param graph a {@link edu.cmu.tetrad.graph.Graph} object + * @param a a {@link Node} object + * @param b a {@link Node} object + * @param c a {@link Node} object + * @param graph a {@link Graph} object */ - private void ddpOrient(Node a, Node b, Node c, Graph graph) { + private boolean ddpOrient(Node a, Node b, Node c, Graph graph) { Queue Q = new ArrayDeque<>(20); Set V = new HashSet<>(); Node e = null; - int distance = 0; Map previous = new HashMap<>(); - Set colliderPath = new HashSet<>(); - colliderPath.add(a); + List path = new ArrayList<>(); List cParents = graph.getParents(c); @@ -707,10 +705,6 @@ private void ddpOrient(Node a, Node b, Node c, Graph graph) { if (e == null || e == t) { e = t; - distance++; - if (distance > 0 && distance > (this.maxPathLength == -1 ? 1000 : this.maxPathLength)) { - return; - } } List nodesInTo = graph.getNodesInTo(t, Endpoint.ARROW); @@ -724,7 +718,7 @@ private void ddpOrient(Node a, Node b, Node c, Graph graph) { continue; } - previous.put(d, t); +// previous.put(d, t); Node p = previous.get(t); if (!graph.isDefCollider(d, t, p)) { @@ -732,11 +726,14 @@ private void ddpOrient(Node a, Node b, Node c, Graph graph) { } previous.put(d, t); - colliderPath.add(t); + + if (!path.contains(t)) { + path.add(t); + } if (!graph.isAdjacentTo(d, c)) { - if (doDdpOrientation(d, a, b, c, graph, colliderPath)) { - return; + if (doDdpOrientation(d, a, b, c, path, graph)) { + return true; } } @@ -746,6 +743,8 @@ private void ddpOrient(Node a, Node b, Node c, Graph graph) { } } } + + return false; } /** @@ -940,33 +939,86 @@ public void rulesR8R9R10(Graph graph) { * at B; otherwise, there should be a noncollider at B. *
* - * @param d the 'd' node - * @param a the 'a' node - * @param b the 'b' node - * @param c the 'c' node - * @param graph the graph representation - * @param colliderPath the list of nodes in the collider path + * @param e the 'e' node + * @param a the 'a' node + * @param b the 'b' node + * @param c the 'c' node + * @param graph the graph representation * @return true if the orientation is determined, false otherwise - * @throws IllegalArgumentException if 'd' is adjacent to 'c' + * @throws IllegalArgumentException if 'e' is adjacent to 'c' */ - private boolean doDdpOrientation(Node d, Node a, Node b, Node c, Graph graph, Set colliderPath) { - if (graph.isAdjacentTo(d, c)) { - throw new IllegalArgumentException(); + private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph graph) { + if (graph.getEndpoint(b, c) != Endpoint.ARROW) { + return false; } - Set sepset = getSepsets().getSepsetContaining(d, c, colliderPath); + if (graph.getEndpoint(c, b) != Endpoint.CIRCLE) { + return false; + } - if (this.verbose) { - logger.forceLogMessage("Sepset for d = " + d + " and c = " + c + " = " + sepset); + if (graph.getEndpoint(a, c) != Endpoint.ARROW) { + return false; } - if (sepset == null) { - if (this.verbose) { - logger.forceLogMessage("Must be a sepset: " + d + " and " + c + "; they're non-adjacent."); + if (graph.getEndpoint(b, a) != Endpoint.ARROW) { + return false; + } + + if (graph.getEndpoint(c, a) != Endpoint.TAIL) { + return false; + } + + if (!path.contains(a)) { + throw new IllegalArgumentException("Path does not contain a"); + } + + for (Node n : path) { + if (!graph.isParentOf(n, c)) { + throw new IllegalArgumentException("Node " + n + " is not a parent of " + c); } + } + + Set sepset = getSepsets().getSepsetContaining(e, c, new HashSet<>(path)); + + if (sepset == null) { return false; } + if (this.verbose) { + logger.forceLogMessage("Sepset for e = " + e + " and c = " + c + " = " + sepset); + } + + boolean collider = !sepset.contains(b); + + if (collider) { + if (doDiscriminatingPathColliderRule) { + graph.setEndpoint(a, b, Endpoint.ARROW); + graph.setEndpoint(c, b, Endpoint.ARROW); + + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } + + return true; + } + } else { + if (doDiscriminatingPathTailRule) { + graph.setEndpoint(c, b, Endpoint.TAIL); + + if (this.verbose) { + TetradLogger.getInstance().forceLogMessage( + "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); + } + + return true; + } + } + + if (graph.isAdjacentTo(e, c)) { + throw new IllegalArgumentException(); + } + if (!sepset.contains(b) && doDiscriminatingPathColliderRule) { if (!isArrowheadAllowed(a, b, graph, knowledge)) { return false; @@ -981,7 +1033,7 @@ private boolean doDdpOrientation(Node d, Node a, Node b, Node c, Graph graph, Se if (this.verbose) { this.logger.forceLogMessage( - "R4: Definite discriminating path collider rule d = " + d + " " + GraphUtils.pathString(graph, a, b, c)); + "R4: Definite discriminating path collider rule d = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } this.changeFlag = true; @@ -990,7 +1042,7 @@ private boolean doDdpOrientation(Node d, Node a, Node b, Node c, Graph graph, Se if (this.verbose) { this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg( - "R4: Definite discriminating path tail rule d = " + d, graph.getEdge(b, c))); + "R4: Definite discriminating path tail rule d = " + e, graph.getEdge(b, c))); } this.changeFlag = true; From 5e920bbec9e5495601cf807ac72100a9d5c6f8d2 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 3 Jun 2024 06:07:12 -0400 Subject: [PATCH 03/29] Refactor triangle reasoning in LvLite and LvLiteDsepFriendly In this commit, the triangle reasoning logic was refactored into a separate method for both LvLite and LvLiteDsepFriendly. Additionally, the extra conditional statements were removed, and readable variables were introduced for ease of understanding. Unnecessary codes were successfully cleaned up. --- .../algorithm/oracle/pag/Gfci.java | 5 +- .../java/edu/cmu/tetrad/graph/GraphUtils.java | 2 +- .../main/java/edu/cmu/tetrad/search/GFci.java | 32 ++-- .../java/edu/cmu/tetrad/search/LvLite.java | 104 +++++++------ .../cmu/tetrad/search/LvLiteDsepFriendly.java | 141 ++++++++++-------- 5 files changed, 160 insertions(+), 124 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java index cebab5493c..ffa6d772dc 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Gfci.java @@ -102,8 +102,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); - search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setNumThreads(parameters.getInt(Params.NUM_THREADS)); @@ -162,7 +161,7 @@ public List getParameters() { parameters.add(Params.MAX_DEGREE); parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.COMPLETE_RULE_SET_USED); - parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.POSSIBLE_MSEP_DONE); parameters.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java index fc65ba2a9f..9b49ba1b74 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java @@ -2495,7 +2495,7 @@ public static void gfciR0(Graph graph, Graph referenceCpdag, SepsetProducer seps Node a = adjacentNodes.get(combination[0]); Node c = adjacentNodes.get(combination[1]); - if (referenceCpdag.isDefCollider(a, b, c) + if (referenceCpdag.isDefCollider(a, b, c) && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && FciOrient.isArrowheadAllowed(a, b, graph, knowledge) && FciOrient.isArrowheadAllowed(c, b, graph, knowledge) && !referenceCpdag.isAdjacentTo(a, c) && !graph.isAdjacentTo(a, c)) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index 3116cd5f88..0db05b11b0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -98,10 +98,6 @@ public final class GFci implements IGraphSearch { * Whether one-edge faithfulness is assumed. */ private boolean faithfulnessAssumed = true; - /** - * Whether the discriminating path rule should be used. - */ - private boolean doDiscriminatingPathRule = true; /** * The depth for independence testing. */ @@ -114,6 +110,10 @@ public final class GFci implements IGraphSearch { * Whether verbose output should be printed. */ private boolean verbose; + /** + * Whether the discriminating path tail rule should be used. + */ + private boolean doDiscriminatingPathTailRule = true; /** * Whether the discriminating path collider rule should be used. */ @@ -173,7 +173,7 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); - fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); fciOrient.setKnowledge(knowledge); @@ -278,15 +278,6 @@ public void setFaithfulnessAssumed(boolean faithfulnessAssumed) { this.faithfulnessAssumed = faithfulnessAssumed; } - /** - * Sets whether the discriminating path rule should be used. - * - * @param doDiscriminatingPathRule True, if so. - */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; - } - /** * Sets the depth of the search for the possible m-sep search. * @@ -309,9 +300,18 @@ public void setNumThreads(int numThreads) { } /** - * Sets whether the discriminating path collider rules should be used. + * Sets whether the discriminating path tail rule should be used. + * + * @param doDiscriminatingPathTailRule True, if the discriminating path collider rules should be used. False, otherwise. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathColliderRule True, if the discriminating path collider rules should be used. False, otherwise. + * @param doDiscriminatingPathColliderRule True, if the discriminating path collider rule should be used. False, otherwise. */ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 1d5497a025..10a51c80c4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -303,7 +303,6 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); -// if (pag.isAdjacentTo(x, y)) { if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -314,7 +313,6 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } -// } } } } @@ -345,62 +343,78 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } else if (allowTucks && pag.isAdjacentTo(x, y)) { - scorer.goToBookmark(); - scorer.tuck(b, x); - - boolean scorerUnshieldedCollider = scorer.unshieldedCollider(x, b, y); - boolean pagTriple = triple(pag, x, b, y); - boolean colliderAllowed = colliderAllowed(pag, x, b, y); + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); + } + } + } + } - if (pagTriple && scorerUnshieldedCollider && colliderAllowed) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + boolean _adj = pag.isAdjacentTo(x, y); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().forceLogMessage( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } + } - List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); - commonAdj.retainAll(pag.getAdjacentNodes(y)); + private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove) { - List commonChildren = new ArrayList<>(pag.getChildren(x)); - commonChildren.retainAll(pag.getChildren(y)); + // Find possible d-connecting common adjacents of x and y. + List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); + commonAdj.retainAll(pag.getAdjacentNodes(y)); - commonAdj.removeAll(commonChildren); + List commonChildren = new ArrayList<>(pag.getChildren(x)); + commonChildren.retainAll(pag.getChildren(y)); - for (Node a : commonAdj) { - if (a == b) continue; + commonAdj.removeAll(commonChildren); - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); + if (!pag.isDefCollider(x, b, y)) { + // Tuck x before b. + scorer.goToBookmark(); + scorer.tuck(b, x); - unshieldedColliders.add(new Triple(x, a, y)); + // If we can now copy the collider from the scorer, do so. + if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(b, y) && scorer.unshieldedCollider(x, b, y) + && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "### Also oriented " + x + " *-> " + b + " <-* " + y + "."); - } - } - } - } + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); } } - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); + // But check all other possible d-connecting common adjacents of x and y + for (Node a : commonAdj) { - boolean _adj = pag.isAdjacentTo(x, y); + // Tuck those too, one at a time + scorer.tuck(a, x); - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + // If we can now copy the collider from the scorer, do so. + if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(a, y) && scorer.unshieldedCollider(x, a, y) + && colliderAllowed(pag, x, a, y)) { + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { TetradLogger.getInstance().forceLogMessage( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } } } @@ -564,10 +578,10 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP * consists of colliders that are parents of c. * - * @param a a {@link Node} object - * @param b a {@link Node} object - * @param c a {@link Node} object - * @param graph a {@link Graph} object + * @param a a {@link Node} object + * @param b a {@link Node} object + * @param c a {@link Node} object + * @param graph a {@link Graph} object */ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { Queue Q = new ArrayDeque<>(20); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index cca968ef53..3826925fc3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -27,6 +27,7 @@ import edu.cmu.tetrad.search.utils.DagSepsets; import edu.cmu.tetrad.search.utils.FciOrient; import edu.cmu.tetrad.search.utils.TeyssierScorer; +import edu.cmu.tetrad.util.SublistGenerator; import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; @@ -204,10 +205,18 @@ public Graph search() { TetradLogger.getInstance().forceLogMessage("Running BOSS to get CPDAG and best order."); } + test.setVerbose(false); + test.setVerbose(verbose); edu.cmu.tetrad.search.Grasp grasp = new edu.cmu.tetrad.search.Grasp(test, score); grasp.setSeed(seed); +// grasp.setDepth(depth); +// grasp.setUncoveredDepth(uncoveredDepth); +// grasp.setNonSingularDepth(nonSingularDepth); + grasp.setDepth(3); + grasp.setUncoveredDepth(1); + grasp.setNonSingularDepth(1); grasp.setDepth(depth); grasp.setUncoveredDepth(uncoveredDepth); grasp.setNonSingularDepth(nonSingularDepth); @@ -216,7 +225,7 @@ public Graph search() { grasp.setUseRaskuttiUhler(useRaskuttiUhler); grasp.setUseDataOrder(useDataOrder); grasp.setAllowInternalRandomness(allowInternalRandomness); - grasp.setVerbose(verbose); + grasp.setVerbose(false); grasp.setNumStarts(numStarts); grasp.setKnowledge(this.knowledge); @@ -323,7 +332,6 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); -// if (pag.isAdjacentTo(x, y)) { if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -334,7 +342,6 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } -// } } } } @@ -365,67 +372,96 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } else if (allowTucks && pag.isAdjacentTo(x, y)) { - scorer.goToBookmark(); - scorer.tuck(b, x); - - boolean scorerUnshieldedCollider = scorer.unshieldedCollider(x, b, y); - boolean pagTriple = triple(pag, x, b, y); - boolean colliderAllowed = colliderAllowed(pag, x, b, y); + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); + } + } + } + } - if (pagTriple && scorerUnshieldedCollider && colliderAllowed) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + boolean _adj = pag.isAdjacentTo(x, y); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().forceLogMessage( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } + } - List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); - commonAdj.retainAll(pag.getAdjacentNodes(y)); + private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove) { - List commonChildren = new ArrayList<>(pag.getChildren(x)); - commonChildren.retainAll(pag.getChildren(y)); + // Find possible d-connecting common adjacents of x and y. + List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); + commonAdj.retainAll(pag.getAdjacentNodes(y)); - commonAdj.removeAll(commonChildren); + List commonChildren = new ArrayList<>(pag.getChildren(x)); + commonChildren.retainAll(pag.getChildren(y)); - for (Node a : commonAdj) { - if (a == b) continue; + commonAdj.removeAll(commonChildren); - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); + if (!pag.isDefCollider(x, b, y)) { + // Tuck x before b. + scorer.goToBookmark(); + scorer.tuck(b, x); - unshieldedColliders.add(new Triple(x, a, y)); + // If we can now copy the collider from the scorer, do so. + if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(b, y) && scorer.unshieldedCollider(x, b, y) + && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().forceLogMessage( - "### Also oriented " + x + " *-> " + b + " <-* " + y + "."); - } - } - } - } + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); } } - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); + // But check all other possible d-connecting common adjacents of x and y + for (Node a : commonAdj) { - boolean _adj = pag.isAdjacentTo(x, y); + // Tuck those too, one at a time + scorer.tuck(a, x); - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + // If we can now copy the collider from the scorer, do so. + if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(a, y) && scorer.unshieldedCollider(x, a, y) + && colliderAllowed(pag, x, a, y)) { + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { TetradLogger.getInstance().forceLogMessage( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } } } } + /** + * Checks if three nodes are connected in a graph. + * + * @param graph the graph to check for connectivity + * @param a the first node + * @param b the second node + * @param c the third node + * @return {@code true} if all three nodes are connected, {@code false} otherwise + */ + private boolean triple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + } + /** * Determines if the collider is allowed. * @@ -469,19 +505,6 @@ private boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); } - /** - * Checks if three nodes are connected in a graph. - * - * @param graph the graph to check for connectivity - * @param a the first node - * @param b the second node - * @param c the third node - * @return {@code true} if all three nodes are connected, {@code false} otherwise - */ - private boolean triple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); - } - /** * Checks if the given nodes are unshielded colliders when considering the given graph. * @@ -584,10 +607,10 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP * consists of colliders that are parents of c. * - * @param a a {@link Node} object - * @param b a {@link Node} object - * @param c a {@link Node} object - * @param graph a {@link Graph} object + * @param a a {@link Node} object + * @param b a {@link Node} object + * @param c a {@link Node} object + * @param graph a {@link Graph} object */ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { Queue Q = new ArrayDeque<>(20); From 8f0034117991b0f2f7e25bdfc8ea7cff9684dad3 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 3 Jun 2024 18:38:15 -0400 Subject: [PATCH 04/29] Refine GFci-R0 algorithm for better graph node orientation The code updates improve the efficiency of the GFci-R0 algorithm. These improvements involve better handling of nodes within graphs, including refinements in recognizing unshielded triples and allowing colliders. Enhancements also include additional condition checks to avoid redundant operations and incorrect orientations. --- .../java/edu/cmu/tetrad/graph/GraphUtils.java | 149 ++++++++++++------ .../main/java/edu/cmu/tetrad/search/GFci.java | 1 + .../java/edu/cmu/tetrad/search/LvDumb.java | 4 +- .../java/edu/cmu/tetrad/search/LvLite.java | 91 ++++++++++- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 92 ++++++++++- 5 files changed, 277 insertions(+), 60 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java index 9b49ba1b74..5fd270237d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java @@ -2464,25 +2464,25 @@ public static Graph convert(String spec) { } /** - * Applies the GFCI-R0 algorithm to orient edges in a graph based on a reference CPDAG, sepsets, and knowledge. This - * method modifies the given graph by changing the orientation of edges. Due to Spirtes. + * Applies the GFCI-R0 algorithm to orient edges in a pag based on a reference CPDAG, sepsets, and knowledge. This + * method modifies the given pag by changing the orientation of edges. Due to Spirtes. * - * @param graph The graph to be modified. - * @param referenceCpdag The reference CPDAG to guide the orientation of edges. - * @param sepsets The sepsets used to determine the orientation of edges. - * @param knowledge The knowledge used to determine the orientation of edges. - * @param verbose Whether to print verbose output. + * @param pag The pag to be modified. + * @param cpdag The reference CPDAG to guide the orientation of edges. + * @param sepsets The sepsets used to determine the orientation of edges. + * @param knowledge The knowledge used to determine the orientation of edges. + * @param verbose Whether to print verbose output. */ - public static void gfciR0(Graph graph, Graph referenceCpdag, SepsetProducer sepsets, Knowledge knowledge, + public static void gfciR0(Graph pag, Graph cpdag, SepsetProducer sepsets, Knowledge knowledge, boolean verbose) { - graph.reorientAllWith(Endpoint.CIRCLE); + pag.reorientAllWith(Endpoint.CIRCLE); - fciOrientbk(knowledge, graph, graph.getNodes()); + fciOrientbk(knowledge, pag, pag.getNodes()); - List nodes = graph.getNodes(); + List nodes = pag.getNodes(); - for (Node b : nodes) { - List adjacentNodes = new ArrayList<>(graph.getAdjacentNodes(b)); + for (Node y : nodes) { + List adjacentNodes = new ArrayList<>(pag.getAdjacentNodes(y)); if (adjacentNodes.size() < 2) { continue; @@ -2492,52 +2492,50 @@ public static void gfciR0(Graph graph, Graph referenceCpdag, SepsetProducer seps int[] combination; while ((combination = cg.next()) != null) { - Node a = adjacentNodes.get(combination[0]); - Node c = adjacentNodes.get(combination[1]); - - if (referenceCpdag.isDefCollider(a, b, c) && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) - && FciOrient.isArrowheadAllowed(a, b, graph, knowledge) - && FciOrient.isArrowheadAllowed(c, b, graph, knowledge) - && !referenceCpdag.isAdjacentTo(a, c) && !graph.isAdjacentTo(a, c)) { + Node x = adjacentNodes.get(combination[0]); + Node z = adjacentNodes.get(combination[1]); - graph.setEndpoint(a, b, Endpoint.ARROW); - graph.setEndpoint(c, b, Endpoint.ARROW); + if (unshieldedTriple(pag, x, y, z) && unshieldedCollider(cpdag, x, y, z)) { + if (colliderAllowed(pag, x, y, z, knowledge)) { + pag.setEndpoint(x, y, Endpoint.ARROW); + pag.setEndpoint(z, y, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().forceLogMessage("Oriented collider " + a + " *-> " + b + " <-* " + c + " (from score search))."); + if (verbose) { + TetradLogger.getInstance().forceLogMessage("Copied " + x + " *-> " + y + " <-* " + z + " from CPDAG."); - if (Edges.isBidirectedEdge(graph.getEdge(a, b))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(a, b)); - } + if (Edges.isBidirectedEdge(pag.getEdge(x, y))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(x, y)); + } - if (Edges.isBidirectedEdge(graph.getEdge(b, c))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(b, c)); + if (Edges.isBidirectedEdge(pag.getEdge(y, z))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(y, z)); + } } } - } else if (referenceCpdag.isAdjacentTo(a, c)) { - Set sepset = sepsets.getSepset(a, c); + } else if (cpdag.isAdjacentTo(x, z)) { + if (colliderAllowed(pag, x, y, z, knowledge)) { + Set sepset = sepsets.getSepset(x, z); - if (sepset != null && graph.isAdjacentTo(a, c)) { - if (graph.isAdjacentTo(a, c)) { - graph.removeEdge(a, c); - } + if (sepset != null) { + pag.removeEdge(x, z); - if (!sepset.contains(b) && FciOrient.isArrowheadAllowed(a, b, graph, knowledge) && FciOrient.isArrowheadAllowed(c, b, graph, knowledge)) { - graph.setEndpoint(a, b, Endpoint.ARROW); - graph.setEndpoint(c, b, Endpoint.ARROW); + if (!sepset.contains(y)) { + pag.setEndpoint(x, y, Endpoint.ARROW); + pag.setEndpoint(z, y, Endpoint.ARROW); - if (verbose) { - double p = sepsets.getPValue(a, c, sepset); - String _p = p < 0.0001 ? "< 0.0001" : String.format("%.4f", p); + if (verbose) { + double p = sepsets.getPValue(x, z, sepset); + String _p = p < 0.0001 ? "< 0.0001" : String.format("%.4f", p); - TetradLogger.getInstance().forceLogMessage("Oriented collider " + a + " *-> " + b + " <-* " + c + " (from test)), p = " + _p + "."); + TetradLogger.getInstance().forceLogMessage("Oriented collider by test " + x + " *-> " + y + " <-* " + z + ", p = " + _p + "."); - if (Edges.isBidirectedEdge(graph.getEdge(a, b))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(a, b)); - } + if (Edges.isBidirectedEdge(pag.getEdge(x, y))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(x, y)); + } - if (Edges.isBidirectedEdge(graph.getEdge(b, c))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + graph.getEdge(b, c)); + if (Edges.isBidirectedEdge(pag.getEdge(y, z))) { + TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(y, z)); + } } } } @@ -2547,6 +2545,63 @@ public static void gfciR0(Graph graph, Graph referenceCpdag, SepsetProducer seps } } + + /** + * Checks if three nodes are connected in a graph. + * + * @param graph the graph to check for connectivity + * @param a the first node + * @param b the second node + * @param c the third node + * @return {@code true} if all three nodes are connected, {@code false} otherwise + */ + private static boolean triple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + } + + /** + * Checks if three nodes in a graph form an unshielded triple. An unshielded triple is a configuration where node a + * is adjacent to node b, node b is adjacent to node c, but node a is not adjacent to node c. + * + * @param graph The graph in which the nodes reside. + * @param a The first node in the triple. + * @param b The second node in the triple. + * @param c The third node in the triple. + * @return {@code true} if the nodes form an unshielded triple, {@code false} otherwise. + */ + private static boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); + } + + /** + * Determines if the collider is allowed. + * + * @param pag The Graph representing the PAG. + * @param x The Node object representing the first node. + * @param b The Node object representing the second node. + * @param y The Node object representing the third node. + * @return true if the collider is allowed, false otherwise. + */ + private static boolean colliderAllowed(Graph pag, Node x, Node b, Node y, Knowledge knowledge) { + if (true) return true; + + return FciOrient.isArrowheadAllowed(x, b, pag, knowledge) + && FciOrient.isArrowheadAllowed(y, b, pag, knowledge); + } + + /** + * Checks if the given nodes are unshielded colliders when considering the given graph. + * + * @param graph the graph to consider + * @param a the first node + * @param b the second node + * @param c the third node + * @return true if the nodes are unshielded colliders, false otherwise + */ + private static boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { + return a != c && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); + } + /** * Attempts to orient the edges in the graph based on the given knowledge. * diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index 0db05b11b0..c644ed2fa2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -316,4 +316,5 @@ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } + } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index 35a690a93f..6d4e149c1c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -157,9 +157,9 @@ public Graph search() { TetradLogger.getInstance().forceLogMessage("Initializing scorer with BOSS best order."); } - var cpdag = scorer.getGraph(true); + var dag = scorer.getGraph(false); - DagToPag dagToPag = new DagToPag(cpdag); + DagToPag dagToPag = new DagToPag(dag); dagToPag.setKnowledge(knowledge); dagToPag.setCompleteRuleSetUsed(completeRuleSetUsed); dagToPag.setDoDiscriminatingPathRule(doDiscriminatingPathRule); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 10a51c80c4..af656d3032 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -330,9 +330,20 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); + boolean lookAt = x.getName().equals("X1") && y.getName().equals("X12"); + + // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - if (unshieldedTriple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { + boolean unshieldedTriple = unshieldedTriple(pag, x, b, y); + boolean unshieldedCollider = scorer.unshieldedCollider(x, b, y); + boolean colliderAllowed = colliderAllowed(pag, x, b, y); + + if (lookAt) { + System.out.println("R0: " + x + " " + b + " " + y); + } + + if (unshieldedTriple && unshieldedCollider && colliderAllowed) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -367,22 +378,43 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove) { + if (x == b || x == y || b == y) { + return; + } + + + + if (pag.getEdge(x, y).pointsTowards(y)) { + var r = x; + x = y; + y = r; + } + + // Find possible d-connecting common adjacents of x and y. List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); commonAdj.retainAll(pag.getAdjacentNodes(y)); - List commonChildren = new ArrayList<>(pag.getChildren(x)); - commonChildren.retainAll(pag.getChildren(y)); + List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); + commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); commonAdj.removeAll(commonChildren); + boolean oriented = false; + if (!pag.isDefCollider(x, b, y)) { + // Tuck x before b. scorer.goToBookmark(); + + for (Node node : pag.getParents(x)) { + scorer.tuck(node, x); + } + scorer.tuck(b, x); // If we can now copy the collider from the scorer, do so. - if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(b, y) && scorer.unshieldedCollider(x, b, y) + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -394,17 +426,41 @@ && colliderAllowed(pag, x, b, y)) { toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); + + oriented = true; + } + + if (!oriented) { + scorer.tuck(b, y); + scorer.tuck(b, x); + + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) + && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); + + oriented = true; + } } } // But check all other possible d-connecting common adjacents of x and y for (Node a : commonAdj) { + if (a == b) continue; // Tuck those too, one at a time scorer.tuck(a, x); // If we can now copy the collider from the scorer, do so. - if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(a, y) && scorer.unshieldedCollider(x, a, y) + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) && colliderAllowed(pag, x, a, y)) { pag.setEndpoint(x, a, Endpoint.ARROW); pag.setEndpoint(y, a, Endpoint.ARROW); @@ -416,10 +472,33 @@ && colliderAllowed(pag, x, a, y)) { TetradLogger.getInstance().forceLogMessage( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } + + oriented = true; + } + + if (!oriented) { + scorer.tuck(a, y); + scorer.tuck(a, x); + + // If we can now copy the collider from the scorer, do so. + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) + && colliderAllowed(pag, x, a, y)) { + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); + } + + oriented = true; + } } } } - /** * Determines if the collider is allowed. * diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 3826925fc3..8d35289a46 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -31,7 +31,9 @@ import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; +import java.awt.*; import java.util.*; +import java.util.List; /** * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the @@ -359,9 +361,20 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); + boolean lookAt = x.getName().equals("X1") && y.getName().equals("X12"); + + // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - if (unshieldedTriple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { + boolean unshieldedTriple = unshieldedTriple(pag, x, b, y); + boolean unshieldedCollider = scorer.unshieldedCollider(x, b, y); + boolean colliderAllowed = colliderAllowed(pag, x, b, y); + + if (lookAt) { + System.out.println("R0: " + x + " " + b + " " + y); + } + + if (unshieldedTriple && unshieldedCollider && colliderAllowed) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -396,22 +409,43 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove) { + if (x == b || x == y || b == y) { + return; + } + + + + if (pag.getEdge(x, y).pointsTowards(y)) { + var r = x; + x = y; + y = r; + } + + // Find possible d-connecting common adjacents of x and y. List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); commonAdj.retainAll(pag.getAdjacentNodes(y)); - List commonChildren = new ArrayList<>(pag.getChildren(x)); - commonChildren.retainAll(pag.getChildren(y)); + List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); + commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); commonAdj.removeAll(commonChildren); + boolean oriented = false; + if (!pag.isDefCollider(x, b, y)) { + // Tuck x before b. scorer.goToBookmark(); + + for (Node node : pag.getParents(x)) { + scorer.tuck(node, x); + } + scorer.tuck(b, x); // If we can now copy the collider from the scorer, do so. - if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(b, y) && scorer.unshieldedCollider(x, b, y) + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -423,17 +457,41 @@ && colliderAllowed(pag, x, b, y)) { toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); + + oriented = true; + } + + if (!oriented) { + scorer.tuck(b, y); + scorer.tuck(b, x); + + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) + && colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); + + oriented = true; + } } } // But check all other possible d-connecting common adjacents of x and y for (Node a : commonAdj) { + if (a == b) continue; // Tuck those too, one at a time scorer.tuck(a, x); // If we can now copy the collider from the scorer, do so. - if (pag.isAdjacentTo(x, b) && pag.isAdjacentTo(a, y) && scorer.unshieldedCollider(x, a, y) + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) && colliderAllowed(pag, x, a, y)) { pag.setEndpoint(x, a, Endpoint.ARROW); pag.setEndpoint(y, a, Endpoint.ARROW); @@ -445,6 +503,30 @@ && colliderAllowed(pag, x, a, y)) { TetradLogger.getInstance().forceLogMessage( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } + + oriented = true; + } + + if (!oriented) { + scorer.tuck(a, y); + scorer.tuck(a, x); + + // If we can now copy the collider from the scorer, do so. + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) + && colliderAllowed(pag, x, a, y)) { + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); + + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, a, y)); + + if (verbose) { + TetradLogger.getInstance().forceLogMessage( + "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); + } + + oriented = true; + } } } } From 74c064ad1d9c038075001145fbc98b1e66cc4257 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 3 Jun 2024 18:40:39 -0400 Subject: [PATCH 05/29] Update LvDumb class description The description of the LvDumb class has been updated to more accurately reflect its functionality. Specifically, it has been clarified that the LV-Dumb algorithm is used to find the BOSS DAG for the dataset, which is then reported as a PAG (Partially Ancestral Graph) structure. --- tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index 6d4e149c1c..8d9c898ffe 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -30,11 +30,8 @@ import java.util.*; /** - * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the - * structure of a graphical model from observational data. - *

- * This class provides methods for running the search algorithm and getting the learned pattern as a PAG (Partially - * Annotated Graph). + * LvDumb is a class that implements the IGraphSearch interface. The LV-Dumb algorithm finds the BOSS DAG for + * the dataset and then simply reports the PAG (Partially Ancestral Graph) structure of the BOSS DAG. * * @author josephramsey */ From 9ba945b94956d05ddbaf061b94bf8a83a3a4ab28 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 3 Jun 2024 18:41:23 -0400 Subject: [PATCH 06/29] Update LvDumb class documentation The documentation for the LvDumb class has been updated to better describe how it handles latent variable reasoning. More specifically, the doc now mentions that the class reports the PAG structure of the BOSS DAG without performing any further latent variable reasoning. --- tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index 8d9c898ffe..2cf2b71984 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -31,7 +31,8 @@ /** * LvDumb is a class that implements the IGraphSearch interface. The LV-Dumb algorithm finds the BOSS DAG for - * the dataset and then simply reports the PAG (Partially Ancestral Graph) structure of the BOSS DAG. + * the dataset and then simply reports the PAG (Partially Ancestral Graph) structure of the BOSS DAG, without + * doing any further laten variable reasoning. * * @author josephramsey */ From 9d4986fee5ee49cf11ec39c82af9bbdc4fd621d8 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 00:17:18 -0400 Subject: [PATCH 07/29] Update discriminating path rule in various classes The commit includes changes across multiple classes where the generic 'discriminating path rule' is divided into two specific rules: 'discriminating path tail rule' and 'discriminating path collider rule'. This update increases the clarity and specificity of the rule application during the search operation in these classes. --- .../algcomparison/algorithm/multi/FciIod.java | 6 ++- .../algorithm/oracle/pag/Bfci.java | 6 ++- .../algorithm/oracle/pag/Cfci.java | 6 ++- .../algorithm/oracle/pag/Fci.java | 6 ++- .../algorithm/oracle/pag/FciMax.java | 6 ++- .../algorithm/oracle/pag/GraspFci.java | 4 +- .../algorithm/oracle/pag/LvDumb.java | 6 ++- .../algorithm/oracle/pag/SpFci.java | 6 ++- .../main/java/edu/cmu/tetrad/search/BFci.java | 28 +++++++++---- .../main/java/edu/cmu/tetrad/search/Cfci.java | 24 +++++++---- .../main/java/edu/cmu/tetrad/search/Fci.java | 27 ++++++++---- .../java/edu/cmu/tetrad/search/FciMax.java | 27 ++++++++---- .../main/java/edu/cmu/tetrad/search/GFci.java | 6 +-- .../java/edu/cmu/tetrad/search/GraspFci.java | 42 +++++++++---------- .../java/edu/cmu/tetrad/search/LvDumb.java | 34 +++++++++------ .../java/edu/cmu/tetrad/search/LvLite.java | 36 ++++++++-------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 22 +++++----- .../java/edu/cmu/tetrad/search/SpFci.java | 35 ++++++++++------ .../edu/cmu/tetrad/search/utils/DagToPag.java | 25 +++++++---- .../cmu/tetrad/search/utils/FciOrient.java | 17 ++++---- .../cmu/tetrad/search/utils/TsDagToPag.java | 24 +++++++---- .../main/java/edu/cmu/tetrad/util/Params.java | 4 -- .../src/main/resources/docs/manual/index.html | 22 ---------- .../java/edu/cmu/tetrad/test/TestFci.java | 3 +- 24 files changed, 247 insertions(+), 175 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FciIod.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FciIod.java index db574648b8..5759bb998e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FciIod.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FciIod.java @@ -104,7 +104,8 @@ public Graph search(List dataSets, Parameters parameters) { search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setPossibleMsepSearchDone(parameters.getBoolean(Params.POSSIBLE_MSEP_DONE)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.setStable(parameters.getBoolean(Params.STABLE_FAS)); @@ -169,7 +170,8 @@ public List getParameters() { parameters.add(Params.STABLE_FAS); parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.POSSIBLE_MSEP_DONE); - parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.COMPLETE_RULE_SET_USED); parameters.add(Params.TIME_LAG); parameters.add(Params.VERBOSE); 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 230173c75f..526674d276 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 @@ -114,7 +114,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setBossUseBes(parameters.getBoolean(Params.USE_BES)); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setDepth(parameters.getInt(Params.DEPTH)); search.setNumThreads(parameters.getInt(Params.NUM_THREADS)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); @@ -172,7 +173,8 @@ public List getParameters() { params.add(Params.USE_BES); params.add(Params.MAX_PATH_LENGTH); params.add(Params.COMPLETE_RULE_SET_USED); - params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); params.add(Params.DEPTH); params.add(Params.TIME_LAG); params.add(Params.SEED); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java index 2cc634afe9..134207476b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java @@ -98,7 +98,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setKnowledge(this.knowledge); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setPossibleMsepSearchDone(parameters.getBoolean(Params.POSSIBLE_MSEP_DONE)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); return search.search(); @@ -146,7 +147,8 @@ public List getParameters() { List parameters = new ArrayList<>(); parameters.add(Params.DEPTH); parameters.add(Params.POSSIBLE_MSEP_DONE); - parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.COMPLETE_RULE_SET_USED); parameters.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Fci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Fci.java index 9a4472bf35..e6bb8f3fa7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Fci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Fci.java @@ -105,7 +105,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setPossibleMsepSearchDone(parameters.getBoolean(Params.POSSIBLE_MSEP_DONE)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.setPcHeuristicType(pcHeuristicType); search.setStable(parameters.getBoolean(Params.STABLE_FAS)); @@ -158,7 +159,8 @@ public List getParameters() { parameters.add(Params.PC_HEURISTIC); parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.POSSIBLE_MSEP_DONE); - parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.COMPLETE_RULE_SET_USED); parameters.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/FciMax.java index d25ab8527d..d122e76d16 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/FciMax.java @@ -104,7 +104,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setKnowledge(this.knowledge); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setPossibleMsepSearchDone(parameters.getBoolean(Params.POSSIBLE_MSEP_DONE)); search.setPcHeuristicType(pcHeuristicType); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); @@ -155,7 +156,8 @@ public List getParameters() { parameters.add(Params.DEPTH); parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.COMPLETE_RULE_SET_USED); - parameters.add(Params.DO_DISCRIMINATING_PATH_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.POSSIBLE_MSEP_DONE); // parameters.add(Params.PC_HEURISTIC); parameters.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java index f4dc2bae29..3bf4fb3f1e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/GraspFci.java @@ -126,7 +126,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setDepth(parameters.getInt(Params.DEPTH)); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); // General @@ -191,7 +191,7 @@ public List getParameters() { params.add(Params.DEPTH); params.add(Params.MAX_PATH_LENGTH); params.add(Params.COMPLETE_RULE_SET_USED); - params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); params.add(Params.POSSIBLE_MSEP_DONE); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java index 0004308982..03a848d20d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java @@ -125,7 +125,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); // LV-Lite - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); // General search.setVerbose(parameters.getBoolean(Params.VERBOSE)); @@ -182,7 +183,8 @@ public List getParameters() { // FCI-ORIENT params.add(Params.COMPLETE_RULE_SET_USED); - params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); // General params.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java index 3920f83237..35933dfa94 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java @@ -111,7 +111,8 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setKnowledge(this.knowledge); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - search.setDoDiscriminatingPathRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); Object obj = parameters.get(Params.PRINT_STREAM); @@ -167,7 +168,8 @@ public List getParameters() { params.add(Params.MAX_PATH_LENGTH); params.add(Params.COMPLETE_RULE_SET_USED); - params.add(Params.DO_DISCRIMINATING_PATH_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); params.add(Params.DEPTH); params.add(Params.TIME_LAG); params.add(Params.VERBOSE); 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 4b37665eb6..559fc3fe99 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 @@ -103,9 +103,13 @@ public final class BFci implements IGraphSearch { */ private int depth = -1; /** - * Whether to apply the discriminating path rule during the search. + * Whether to apply the discriminating path tail rule during the search. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + /** + * Whether to apply the discriminating path collider rule during the search. + */ + private boolean doDiscriminatingPathColliderRule = true; /** * Determines whether the Boss search algorithm should use the BES (Backward elimination of shadows) method as a * final step. @@ -188,8 +192,8 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); fciOrient.setKnowledge(knowledge); @@ -267,12 +271,19 @@ public void setDepth(int depth) { } /** - * Sets whether the discriminating path rule should be used. + * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathRule True if the discriminating path rule should be used, false otherwise. + * @param doDiscriminatingPathTailRule True if the discriminating path tail rule should be used, false otherwise. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } /** @@ -305,3 +316,4 @@ public void setNumThreads(int numThreads) { this.numThreads = numThreads; } } + diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java index b7e9f348d5..336de2893c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java @@ -74,7 +74,8 @@ public final class Cfci implements IGraphSearch { // Whether verbose output (about independencies) is output. private boolean verbose; // Whether to do the discriminating path rule. - private boolean doDiscriminatingPathRule; + private boolean doDiscriminatingPathTailRule; + private boolean doDiscriminatingPathColliderRule; /** * Constructs a new FCI search for the given independence test and background knowledge. @@ -170,8 +171,8 @@ public Graph search() { new SepsetMap(), this.depth, knowledge)); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathColliderRule); fciOrient.setMaxPathLength(-1); fciOrient.setKnowledge(this.knowledge); fciOrient.ruleR0(this.graph); @@ -459,12 +460,21 @@ public void setMaxReachablePathLength(int maxReachablePathLength) { } /** - * Whether to do the discriminating path rule. + * Sets whether the discriminating path tail rule should be used. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathRule True iff the discriminating path rule is done. + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java index 73f9a58c94..010eb94d37 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java @@ -119,7 +119,11 @@ public final class Fci implements IGraphSearch { /** * Whether the discriminating path rule should be used. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + /** + * Whether the discriminating path rule should be used. + */ + private boolean doDiscriminatingPathColliderRule = true; /** * Constructor. @@ -214,8 +218,8 @@ public Graph search() { fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setMaxPathLength(this.maxPathLength); - fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathColliderRule); fciOrient.setVerbose(this.verbose); fciOrient.setKnowledge(this.knowledge); @@ -353,12 +357,21 @@ public void setStable(boolean stable) { } /** - * Sets whether the discriminating path rule should be used. + * Sets whether the discriminating path tail rule should be used. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathRule True, if so. + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java index b72e766d28..0eb959b7eb 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java @@ -103,9 +103,15 @@ public final class FciMax implements IGraphSearch { */ private boolean completeRuleSetUsed = true; /** - * Whether the discriminating path rule will be used in search. + * Determines whether the discriminating path tail rule should be applied during the search. + * If set to true, the rule will be applied. If set to false, the rule will not be applied. + */ + private boolean doDiscriminatingPathTailRule = true; + /** + * This variable specifies whether the discriminating path collider rule should be applied during the search. + * If set to true, the rule will be applied; if set to false, the rule will not be applied. */ - private boolean doDiscriminatingPathRule = false; + private boolean doDiscriminatingPathColliderRule = true; /** * Whether the discriminating path rule will be used in search. */ @@ -313,14 +319,15 @@ public void setStable(boolean stable) { } /** - * Sets whether the discriminating path rule will be used in search. + * Sets whether the discriminating path tail rule should be applied during the search. * - * @param doDiscriminatingPathRule True, if so. + * @param doDiscriminatingPathTailRule True, if the rule should be applied. False otherwise. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } + /** * Retrieves an instance of FciOrient with all necessary parameters set. * @@ -332,8 +339,8 @@ private FciOrient getFciOrient() { fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setMaxPathLength(this.maxPathLength); - fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); fciOrient.setVerbose(this.verbose); fciOrient.setKnowledge(this.knowledge); return fciOrient; @@ -473,6 +480,10 @@ private void doNode(Graph graph, Map scores, Node b) { } } } + + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index c644ed2fa2..7224094c6b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -172,8 +172,8 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); fciOrient.setKnowledge(knowledge); @@ -302,7 +302,7 @@ public void setNumThreads(int numThreads) { /** * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathTailRule True, if the discriminating path collider rules should be used. False, otherwise. + * @param doDiscriminatingPathTailRule True, if so. */ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; @@ -311,7 +311,7 @@ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule /** * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathColliderRule True, if the discriminating path collider rule should be used. False, otherwise. + * @param doDiscriminatingPathColliderRule True, if so. */ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; 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 3a32af8d76..b405b59509 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 @@ -95,9 +95,13 @@ public final class GraspFci implements IGraphSearch { */ private boolean useScore = true; /** - * Whether to use the discriminating path rule. + * Whether to use the discriminating path tail rule. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + /** + * Whether to use the discriminating path collider rule. + */ + private boolean doDiscriminatingPathColliderRule = true; /** * Whether to use the ordered version of GRaSP. */ @@ -125,10 +129,6 @@ public final class GraspFci implements IGraphSearch { * True iff verbose output should be printed. */ private boolean verbose; - /** - * Indicates whether the discriminating path collider rule should be used in GRaSP. - */ - private boolean setDoDiscriminatingPathColliderRule = true; /** * Constructs a new GraspFci object. @@ -196,8 +196,8 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(setDoDiscriminatingPathColliderRule); - fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); fciOrient.setKnowledge(knowledge); @@ -285,12 +285,21 @@ public void setUseScore(boolean useScore) { } /** - * Sets whether to use the discriminating path rule for GRaSP. + * Sets whether to use the discriminating path tail rule for GRaSP. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether to use the discriminating path collider rule for GRaSP. * - * @param doDiscriminatingPathRule True, if so. + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } /** @@ -339,13 +348,4 @@ public void setSeed(long seed) { public void setDepth(int depth) { this.depth = depth; } - - /** - * Sets whether to use the discriminating path collider rule for GRaSP. - * - * @param doDiscriminatingPathColliderRule True, if so. - */ - public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { - this.setDoDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; - } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index 2cf2b71984..e1c8098ce4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -66,14 +66,15 @@ public final class LvDumb implements IGraphSearch { */ private boolean useBes = false; /** - * This variable represents whether the discriminating path rule is used in the LV-Lite class. - *

- * The discriminating path rule is a rule used in the search algorithm. It determines whether the algorithm - * considers discriminating paths when searching for patterns in the data. - *

- * By default, the value of this variable is set to true, indicating that the discriminating path rule is used. + * Determines whether the search algorithm should use the Discriminating Path Tail Rule. + * If set to true, the search algorithm will use the Discriminating Path Tail Rule. + * If set to false, the search algorithm will not use the Discriminating Path Tail Rule. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + /** + * This variable determines whether the Discriminating Path Collider Rule should be used during the search algorithm. + */ + private boolean doDiscriminatingPathColliderRule = true; /** * True iff verbose output should be printed. */ @@ -160,7 +161,7 @@ public Graph search() { DagToPag dagToPag = new DagToPag(dag); dagToPag.setKnowledge(knowledge); dagToPag.setCompleteRuleSetUsed(completeRuleSetUsed); - dagToPag.setDoDiscriminatingPathRule(doDiscriminatingPathRule); + dagToPag.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); return dagToPag.convert(); } @@ -220,11 +221,20 @@ public void setUseBes(boolean useBes) { } /** - * Sets whether the search algorithm should use the Discriminating Path Rule. + * Sets whether the discriminating path tail rule should be used. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathRule true if the Discriminating Path Rule should be used, false otherwise + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index af656d3032..f6cc012476 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -56,7 +56,7 @@ public final class LvLite implements IGraphSearch { */ private int numStarts = 1; /** - * Whether to use data order. + * Flag indicating whether to use data order. */ private boolean useDataOrder = true; /** @@ -236,21 +236,21 @@ public void setNumStarts(int numStarts) { } /** - * Sets whether the search algorithm should use the order of the data set during the search. + * Sets whether the discriminating path tail rule should be used. * - * @param useDataOrder true if the algorithm should use the data order, false otherwise + * @param doDiscriminatingPathTailRule True, if so. */ - public void setUseDataOrder(boolean useDataOrder) { - this.useDataOrder = useDataOrder; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } /** - * Sets whether the search algorithm should use the Discriminating Path Rule. + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathTailRule true if the Discriminating Path Rule should be used, false otherwise + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { - this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } /** @@ -262,15 +262,6 @@ public void setUseBes(boolean useBes) { this.useBes = useBes; } - /** - * Sets the value of the doDiscriminatingPathColliderRule property. - * - * @param doDiscriminatingPathColliderRule the new value for the doDiscriminatingPathColliderRule property - */ - public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { - this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; - } - /** * Orients and removes edges in a graph according to specified rules. Edges are removed in the course of the * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the @@ -833,4 +824,13 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path public void setAllowTucks(boolean allowTucks) { this.allowTucks = allowTucks; } + + /** + * Sets the flag indicating whether to use data order. + * + * @param useDataOrder {@code true} if the data order should be used, {@code false} otherwise. + */ + public void setUseDataOrder(boolean useDataOrder) { + this.useDataOrder = useDataOrder; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 8d35289a46..af6b3ac83c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -294,9 +294,18 @@ public void setUseBes(boolean useBes) { } /** - * Sets the value of the doDiscriminatingPathColliderRule property. + * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathColliderRule the new value for the doDiscriminatingPathColliderRule property + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. + * + * @param doDiscriminatingPathColliderRule True, if so. */ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; @@ -931,15 +940,6 @@ public void setUseScore(boolean useScore) { this.useScore = useScore; } - /** - * Sets whether to use the discriminating path rule for GRaSP. - * - * @param doDiscriminatingPathTailRule True, if so. - */ - public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { - this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; - } - /** * Sets depth for singular tucks. * 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 824256d893..9ed7b3f757 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 @@ -102,13 +102,13 @@ public final class SpFci implements IGraphSearch { */ private int depth = -1; /** - * Represents whether the discriminating path rule is applied during the search. - *

- * By default, the discriminating path rule is enabled. - *

- * Setting this variable to false disables the application of the discriminating path rule. + * Determines whether the search algorithm should use the Discriminating Path Tail Rule. */ - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + /** + * Determines whether the search algorithm should use the Discriminating Path Collider Rule. + */ + private boolean doDiscriminatingPathTCollideRule = true; /** * True iff verbose output should be printed. */ @@ -166,8 +166,8 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets); fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(doDiscriminatingPathTCollideRule); fciOrient.setMaxPathLength(maxPathLength); fciOrient.setVerbose(verbose); fciOrient.setKnowledge(knowledge); @@ -296,11 +296,20 @@ public void setDepth(int depth) { } /** - * Sets whether the discriminating path search is done. - * - * @param doDiscriminatingPathRule True, if so. + * Sets whether the discriminating path tail rule is done. + * @param doDiscriminatingPathTailRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } + + /** + * Sets whether the discriminating path collider rule is done. + * @param doDiscriminatingPathTCollideRule True, if so. + */ + public void setDoDiscriminatingPathTCollideRule(boolean doDiscriminatingPathTCollideRule) { + this.doDiscriminatingPathTCollideRule = doDiscriminatingPathTCollideRule; + } + + } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java index f072ac9a03..ed015ef176 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.LinkedList; import java.util.List; -import java.util.WeakHashMap; /** @@ -60,7 +59,8 @@ public final class DagToPag { */ private boolean verbose; private int maxPathLength = -1; - private boolean doDiscriminatingPathRule = true; + private boolean doDiscriminatingPathTailRule = true; + private boolean doDiscriminatingPathColliderRule = true; /** @@ -128,8 +128,8 @@ public Graph convert() { FciOrient fciOrient = new FciOrient(new DagSepsets(this.dag)); fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setKnowledge(this.knowledge); fciOrient.setVerbose(false); @@ -206,12 +206,21 @@ public void setMaxPathLength(int maxPathLength) { } /** - *

Setter for the field doDiscriminatingPathRule.

+ * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathRule a boolean + * @param doDiscriminatingPathTailRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. + * + * @param doDiscriminatingPathColliderRule True, if so. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } private Graph calcAdjacencyGraph() { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java index cb0248e04c..2c7540d15a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java @@ -70,7 +70,6 @@ public final class FciOrient { private boolean doDiscriminatingPathColliderRule = true; private boolean doDiscriminatingPathTailRule = true; - /** * Constructs a new FCI search for the given independence test and background knowledge. * @@ -1296,21 +1295,21 @@ public void setChangeFlag(boolean changeFlag) { } /** - * Sets whether the discriminating path collider rule should be done. + * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathColliderRule True is done. + * @param doDiscriminatingPathTailRule True, if so. */ - public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { - this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } /** - * Sets whether the discriminating path tail rule should be done. + * Sets whether the discriminating path collider rule should be used. * - * @param doDiscriminatingPathTailRule True if done. + * @param doDiscriminatingPathColliderRule True, if so. */ - public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { - this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java index 73e33945d5..19d8193cad 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java @@ -61,7 +61,8 @@ public final class TsDagToPag { private boolean verbose; private int maxPathLength = -1; private Graph truePag; - private boolean doDiscriminatingPathRule = false; + private boolean doDiscriminatingPathTailRule = true; + private boolean doDiscriminatingPathColliderRule = true; /** @@ -206,8 +207,8 @@ public Graph convert() { FciOrient fciOrient = new FciOrient(new DagSepsets(this.dag)); System.out.println("Complete rule set is used? " + this.completeRuleSetUsed); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathRule); - fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathRule); + fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); + fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); fciOrient.setChangeFlag(false); fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setKnowledge(this.knowledge); @@ -318,14 +319,23 @@ public void setTruePag(Graph truePag) { } /** - *

Setter for the field doDiscriminatingPathRule.

+ /** + * Sets whether the discriminating path tail rule should be used. * - * @param doDiscriminatingPathRule a boolean + * @param doDiscriminatingPathTailRule True, if so. */ - public void setDoDiscriminatingPathRule(boolean doDiscriminatingPathRule) { - this.doDiscriminatingPathRule = doDiscriminatingPathRule; + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; } + /** + * Sets whether the discriminating path collider rule should be used. + * + * @param doDiscriminatingPathColliderRule True, if so. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } private Graph calcAdjacencyGraph() { List allNodes = this.dag.getNodes(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java index 0b2d146059..f8b9300bb3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java @@ -84,10 +84,6 @@ public final class Params { * Constant COMPLETE_RULE_SET_USED="completeRuleSetUsed" */ public static final String COMPLETE_RULE_SET_USED = "completeRuleSetUsed"; - /** - * Constant DO_DISCRIMINATING_PATH_RULE="doDiscriminatingPathRule" - */ - public static final String DO_DISCRIMINATING_PATH_RULE = "doDiscriminatingPathRule"; /** * Constant DO_DISCRIMINATING_PATH_COLLIDER_RULE="doDiscriminatingPathColliderRule" */ diff --git a/tetrad-lib/src/main/resources/docs/manual/index.html b/tetrad-lib/src/main/resources/docs/manual/index.html index ed8d38f0fd..223b63570a 100755 --- a/tetrad-lib/src/main/resources/docs/manual/index.html +++ b/tetrad-lib/src/main/resources/docs/manual/index.html @@ -5161,28 +5161,6 @@

coefLow

Boolean -

doDiscriminatingPathRule

-
    -
  • Short Description: Yes if the discriminating path rule - should be done, No if not
  • -
  • Long Description: Yes if the discriminating path - FCI rule (part of the final orientation, requiring an additional test) - should be done, No if not -
  • -
  • Default Value: true
  • -
  • Lower - Bound:
  • -
  • Upper Bound:
  • -
  • Value Type: - Boolean
  • -
-

resolveAlmostCyclicPaths

    Date: Tue, 4 Jun 2024 00:38:32 -0400 Subject: [PATCH 08/29] Implement option for internal algorithmic randomness In this commit, an option has been added to allow for internal randomness in the search algorithm. This feature is toggleable through setAllowInternalRandomness(). Other changes include removing the Bes algorithm related code, adjusting max path length for various orientation heuristics, and cleaning up/resetting several default configurations. Documentation for class variables has also been improved. --- .../algorithm/oracle/pag/Cfci.java | 2 + .../oracle/pag/LvLiteDsepFriendly.java | 2 + .../main/java/edu/cmu/tetrad/search/Cfci.java | 7 +++- .../main/java/edu/cmu/tetrad/search/Fci.java | 2 +- .../java/edu/cmu/tetrad/search/FciMax.java | 2 +- .../java/edu/cmu/tetrad/search/LvLite.java | 1 + .../cmu/tetrad/search/LvLiteDsepFriendly.java | 40 +++++++++---------- .../java/edu/cmu/tetrad/search/SpFci.java | 2 - .../edu/cmu/tetrad/search/utils/DagToPag.java | 2 +- .../edu/cmu/tetrad/search/utils/MaxP.java | 2 +- .../edu/cmu/tetrad/search/utils/PcCommon.java | 2 +- .../cmu/tetrad/search/utils/TsDagToPag.java | 2 +- .../study/performance/PerformanceTests.java | 2 +- .../performance/PerformanceTestsDan.java | 2 +- 14 files changed, 39 insertions(+), 31 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java index 134207476b..09dbb407a9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/Cfci.java @@ -100,6 +100,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setPossibleMsepSearchDone(parameters.getBoolean(Params.POSSIBLE_MSEP_DONE)); search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); + search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); return search.search(); @@ -150,6 +151,7 @@ public List getParameters() { parameters.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); parameters.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); parameters.add(Params.COMPLETE_RULE_SET_USED); + parameters.add(Params.MAX_PATH_LENGTH); parameters.add(Params.TIME_LAG); parameters.add(Params.VERBOSE); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java index 07d55f70f2..6ebe9c23f3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -117,6 +117,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setSingularDepth(parameters.getInt(Params.GRASP_SINGULAR_DEPTH)); search.setNonSingularDepth(parameters.getInt(Params.GRASP_NONSINGULAR_DEPTH)); search.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG)); + search.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS)); search.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE)); search.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER)); search.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER)); @@ -186,6 +187,7 @@ public List getParameters() { params.add(Params.GRASP_USE_RASKUTTI_UHLER); params.add(Params.USE_DATA_ORDER); params.add(Params.NUM_STARTS); + params.add(Params.ALLOW_INTERNAL_RANDOMNESS); // FCI params.add(Params.DEPTH); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java index 336de2893c..282a012003 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java @@ -76,6 +76,7 @@ public final class Cfci implements IGraphSearch { // Whether to do the discriminating path rule. private boolean doDiscriminatingPathTailRule; private boolean doDiscriminatingPathColliderRule; + private int maxPathLength = -1; /** * Constructs a new FCI search for the given independence test and background knowledge. @@ -173,7 +174,7 @@ public Graph search() { fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathTailRule); fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathColliderRule); - fciOrient.setMaxPathLength(-1); + fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setKnowledge(this.knowledge); fciOrient.ruleR0(this.graph); fciOrient.doFinalOrientation(this.graph); @@ -551,6 +552,10 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { } } + public void setMaxPathLength(int maxPathLength) { + this.maxPathLength = maxPathLength; + } + private enum TripleType { COLLIDER, NONCOLLIDER, AMBIGUOUS } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java index 010eb94d37..5c19485c14 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java @@ -217,9 +217,9 @@ public Graph search() { FciOrient fciOrient = new FciOrient(sepsets1); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); - fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathTailRule); fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathColliderRule); + fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setVerbose(this.verbose); fciOrient.setKnowledge(this.knowledge); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java index 0eb959b7eb..6309f30f6e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java @@ -338,9 +338,9 @@ private FciOrient getFciOrient() { FciOrient fciOrient = new FciOrient(new SepsetsSet(this.sepsets, this.independenceTest)); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); - fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); + fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setVerbose(this.verbose); fciOrient.setKnowledge(this.knowledge); return fciOrient; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index f6cc012476..404fe21952 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -177,6 +177,7 @@ public Graph search() { fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(false); fciOrient.setDoDiscriminatingPathTailRule(false); + fciOrient.setMaxPathLength(-1); fciOrient.setKnowledge(knowledge); fciOrient.setVerbose(verbose); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index af6b3ac83c..c78676e3ec 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -27,11 +27,9 @@ import edu.cmu.tetrad.search.utils.DagSepsets; import edu.cmu.tetrad.search.utils.FciOrient; import edu.cmu.tetrad.search.utils.TeyssierScorer; -import edu.cmu.tetrad.util.SublistGenerator; import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; -import java.awt.*; import java.util.*; import java.util.List; @@ -45,13 +43,27 @@ * @author josephramsey */ public final class LvLiteDsepFriendly implements IGraphSearch { + /** + * This variable represents a list of nodes that store different variables. + * It is declared as private and final, hence it cannot be modified or accessed from outside + * the class where it is declared. + */ private final ArrayList variables; + /** + * Indicates whether to use Raskutti Uhler feature. + */ private boolean useRaskuttiUhler; + /** + * The independence test. + */ private IndependenceTest test; /** * The score. */ private Score score; + /** + * Indicates whether or not the score should be used. + */ private boolean useScore; /** * The background knowledge. @@ -69,14 +81,6 @@ public final class LvLiteDsepFriendly implements IGraphSearch { * Whether to use data order. */ private boolean useDataOrder = true; - /** - * This flag represents whether the Bes algorithm should be used in the search. - *

    - * If set to true, the Bes algorithm will be used. If set to false, the Bes algorithm will not be used. - *

    - * By default, the value of this flag is false. - */ - private boolean useBes = false; /** * This variable represents whether the discriminating path rule is used in the LV-Lite class. *

    @@ -127,7 +131,7 @@ public final class LvLiteDsepFriendly implements IGraphSearch { */ private int depth = 3; /** - * Whether to allow internal randomness in the algorithm. + * Specifies whether internal randomness is allowed. */ private boolean allowInternalRandomness = false; /** @@ -263,6 +267,7 @@ public Graph search() { fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(false); fciOrient.setDoDiscriminatingPathTailRule(false); + fciOrient.setMaxPathLength(maxPathLength); fciOrient.setKnowledge(knowledge); fciOrient.setVerbose(verbose); @@ -284,15 +289,6 @@ public Graph search() { return GraphUtils.replaceNodes(pag, this.score.getVariables()); } - /** - * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. - * - * @param useBes true to use the BES algorithm, false otherwise - */ - public void setUseBes(boolean useBes) { - this.useBes = useBes; - } - /** * Sets whether the discriminating path tail rule should be used. * @@ -1000,4 +996,8 @@ public void setMaxPathLength(int maxPathLength) { this.maxPathLength = maxPathLength; } + + public void setAllowInternalRandomness(boolean allowInternalRandomness) { + this.allowInternalRandomness = allowInternalRandomness; + } } 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 9ed7b3f757..82c993e8e3 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 @@ -310,6 +310,4 @@ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule public void setDoDiscriminatingPathTCollideRule(boolean doDiscriminatingPathTCollideRule) { this.doDiscriminatingPathTCollideRule = doDiscriminatingPathTCollideRule; } - - } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java index ed015ef176..92ef29da16 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java @@ -126,10 +126,10 @@ public Graph convert() { } FciOrient fciOrient = new FciOrient(new DagSepsets(this.dag)); - fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); + fciOrient.setMaxPathLength(this.maxPathLength); fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setKnowledge(this.knowledge); fciOrient.setVerbose(false); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java index 5e1d9bcba3..16482087a1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java @@ -45,7 +45,7 @@ public final class MaxP { private int depth = -1; private Knowledge knowledge = new Knowledge(); private boolean useHeuristic; - private int maxPathLength = 3; + private int maxPathLength = -1; private PcCommon.ConflictRule conflictRule = PcCommon.ConflictRule.PRIORITIZE_EXISTING; private boolean verbose = false; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java index 2f13ea8a12..e7e14e514b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java @@ -101,7 +101,7 @@ public final class PcCommon implements IGraphSearch { /** * The max path length for the max p collider orientation heuristic. */ - private int maxPathLength = 3; + private int maxPathLength = -1; /** * The type of FAS to be used. diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java index 19d8193cad..cb2de9bd7e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java @@ -209,8 +209,8 @@ public Graph convert() { fciOrient.setCompleteRuleSetUsed(this.completeRuleSetUsed); fciOrient.setDoDiscriminatingPathTailRule(this.doDiscriminatingPathTailRule); fciOrient.setDoDiscriminatingPathColliderRule(this.doDiscriminatingPathColliderRule); - fciOrient.setChangeFlag(false); fciOrient.setMaxPathLength(this.maxPathLength); + fciOrient.setChangeFlag(false); fciOrient.setKnowledge(this.knowledge); fciOrient.ruleR0(graph); fciOrient.doFinalOrientation(graph); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTests.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTests.java index 214bca12d1..e66c52f02d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTests.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTests.java @@ -1415,7 +1415,7 @@ public void testGFciComparison() { final double alpha = 0.01; final double penaltyDiscount = 3.0; final int depth = 3; - final int maxPathLength = 3; + final int maxPathLength = -1; final boolean possibleMsepDone = true; final boolean completeRuleSetUsed = false; final boolean faithfulnessAssumed = true; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTestsDan.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTestsDan.java index ed3272e212..15022c6627 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTestsDan.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/performance/PerformanceTestsDan.java @@ -74,7 +74,7 @@ private void testIdaOutputForDan() { final double alphaPc = 0.01; final int penaltyDiscount = 1; final int depth = 3; - final int maxPathLength = 3; + final int maxPathLength = -1; final int numVars = 15; final double edgesPerNode = 1.0; From c372d00752cf69d2d7ad2aeff697f8e967020fb6 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 00:40:36 -0400 Subject: [PATCH 09/29] Implement option for internal algorithmic randomness In this commit, an option has been added to allow for internal randomness in the search algorithm. This feature is toggleable through setAllowInternalRandomness(). Other changes include removing the Bes algorithm related code, adjusting max path length for various orientation heuristics, and cleaning up/resetting several default configurations. Documentation for class variables has also been improved. --- .../cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java | 2 +- tetrad-lib/src/main/java/edu/cmu/tetrad/search/SpFci.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java index 35933dfa94..db237b66e6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/SpFci.java @@ -112,7 +112,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); - search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); + search.setDoDiscriminatingPathCollideRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setVerbose(parameters.getBoolean(Params.VERBOSE)); Object obj = parameters.get(Params.PRINT_STREAM); 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 82c993e8e3..512c39cdda 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 @@ -307,7 +307,7 @@ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule * Sets whether the discriminating path collider rule is done. * @param doDiscriminatingPathTCollideRule True, if so. */ - public void setDoDiscriminatingPathTCollideRule(boolean doDiscriminatingPathTCollideRule) { + public void setDoDiscriminatingPathCollideRule(boolean doDiscriminatingPathTCollideRule) { this.doDiscriminatingPathTCollideRule = doDiscriminatingPathTCollideRule; } } From bff7e1974feb251b8b03cc79f9921eb5d3ac7d3b Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 00:46:48 -0400 Subject: [PATCH 10/29] Refactor method to set maximum discriminating path length The method across multiple classes has been refactored to set the maximum length of any discriminating path. The parameters have been updated to allow for unlimited length using -1. The change also includes adding validation checks to ensure the length is either -1 or a non-negative integer. --- .../main/java/edu/cmu/tetrad/search/BFci.java | 4 ++-- .../main/java/edu/cmu/tetrad/search/Cfci.java | 10 +++++++++- .../main/java/edu/cmu/tetrad/search/Fci.java | 4 ++-- .../java/edu/cmu/tetrad/search/FciMax.java | 4 ++-- .../main/java/edu/cmu/tetrad/search/GFci.java | 2 +- .../java/edu/cmu/tetrad/search/GraspFci.java | 2 +- .../java/edu/cmu/tetrad/search/LvLite.java | 19 ++++++++++++++++++- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 2 +- .../main/java/edu/cmu/tetrad/search/Rfci.java | 5 ++--- .../java/edu/cmu/tetrad/search/SpFci.java | 2 +- .../java/edu/cmu/tetrad/search/SvarFci.java | 4 ++-- .../edu/cmu/tetrad/search/utils/DagToPag.java | 9 ++++++--- .../cmu/tetrad/search/utils/FciOrient.java | 2 +- .../edu/cmu/tetrad/search/utils/MaxP.java | 8 ++++++-- .../tetrad/search/utils/SvarFciOrient.java | 2 +- .../cmu/tetrad/search/utils/TsDagToPag.java | 8 ++++++-- .../constraint/search/PagSamplingRfci.java | 8 ++++++-- 17 files changed, 67 insertions(+), 28 deletions(-) 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 559fc3fe99..407f63a188 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 @@ -222,9 +222,9 @@ public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { } /** - * Returns the maximum length of any discriminating path, or -1 if unlimited. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This maximum. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java index 282a012003..e4e3a60a71 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java @@ -551,8 +551,16 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { TetradLogger.getInstance().forceLogMessage("Finishing BK Orientation."); } } - + /** + * Sets the maximum length of any discriminating path. + * + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. + */ public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + this.maxPathLength = maxPathLength; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java index 5c19485c14..b2a11edaf1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java @@ -306,9 +306,9 @@ public void setPossibleMsepSearchDone(boolean possibleMsepSearchDone) { } /** - * Sets the maximum length of any discriminating path, or -1 if unlimited. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This maximum. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java index 6309f30f6e..bf6e207433 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java @@ -269,9 +269,9 @@ public void setPossibleMsepSearchDone(boolean possibleMsepSearchDone) { } /** - * Sets the maximum length of any discriminating path, or -1 if unlimited. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This maximum. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index 7224094c6b..88bb5d5c81 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -229,7 +229,7 @@ public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { } /** - * Sets the maximum path length for the discriminating path rule. + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ 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 b405b59509..ac1407c7f8 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 @@ -227,7 +227,7 @@ public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { } /** - * Sets the maximum length of any discriminating path searched. + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 404fe21952..777345cec8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -92,6 +92,10 @@ public final class LvLite implements IGraphSearch { * tucks are enabled or disabled. */ private boolean allowTucks = true; + /** + * The maximum length of a discriminating path. + */ + private int maxPathLength; /** * LV-Lite constructor. Initializes a new object of LvLite search algorithm with the given IndependenceTest and @@ -177,7 +181,7 @@ public Graph search() { fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(false); fciOrient.setDoDiscriminatingPathTailRule(false); - fciOrient.setMaxPathLength(-1); + fciOrient.setMaxPathLength(maxPathLength); fciOrient.setKnowledge(knowledge); fciOrient.setVerbose(verbose); @@ -834,4 +838,17 @@ public void setAllowTucks(boolean allowTucks) { public void setUseDataOrder(boolean useDataOrder) { this.useDataOrder = useDataOrder; } + + /** + * Sets the maximum length of any discriminating path. + * + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. + */ + public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + + this.maxPathLength = maxPathLength; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index c78676e3ec..e79a19c193 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -985,7 +985,7 @@ public void setDepth(int depth) { /** - * Sets the maximum length of any discriminating path searched. + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java index 0761f4877c..0df5fd2495 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java @@ -271,7 +271,7 @@ public int getMaxPathLength() { } /** - * Sets the maximum path length for discriminating paths. + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ @@ -280,8 +280,7 @@ public void setMaxPathLength(int maxPathLength) { throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); } - this.maxPathLength = maxPathLength == -1 - ? Integer.MAX_VALUE : maxPathLength; + this.maxPathLength = maxPathLength; } /** 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 512c39cdda..934d57367a 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 @@ -247,7 +247,7 @@ public int getMaxPathLength() { } /** - * Sets the max path length for discriminating paths. + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFci.java index 67aadbc66c..46922313fd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFci.java @@ -289,9 +289,9 @@ public int getMaxPathLength() { } /** - * Sets the maximum length of any discriminating path, or -1 if unlimited. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This length. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { if (maxPathLength < -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java index 92ef29da16..22f29a8ad8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java @@ -196,12 +196,15 @@ public void setVerbose(boolean verbose) { } /** - * Sets the maximum path length for some rules in the conversion. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This length. - * @see FciOrient + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + this.maxPathLength = maxPathLength; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java index 2c7540d15a..15306b6261 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java @@ -1264,7 +1264,7 @@ public int getMaxPathLength() { } /** - *

    Setter for the field maxPathLength.

    + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java index 16482087a1..c23585de6d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MaxP.java @@ -88,11 +88,15 @@ public void setUseHeuristic(boolean useHeuristic) { } /** - * Sets the max path length to use for the max P heuristic. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength This maximum. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + this.maxPathLength = maxPathLength; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java index 64a3687dfc..e086f52481 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java @@ -1001,7 +1001,7 @@ public int getMaxPathLength() { } /** - *

    Setter for the field maxPathLength.

    + * Sets the maximum length of any discriminating path. * * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java index cb2de9bd7e..cd0a5d6a11 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java @@ -292,11 +292,15 @@ public int getMaxPathLength() { } /** - *

    Setter for the field maxPathLength.

    + * Sets the maximum length of any discriminating path. * - * @param maxPathLength a int + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + this.maxPathLength = maxPathLength; } diff --git a/tetrad-lib/src/main/java/edu/pitt/dbmi/algo/bayesian/constraint/search/PagSamplingRfci.java b/tetrad-lib/src/main/java/edu/pitt/dbmi/algo/bayesian/constraint/search/PagSamplingRfci.java index b7595e9616..8e3581242a 100644 --- a/tetrad-lib/src/main/java/edu/pitt/dbmi/algo/bayesian/constraint/search/PagSamplingRfci.java +++ b/tetrad-lib/src/main/java/edu/pitt/dbmi/algo/bayesian/constraint/search/PagSamplingRfci.java @@ -153,11 +153,15 @@ public void setDepth(int depth) { } /** - * Set the maximum path length. + * Sets the maximum length of any discriminating path. * - * @param maxPathLength the maximum path length. + * @param maxPathLength the maximum length of any discriminating path, or -1 if unlimited. */ public void setMaxPathLength(int maxPathLength) { + if (maxPathLength < -1) { + throw new IllegalArgumentException("Max path length must be -1 (unlimited) or >= 0: " + maxPathLength); + } + this.maxPathLength = maxPathLength; } From e66db4b01968b356e7d94e15534866dffc91225e Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 05:34:57 -0400 Subject: [PATCH 11/29] Refactor method to set maximum discriminating path length The method across multiple classes has been refactored to set the maximum length of any discriminating path. The parameters have been updated to allow for unlimited length using -1. The change also includes adding validation checks to ensure the length is either -1 or a non-negative integer. --- .../main/java/edu/cmu/tetradapp/Tetrad.java | 5 +- .../cmu/tetradapp/app/LoadSessionAction.java | 2 +- .../edu/cmu/tetradapp/app/TetradDesktop.java | 2 +- .../editor/GeneralAlgorithmEditor.java | 2 +- .../editor/GeneralizedTemplateEditor.java | 2 +- .../editor/LogisticRegressionEditor.java | 2 +- .../tetradapp/editor/MarkovCheckEditor.java | 2 +- .../editor/RandomMimParamsEditor.java | 12 +-- .../tetradapp/editor/RegressionEditor.java | 2 +- .../editor/search/AlgorithmCard.java | 6 +- .../knowledge_editor/KnowledgeBoxEditor.java | 4 +- .../model/AbstractAlgorithmRunner.java | 8 +- .../model/AbstractMBSearchRunner.java | 8 +- .../model/AllEdgesUndirectedWrapper.java | 2 +- .../model/ApproximateUpdaterWrapper.java | 20 ++--- .../model/BayesEstimatorWrapper.java | 12 +-- .../cmu/tetradapp/model/BayesImWrapper.java | 9 +-- .../tetradapp/model/BayesImWrapperObs.java | 9 +-- .../cmu/tetradapp/model/BayesPmWrapper.java | 12 +-- .../model/BayesUpdaterClassifierWrapper.java | 8 +- .../model/BidirectedToUndirectedWrapper.java | 2 +- .../tetradapp/model/BooleanGlassGeneIm.java | 8 +- .../model/BootstrapSamplerWrapper.java | 8 +- .../cmu/tetradapp/model/CPDAGFitModel.java | 8 +- .../model/CPDAGFromDagGraphWrapper.java | 4 +- .../tetradapp/model/CalculatorWrapper.java | 8 +- .../tetradapp/model/CheckKnowledgeModel.java | 8 +- .../model/CptInvariantUpdaterWrapper.java | 8 +- .../tetradapp/model/DagFromCPDAGWrapper.java | 2 +- .../edu/cmu/tetradapp/model/DagWrapper.java | 12 +-- .../edu/cmu/tetradapp/model/DataWrapper.java | 8 +- .../model/DirichletBayesImWrapper.java | 12 +-- .../model/DirichletEstimatorWrapper.java | 12 +-- .../model/EdgewiseComparisonModel.java | 10 +-- .../model/EmBayesEstimatorWrapper.java | 12 +-- .../model/ExtractStructureModelWrapper.java | 2 +- .../tetradapp/model/ForbiddenGraphModel.java | 4 +- .../model/GeneralAlgorithmRunner.java | 8 +- .../model/GeneralizedSemEstimatorWrapper.java | 12 +-- .../model/GeneralizedSemImWrapper.java | 12 +-- .../model/GeneralizedSemPmWrapper.java | 12 +-- .../model/GenerateCompleteGraphWrapper.java | 2 +- .../model/GraphComparisonParams.java | 8 +- .../model/GraphSelectionWrapper.java | 12 +-- .../edu/cmu/tetradapp/model/GraphWrapper.java | 10 +-- .../cmu/tetradapp/model/GridSearchModel.java | 10 +-- .../model/IdentifiabilityWrapper.java | 20 ++--- .../model/IndependenceResultIndFacts.java | 8 +- .../tetradapp/model/JunctionTreeWrapper.java | 12 +-- .../tetradapp/model/KnowledgeBoxModel.java | 2 +- .../model/LogisticRegressionRunner.java | 14 ++-- .../cmu/tetradapp/model/MagInPagWrapper.java | 2 +- .../model/MeasurementModelWrapper.java | 8 +- .../cmu/tetradapp/model/MimBuildRunner.java | 14 ++-- .../tetradapp/model/MimBuildTrekRunner.java | 14 ++-- .../tetradapp/model/Misclassifications.java | 10 +-- .../model/MissingDataInjectorWrapper.java | 8 +- .../model/PValueImproverWrapper.java | 8 +- .../model/PagFromDagGraphWrapper.java | 4 +- .../cmu/tetradapp/model/RegressionRunner.java | 14 ++-- .../model/RemoveNonSkeletonEdgesModel.java | 4 +- .../model/RemoveNullEdgesGraphWrapper.java | 2 +- .../ReplaceMissingWithRandomWrapper.java | 8 +- .../tetradapp/model/RequiredGraphModel.java | 4 +- .../model/RowSummingExactWrapper.java | 20 ++--- .../tetradapp/model/ScoredGraphsWrapper.java | 20 ++--- .../tetradapp/model/SemEstimatorWrapper.java | 18 ++--- .../cmu/tetradapp/model/SemGraphWrapper.java | 12 +-- .../edu/cmu/tetradapp/model/SemImWrapper.java | 14 ++-- .../edu/cmu/tetradapp/model/SemPmWrapper.java | 14 ++-- .../tetradapp/model/SemUpdaterWrapper.java | 8 +- .../tetradapp/model/SessionNodeWrapper.java | 8 +- .../cmu/tetradapp/model/SessionWrapper.java | 8 +- .../model/StandardizedSemImWrapper.java | 12 +-- .../model/StructEmBayesSearchRunner.java | 12 +-- .../tetradapp/model/TabularComparison.java | 10 +-- .../cmu/tetradapp/model/TetradMetadata.java | 8 +- .../tetradapp/model/TimeLagGraphWrapper.java | 12 +-- .../model/TsPagFromDagGraphWrapper.java | 4 +- .../model/UndirectedToBidirectedWrapper.java | 2 +- .../model/datamanip/DeterminismWraper.java | 8 +- .../datamanip/DiscretizationWrapper.java | 8 +- .../cmu/tetradapp/session/SessionNode.java | 4 +- .../tetradapp/session/SimulationStudy.java | 8 +- .../ui/tool/SessionFileTransferHandler.java | 6 +- .../cmu/tetradapp/util/WatchedProcess.java | 4 +- .../workbench/AbstractWorkbench.java | 8 +- .../tetradapp/workbench/GraphNodeError.java | 8 +- .../tetradapp/workbench/GraphNodeLatent.java | 8 +- .../tetradapp/workbench/GraphNodeLocked.java | 8 +- .../workbench/GraphNodeMeasured.java | 8 +- .../workbench/GraphNodeRandomized.java | 8 +- .../cmu/tetrad/algcomparison/Comparison.java | 18 ++--- .../algcomparison/algorithm/Algorithms.java | 8 +- .../algcomparison/algorithm/cluster/Bpc.java | 2 +- .../algcomparison/algorithm/cluster/Fofc.java | 2 +- .../algorithm/continuous/dag/Dagma.java | 2 +- .../continuous/dag/DirectLingam.java | 2 +- .../algorithm/continuous/dag/IcaLingD.java | 16 ++-- .../algorithm/continuous/dag/IcaLingam.java | 4 +- .../algorithm/oracle/cpdag/Cstar.java | 6 +- .../algorithm/other/FactorAnalysis.java | 2 +- .../simulation/GeneralSemSimulation.java | 2 +- .../algcomparison/simulation/Simulations.java | 8 +- .../algcomparison/statistic/Maximal.java | 6 +- .../algcomparison/statistic/Statistics.java | 8 +- .../cmu/tetrad/bayes/ApproximateUpdater.java | 8 +- .../edu/cmu/tetrad/bayes/BayesImProbs.java | 8 +- .../java/edu/cmu/tetrad/bayes/BayesPm.java | 8 +- .../bayes/CptInvariantMarginalCalculator.java | 8 +- .../cmu/tetrad/bayes/CptInvariantUpdater.java | 8 +- .../cmu/tetrad/bayes/DirichletBayesIm.java | 8 +- .../java/edu/cmu/tetrad/bayes/Evidence.java | 8 +- .../bayes/FactoredBayesStructuralEM.java | 74 +++++++++---------- .../edu/cmu/tetrad/bayes/Identifiability.java | 8 +- .../tetrad/bayes/JunctionTreeAlgorithm.java | 8 +- .../cmu/tetrad/bayes/JunctionTreeUpdater.java | 8 +- .../edu/cmu/tetrad/bayes/Manipulation.java | 8 +- .../java/edu/cmu/tetrad/bayes/MlBayesIm.java | 8 +- .../edu/cmu/tetrad/bayes/MlBayesImObs.java | 8 +- .../edu/cmu/tetrad/bayes/Proposition.java | 8 +- .../edu/cmu/tetrad/bayes/StoredCellProbs.java | 8 +- .../ClassifierBayesUpdaterDiscrete.java | 4 +- .../tetrad/classify/ClassifierMbDiscrete.java | 40 +++++----- .../java/edu/cmu/tetrad/data/BoxDataSet.java | 8 +- .../java/edu/cmu/tetrad/data/Clusters.java | 8 +- .../data/ContinuousDiscretizationSpec.java | 8 +- .../cmu/tetrad/data/ContinuousVariable.java | 9 +-- .../data/CorrelationMatrixOnTheFly.java | 8 +- .../edu/cmu/tetrad/data/CovarianceMatrix.java | 8 +- .../tetrad/data/CovarianceMatrixOnTheFly.java | 8 +- .../edu/cmu/tetrad/data/DataModelList.java | 8 +- .../edu/cmu/tetrad/data/DelimiterType.java | 8 +- .../data/DiscreteDiscretizationSpec.java | 8 +- .../edu/cmu/tetrad/data/DiscreteVariable.java | 8 +- .../cmu/tetrad/data/DiscreteVariableType.java | 8 +- .../edu/cmu/tetrad/data/KnowledgeEdge.java | 8 +- .../edu/cmu/tetrad/data/KnowledgeGroup.java | 8 +- .../edu/cmu/tetrad/data/LogDataUtils.java | 6 +- .../cmu/tetrad/data/NumberObjectDataSet.java | 8 +- .../edu/cmu/tetrad/data/SimpleDataLoader.java | 34 ++++----- .../edu/cmu/tetrad/data/SplitCasesSpec.java | 8 +- .../edu/cmu/tetrad/data/TimeSeriesData.java | 8 +- .../main/java/edu/cmu/tetrad/graph/Edge.java | 8 +- .../cmu/tetrad/graph/EdgeTypeProbability.java | 8 +- .../java/edu/cmu/tetrad/graph/Endpoint.java | 8 +- .../java/edu/cmu/tetrad/graph/GraphUtils.java | 16 ++-- .../cmu/tetrad/graph/IndependenceFact.java | 8 +- .../edu/cmu/tetrad/graph/OrderedPair.java | 8 +- .../main/java/edu/cmu/tetrad/graph/Paths.java | 10 +-- .../java/edu/cmu/tetrad/graph/Triple.java | 8 +- .../tetrad/regression/RegressionResult.java | 8 +- .../main/java/edu/cmu/tetrad/search/BFci.java | 4 +- .../edu/cmu/tetrad/search/BossLingam.java | 2 +- .../main/java/edu/cmu/tetrad/search/Bpc.java | 4 +- .../main/java/edu/cmu/tetrad/search/Ccd.java | 4 +- .../main/java/edu/cmu/tetrad/search/Cfci.java | 28 +++---- .../main/java/edu/cmu/tetrad/search/Cpc.java | 22 +++--- .../java/edu/cmu/tetrad/search/Cstar.java | 40 +++++----- .../main/java/edu/cmu/tetrad/search/Fas.java | 4 +- .../main/java/edu/cmu/tetrad/search/Fasd.java | 10 +-- .../java/edu/cmu/tetrad/search/FaskOrig.java | 64 ++++++++-------- .../java/edu/cmu/tetrad/search/FastIca.java | 24 +++--- .../main/java/edu/cmu/tetrad/search/Fci.java | 4 +- .../java/edu/cmu/tetrad/search/FciMax.java | 4 +- .../main/java/edu/cmu/tetrad/search/Fges.java | 18 ++--- .../java/edu/cmu/tetrad/search/FgesMb.java | 16 ++-- .../main/java/edu/cmu/tetrad/search/Fofc.java | 2 +- .../main/java/edu/cmu/tetrad/search/Ftfc.java | 2 +- .../main/java/edu/cmu/tetrad/search/GFci.java | 4 +- .../java/edu/cmu/tetrad/search/Grasp.java | 14 ++-- .../java/edu/cmu/tetrad/search/GraspFci.java | 4 +- .../java/edu/cmu/tetrad/search/IcaLingD.java | 6 +- .../java/edu/cmu/tetrad/search/IcaLingam.java | 2 +- .../main/java/edu/cmu/tetrad/search/Ida.java | 2 +- .../main/java/edu/cmu/tetrad/search/Lofs.java | 8 +- .../java/edu/cmu/tetrad/search/LvDumb.java | 12 +-- .../java/edu/cmu/tetrad/search/LvLite.java | 36 ++++----- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 36 ++++----- .../edu/cmu/tetrad/search/MarkovCheck.java | 5 +- .../main/java/edu/cmu/tetrad/search/Pc.java | 8 +- .../main/java/edu/cmu/tetrad/search/PcMb.java | 48 ++++++------ .../main/java/edu/cmu/tetrad/search/Pcd.java | 8 +- .../main/java/edu/cmu/tetrad/search/Rfci.java | 8 +- .../java/edu/cmu/tetrad/search/SpFci.java | 4 +- .../java/edu/cmu/tetrad/search/SvarFas.java | 10 +-- .../java/edu/cmu/tetrad/search/SvarFci.java | 6 +- .../java/edu/cmu/tetrad/search/SvarFges.java | 38 +++++----- .../java/edu/cmu/tetrad/search/SvarGfci.java | 16 ++-- .../cmu/tetrad/search/score/SemBicScore.java | 2 +- .../ConditionalCorrelationIndependence.java | 2 +- .../tetrad/search/test/IndTestChiSquare.java | 4 +- .../test/IndTestConditionalCorrelation.java | 2 +- .../test/IndTestConditionalGaussianLrt.java | 2 +- .../test/IndTestDegenerateGaussianLrt.java | 2 +- .../tetrad/search/test/IndTestFisherZ.java | 8 +- .../IndTestFisherZConcatenateResiduals.java | 2 +- .../test/IndTestFisherZFisherPValue.java | 2 +- .../tetrad/search/test/IndTestGSquare.java | 4 +- .../cmu/tetrad/search/test/IndTestHsic.java | 2 +- .../search/test/IndTestIndependenceFacts.java | 2 +- .../cmu/tetrad/search/test/IndTestMulti.java | 4 +- .../cmu/tetrad/search/test/IndTestMvpLrt.java | 6 +- .../search/test/IndTestProbabilistic.java | 2 +- .../tetrad/search/test/IndTestRegression.java | 8 +- .../search/test/IndependenceResult.java | 8 +- .../java/edu/cmu/tetrad/search/test/Kci.java | 12 +-- .../edu/cmu/tetrad/search/test/MsepTest.java | 2 +- .../cmu/tetrad/search/test/ScoreIndTest.java | 2 +- .../java/edu/cmu/tetrad/search/utils/Bes.java | 6 +- .../tetrad/search/utils/BesPermutation.java | 6 +- .../tetrad/search/utils/BpcAlgorithmType.java | 8 +- .../cmu/tetrad/search/utils/BpcTestType.java | 8 +- .../search/utils/ClusterSignificance.java | 8 +- .../cmu/tetrad/search/utils/ClusterUtils.java | 2 +- .../cmu/tetrad/search/utils/FciOrient.java | 52 ++++++------- .../cmu/tetrad/search/utils/FgesOrienter.java | 30 ++++---- .../tetrad/search/utils/GraphSearchUtils.java | 30 ++++---- .../tetrad/search/utils/GraphoidAxioms.java | 74 +++++++++---------- .../tetrad/search/utils/LogUtilsSearch.java | 2 +- .../cmu/tetrad/search/utils/MeekRules.java | 6 +- .../edu/cmu/tetrad/search/utils/PcCommon.java | 6 +- .../tetrad/search/utils/ResolveSepsets.java | 12 +-- .../edu/cmu/tetrad/search/utils/Sextad.java | 8 +- .../tetrad/search/utils/SvarFciOrient.java | 38 +++++----- .../search/utils/TetradTestContinuous.java | 4 +- .../cmu/tetrad/search/utils/TsDagToPag.java | 2 +- .../search/work_in_progress/FasDci.java | 8 +- .../search/work_in_progress/FasFdr.java | 6 +- .../search/work_in_progress/GraspTol.java | 14 ++-- .../search/work_in_progress/HbsmsBeam.java | 8 +- .../search/work_in_progress/HbsmsGes.java | 26 +++---- .../work_in_progress/IndTestCramerT.java | 2 +- .../IndTestFisherZPercentIndependent.java | 2 +- .../IndTestFisherZRecursive.java | 2 +- .../IndTestMixedMultipleTTest.java | 4 +- .../work_in_progress/IndTestMnlrLr.java | 2 +- .../IndTestMultinomialLogisticRegression.java | 6 +- .../work_in_progress/IndTestSepsetDci.java | 4 +- .../tetrad/search/work_in_progress/Ion.java | 20 ++--- .../tetrad/search/work_in_progress/Kpc.java | 8 +- .../tetrad/search/work_in_progress/Mmmb.java | 10 +-- .../ProbabilisticMapIndependence.java | 2 +- .../work_in_progress/ResolveSepsetsDci.java | 12 +-- .../search/work_in_progress/SampleVcpc.java | 34 ++++----- .../work_in_progress/SampleVcpcFast.java | 34 ++++----- .../search/work_in_progress/Sextad.java | 8 +- .../tetrad/search/work_in_progress/VcFas.java | 6 +- .../tetrad/search/work_in_progress/VcPc.java | 22 +++--- .../search/work_in_progress/VcPcAlt.java | 34 ++++----- .../search/work_in_progress/VcPcFast.java | 22 +++--- .../java/edu/cmu/tetrad/sem/DagScorer.java | 8 +- .../edu/cmu/tetrad/sem/GeneralizedSemPm.java | 8 +- .../main/java/edu/cmu/tetrad/sem/Mapping.java | 8 +- .../edu/cmu/tetrad/sem/ParamConstraint.java | 8 +- .../java/edu/cmu/tetrad/sem/Parameter.java | 8 +- .../edu/cmu/tetrad/sem/ParameterPair.java | 8 +- .../java/edu/cmu/tetrad/sem/SemEstimator.java | 18 ++--- .../edu/cmu/tetrad/sem/SemEstimatorGibbs.java | 8 +- .../tetrad/sem/SemEstimatorGibbsParams.java | 8 +- .../java/edu/cmu/tetrad/sem/SemEvidence.java | 8 +- .../main/java/edu/cmu/tetrad/sem/SemIm.java | 8 +- .../edu/cmu/tetrad/sem/SemManipulation.java | 8 +- .../edu/cmu/tetrad/sem/SemOptimizerEm.java | 4 +- .../tetrad/sem/SemOptimizerRegression.java | 4 +- .../edu/cmu/tetrad/sem/SemOptimizerRicf.java | 2 +- .../tetrad/sem/SemOptimizerScattershot.java | 10 +-- .../main/java/edu/cmu/tetrad/sem/SemPm.java | 8 +- .../edu/cmu/tetrad/sem/SemProposition.java | 8 +- .../java/edu/cmu/tetrad/sem/SemUpdater.java | 8 +- .../edu/cmu/tetrad/sem/StandardizedSemIm.java | 8 +- .../gene/graph/StoredLagGraphParams.java | 8 +- .../tetrad/gene/history/BooleanFunction.java | 8 +- .../gene/tetrad/gene/history/DishModel.java | 8 +- .../gene/tetrad/gene/history/GeneHistory.java | 8 +- .../gene/history/IndexedConnectivity.java | 8 +- .../tetrad/gene/history/IndexedLagGraph.java | 8 +- .../tetrad/gene/history/IndexedParent.java | 8 +- .../gene/tetrad/gene/history/LaggedEdge.java | 8 +- .../gene/tetrad/gene/history/Polynomial.java | 8 +- .../tetrad/gene/history/PolynomialTerm.java | 8 +- .../gene/simulation/MeasurementSimulator.java | 8 +- .../study/gene/tetradapp/model/GenePm.java | 8 +- .../model/MeasurementSimulatorParams.java | 8 +- .../tetrad/util/AlgorithmDescriptions.java | 2 +- .../util/IndependenceTestDescriptions.java | 2 +- .../main/java/edu/cmu/tetrad/util/Matrix.java | 8 +- .../cmu/tetrad/util/ParamDescriptions.java | 2 +- .../java/edu/cmu/tetrad/util/Parameters.java | 8 +- .../java/edu/cmu/tetrad/util/PointXy.java | 8 +- .../cmu/tetrad/util/ScoreDescriptions.java | 2 +- .../edu/cmu/tetrad/util/TetradLogger.java | 2 +- .../main/java/edu/cmu/tetrad/util/Vector.java | 8 +- .../java/edu/cmu/tetrad/util/Version.java | 8 +- .../edu/cmu/tetrad/util/dist/ChiSquare.java | 8 +- .../java/edu/cmu/tetrad/util/dist/Normal.java | 8 +- .../java/edu/cmu/tetrad/util/dist/Split.java | 8 +- .../cmu/tetrad/util/dist/TruncatedNormal.java | 8 +- .../edu/cmu/tetrad/util/dist/Uniform.java | 8 +- ...TestMultinomialLogisticRegressionWald.java | 8 +- .../java/edu/cmu/tetrad/test/TestFges.java | 2 +- 301 files changed, 1455 insertions(+), 1460 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/Tetrad.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/Tetrad.java index d9a12be44e..ffb1ba42cd 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/Tetrad.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/Tetrad.java @@ -20,7 +20,6 @@ /////////////////////////////////////////////////////////////////////////////// package edu.cmu.tetradapp; -import edu.cmu.tetrad.search.work_in_progress.DMSearch; import edu.cmu.tetrad.util.JOptionUtils; import edu.cmu.tetrad.util.TetradLogger; import edu.cmu.tetrad.util.Version; @@ -122,7 +121,7 @@ private static void setLookAndFeel() { UIManager.getSystemLookAndFeelClassName()); } } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("Couldn't set look and feel."); + TetradLogger.getInstance().log("Couldn't set look and feel."); } } @@ -271,7 +270,7 @@ public void componentMoved(ComponentEvent e) { } }); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("Could not set quit handler on this platform.."); + TetradLogger.getInstance().log("Could not set quit handler on this platform.."); } } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/LoadSessionAction.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/LoadSessionAction.java index 4bebe87ce6..774f4d333f 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/LoadSessionAction.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/LoadSessionAction.java @@ -123,7 +123,7 @@ public void watch() { throw e1; } catch (Exception e2) { e2.printStackTrace(); - TetradLogger.getInstance().forceLogMessage("Exception: " + e2.getMessage()); + TetradLogger.getInstance().log("Exception: " + e2.getMessage()); } } else if (o instanceof SessionWrapper) { sessionWrapper = (SessionWrapper) o; diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/TetradDesktop.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/TetradDesktop.java index e9bba6e1e7..8a7b9f0e42 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/TetradDesktop.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/app/TetradDesktop.java @@ -532,7 +532,7 @@ public void setDisplayLogging(boolean displayLogging) { try { TetradLogger.getInstance().setNextOutputStream(); } catch (IllegalStateException e2) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "Unable to setup logging, please restart Tetrad."); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralAlgorithmEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralAlgorithmEditor.java index 623f8c3d3b..7871ee31a2 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralAlgorithmEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralAlgorithmEditor.java @@ -198,7 +198,7 @@ public void setAlgorithmResult(String jsonResult) { this.algorithmRunner.getGraphs().clear(); this.algorithmRunner.getGraphs().add(graph); - TetradLogger.getInstance().forceLogMessage("Remote graph result assigned to algorithmRunner!"); + TetradLogger.getInstance().log("Remote graph result assigned to algorithmRunner!"); firePropertyChange("modelChanged", null, null); this.graphCard.refresh(); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralizedTemplateEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralizedTemplateEditor.java index 3cb094e0b7..9ddfb2a072 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralizedTemplateEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GeneralizedTemplateEditor.java @@ -542,7 +542,7 @@ private void setParseText(String text) { expressionTextDoc.remove(0, expressionTextPane.getText().length()); expressionTextDoc.insertString(0, text, null); } catch (BadLocationException e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); throw new RuntimeException(e); } }); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LogisticRegressionEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LogisticRegressionEditor.java index e40ea519b7..3c66efc268 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LogisticRegressionEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LogisticRegressionEditor.java @@ -144,7 +144,7 @@ public LogisticRegressionEditor(LogisticRegressionRunner regressionRunner) { LayoutUtil.fruchtermanReingoldLayout(outGraph); workbench.setGraph(outGraph); String message = this.modelParameters.getText(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); }); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java index 9c41622422..0d02bd1493 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java @@ -641,7 +641,7 @@ private void setTest() { repaint(); } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e1) { - TetradLogger.getInstance().forceLogMessage("Error: " + e1.getMessage()); + TetradLogger.getInstance().log("Error: " + e1.getMessage()); throw new RuntimeException(e1); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RandomMimParamsEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RandomMimParamsEditor.java index 29cadd625a..ea4b0ef1d6 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RandomMimParamsEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RandomMimParamsEditor.java @@ -76,7 +76,7 @@ public RandomMimParamsEditor(Parameters parameters) { parameters.set("numStructuralEdges", value); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); return oldValue; @@ -97,7 +97,7 @@ public RandomMimParamsEditor(Parameters parameters) { numStructuralEdges.setValue(numStructuralEdges.getValue()); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); numStructuralEdges.setValue(numStructuralEdges.getValue()); @@ -116,7 +116,7 @@ public RandomMimParamsEditor(Parameters parameters) { parameters.set("measurementModelDegree", value); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); return oldValue; @@ -134,7 +134,7 @@ public RandomMimParamsEditor(Parameters parameters) { parameters.set("latentMeasuredImpureParents", value); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); return oldValue; @@ -152,7 +152,7 @@ public RandomMimParamsEditor(Parameters parameters) { parameters.set("measuredMeasuredImpureParents", value); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); return oldValue; @@ -171,7 +171,7 @@ public RandomMimParamsEditor(Parameters parameters) { value); return value; } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // RandomMimParamsEditor.LOGGER.error("", exception); return oldValue; diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RegressionEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RegressionEditor.java index b54a49bdfe..93731b40c1 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RegressionEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/RegressionEditor.java @@ -91,7 +91,7 @@ public RegressionEditor(RegressionRunner regressionRunner) { executeButton.addActionListener(e -> { runRegression(); String message = RegressionEditor.this.reportText.getText(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); }); this.workbench = new GraphWorkbench(outGraph); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/AlgorithmCard.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/AlgorithmCard.java index 9875c4cfc2..ea7efb54b7 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/AlgorithmCard.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/AlgorithmCard.java @@ -519,7 +519,7 @@ public Algorithm getAlgorithmFromInterface(AlgorithmModel algoModel, Independenc try { algorithm = AlgorithmFactory.create(algoClass, indTestClass, scoreClass); } catch (IllegalAccessException | InstantiationException | InvocationTargetException exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); } // Those pairwise algos (R3, RShew, Skew..) require source graph to initialize - Zhou @@ -587,7 +587,7 @@ private void validateAlgorithmOption() { } } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); msg = ""; } @@ -609,7 +609,7 @@ private void validateAlgorithmOption() { JOptionPane.showMessageDialog(this.desktop, exception.getCause().getMessage(), "Please Note", JOptionPane.INFORMATION_MESSAGE); } } catch (IllegalAccessException | InstantiationException | NoSuchMethodException | InvocationTargetException exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); } } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/knowledge_editor/KnowledgeBoxEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/knowledge_editor/KnowledgeBoxEditor.java index dbeec271b8..94415affa2 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/knowledge_editor/KnowledgeBoxEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/knowledge_editor/KnowledgeBoxEditor.java @@ -190,9 +190,9 @@ public KnowledgeBoxEditor(KnowledgeBoxModel knowledgeBoxModel) { addComponentListener(new ComponentAdapter() { @Override public void componentHidden(ComponentEvent e) { - TetradLogger.getInstance().forceLogMessage("Edited Knowledge:"); + TetradLogger.getInstance().log("Edited Knowledge:"); String message = KnowledgeBoxEditor.this.knowledge.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } }); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java index 6df480bc2c..2610b8f52a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java @@ -498,8 +498,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -509,8 +509,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java index 8f1f940537..c33d5dbf8e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java @@ -222,8 +222,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -233,8 +233,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AllEdgesUndirectedWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AllEdgesUndirectedWrapper.java index bb415cd842..4dd303a22f 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AllEdgesUndirectedWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AllEdgesUndirectedWrapper.java @@ -57,7 +57,7 @@ public AllEdgesUndirectedWrapper(GraphSource source, Parameters parameters) { public AllEdgesUndirectedWrapper(Graph graph) { super(GraphUtils.undirectedGraph(graph), "Make Bidirected Edges Undirected"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java index f6c6d90cf2..df6837b0dc 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java @@ -170,15 +170,15 @@ private void setup(BayesIm bayesIm, Parameters params) { if (node != null) { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); - TetradLogger.getInstance().forceLogMessage("\nApproximate Updater"); + TetradLogger.getInstance().log("\nApproximate Updater"); String nodeName = node.getName(); int nodeIndex = bayesIm.getNodeIndex(bayesIm.getNode(nodeName)); double[] priors = getBayesUpdater().calculatePriorMarginals(nodeIndex); double[] marginals = getBayesUpdater().calculateUpdatedMarginals(nodeIndex); - TetradLogger.getInstance().forceLogMessage("\nVariable = " + nodeName); - TetradLogger.getInstance().forceLogMessage("\nEvidence:"); + TetradLogger.getInstance().log("\nVariable = " + nodeName); + TetradLogger.getInstance().log("\nEvidence:"); Evidence evidence = (Evidence) getParams().get("evidence", null); Proposition proposition = evidence.getProposition(); @@ -187,16 +187,16 @@ private void setup(BayesIm bayesIm, Parameters params) { int category = proposition.getSingleCategory(i); if (category != -1) { - TetradLogger.getInstance().forceLogMessage("\t" + variable + " = " + category); + TetradLogger.getInstance().log("\t" + variable + " = " + category); } } - TetradLogger.getInstance().forceLogMessage("\nCat.\tPrior\tMarginal"); + TetradLogger.getInstance().log("\nCat.\tPrior\tMarginal"); for (int i = 0; i < priors.length; i++) { String message = category(evidence, nodeName, i) + "\t" + nf.format(priors[i]) + "\t" + nf.format(marginals[i]); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } TetradLogger.getInstance().reset(); @@ -217,8 +217,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -229,8 +229,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java index 4e3b1b5c7b..788ccc3f44 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java @@ -281,8 +281,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -292,16 +292,16 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } private void log(BayesIm im) { - TetradLogger.getInstance().forceLogMessage("ML estimated Bayes IM."); + TetradLogger.getInstance().log("ML estimated Bayes IM."); String message = im.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } private void estimate(DataSet dataSet, BayesPm bayesPm) { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java index 40853ce285..fe26a6535c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java @@ -39,7 +39,6 @@ import java.io.Serial; import java.util.ArrayList; import java.util.List; -import java.util.function.IntBinaryOperator; /** * Wraps a Bayes IM for use in the Tetrad application. @@ -374,8 +373,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -385,8 +384,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java index e067c1e9ff..9e18d1587b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java @@ -34,7 +34,6 @@ import java.io.IOException; import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; import java.io.Serial; import java.util.List; @@ -161,9 +160,9 @@ public void setName(String name) { //============================== private methods ============================// private void log(BayesIm im) { - TetradLogger.getInstance().forceLogMessage("Maximum likelihood Bayes IM: Observed Variables Only"); + TetradLogger.getInstance().log("Maximum likelihood Bayes IM: Observed Variables Only"); String message = im.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } @Serial @@ -171,8 +170,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java index 33e45aef1a..a7545a1618 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java @@ -516,8 +516,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -527,8 +527,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -559,9 +559,9 @@ public void setName(String name) { //================================= Private Methods ==================================// private void log(BayesPm pm) { - TetradLogger.getInstance().forceLogMessage("Bayes Parametric Model (Bayes PM)"); + TetradLogger.getInstance().log("Bayes Parametric Model (Bayes PM)"); String message = pm.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java index 8fae44e62c..8387d3d676 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java @@ -127,8 +127,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -138,8 +138,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BidirectedToUndirectedWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BidirectedToUndirectedWrapper.java index a7fd775367..9aae033b58 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BidirectedToUndirectedWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BidirectedToUndirectedWrapper.java @@ -57,7 +57,7 @@ public BidirectedToUndirectedWrapper(GraphSource source, Parameters parameters) public BidirectedToUndirectedWrapper(Graph graph) { super(GraphUtils.bidirectedToUndirected(graph), "Make Bidirected Edges Undirected"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java index 118efff835..2aaf946aca 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java @@ -404,8 +404,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -415,8 +415,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java index 2d83e751ac..aad9b8f771 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java @@ -115,8 +115,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -126,8 +126,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java index e62f37119e..96a991a1c5 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java @@ -265,8 +265,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -276,8 +276,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFromDagGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFromDagGraphWrapper.java index 5b2ea14f14..954bd04c73 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFromDagGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFromDagGraphWrapper.java @@ -67,8 +67,8 @@ public CPDAGFromDagGraphWrapper(Graph graph) { Graph cpdag = CPDAGFromDagGraphWrapper.getCpdag(new EdgeListGraph(graph)); setGraph(cpdag); - TetradLogger.getInstance().forceLogMessage("\nGenerating cpdag from DAG."); - TetradLogger.getInstance().forceLogMessage(cpdag + ""); + TetradLogger.getInstance().log("\nGenerating cpdag from DAG."); + TetradLogger.getInstance().log(cpdag + ""); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java index 501cf6803c..47cb8e351c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java @@ -132,8 +132,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -143,8 +143,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java index 84087f1722..591334d384 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java @@ -144,8 +144,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -155,8 +155,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java index 2d963d81d8..5d76971e59 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java @@ -198,8 +198,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -209,8 +209,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagFromCPDAGWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagFromCPDAGWrapper.java index 59f8aaf1ae..521627e172 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagFromCPDAGWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagFromCPDAGWrapper.java @@ -59,7 +59,7 @@ public DagFromCPDAGWrapper(GraphSource source, Parameters parameters) { public DagFromCPDAGWrapper(Graph graph) { super(DagFromCPDAGWrapper.getGraph(graph), "Choose Random DAG in CPDAG."); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } private static Graph getGraph(Graph graph) { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java index 11bbe2c0bd..e89dd97081 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java @@ -287,9 +287,9 @@ public void setDag(Dag graph) { //============================PRIVATE METHODS========================// private void log() { - TetradLogger.getInstance().forceLogMessage("Directed Acyclic Graph (DAG)"); + TetradLogger.getInstance().log("Directed Acyclic Graph (DAG)"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } @Serial @@ -297,8 +297,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -308,8 +308,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java index 4b39f46a26..ad8f57f407 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java @@ -494,8 +494,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -505,8 +505,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java index 5376e4f893..3cce5c40bd 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java @@ -138,8 +138,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -149,8 +149,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -217,8 +217,8 @@ public List getVariables() { } private void log(DirichletBayesIm im) { - TetradLogger.getInstance().forceLogMessage("Dirichlet Bayes IM"); + TetradLogger.getInstance().log("Dirichlet Bayes IM"); String message = im.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java index dd9ec1edc9..f2853211bc 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java @@ -169,8 +169,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -180,8 +180,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -212,8 +212,8 @@ public void setName(String name) { } private void log(DirichletBayesIm im) { - TetradLogger.getInstance().forceLogMessage("Estimated Dirichlet Bayes IM"); - TetradLogger.getInstance().forceLogMessage("" + im); + TetradLogger.getInstance().log("Estimated Dirichlet Bayes IM"); + TetradLogger.getInstance().log("" + im); TetradLogger.getInstance().reset(); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java index 7b9c2b1415..3b9fb2a6e6 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java @@ -105,7 +105,7 @@ public EdgewiseComparisonModel(GraphSource model1, GraphSource model2, Parameter this.targetGraph = model2.getGraph(); } - TetradLogger.getInstance().forceLogMessage("Graph Comparison"); + TetradLogger.getInstance().log("Graph Comparison"); } @@ -184,8 +184,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -195,8 +195,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java index 5c97a20cc7..e9649b572f 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java @@ -111,8 +111,8 @@ public EmBayesEstimatorWrapper(DataWrapper dataWrapper, throw new RuntimeException( "Please specify the search tolerance first."); } - TetradLogger.getInstance().forceLogMessage("EM-Estimated Bayes IM:"); - TetradLogger.getInstance().forceLogMessage("" + this.estimateBayesIm); + TetradLogger.getInstance().log("EM-Estimated Bayes IM:"); + TetradLogger.getInstance().log("" + this.estimateBayesIm); } /** @@ -161,8 +161,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -172,8 +172,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ExtractStructureModelWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ExtractStructureModelWrapper.java index c57413f0bf..adef89ceaf 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ExtractStructureModelWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ExtractStructureModelWrapper.java @@ -82,7 +82,7 @@ public ExtractStructureModelWrapper(Graph graph) { LayoutUtil.fruchtermanReingoldLayout(graph3); setGraph(graph3); - TetradLogger.getInstance().forceLogMessage("\nGenerating CPDAG from DAG."); + TetradLogger.getInstance().log("\nGenerating CPDAG from DAG."); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ForbiddenGraphModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ForbiddenGraphModel.java index 29ac22e62d..46147c2b1e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ForbiddenGraphModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ForbiddenGraphModel.java @@ -257,7 +257,7 @@ public ForbiddenGraphModel(Parameters params, KnowledgeBoxInput input) { createKnowledge(params); - TetradLogger.getInstance().forceLogMessage("Knowledge"); + TetradLogger.getInstance().log("Knowledge"); // This is a conundrum. At this point I dont know whether I am in a // simulation or not. If in a simulation, I should print the knowledge. @@ -265,7 +265,7 @@ public ForbiddenGraphModel(Parameters params, KnowledgeBoxInput input) { // printing the knowledge if it's not empty. if (!((Knowledge) params.get("knowledge", new Knowledge())).isEmpty()) { String message = params.get("knowledge", new Knowledge()).toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java index a9794e516f..3bf8a69663 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java @@ -714,8 +714,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -725,8 +725,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java index 7d904ea31d..c995c78119 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java @@ -136,8 +136,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -147,8 +147,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -199,9 +199,9 @@ public void setShowErrors(boolean showErrors) { //======================= Private methods ====================// private void log(GeneralizedSemIm im) { - TetradLogger.getInstance().forceLogMessage("Generalized SEM IM"); + TetradLogger.getInstance().log("Generalized SEM IM"); String message = im.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java index 9a89901962..09d2a3afea 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java @@ -151,8 +151,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -162,8 +162,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -213,9 +213,9 @@ public void setShowErrors(boolean showErrors) { //======================= Private methods ====================// private void log(GeneralizedSemIm im) { - TetradLogger.getInstance().forceLogMessage("Generalized SEM IM"); + TetradLogger.getInstance().log("Generalized SEM IM"); String message = im.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java index b8bc10cbed..3167c04cdb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java @@ -398,8 +398,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -409,8 +409,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -460,9 +460,9 @@ public void setShowErrors(boolean showErrors) { //======================= Private methods ====================// private void log(GeneralizedSemPm pm) { - TetradLogger.getInstance().forceLogMessage("Generalized Structural Equation Parameter Model (Generalized SEM PM)"); + TetradLogger.getInstance().log("Generalized Structural Equation Parameter Model (Generalized SEM PM)"); String message = pm.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GenerateCompleteGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GenerateCompleteGraphWrapper.java index 9dac636083..3f1becb9cb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GenerateCompleteGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GenerateCompleteGraphWrapper.java @@ -57,7 +57,7 @@ public GenerateCompleteGraphWrapper(GraphSource source, Parameters parameters) { public GenerateCompleteGraphWrapper(Graph graph) { super(GenerateCompleteGraphWrapper.generateCompleteGraph(graph), "Generate Complete Graph"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java index 299a9af3db..940a037a41 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java @@ -230,8 +230,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -241,8 +241,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java index 6620d93bc1..0379c3ae8c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java @@ -118,7 +118,7 @@ public GraphSelectionWrapper(Graph graph, Parameters params) { */ public GraphSelectionWrapper(Graph graphs, Parameters params, String message) { this(graphs, params); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** @@ -963,7 +963,7 @@ private Set pagYStructures(Graph graph, Node z, int i) { } private void log() { - TetradLogger.getInstance().forceLogMessage("General Graph"); + TetradLogger.getInstance().log("General Graph"); } private Set getEdgesFromPath(List path, Graph graph) { @@ -986,8 +986,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -997,8 +997,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java index 6ee93650f7..1e7b616e4d 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java @@ -136,7 +136,7 @@ public GraphWrapper(Graph graph) { * @param message a {@link java.lang.String} object */ public GraphWrapper(Graph graph, String message) { - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); if (graph == null) { throw new NullPointerException("Graph must not be null."); @@ -430,8 +430,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -441,8 +441,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java index 6996cefa89..6dd0623eb3 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java @@ -778,7 +778,7 @@ private List getStatisticsNamesFromImplementations(List(); - TetradLogger.getInstance().forceLogMessage("Linear Regression"); + TetradLogger.getInstance().log("Linear Regression"); if (result == null) { - TetradLogger.getInstance().forceLogMessage("Please double click this regression node to run the regession."); + TetradLogger.getInstance().log("Please double click this regression node to run the regession."); } else { - TetradLogger.getInstance().forceLogMessage(report); + TetradLogger.getInstance().log(report); } } @@ -412,8 +412,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -423,8 +423,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MagInPagWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MagInPagWrapper.java index 52d508392b..d436364784 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MagInPagWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MagInPagWrapper.java @@ -56,7 +56,7 @@ public MagInPagWrapper(GraphSource source, Parameters parameters) { public MagInPagWrapper(Graph graph) { super(MagInPagWrapper.getGraph(graph), "Choose Zhang MAG in PAG."); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } private static Graph getGraph(Graph graph) { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java index 4324571c02..063a12398e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java @@ -181,8 +181,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -192,8 +192,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildRunner.java index ec7db70411..0a72448578 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildRunner.java @@ -170,7 +170,7 @@ public void execute() throws Exception { ICovarianceMatrix latentsCov = mimbuild.getLatentsCov(); - TetradLogger.getInstance().forceLogMessage("Latent covs = \n" + latentsCov); + TetradLogger.getInstance().log("Latent covs = \n" + latentsCov); Graph fullGraph = mimbuild.getFullGraph(); LayoutUtil.defaultLayout(fullGraph); @@ -190,9 +190,9 @@ public void execute() throws Exception { double p = mimbuild.getpValue(); - TetradLogger.getInstance().forceLogMessage("\nStructure graph = " + structureGraph); - TetradLogger.getInstance().forceLogMessage(getLatentClustersString(fullGraph).toString()); - TetradLogger.getInstance().forceLogMessage("P = " + p); + TetradLogger.getInstance().log("\nStructure graph = " + structureGraph); + TetradLogger.getInstance().log(getLatentClustersString(fullGraph).toString()); + TetradLogger.getInstance().log("P = " + p); if (getParams().getBoolean("showMaxP", false)) { if (p > getParams().getDouble("maxP", 1.0)) { @@ -211,10 +211,10 @@ public void execute() throws Exception { setResultGraph((Graph) getParams().get("maxFullGraph", null)); String message1 = "\nMAX Graph = " + getParams().get("maxStructureGraph", null); - TetradLogger.getInstance().forceLogMessage(message1); - TetradLogger.getInstance().forceLogMessage(getLatentClustersString((Graph) getParams().get("maxFullGraph", null)).toString()); + TetradLogger.getInstance().log(message1); + TetradLogger.getInstance().log(getLatentClustersString((Graph) getParams().get("maxFullGraph", null)).toString()); String message = "MAX P = " + getParams().getDouble("maxP", 1.0); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildTrekRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildTrekRunner.java index ba78db39ec..2ea14906a6 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildTrekRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MimBuildTrekRunner.java @@ -215,7 +215,7 @@ public void execute() throws Exception { ICovarianceMatrix latentsCov = mimbuild.getLatentsCov(); - TetradLogger.getInstance().forceLogMessage("Latent covs = \n" + latentsCov); + TetradLogger.getInstance().log("Latent covs = \n" + latentsCov); Graph fullGraph = mimbuild.getFullGraph(); LayoutUtil.defaultLayout(fullGraph); @@ -235,9 +235,9 @@ public void execute() throws Exception { double p = mimbuild.getpValue(); - TetradLogger.getInstance().forceLogMessage("\nStructure graph = " + structureGraph); - TetradLogger.getInstance().forceLogMessage(getLatentClustersString(fullGraph).toString()); - TetradLogger.getInstance().forceLogMessage("P = " + p); + TetradLogger.getInstance().log("\nStructure graph = " + structureGraph); + TetradLogger.getInstance().log(getLatentClustersString(fullGraph).toString()); + TetradLogger.getInstance().log("P = " + p); if (getParams().getBoolean("showMaxP", false)) { if (p > getParams().getDouble("maxP", 1.0)) { @@ -256,10 +256,10 @@ public void execute() throws Exception { setResultGraph((Graph) getParams().get("maxFullGraph", null)); String message1 = "\nMAX Graph = " + getParams().get("maxStructureGraph", null); - TetradLogger.getInstance().forceLogMessage(message1); - TetradLogger.getInstance().forceLogMessage(getLatentClustersString((Graph) getParams().get("maxFullGraph", null)).toString()); + TetradLogger.getInstance().log(message1); + TetradLogger.getInstance().log(getLatentClustersString((Graph) getParams().get("maxFullGraph", null)).toString()); String message = "MAX P = " + getParams().getDouble("maxP", 1.0); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java index 4d32864149..9f6668195d 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java @@ -108,7 +108,7 @@ public Misclassifications(GraphSource model1, GraphSource model2, Parameters par this.targetGraph = model2.getGraph(); } - TetradLogger.getInstance().forceLogMessage("Graph Comparison"); + TetradLogger.getInstance().log("Graph Comparison"); } @@ -186,8 +186,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -197,8 +197,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java index 3ae8ca801d..01a2218849 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java @@ -103,8 +103,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -114,8 +114,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java index a9595e9fa5..bb94da8959 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java @@ -535,8 +535,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -546,8 +546,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PagFromDagGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PagFromDagGraphWrapper.java index b9c2776c79..ba82edc3a4 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PagFromDagGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PagFromDagGraphWrapper.java @@ -64,8 +64,8 @@ public PagFromDagGraphWrapper(Graph graph) { Graph pag = GraphTransforms.dagToPag(graph); setGraph(pag); - TetradLogger.getInstance().forceLogMessage("\nGenerating allow_latent_common_causes from DAG."); - TetradLogger.getInstance().forceLogMessage(pag + ""); + TetradLogger.getInstance().log("\nGenerating allow_latent_common_causes from DAG."); + TetradLogger.getInstance().log(pag + ""); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java index dd16cd1b63..1df8a5b776 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java @@ -151,13 +151,13 @@ public RegressionRunner(DataWrapper dataWrapper, Parameters params) { this.targetName = null; this.regressorNames = new ArrayList<>(); - TetradLogger.getInstance().forceLogMessage("Linear Regression"); + TetradLogger.getInstance().log("Linear Regression"); if (this.result == null) { - TetradLogger.getInstance().forceLogMessage("Please double click this regression node to run the regession."); + TetradLogger.getInstance().log("Please double click this regression node to run the regession."); } else { String message = "\n" + this.result.getResultsTable().toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -399,8 +399,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -410,8 +410,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNonSkeletonEdgesModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNonSkeletonEdgesModel.java index 2ce63687c8..842b48ebb9 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNonSkeletonEdgesModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNonSkeletonEdgesModel.java @@ -249,7 +249,7 @@ public RemoveNonSkeletonEdgesModel(Parameters params, KnowledgeBoxInput input) { createKnowledge(params); - TetradLogger.getInstance().forceLogMessage("Knowledge"); + TetradLogger.getInstance().log("Knowledge"); // This is a conundrum. At this point I dont know whether I am in a // simulation or not. If in a simulation, I should print the knowledge. @@ -257,7 +257,7 @@ public RemoveNonSkeletonEdgesModel(Parameters params, KnowledgeBoxInput input) { // printing the knowledge if it's not empty. if (!((Knowledge) params.get("knowledge", new Knowledge())).isEmpty()) { String message = params.get("knowledge", new Knowledge()).toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNullEdgesGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNullEdgesGraphWrapper.java index 5cc338d05c..7504c8cafd 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNullEdgesGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RemoveNullEdgesGraphWrapper.java @@ -60,7 +60,7 @@ public RemoveNullEdgesGraphWrapper(GraphSource source, Parameters parameters) { public RemoveNullEdgesGraphWrapper(Graph graph) { super(GraphSampling.createGraphWithoutNullEdges(graph), "Remove Null Edges from Boostrapping"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java index 25be3c82cf..c0fc8fa47c 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java @@ -84,8 +84,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -95,8 +95,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RequiredGraphModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RequiredGraphModel.java index dbae7a5302..b4b4c01663 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RequiredGraphModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RequiredGraphModel.java @@ -235,7 +235,7 @@ public RequiredGraphModel(Parameters params, KnowledgeBoxInput input) { createKnowledge(); - TetradLogger.getInstance().forceLogMessage("Knowledge"); + TetradLogger.getInstance().log("Knowledge"); // This is a conundrum. At this point I dont know whether I am in a // simulation or not. If in a simulation, I should print the knowledge. @@ -243,7 +243,7 @@ public RequiredGraphModel(Parameters params, KnowledgeBoxInput input) { // printing the knowledge if it's not empty. if (!((Knowledge) params.get("knowledge", new Knowledge())).isEmpty()) { String message = params.get("knowledge", new Knowledge()).toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java index 5b9cbf53be..258d160986 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java @@ -187,15 +187,15 @@ private void setup(BayesIm bayesIm, Parameters params) { if (node != null) { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); - TetradLogger.getInstance().forceLogMessage("\nRow Summing Exact Updater"); + TetradLogger.getInstance().log("\nRow Summing Exact Updater"); String nodeName = node.getName(); int nodeIndex = bayesIm.getNodeIndex(bayesIm.getNode(nodeName)); double[] priors = getBayesUpdater().calculatePriorMarginals(nodeIndex); double[] marginals = getBayesUpdater().calculateUpdatedMarginals(nodeIndex); - TetradLogger.getInstance().forceLogMessage("\nVariable = " + nodeName); - TetradLogger.getInstance().forceLogMessage("\nEvidence:"); + TetradLogger.getInstance().log("\nVariable = " + nodeName); + TetradLogger.getInstance().log("\nEvidence:"); Evidence evidence = (Evidence) getParams().get("evidence", null); Proposition proposition = evidence.getProposition(); @@ -204,16 +204,16 @@ private void setup(BayesIm bayesIm, Parameters params) { int category = proposition.getSingleCategory(i); if (category != -1) { - TetradLogger.getInstance().forceLogMessage("\t" + variable + " = " + category); + TetradLogger.getInstance().log("\t" + variable + " = " + category); } } - TetradLogger.getInstance().forceLogMessage("\nCat.\tPrior\tMarginal"); + TetradLogger.getInstance().log("\nCat.\tPrior\tMarginal"); for (int i = 0; i < priors.length; i++) { String message = category(evidence, nodeName, i) + "\t" + nf.format(priors[i]) + "\t" + nf.format(marginals[i]); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } TetradLogger.getInstance().reset(); @@ -233,8 +233,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -244,8 +244,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java index 7bcd938d50..1220eadf02 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java @@ -196,18 +196,18 @@ public void setName(String name) { //==========================PRIVATE METHODS===========================// private void log() { - TetradLogger.getInstance().forceLogMessage("DAGs in forbid_latent_common_causes"); - TetradLogger.getInstance().forceLogMessage("\nSelected Graph\n"); + TetradLogger.getInstance().log("DAGs in forbid_latent_common_causes"); + TetradLogger.getInstance().log("\nSelected Graph\n"); String message1 = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); - TetradLogger.getInstance().forceLogMessage("\nAll Graphs:\n"); + TetradLogger.getInstance().log("\nAll Graphs:\n"); int index = 0; for (Graph graph : this.graphsToScores.keySet()) { String message = "\nGraph #" + (++index); - TetradLogger.getInstance().forceLogMessage(message); - TetradLogger.getInstance().forceLogMessage(graph + ""); + TetradLogger.getInstance().log(message); + TetradLogger.getInstance().log(graph + ""); } } @@ -217,8 +217,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -228,8 +228,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java index 2150d14181..1e41b6a6f5 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java @@ -248,15 +248,15 @@ public void setName(String name) { //=============================== Private methods =======================// private void log() { - TetradLogger.getInstance().forceLogMessage("SEM Estimator:"); + TetradLogger.getInstance().log("SEM Estimator:"); String message3 = "" + getEstimatedSemIm(); - TetradLogger.getInstance().forceLogMessage(message3); + TetradLogger.getInstance().log(message3); String message2 = "ChiSq = " + getEstimatedSemIm().getChiSquare(); - TetradLogger.getInstance().forceLogMessage(message2); + TetradLogger.getInstance().log(message2); String message1 = "DOF = " + getEstimatedSemIm().getSemPm().getDof(); - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); String message = "P = " + getEstimatedSemIm().getPValue(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } @Serial @@ -264,8 +264,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -275,8 +275,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java index 31f12bb8ea..8bc9300910 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java @@ -372,9 +372,9 @@ public void setSemGraph(SemGraph graph) { // ============================PRIVATE METHODS========================// private void log() { - TetradLogger.getInstance().forceLogMessage("Structural Equation Model (SEM) Graph"); + TetradLogger.getInstance().log("Structural Equation Model (SEM) Graph"); String message = "" + getGraph(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } @Serial @@ -382,8 +382,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -393,8 +393,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java index 0869190657..2f1b4a1789 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java @@ -242,10 +242,10 @@ public void setName(String name) { //======================== Private methods =======================// private void log(int i, SemIm pm) { - TetradLogger.getInstance().forceLogMessage("Linear SEM IM"); - TetradLogger.getInstance().forceLogMessage("IM # " + (i + 1)); + TetradLogger.getInstance().log("Linear SEM IM"); + TetradLogger.getInstance().log("IM # " + (i + 1)); String message = pm.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } @Serial @@ -253,8 +253,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -264,8 +264,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java index 59569ba04e..524164db08 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java @@ -290,8 +290,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -301,8 +301,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -334,10 +334,10 @@ public void setName(String name) { //======================= Private methods ====================// private void log(int i, SemPm pm) { - TetradLogger.getInstance().forceLogMessage("Linear Structural Equation Parametric Model (SEM PM)"); - TetradLogger.getInstance().forceLogMessage("PM # " + (i + 1)); + TetradLogger.getInstance().log("Linear Structural Equation Parametric Model (SEM PM)"); + TetradLogger.getInstance().log("PM # " + (i + 1)); String message = pm.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java index 82eb710716..ef1da8581a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java @@ -105,8 +105,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -116,8 +116,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java index ced6f2bb8a..979e124a29 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java @@ -200,8 +200,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -211,8 +211,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java index b299a91a11..31bbbe9e3b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java @@ -742,8 +742,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -753,8 +753,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java index d242f327f7..188dab4b67 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java @@ -161,8 +161,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -172,8 +172,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -215,8 +215,8 @@ public List getVariables() { } private void log(StandardizedSemIm pm) { - TetradLogger.getInstance().forceLogMessage("Standardized SEM IM"); + TetradLogger.getInstance().log("Standardized SEM IM"); String message = pm.toString(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java index 5c89466a7e..0a3273c1b5 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java @@ -227,8 +227,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -238,8 +238,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -270,8 +270,8 @@ public void setName(String name) { } private void log() { - TetradLogger.getInstance().forceLogMessage("EM-Estimated Bayes IM"); - TetradLogger.getInstance().forceLogMessage("" + this.estimatedBayesIm); + TetradLogger.getInstance().log("EM-Estimated Bayes IM"); + TetradLogger.getInstance().log("" + this.estimatedBayesIm); } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java index a64f78b3d5..90fc5a7fef 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java @@ -165,7 +165,7 @@ public TabularComparison(GraphSource model1, GraphSource model2, newExecution(); - TetradLogger.getInstance().forceLogMessage("Graph Comparison"); + TetradLogger.getInstance().log("Graph Comparison"); } private void newExecution() { @@ -232,8 +232,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -243,8 +243,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java index b05b5c9e26..28f8adfc78 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java @@ -112,8 +112,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -123,8 +123,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java index bd15052053..4d3668ab8c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java @@ -182,8 +182,8 @@ public static TimeLagGraphWrapper serializableInstance() { private void log() { - TetradLogger.getInstance().forceLogMessage("Directed Acyclic Graph (DAG)"); - TetradLogger.getInstance().forceLogMessage(this.graph + ""); + TetradLogger.getInstance().log("Directed Acyclic Graph (DAG)"); + TetradLogger.getInstance().log(this.graph + ""); } @Serial @@ -191,8 +191,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -202,8 +202,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TsPagFromDagGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TsPagFromDagGraphWrapper.java index c7441ffdf6..72ad6a62b9 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TsPagFromDagGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TsPagFromDagGraphWrapper.java @@ -70,8 +70,8 @@ public TsPagFromDagGraphWrapper(Graph graph) { Graph pag = p.convert(); setGraph(pag); - TetradLogger.getInstance().forceLogMessage("\nGenerating allow_latent_common_causes from DAG."); - TetradLogger.getInstance().forceLogMessage(pag + ""); + TetradLogger.getInstance().log("\nGenerating allow_latent_common_causes from DAG."); + TetradLogger.getInstance().log(pag + ""); } /** diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/UndirectedToBidirectedWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/UndirectedToBidirectedWrapper.java index e3f065028a..d79e6d139c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/UndirectedToBidirectedWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/UndirectedToBidirectedWrapper.java @@ -57,7 +57,7 @@ public UndirectedToBidirectedWrapper(GraphSource source, Parameters parameters) public UndirectedToBidirectedWrapper(Graph graph) { super(GraphUtils.undirectedToBidirected(graph), "Make Bidirected Edges Undirected"); String message = getGraph() + ""; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java index af92c1a7ad..8f3c908afb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java @@ -70,8 +70,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -81,8 +81,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java index 18b3a25247..bb63c74793 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java @@ -101,8 +101,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -112,8 +112,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SessionNode.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SessionNode.java index 3bfbd176b0..5121ac0f54 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SessionNode.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SessionNode.java @@ -576,7 +576,7 @@ public void createModel(Class modelClass, boolean simulation) TetradLogger.getInstance().setTetradLoggerConfig(this.loggerConfig); String message1 = "\n========LOGGING " + getDisplayName() + "\n"; - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); // Collect up the parentModels from the parents. If any model is // null, throw an exception. @@ -614,7 +614,7 @@ public void createModel(Class modelClass, boolean simulation) if (this.model == null) { String message = getDisplayName() + " was not created."; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); throw new CouldNotCreateModelException(modelClass); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SimulationStudy.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SimulationStudy.java index 720d272487..a894c506d8 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SimulationStudy.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/session/SimulationStudy.java @@ -172,12 +172,12 @@ public void execute(SessionNode sessionNode, boolean overwrite) { final boolean doRepetition = true; final boolean simulation = true; - TetradLogger.getInstance().forceLogMessage("\n\n===STARTING SIMULATION STUDY==="); + TetradLogger.getInstance().log("\n\n===STARTING SIMULATION STUDY==="); long time1 = MillisecondTimes.timeMillis(); execute(tierOrdering, doRepetition, simulation, overwrite); - TetradLogger.getInstance().forceLogMessage("\n\n===FINISHING SIMULATION STUDY==="); + TetradLogger.getInstance().log("\n\n===FINISHING SIMULATION STUDY==="); long time2 = MillisecondTimes.timeMillis(); System.out.println("Elapsed time = " + (time2 - time1) / 1000. + " s"); @@ -298,8 +298,8 @@ private boolean execute(LinkedList tierOrdering, boolean doRepetiti try { if (repetition > 1) { - TetradLogger.getInstance().forceLogMessage("\nREPETITION #" + (i + 1) + " FOR " - + sessionNode.getDisplayName() + "\n"); + TetradLogger.getInstance().log("\nREPETITION #" + (i + 1) + " FOR " + + sessionNode.getDisplayName() + "\n"); } boolean created = sessionNode.createModel(simulation); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/ui/tool/SessionFileTransferHandler.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/ui/tool/SessionFileTransferHandler.java index 1eae08dd3f..7ccf5a8f79 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/ui/tool/SessionFileTransferHandler.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/ui/tool/SessionFileTransferHandler.java @@ -148,15 +148,15 @@ public boolean importData(TransferSupport support) { DesktopController.getInstance().closeEmptySessions(); DesktopController.getInstance().putMetadata(sessionWrapper, metadata); } catch (FileNotFoundException exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "That wasn't a TETRAD session file: " + file); } catch (Exception exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "An error occurred attempting to load the session."); } } } catch (UnsupportedFlavorException | IOException exception) { - TetradLogger.getInstance().forceLogMessage(exception.toString()); + TetradLogger.getInstance().log(exception.toString()); // SessionFileTransferHandler.LOGGER.error("", exception); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/WatchedProcess.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/WatchedProcess.java index d9f67e0c3c..cf95a8e8f4 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/WatchedProcess.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/WatchedProcess.java @@ -80,10 +80,10 @@ private synchronized void startLongRunningThread() { try { watch(); } catch (InterruptedException e) { - TetradLogger.getInstance().forceLogMessage("Thread was interrupted while watching. Stopping; see console for stack trace."); + TetradLogger.getInstance().log("Thread was interrupted while watching. Stopping; see console for stack trace."); e.printStackTrace(); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("Exception while watching; see console for stack trace."); + TetradLogger.getInstance().log("Exception while watching; see console for stack trace."); e.printStackTrace(); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java index 1f362722bd..7325f95a10 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java @@ -2990,8 +2990,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -3001,8 +3001,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java index 809fe00029..3c708cef35 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java @@ -160,8 +160,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -171,8 +171,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java index 1ca46d0ce5..befd2d0d0b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java @@ -172,8 +172,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -183,8 +183,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java index 109c395fad..aa345ab50f 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java @@ -171,8 +171,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -182,8 +182,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java index 19ec69f8df..c0a80f4c5a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java @@ -214,8 +214,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -225,8 +225,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java index f6c6f7e478..844f53992a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java @@ -171,8 +171,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -182,8 +182,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java index b7ed54d4d4..73915dc677 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java @@ -731,7 +731,7 @@ public void saveToFiles(String dataPath, Simulation simulation, Parameters param out.close(); } } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("IO Exception: " + e.getMessage()); + TetradLogger.getInstance().log("IO Exception: " + e.getMessage()); } } @@ -825,7 +825,7 @@ public void saveToFilesSingleSimulation(String dataPath, Simulation simulation, } } } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("IO Exception: " + e.getMessage()); + TetradLogger.getInstance().log("IO Exception: " + e.getMessage()); } } @@ -838,7 +838,7 @@ public void saveToFilesSingleSimulation(String dataPath, Simulation simulation, public void configuration(String path) { try { if (!new File(path).mkdirs()) - TetradLogger.getInstance().forceLogMessage("Path already exists: " + new File(path)); + TetradLogger.getInstance().log("Path already exists: " + new File(path)); PrintStream out = new PrintStream(Files.newOutputStream(new File(path, "Configuration.txt").toPath())); @@ -1010,7 +1010,7 @@ public void configuration(String path) { out.close(); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("Exception: " + e.getMessage()); + TetradLogger.getInstance().log("Exception: " + e.getMessage()); } } @@ -1314,11 +1314,11 @@ private void deleteFilesThenDirectory(File dir) { deleteFilesThenDirectory(currentFile); } else { if (!currentFile.delete()) - TetradLogger.getInstance().forceLogMessage("File could not be deleted: " + currentFile); + TetradLogger.getInstance().log("File could not be deleted: " + currentFile); } } - if (!dir.delete()) TetradLogger.getInstance().forceLogMessage("Directory could not be deleted: " + dir); + if (!dir.delete()) TetradLogger.getInstance().log("Directory could not be deleted: " + dir); } private void doRun(List algorithmSimulationWrappers, List simulationWrappers, Statistics statistics, @@ -1387,8 +1387,8 @@ private void doRun(List algorithmSimulationWrappers, } } catch (Exception e) { e.printStackTrace(); - TetradLogger.getInstance().forceLogMessage("\nCould not run " + algorithmWrapper.getDescription() - + " on " + simulationWrapper.getDescription() + " because of " + e.getMessage()); + TetradLogger.getInstance().log("\nCould not run " + algorithmWrapper.getDescription() + + " on " + simulationWrapper.getDescription() + " because of " + e.getMessage()); return; } @@ -1552,7 +1552,7 @@ private void saveGraph(String resultsPath, Graph graph, int i, int simIndex, Alg outElapsed.println(elapsed); outElapsed.close(); } catch (FileNotFoundException e) { - TetradLogger.getInstance().forceLogMessage("File not found exception: " + e.getMessage()); + TetradLogger.getInstance().log("File not found exception: " + e.getMessage()); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java index 2655933f48..3e8ddb7511 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java @@ -56,8 +56,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -67,8 +67,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Bpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Bpc.java index 95f35b31dd..ca5080b8b3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Bpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Bpc.java @@ -109,7 +109,7 @@ public Graph search(DataModel dataModel, Parameters parameters) { ICovarianceMatrix latentsCov = mimbuild.getLatentsCov(); - TetradLogger.getInstance().forceLogMessage("Latent covs = \n" + latentsCov); + TetradLogger.getInstance().log("Latent covs = \n" + latentsCov); Graph fullGraph = mimbuild.getFullGraph(); LayoutUtil.defaultLayout(fullGraph); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Fofc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Fofc.java index 928cb77bd3..15b1053e38 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Fofc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Fofc.java @@ -132,7 +132,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { ICovarianceMatrix latentsCov = mimbuild.getLatentsCov(); - TetradLogger.getInstance().forceLogMessage("Latent covs = \n" + latentsCov); + TetradLogger.getInstance().log("Latent covs = \n" + latentsCov); Graph fullGraph = mimbuild.getFullGraph(); LayoutUtil.defaultLayout(fullGraph); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/Dagma.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/Dagma.java index 39dda4da0a..5c9bed6cf8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/Dagma.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/Dagma.java @@ -68,7 +68,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setWThreshold(parameters.getDouble(Params.W_THRESHOLD)); search.setCpdag(parameters.getBoolean(Params.CPDAG)); Graph graph = search.search(); - TetradLogger.getInstance().forceLogMessage(graph.toString()); + TetradLogger.getInstance().log(graph.toString()); LogUtilsSearch.stampWithBic(graph, dataModel); return graph; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/DirectLingam.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/DirectLingam.java index 9920aaa1d4..5bcfc88d66 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/DirectLingam.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/DirectLingam.java @@ -80,7 +80,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { edu.cmu.tetrad.search.DirectLingam search = new edu.cmu.tetrad.search.DirectLingam(data, score); Graph graph = search.search(); - TetradLogger.getInstance().forceLogMessage(graph.toString()); + TetradLogger.getInstance().log(graph.toString()); LogUtilsSearch.stampWithBic(graph, dataModel); return graph; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingD.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingD.java index 6a9ed979b4..f9e3942bd0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingD.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingD.java @@ -141,22 +141,22 @@ public Graph runSearch(DataModel dataSet, Parameters parameters) { if (parameters.getBoolean(Params.VERBOSE)) { for (Graph graph : unstableGraphs) { - TetradLogger.getInstance().forceLogMessage("LiNG-D Model #" + (++count) + " Stable = False"); - TetradLogger.getInstance().forceLogMessage(_bHats.get(graph).toString()); - TetradLogger.getInstance().forceLogMessage(graph.toString()); + TetradLogger.getInstance().log("LiNG-D Model #" + (++count) + " Stable = False"); + TetradLogger.getInstance().log(_bHats.get(graph).toString()); + TetradLogger.getInstance().log(graph.toString()); } } else if (!unstableGraphs.isEmpty()) { - TetradLogger.getInstance().forceLogMessage("To see unstable models and and their B matrices, set the verbose flag to true"); + TetradLogger.getInstance().log("To see unstable models and and their B matrices, set the verbose flag to true"); } for (Graph graph : stableGraphs) { - TetradLogger.getInstance().forceLogMessage("LiNG-D Model #" + (++count) + " Stable = True"); - TetradLogger.getInstance().forceLogMessage(_bHats.get(graph).toString()); - TetradLogger.getInstance().forceLogMessage(graph.toString()); + TetradLogger.getInstance().log("LiNG-D Model #" + (++count) + " Stable = True"); + TetradLogger.getInstance().log(_bHats.get(graph).toString()); + TetradLogger.getInstance().log(graph.toString()); } if (stableGraphs.isEmpty()) { - TetradLogger.getInstance().forceLogMessage("## There were no stable models. ##"); + TetradLogger.getInstance().log("## There were no stable models. ##"); } return stableGraphs.isEmpty() ? new EdgeListGraph() : stableGraphs.get(0); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingam.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingam.java index 37c7d1669e..f04f478eb6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingam.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/continuous/dag/IcaLingam.java @@ -82,8 +82,8 @@ public Graph runSearch(DataModel dataSet, Parameters parameters) { Graph graph = IcaLingD.makeGraph(bHat, data.getVariables()); if (parameters.getBoolean(Params.VERBOSE)) { - TetradLogger.getInstance().forceLogMessage("BHat = " + bHat); - TetradLogger.getInstance().forceLogMessage("Graph = " + graph); + TetradLogger.getInstance().log("BHat = " + bHat); + TetradLogger.getInstance().log("Graph = " + graph); } LogUtilsSearch.stampWithBic(graph, dataSet); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Cstar.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Cstar.java index ab580a952f..b8d4bc162d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Cstar.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Cstar.java @@ -158,9 +158,9 @@ public Graph search(DataModel dataSet, Parameters parameters) { records = allRecords.getLast(); - TetradLogger.getInstance().forceLogMessage("CStaR Table"); + TetradLogger.getInstance().log("CStaR Table"); String table1 = cStaR.makeTable(edu.cmu.tetrad.search.Cstar.cStar(allRecords)); - TetradLogger.getInstance().forceLogMessage(table1); + TetradLogger.getInstance().log(table1); // Print table1 to file. File _file = new File(cStaR.getDir(), "/cstar_table.txt"); @@ -172,7 +172,7 @@ public Graph search(DataModel dataSet, Parameters parameters) { System.out.println("Error writing to file: " + _file.getAbsolutePath()); } - TetradLogger.getInstance().forceLogMessage("Files stored in : " + cStaR.getDir().getAbsolutePath()); + TetradLogger.getInstance().log("Files stored in : " + cStaR.getDir().getAbsolutePath()); // This stops the program from running in R. // JOptionPane.showMessageDialog(null, "Files stored in : " + cStaR.getDir().getAbsolutePath()); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/other/FactorAnalysis.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/other/FactorAnalysis.java index 0a5afa27dd..a4d5cdc486 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/other/FactorAnalysis.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/other/FactorAnalysis.java @@ -112,7 +112,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { } System.out.println(output); - TetradLogger.getInstance().forceLogMessage(output); + TetradLogger.getInstance().log(output); } return graph; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/GeneralSemSimulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/GeneralSemSimulation.java index 6e2a5e6a9f..6bc9b81b44 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/GeneralSemSimulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/GeneralSemSimulation.java @@ -344,7 +344,7 @@ private GeneralizedSemPm getPm(Graph graph, Parameters parameters) { pm.setParametersTemplate(parameters.getString(Params.GENERAL_SEM_PARAMETER_TEMPLATE)); } catch (ParseException e) { - TetradLogger.getInstance().forceLogMessage("Exception: " + e.getMessage()); + TetradLogger.getInstance().log("Exception: " + e.getMessage()); } return pm; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java index ab17fb9c11..5a2794e05d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java @@ -54,8 +54,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -65,8 +65,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Maximal.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Maximal.java index 8979282083..47a5344bb2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Maximal.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Maximal.java @@ -56,9 +56,9 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) { List inducingPath = estGraph.paths().getInducingPath(n1, n2); if (inducingPath != null) { - TetradLogger.getInstance().forceLogMessage("Maximality check: Found an inducing path for " - + n1 + "..." + n2 + ": " - + GraphUtils.pathString(estGraph, inducingPath, false)); + TetradLogger.getInstance().log("Maximality check: Found an inducing path for " + + n1 + "..." + n2 + ": " + + GraphUtils.pathString(estGraph, inducingPath, false)); maximal = false; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java index 980d525f61..5b32a76dca 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java @@ -105,8 +105,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -116,8 +116,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java index 4b92bf0e02..2d19b7d17d 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java @@ -377,8 +377,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -388,8 +388,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java index 69390727a3..2ce649fa99 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java @@ -290,8 +290,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -301,8 +301,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java index 998901cf3a..b21b35cdae 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java @@ -581,8 +581,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -592,8 +592,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java index b3799da844..f4df08d42b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java @@ -220,8 +220,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -231,8 +231,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java index c86bc176f0..e558efd37b 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java @@ -298,8 +298,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -309,8 +309,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java index b51596d2cf..6b441d612a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java @@ -1178,8 +1178,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1189,8 +1189,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java index ed69d59b48..dccc670de7 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java @@ -345,8 +345,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -356,8 +356,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/FactoredBayesStructuralEM.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/FactoredBayesStructuralEM.java index 9d80fed924..6e28537f6d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/FactoredBayesStructuralEM.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/FactoredBayesStructuralEM.java @@ -119,7 +119,7 @@ private static double factorScoreMD(Dag dag, BdeMetricCache bdeMetricCache, bayesPm, bayesIm); String message = "Score for factor " + node1.getName() + " = " + fScore; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); score += fScore; } @@ -133,7 +133,7 @@ private static double factorScoreMD(Dag dag, BdeMetricCache bdeMetricCache, * @return a {@link edu.cmu.tetrad.bayes.BayesIm} object */ public BayesIm maximization(double tolerance) { - TetradLogger.getInstance().forceLogMessage("FactoredBayesStructuralEM.maximization()"); + TetradLogger.getInstance().log("FactoredBayesStructuralEM.maximization()"); this.tolerance = tolerance; return iterate(); } @@ -186,7 +186,7 @@ public BayesIm iterate() { *

    scoreTest.

    */ public void scoreTest() { - TetradLogger.getInstance().forceLogMessage("scoreTest"); + TetradLogger.getInstance().log("scoreTest"); //System.out.println(bayesPmM0.getGraph()); BdeMetricCache bdeMetricCache; @@ -208,14 +208,14 @@ public void scoreTest() { BayesPm bayesPmTest0 = new BayesPm(dag0); - TetradLogger.getInstance().forceLogMessage("Observed conts for nodes of L1,X1,X2,X3 (no edges) " + - "using the MAP parameters based on that same graph"); + TetradLogger.getInstance().log("Observed conts for nodes of L1,X1,X2,X3 (no edges) " + + "using the MAP parameters based on that same graph"); - TetradLogger.getInstance().forceLogMessage("Graph of PM: "); - TetradLogger.getInstance().forceLogMessage("" + bayesPmTest0.getDag()); + TetradLogger.getInstance().log("Graph of PM: "); + TetradLogger.getInstance().log("" + bayesPmTest0.getDag()); - TetradLogger.getInstance().forceLogMessage("Graph of IM: "); - TetradLogger.getInstance().forceLogMessage("" + bayesImMn0.getBayesPm().getDag()); + TetradLogger.getInstance().log("Graph of IM: "); + TetradLogger.getInstance().log("" + bayesImMn0.getBayesPm().getDag()); bdeMetricCache = new BdeMetricCache(this.dataSet, bayesPmTest0); @@ -228,30 +228,30 @@ public void scoreTest() { for (int j = 0; j < counts0[0].length; j++) { System.out.print(" " + aCounts0[j]); } - TetradLogger.getInstance().forceLogMessage("\n"); + TetradLogger.getInstance().log("\n"); } - TetradLogger.getInstance().forceLogMessage("\n"); + TetradLogger.getInstance().log("\n"); } double score0 = FactoredBayesStructuralEM.factorScoreMD(dag0, bdeMetricCache, bayesPmTest0, bayesImMn0); - TetradLogger.getInstance().forceLogMessage("Score of L1,X1,X2,X3 (no edges) for itself = " + score0); + TetradLogger.getInstance().log("Score of L1,X1,X2,X3 (no edges) for itself = " + score0); - TetradLogger.getInstance().forceLogMessage("===============\n\n"); + TetradLogger.getInstance().log("===============\n\n"); - TetradLogger.getInstance().forceLogMessage("Score of X1-->L1 for L1,X1,X2,X3 (no edges) = " + score0); + TetradLogger.getInstance().log("Score of X1-->L1 for L1,X1,X2,X3 (no edges) = " + score0); BayesPm bayesPmTest1 = new BayesPm(dag1); - TetradLogger.getInstance().forceLogMessage("Observed counts for nodes of X1-->L1 for L1,X1,X2,X3 (no edges)"); + TetradLogger.getInstance().log("Observed counts for nodes of X1-->L1 for L1,X1,X2,X3 (no edges)"); - TetradLogger.getInstance().forceLogMessage("Graph of PM : "); - TetradLogger.getInstance().forceLogMessage("" + bayesPmTest1.getDag()); + TetradLogger.getInstance().log("Graph of PM : "); + TetradLogger.getInstance().log("" + bayesPmTest1.getDag()); - TetradLogger.getInstance().forceLogMessage("Graph of IM: "); - TetradLogger.getInstance().forceLogMessage("" + bayesImMn0.getBayesPm().getDag()); + TetradLogger.getInstance().log("Graph of IM: "); + TetradLogger.getInstance().log("" + bayesImMn0.getBayesPm().getDag()); bdeMetricCache = new BdeMetricCache(this.dataSet, bayesPmTest1); @@ -263,17 +263,17 @@ public void scoreTest() { bayesPmTest1, bayesImMn0); for (double[] aCounts1 : counts1) { for (int j = 0; j < counts1[0].length; j++) { - TetradLogger.getInstance().forceLogMessage(" " + aCounts1[j]); + TetradLogger.getInstance().log(" " + aCounts1[j]); } - TetradLogger.getInstance().forceLogMessage("\n"); + TetradLogger.getInstance().log("\n"); } - TetradLogger.getInstance().forceLogMessage("\n"); + TetradLogger.getInstance().log("\n"); } double score1 = FactoredBayesStructuralEM.factorScoreMD(dag1, bdeMetricCache, bayesPmTest1, bayesImMn0); - TetradLogger.getInstance().forceLogMessage("Score of X1-->L1 for L1,X1,X2,X3 (no edges) = " + score1); + TetradLogger.getInstance().log("Score of X1-->L1 for L1,X1,X2,X3 (no edges) = " + score1); } @@ -311,15 +311,15 @@ public void run() { this.iteration++; this.bayesPmMn = this.bayesPmMnplus1; - TetradLogger.getInstance().forceLogMessage("In Factored Bayes Struct EM Iteration number " + - this.iteration); + TetradLogger.getInstance().log("In Factored Bayes Struct EM Iteration number " + + this.iteration); //Compute the MAP parameters for Mn given o. - TetradLogger.getInstance().forceLogMessage("Starting EM Bayes estimator to get MAP parameters of Mn"); + TetradLogger.getInstance().log("Starting EM Bayes estimator to get MAP parameters of Mn"); EmBayesEstimator emBayesEst = new EmBayesEstimator(this.bayesPmMn, FactoredBayesStructuralEM.this.dataSet); BayesIm bayesImMn = emBayesEst.maximization(FactoredBayesStructuralEM.this.tolerance); - TetradLogger.getInstance().forceLogMessage("Estimation of MAP parameters of Mn complete. \n\n"); + TetradLogger.getInstance().log("Estimation of MAP parameters of Mn complete. \n\n"); //Perform search over models... Graph graphMn = this.bayesPmMn.getDag(); @@ -331,10 +331,10 @@ public void run() { EdgeListGraph edges = new EdgeListGraph(dagMn); - TetradLogger.getInstance().forceLogMessage("Initial graph Mn = "); + TetradLogger.getInstance().log("Initial graph Mn = "); String message = edges.toString(); - TetradLogger.getInstance().forceLogMessage(message); - TetradLogger.getInstance().forceLogMessage("Its score = " + bestScore); + TetradLogger.getInstance().log(message); + TetradLogger.getInstance().log("Its score = " + bestScore); for (Graph model : models) { Dag dag = new Dag(model); @@ -352,8 +352,8 @@ public void run() { bayesImMn); EdgeListGraph edgesTest = new EdgeListGraph(dag); - TetradLogger.getInstance().forceLogMessage("For the model with graph \n" + edgesTest); - TetradLogger.getInstance().forceLogMessage("Model Score = " + score); + TetradLogger.getInstance().log("For the model with graph \n" + edgesTest); + TetradLogger.getInstance().log("Model Score = " + score); if (score <= bestScore) { continue; //This is not better than the best to date. @@ -365,13 +365,13 @@ public void run() { this.bayesPmMnplus1 = bayesPmTest; } - TetradLogger.getInstance().forceLogMessage("In iteration: " + this.iteration); - TetradLogger.getInstance().forceLogMessage("bestScore, oldBestScore " + bestScore + " " + - this.oldBestScore); + TetradLogger.getInstance().log("In iteration: " + this.iteration); + TetradLogger.getInstance().log("bestScore, oldBestScore " + bestScore + " " + + this.oldBestScore); EdgeListGraph edgesBest = new EdgeListGraph(this.bayesPmMnplus1.getDag()); - TetradLogger.getInstance().forceLogMessage("Graph of model: \n" + edgesBest); - TetradLogger.getInstance().forceLogMessage("===================================="); + TetradLogger.getInstance().log("Graph of model: \n" + edgesBest); + TetradLogger.getInstance().log("===================================="); this.oldBestScore = bestScore; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java index d5bfb70305..1f1704a25d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java @@ -1001,8 +1001,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1012,8 +1012,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java index 00100afecb..afdf665eaf 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java @@ -1001,8 +1001,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1012,8 +1012,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java index fe4358618a..97bca6bc8f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java @@ -332,8 +332,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -343,8 +343,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java index dd99658025..c2292c82af 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java @@ -190,8 +190,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -201,8 +201,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java index 571cb8888a..9f5ceaadb6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java @@ -1403,8 +1403,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1414,8 +1414,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java index 0f3d33af34..3126f1a29b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java @@ -1201,8 +1201,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1212,8 +1212,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java index 9bbe285456..3e35240487 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java @@ -540,8 +540,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -551,8 +551,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java index eb6107752c..3f340492b0 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java @@ -412,8 +412,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -423,8 +423,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java index d930713f3e..b9399aa9df 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierBayesUpdaterDiscrete.java @@ -261,11 +261,11 @@ public int[] classify() { //combinations of values of the variables do not occur in the //training dataset. If that happens skip the case. if (estimatedValue < 0) { - TetradLogger.getInstance().forceLogMessage("Case " + i + " does not return valid marginal."); + TetradLogger.getInstance().log("Case " + i + " does not return valid marginal."); for (int m = 0; m < nvars; m++) { String message = " " + selectedData.getDouble(i, m); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } estimatedValues[i] = DiscreteVariable.MISSING_VALUE; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java index d1ba9ff456..1c6ab25fa7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/classify/ClassifierMbDiscrete.java @@ -126,7 +126,7 @@ public ClassifierMbDiscrete(String trainPath, String testPath, String targetStri priorString + " " + maxMissingString + " "; - TetradLogger.getInstance().forceLogMessage(s); + TetradLogger.getInstance().log(s); DataSet train = SimpleDataLoader.loadContinuousData(new File(trainPath), "//", '\"', "*", true, Delimiter.TAB, false); @@ -218,9 +218,9 @@ public int[] classify() { Pc cpdagSearch = new Pc(new IndTestChiSquare(subset, 0.05)); Graph mbCPDAG = cpdagSearch.search(); - TetradLogger.getInstance().forceLogMessage("CPDAG = " + mbCPDAG); + TetradLogger.getInstance().log("CPDAG = " + mbCPDAG); MbUtils.trimToMbNodes(mbCPDAG, this.target, true); - TetradLogger.getInstance().forceLogMessage("Trimmed CPDAG = " + mbCPDAG); + TetradLogger.getInstance().log("Trimmed CPDAG = " + mbCPDAG); // Removing bidirected edges from the CPDAG before selecting a DAG. 4 for (Edge edge : mbCPDAG.getEdges()) { @@ -231,10 +231,10 @@ public int[] classify() { Graph selectedDag = MbUtils.getOneMbDag(mbCPDAG); - TetradLogger.getInstance().forceLogMessage("Selected DAG = " + selectedDag); + TetradLogger.getInstance().log("Selected DAG = " + selectedDag); String message1 = "Vars = " + selectedDag.getNodes(); - TetradLogger.getInstance().forceLogMessage(message1); - TetradLogger.getInstance().forceLogMessage("\nClassification using selected MB DAG:"); + TetradLogger.getInstance().log(message1); + TetradLogger.getInstance().log("\nClassification using selected MB DAG:"); NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); List mbNodes = selectedDag.getNodes(); @@ -256,7 +256,7 @@ public int[] classify() { } //Create an updater for the instantiated Bayes net. - TetradLogger.getInstance().forceLogMessage("Estimating Bayes net; please wait..."); + TetradLogger.getInstance().log("Estimating Bayes net; please wait..."); DirichletBayesIm prior = DirichletBayesIm.symmetricDirichletIm(bayesPm, this.prior); BayesIm bayesIm = DirichletEstimator.estimate(prior, trainDataSubset); @@ -314,9 +314,9 @@ public int[] classify() { } if (numMissing > this.maxMissing) { - TetradLogger.getInstance().forceLogMessage("classification(" + k + ") = " + - "not done since number of missing values too high " + - "(" + numMissing + ")."); + TetradLogger.getInstance().log("classification(" + k + ") = " + + "not done since number of missing values too high " + + "(" + numMissing + ")."); continue; } @@ -353,7 +353,7 @@ public int[] classify() { } String estimatedCategory = this.targetVariable.getCategories().get(_category); - TetradLogger.getInstance().forceLogMessage("classification(" + k + ") = " + estimatedCategory); + TetradLogger.getInstance().log("classification(" + k + ") = " + estimatedCategory); estimatedCategories[k] = _category; } @@ -389,9 +389,9 @@ public int[] classify() { 100.0 * ((double) numberCorrect) / ((double) numberCounted); // Print the cross classification. - TetradLogger.getInstance().forceLogMessage(""); - TetradLogger.getInstance().forceLogMessage("\t\t\tEstimated\t"); - TetradLogger.getInstance().forceLogMessage("Observed\t"); + TetradLogger.getInstance().log(""); + TetradLogger.getInstance().log("\t\t\tEstimated\t"); + TetradLogger.getInstance().log("Observed\t"); StringBuilder buf0 = new StringBuilder(); buf0.append("\t"); @@ -400,7 +400,7 @@ public int[] classify() { buf0.append(this.targetVariable.getCategory(m)).append("\t"); } - TetradLogger.getInstance().forceLogMessage(buf0.toString()); + TetradLogger.getInstance().log(buf0.toString()); for (int k = 0; k < numCategories; k++) { StringBuilder buf = new StringBuilder(); @@ -410,14 +410,14 @@ public int[] classify() { for (int m = 0; m < numCategories; m++) buf.append(crossTabs[k][m]).append("\t"); - TetradLogger.getInstance().forceLogMessage(buf.toString()); + TetradLogger.getInstance().log(buf.toString()); } - TetradLogger.getInstance().forceLogMessage(""); - TetradLogger.getInstance().forceLogMessage("Number correct = " + numberCorrect); - TetradLogger.getInstance().forceLogMessage("Number counted = " + numberCounted); + TetradLogger.getInstance().log(""); + TetradLogger.getInstance().log("Number correct = " + numberCorrect); + TetradLogger.getInstance().log("Number counted = " + numberCounted); String message = "Percent correct = " + nf.format(percentCorrect1) + "%"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); this.crossTabulation = crossTabs; this.percentCorrect = percentCorrect1; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java index 2328316cf8..ac017bed50 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java @@ -171,8 +171,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -182,8 +182,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java index bac9f462ba..29a1af20e7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java @@ -328,8 +328,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -339,8 +339,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java index e1cdac0337..7ae03427ff 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java @@ -159,8 +159,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -170,8 +170,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java index 7a01602049..313d49f5a6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java @@ -23,7 +23,6 @@ import edu.cmu.tetrad.graph.Node; import edu.cmu.tetrad.graph.NodeType; import edu.cmu.tetrad.graph.NodeVariableType; -import edu.cmu.tetrad.util.Params; import edu.cmu.tetrad.util.TetradLogger; import java.beans.PropertyChangeListener; @@ -292,8 +291,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -303,8 +302,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java index 1e9e4bd225..b794ca75a1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java @@ -447,8 +447,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -458,8 +458,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java index 1e6be1e1c7..85788530c4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java @@ -565,8 +565,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -576,8 +576,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java index 9b06a71d8a..4d1fd07a7d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java @@ -864,8 +864,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -875,8 +875,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java index 2d0eaac919..0720eb8908 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java @@ -352,8 +352,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -363,8 +363,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java index 296ce176f7..ff07ae7501 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java @@ -124,8 +124,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -135,8 +135,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java index 64f133d050..6d2a516bba 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java @@ -106,8 +106,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -117,8 +117,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java index 2c1ab7632c..a44f180bcf 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java @@ -509,8 +509,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -520,8 +520,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java index 6150fe1825..9d83f4adf3 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java @@ -107,8 +107,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -118,8 +118,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java index f709173930..29ea7b7469 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java @@ -132,8 +132,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -143,8 +143,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java index 66e6ca59a0..2618bae63b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java @@ -228,8 +228,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -239,8 +239,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/LogDataUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/LogDataUtils.java index a0c956f099..72a6a10a44 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/LogDataUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/LogDataUtils.java @@ -45,12 +45,12 @@ private LogDataUtils() { * @param list a {@link edu.cmu.tetrad.data.DataModelList} object */ public static void logDataModelList(String info, DataModelList list) { - TetradLogger.getInstance().forceLogMessage(info); + TetradLogger.getInstance().log(info); if (list.size() == 1) { - TetradLogger.getInstance().forceLogMessage("\nThere is one data set in this box."); + TetradLogger.getInstance().log("\nThere is one data set in this box."); } else { - TetradLogger.getInstance().forceLogMessage("\nThere are " + list.size() + " data sets in this box."); + TetradLogger.getInstance().log("\nThere are " + list.size() + " data sets in this box."); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java index 9d3885b5ae..f75055fdce 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java @@ -187,8 +187,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -198,8 +198,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SimpleDataLoader.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SimpleDataLoader.java index 47b95c94fc..01d8fd9a7f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SimpleDataLoader.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SimpleDataLoader.java @@ -195,7 +195,7 @@ public static ICovarianceMatrix loadCovarianceMatrix(char[] chars, String commen ICovarianceMatrix covarianceMatrix = doCovariancePass(reader2, commentMarker, delimiterType, quoteChar, missingValueMarker); - TetradLogger.getInstance().forceLogMessage("\nData set loaded!"); + TetradLogger.getInstance().log("\nData set loaded!"); return covarianceMatrix; } @@ -221,7 +221,7 @@ public static ICovarianceMatrix loadCovarianceMatrix(File file, String commentMa ICovarianceMatrix covarianceMatrix = doCovariancePass(reader, commentMarker, delimiter, quoteCharacter, missingValueMarker); - TetradLogger.getInstance().forceLogMessage("\nCovariance matrix loaded!"); + TetradLogger.getInstance().log("\nCovariance matrix loaded!"); return covarianceMatrix; } catch (FileNotFoundException e) { throw e; @@ -236,13 +236,13 @@ public static ICovarianceMatrix loadCovarianceMatrix(File file, String commentMa private static ICovarianceMatrix doCovariancePass(Reader reader, String commentMarker, DelimiterType delimiterType, char quoteChar, String missingValueMarker) { - TetradLogger.getInstance().forceLogMessage("\nDATA LOADING PARAMETERS:"); - TetradLogger.getInstance().forceLogMessage("File type = COVARIANCE"); - TetradLogger.getInstance().forceLogMessage("Comment marker = " + commentMarker); - TetradLogger.getInstance().forceLogMessage("Delimiter type = " + delimiterType); - TetradLogger.getInstance().forceLogMessage("Quote char = " + quoteChar); - TetradLogger.getInstance().forceLogMessage("Missing value marker = " + missingValueMarker); - TetradLogger.getInstance().forceLogMessage("--------------------"); + TetradLogger.getInstance().log("\nDATA LOADING PARAMETERS:"); + TetradLogger.getInstance().log("File type = COVARIANCE"); + TetradLogger.getInstance().log("Comment marker = " + commentMarker); + TetradLogger.getInstance().log("Delimiter type = " + delimiterType); + TetradLogger.getInstance().log("Quote char = " + quoteChar); + TetradLogger.getInstance().log("Missing value marker = " + missingValueMarker); + TetradLogger.getInstance().log("--------------------"); Lineizer lineizer = new Lineizer(reader, commentMarker); @@ -287,7 +287,7 @@ private static ICovarianceMatrix doCovariancePass(Reader reader, String commentM String _token = st.nextToken(); if ("".equals(_token)) { - TetradLogger.getInstance().forceLogMessage("Parsed an empty token for a variable name--ignoring."); + TetradLogger.getInstance().log("Parsed an empty token for a variable name--ignoring."); continue; } @@ -296,10 +296,10 @@ private static ICovarianceMatrix doCovariancePass(Reader reader, String commentM String[] varNames = vars.toArray(new String[0]); - TetradLogger.getInstance().forceLogMessage("Variables:"); + TetradLogger.getInstance().log("Variables:"); for (String varName : varNames) { - TetradLogger.getInstance().forceLogMessage(varName + " --> Continuous"); + TetradLogger.getInstance().log(varName + " --> Continuous"); } // Read br covariances. @@ -318,8 +318,8 @@ private static ICovarianceMatrix doCovariancePass(Reader reader, String commentM String literal = st.nextToken(); if ("".equals(literal)) { - TetradLogger.getInstance().forceLogMessage("Parsed an empty token for a " - + "covariance value--ignoring."); + TetradLogger.getInstance().log("Parsed an empty token for a " + + "covariance value--ignoring."); continue; } @@ -343,7 +343,7 @@ private static ICovarianceMatrix doCovariancePass(Reader reader, String commentM covarianceMatrix.setKnowledge(knowledge); - TetradLogger.getInstance().forceLogMessage("\nData set loaded!"); + TetradLogger.getInstance().log("\nData set loaded!"); return covarianceMatrix; } @@ -482,7 +482,7 @@ private static Knowledge loadKnowledge(Lineizer lineizer, Pattern delimiter) { firstLine = line; } - TetradLogger.getInstance().forceLogMessage("\nLoading knowledge."); + TetradLogger.getInstance().log("\nLoading knowledge."); SECTIONS: while (lineizer.hasMoreLines()) { @@ -552,7 +552,7 @@ private static Knowledge loadKnowledge(Lineizer lineizer, Pattern delimiter) { knowledge.addToTier(tier, name); - TetradLogger.getInstance().forceLogMessage("Adding to tier " + (tier) + " " + name); + TetradLogger.getInstance().log("Adding to tier " + (tier) + " " + name); } } } else if ("forbiddengroup".equalsIgnoreCase(line.trim())) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java index 565e9a7783..f5d810bc81 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java @@ -105,8 +105,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -116,8 +116,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java index 90deff9815..2f2fc01cf8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java @@ -253,8 +253,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -264,8 +264,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java index 83494ae54d..732bd4d4a8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java @@ -462,8 +462,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -473,8 +473,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java index 7feeefb96b..5dd7515568 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java @@ -183,8 +183,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -194,8 +194,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java index d0bd1ea96f..ab1703fdf6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java @@ -72,8 +72,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -83,8 +83,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java index 5fd270237d..9be2746d29 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/GraphUtils.java @@ -1927,8 +1927,8 @@ public static void gfciExtraEdgeRemovalStep(Graph graph, Graph cpdag, List if (verbose) { double pValue = sepsets.getPValue(a, c, sepset); - TetradLogger.getInstance().forceLogMessage("Removed edge " + a + " -- " + c - + " in extra-edge removal step; sepset = " + sepset + ", p-value = " + pValue + "."); + TetradLogger.getInstance().log("Removed edge " + a + " -- " + c + + " in extra-edge removal step; sepset = " + sepset + ", p-value = " + pValue + "."); } } } @@ -2501,14 +2501,14 @@ public static void gfciR0(Graph pag, Graph cpdag, SepsetProducer sepsets, Knowle pag.setEndpoint(z, y, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Copied " + x + " *-> " + y + " <-* " + z + " from CPDAG."); + TetradLogger.getInstance().log("Copied " + x + " *-> " + y + " <-* " + z + " from CPDAG."); if (Edges.isBidirectedEdge(pag.getEdge(x, y))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(x, y)); + TetradLogger.getInstance().log("Created bidirected edge: " + pag.getEdge(x, y)); } if (Edges.isBidirectedEdge(pag.getEdge(y, z))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(y, z)); + TetradLogger.getInstance().log("Created bidirected edge: " + pag.getEdge(y, z)); } } } @@ -2527,14 +2527,14 @@ public static void gfciR0(Graph pag, Graph cpdag, SepsetProducer sepsets, Knowle double p = sepsets.getPValue(x, z, sepset); String _p = p < 0.0001 ? "< 0.0001" : String.format("%.4f", p); - TetradLogger.getInstance().forceLogMessage("Oriented collider by test " + x + " *-> " + y + " <-* " + z + ", p = " + _p + "."); + TetradLogger.getInstance().log("Oriented collider by test " + x + " *-> " + y + " <-* " + z + ", p = " + _p + "."); if (Edges.isBidirectedEdge(pag.getEdge(x, y))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(x, y)); + TetradLogger.getInstance().log("Created bidirected edge: " + pag.getEdge(x, y)); } if (Edges.isBidirectedEdge(pag.getEdge(y, z))) { - TetradLogger.getInstance().forceLogMessage("Created bidirected edge: " + pag.getEdge(y, z)); + TetradLogger.getInstance().log("Created bidirected edge: " + pag.getEdge(y, z)); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java index 02121301eb..440e6b0d6c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java @@ -258,8 +258,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -269,8 +269,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java index 273774c63a..4e1e3ddc80 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java @@ -121,8 +121,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -132,8 +132,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java index d158c34e60..347a6327d4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java @@ -2040,7 +2040,7 @@ private boolean visibleEdgeHelperVisit(Node c, Node a, Node b, LinkedList public boolean existsDirectedCycle() { for (Node node : graph.getNodes()) { if (existsDirectedPath(node, node)) { - TetradLogger.getInstance().forceLogMessage("Cycle found at node " + node.getName() + "."); + TetradLogger.getInstance().log("Cycle found at node " + node.getName() + "."); return true; } } @@ -2610,8 +2610,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -2621,8 +2621,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java index 5027a49f85..ed70040453 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java @@ -180,8 +180,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -191,8 +191,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java index efa23ff67e..2591f7eeab 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java @@ -363,8 +363,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -374,8 +374,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } 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 407f63a188..782701621e 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 @@ -165,8 +165,8 @@ public Graph search() { List nodes = getIndependenceTest().getVariables(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting BFCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting BFCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } Boss subAlg = new Boss(this.score); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossLingam.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossLingam.java index 2d3ce7d2ae..f6efc3bbf5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossLingam.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossLingam.java @@ -128,7 +128,7 @@ public Graph search() { } } - TetradLogger.getInstance().forceLogMessage("Returning: " + toOrient); + TetradLogger.getInstance().log("Returning: " + toOrient); return toOrient; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Bpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Bpc.java index 96b83372a7..1c93b36f00 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Bpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Bpc.java @@ -143,7 +143,7 @@ public Bpc(DataSet dataSet, double alpha, BpcTestType sigTestType) { public Graph search() { long start = MillisecondTimes.timeMillis(); - TetradLogger.getInstance().forceLogMessage("BPC alpha = " + this.alpha + " test = " + this.sigTestType); + TetradLogger.getInstance().log("BPC alpha = " + this.alpha + " test = " + this.sigTestType); List variables = this.tetradTest.getVariables(); List clustering = findMeasurementPattern(variables); @@ -166,7 +166,7 @@ public Graph search() { long stop = MillisecondTimes.timeMillis(); long elapsed = stop - start; - TetradLogger.getInstance().forceLogMessage("Elapsed " + elapsed + " ms"); + TetradLogger.getInstance().log("Elapsed " + elapsed + " ms"); Set> _clustering = new HashSet<>(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ccd.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ccd.java index 75efc116e9..d07c0a1905 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ccd.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ccd.java @@ -262,7 +262,7 @@ private void doNodeCollider(Graph graph, Map colliders, Map> supSepset, Graph psi) { - TetradLogger.getInstance().forceLogMessage("\nStep E"); + TetradLogger.getInstance().log("\nStep E"); for (Triple triple : psi.getDottedUnderlines()) { Node a = triple.getX(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java index e4e3a60a71..9f6c0f0b10 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Cfci.java @@ -101,8 +101,8 @@ public Graph search() { long beginTime = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Starting CFCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + this.independenceTest + "."); + TetradLogger.getInstance().log("Starting CFCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + this.independenceTest + "."); } setMaxReachablePathLength(this.maxReachablePathLength); @@ -132,7 +132,7 @@ public Graph search() { long time2 = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Step C: " + (time2 - time1) / 1000. + "s"); + TetradLogger.getInstance().log("Step C: " + (time2 - time1) / 1000. + "s"); } // Step FCI D. @@ -148,7 +148,7 @@ public Graph search() { long time4 = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Step D: " + (time4 - time3) / 1000. + "s"); + TetradLogger.getInstance().log("Step D: " + (time4 - time3) / 1000. + "s"); } // Reorient all edges as o-o. @@ -163,7 +163,7 @@ public Graph search() { long time6 = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Step CI C: " + (time6 - time5) / 1000. + "s"); + TetradLogger.getInstance().log("Step CI C: " + (time6 - time5) / 1000. + "s"); } // Step CI D. (Zhang's step F4.) @@ -183,7 +183,7 @@ public Graph search() { this.elapsedTime = endTime - beginTime; if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Returning graph: " + this.graph); + TetradLogger.getInstance().log("Returning graph: " + this.graph); } return this.graph; @@ -268,7 +268,7 @@ private Graph getGraph() { private void ruleR0(IndependenceTest test, int depth, SepsetMap sepsets) { if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); } this.ambiguousTriples = new HashSet<>(); @@ -302,7 +302,7 @@ private void ruleR0(IndependenceTest test, int depth, SepsetMap sepsets) { if (this.verbose) { String message = "Collider: " + Triple.pathString(this.graph, x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -312,14 +312,14 @@ private void ruleR0(IndependenceTest test, int depth, SepsetMap sepsets) { getGraph().addAmbiguousTriple(triple.getX(), triple.getY(), triple.getZ()); if (this.verbose) { String message = "AmbiguousTriples: " + Triple.pathString(this.graph, x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } } @@ -487,7 +487,7 @@ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColl */ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Starting BK Orientation."); + TetradLogger.getInstance().log("Starting BK Orientation."); } for (Iterator it = @@ -511,7 +511,7 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -543,12 +543,12 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing BK Orientation."); + TetradLogger.getInstance().log("Finishing BK Orientation."); } } /** 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 e86b783996..969c070354 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 @@ -154,8 +154,8 @@ public Cpc(IndependenceTest independenceTest) { public Graph search() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting CPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting CPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); @@ -199,8 +199,8 @@ public Graph search() { this.elapsedTime = endTime - startTime; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); } this.colliderTriples = search.getColliderTriples(); @@ -371,23 +371,23 @@ public void setPcHeuristicType(PcCommon.PcHeuristicType pcHeuristicType) { */ private void logTriples() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("\nCollider triples:"); + TetradLogger.getInstance().log("\nCollider triples:"); for (Triple triple : this.colliderTriples) { - TetradLogger.getInstance().forceLogMessage("Collider: " + triple); + TetradLogger.getInstance().log("Collider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nNoncollider triples:"); + TetradLogger.getInstance().log("\nNoncollider triples:"); for (Triple triple : this.noncolliderTriples) { - TetradLogger.getInstance().forceLogMessage("Noncollider: " + triple); + TetradLogger.getInstance().log("Noncollider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nAmbiguous triples (i.e. list of triples for which " + - "\nthere is ambiguous data about whether they are colliders or not):"); + TetradLogger.getInstance().log("\nAmbiguous triples (i.e. list of triples for which " + + "\nthere is ambiguous data about whether they are colliders or not):"); for (Triple triple : getAmbiguousTriples()) { - TetradLogger.getInstance().forceLogMessage("Ambiguous: " + triple); + TetradLogger.getInstance().log("Ambiguous: " + triple); } } } 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 affc08e4d8..d4a3d8e2b0 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 @@ -204,7 +204,7 @@ public LinkedList> getRecords(DataSet dataSet, List pos if (path == null || path.isEmpty()) { path = "cstar-out"; - TetradLogger.getInstance().forceLogMessage("Using path = 'cstar-out'."); + TetradLogger.getInstance().log("Using path = 'cstar-out'."); } File origDir = null; @@ -235,10 +235,10 @@ public LinkedList> getRecords(DataSet dataSet, List pos throw new IllegalStateException("Could not make a new directory; perhaps file permissions need to be adjusted."); } - TetradLogger.getInstance().forceLogMessage("Creating directories for " + newDir.getAbsolutePath()); + TetradLogger.getInstance().log("Creating directories for " + newDir.getAbsolutePath()); newDir = new File(path); - TetradLogger.getInstance().forceLogMessage("Using files in directory " + origDir.getAbsolutePath()); + TetradLogger.getInstance().log("Using files in directory " + origDir.getAbsolutePath()); this.newDir = newDir; @@ -247,10 +247,10 @@ public LinkedList> getRecords(DataSet dataSet, List pos LinkedList> allRecords = new LinkedList<>(); - TetradLogger.getInstance().forceLogMessage("Results directory = " + newDir.getAbsolutePath()); + TetradLogger.getInstance().log("Results directory = " + newDir.getAbsolutePath()); if (new File(origDir, "possible.causes.txt").exists() && new File(newDir, "possible.causes.txt").exists()) { - TetradLogger.getInstance().forceLogMessage("Loading data, possible causes, and possible effects from " + origDir.getAbsolutePath()); + TetradLogger.getInstance().log("Loading data, possible causes, and possible effects from " + origDir.getAbsolutePath()); possibleCauses = readVars(dataSet, origDir, "possible.causes.txt"); possibleEffects = readVars(dataSet, origDir, "possible.effects.txt"); } @@ -299,7 +299,7 @@ private Task(int subsample, List possibleCauses, List possibleEffect } public double[][] call() { - TetradLogger.getInstance().forceLogMessage("\nRunning subsample " + (this.subsample + 1) + " of " + Cstar.this.numSubsamples + "."); + TetradLogger.getInstance().log("\nRunning subsample " + (this.subsample + 1) + " of " + Cstar.this.numSubsamples + "."); try { BootstrapSampler sampler = new BootstrapSampler(); @@ -308,11 +308,11 @@ public double[][] call() { double[][] effects; if (new File(origDir, "cpdag." + (this.subsample + 1) + ".txt").exists() && new File(origDir, "effects." + (this.subsample + 1) + ".txt").exists()) { - TetradLogger.getInstance().forceLogMessage("Loading CPDAG and effects from " + origDir.getAbsolutePath() + " for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Loading CPDAG and effects from " + origDir.getAbsolutePath() + " for index " + (this.subsample + 1)); cpdag = GraphSaveLoadUtils.loadGraphTxt(new File(origDir, "cpdag." + (this.subsample + 1) + ".txt")); effects = loadMatrix(new File(origDir, "effects." + (this.subsample + 1) + ".txt")); } else { - TetradLogger.getInstance().forceLogMessage("Sampling data for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Sampling data for index " + (this.subsample + 1)); if (Cstar.this.sampleStyle == SampleStyle.BOOTSTRAP) { sampler.setWithoutReplacements(false); @@ -325,16 +325,16 @@ public double[][] call() { } if (Cstar.this.cpdagAlgorithm == CpdagAlgorithm.PC_STABLE) { - TetradLogger.getInstance().forceLogMessage("Running PC-Stable for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Running PC-Stable for index " + (this.subsample + 1)); cpdag = getPatternPcStable(sample); } else if (Cstar.this.cpdagAlgorithm == CpdagAlgorithm.FGES) { - TetradLogger.getInstance().forceLogMessage("Running FGES for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Running FGES for index " + (this.subsample + 1)); cpdag = getPatternFges(sample); } else if (Cstar.this.cpdagAlgorithm == CpdagAlgorithm.BOSS) { - TetradLogger.getInstance().forceLogMessage("Running BOSS for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Running BOSS for index " + (this.subsample + 1)); cpdag = getPatternBoss(sample); } else if (Cstar.this.cpdagAlgorithm == CpdagAlgorithm.RESTRICTED_BOSS) { - TetradLogger.getInstance().forceLogMessage("Running Restricted BOSS for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Running Restricted BOSS for index " + (this.subsample + 1)); cpdag = getPatternRestrictedBoss(sample, this._dataSet); } else { throw new IllegalArgumentException("That type of of cpdag algorithm is not configured: " + Cstar.this.cpdagAlgorithm); @@ -344,7 +344,7 @@ public double[][] call() { effects = new double[this.possibleCauses.size()][this.possibleEffects.size()]; - TetradLogger.getInstance().forceLogMessage("Running IDA for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Running IDA for index " + (this.subsample + 1)); for (int e = 0; e < this.possibleEffects.size(); e++) { Map minEffects = ida.calculateMinimumTotalEffectsOnY(this.possibleEffects.get(e)); @@ -355,7 +355,7 @@ public double[][] call() { } } - TetradLogger.getInstance().forceLogMessage("Saving CPDAG and effects for index " + (this.subsample + 1)); + TetradLogger.getInstance().log("Saving CPDAG and effects for index " + (this.subsample + 1)); saveMatrix(effects, new File(newDir, "effects." + (this.subsample + 1) + ".txt")); try { @@ -402,7 +402,7 @@ public double[][] call() { try { if (Cstar.this.verbose) { - TetradLogger.getInstance().forceLogMessage("Examining top bracket = " + this.topBracket + "."); + TetradLogger.getInstance().log("Examining top bracket = " + this.topBracket + "."); } List tuples = new ArrayList<>(); @@ -801,7 +801,7 @@ private List runCallablesDoubleArray(List> task try { results.add(future.get()); } catch (InterruptedException | ExecutionException e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); } } @@ -1043,8 +1043,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1054,8 +1054,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fas.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fas.java index ac1d4ac4fe..2e01015d65 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fas.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fas.java @@ -151,7 +151,7 @@ public Graph search(List nodes) { this.logger.addOutputStream(out); if (verbose) { - this.logger.forceLogMessage("Starting Fast Adjacency Search."); + this.logger.log("Starting Fast Adjacency Search."); } this.test.setVerbose(this.verbose); @@ -248,7 +248,7 @@ public Graph search(List nodes) { } if (verbose) { - this.logger.forceLogMessage("Finishing Fast Adjacency Search."); + this.logger.log("Finishing Fast Adjacency Search."); } this.elapsedTime = MillisecondTimes.timeMillis() - startTime; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fasd.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fasd.java index 8adfddd09c..4bea05fa23 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fasd.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fasd.java @@ -118,7 +118,7 @@ public Fasd(IndependenceTest test) { * @return a graph which indicates which variables are independent conditional on which other variables */ public Graph search() { - TetradLogger.getInstance().forceLogMessage("Starting Fast Adjacency Search."); + TetradLogger.getInstance().log("Starting Fast Adjacency Search."); this.graph.removeEdges(this.graph.getEdges()); this.sepset = new SepsetMap(); @@ -161,7 +161,7 @@ public Graph search() { } } - TetradLogger.getInstance().forceLogMessage("Finishing Fast Adjacency Search."); + TetradLogger.getInstance().log("Finishing Fast Adjacency Search."); return this.graph; } @@ -332,7 +332,7 @@ private boolean searchAtDepth0(List nodes, IndependenceTest test, Map" + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\tknowledge_forbidden" + + "\t" + nf.format(lr) + + "\t" + X + "<->" + Y ); continue; } if (knowledgeOrients(X, Y)) { - TetradLogger.getInstance().forceLogMessage(X + "\t" + Y + "\tknowledge" - + "\t" + nf.format(lr) - + "\t" + X + "-->" + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\tknowledge" + + "\t" + nf.format(lr) + + "\t" + X + "-->" + Y ); graph.addDirectedEdge(X, Y); } else if (knowledgeOrients(Y, X)) { - TetradLogger.getInstance().forceLogMessage(X + "\t" + Y + "\tknowledge" - + "\t" + nf.format(lr) - + "\t" + X + "<--" + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\tknowledge" + + "\t" + nf.format(lr) + + "\t" + X + "<--" + Y ); graph.addDirectedEdge(Y, X); } else { if (passesTwoCycleScreening(x, y)) { if (this.twoCycleScreeningCutoff != 0) { - TetradLogger.getInstance().forceLogMessage(X + "\t" + Y + "\t2-cycle Prescreen" - + "\t" + nf.format(lr) - + "\t" + X + "...TC?..." + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\t2-cycle Prescreen" + + "\t" + nf.format(lr) + + "\t" + X + "...TC?..." + Y ); } @@ -579,15 +579,15 @@ public Graph search() { } if (lr > 0) { - TetradLogger.getInstance().forceLogMessage(X + "\t" + Y + "\tleft-right" - + "\t" + nf.format(lr) - + "\t" + X + "-->" + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\tleft-right" + + "\t" + nf.format(lr) + + "\t" + X + "-->" + Y ); graph.addDirectedEdge(X, Y); } else if (lr < 0) { - TetradLogger.getInstance().forceLogMessage(Y + "\t" + X + "\tleft-right" - + "\t" + nf.format(lr) - + "\t" + Y + "-->" + X + TetradLogger.getInstance().log(Y + "\t" + X + "\tleft-right" + + "\t" + nf.format(lr) + + "\t" + Y + "-->" + X ); graph.addDirectedEdge(Y, X); } @@ -934,7 +934,7 @@ private boolean twoCycleTest(int i, int j, double[][] D, Graph G0, List V) pc1 = partialCorrelation(x, y, _Z, x, 0); pc2 = partialCorrelation(x, y, _Z, y, 0); } catch (SingularMatrixException e) { - TetradLogger.getInstance().forceLogMessage("Singularity X = " + X + " Y = " + Y + " adj = " + adj); + TetradLogger.getInstance().log("Singularity X = " + X + " Y = " + Y + " adj = " + adj); continue; } @@ -1044,9 +1044,9 @@ private void logTwoCycle(NumberFormat nf, List variables, double[][] d, No double lr = leftRight(x, y); - TetradLogger.getInstance().forceLogMessage(X + "\t" + Y + "\t" + type - + "\t" + nf.format(lr) - + "\t" + X + "<=>" + Y + TetradLogger.getInstance().log(X + "\t" + Y + "\t" + type + + "\t" + nf.format(lr) + + "\t" + X + "<=>" + Y ); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FastIca.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FastIca.java index 6f3b671167..d8f0d109a5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FastIca.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FastIca.java @@ -302,7 +302,7 @@ public void setRowNorm(boolean rowNorm) { */ public void setMaxIterations(int maxIterations) { if (maxIterations < 1) { - TetradLogger.getInstance().forceLogMessage("maxIterations should be positive."); + TetradLogger.getInstance().log("maxIterations should be positive."); } this.maxIterations = maxIterations; @@ -315,7 +315,7 @@ public void setMaxIterations(int maxIterations) { */ public void setTolerance(double tolerance) { if (!(tolerance > 0)) { - TetradLogger.getInstance().forceLogMessage("Tolerance should be positive."); + TetradLogger.getInstance().log("Tolerance should be positive."); } this.tolerance = tolerance; @@ -351,8 +351,8 @@ public IcaResult findComponents() { int p = this.X.getNumRows(); if (this.numComponents > min(n, p)) { - TetradLogger.getInstance().forceLogMessage("Requested number of components is too large."); - TetradLogger.getInstance().forceLogMessage("Reset to " + min(n, p)); + TetradLogger.getInstance().log("Requested number of components is too large."); + TetradLogger.getInstance().log("Reset to " + min(n, p)); this.numComponents = min(n, p); } @@ -368,7 +368,7 @@ public IcaResult findComponents() { } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Centering"); + TetradLogger.getInstance().log("Centering"); } center(this.X); @@ -378,7 +378,7 @@ public IcaResult findComponents() { } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Whitening"); + TetradLogger.getInstance().log("Whitening"); } // Whiten. @@ -423,18 +423,18 @@ private Matrix icaDeflation(Matrix X, double tolerance, int function, double alpha, int maxIterations, boolean verbose, Matrix wInit) { if (verbose && function == FastIca.LOGCOSH) { - TetradLogger.getInstance().forceLogMessage("Deflation FastIca using lgcosh approx. to neg-entropy function"); + TetradLogger.getInstance().log("Deflation FastIca using lgcosh approx. to neg-entropy function"); } if (verbose && function == FastIca.EXP) { - TetradLogger.getInstance().forceLogMessage("Deflation FastIca using exponential approx. to neg-entropy function"); + TetradLogger.getInstance().log("Deflation FastIca using exponential approx. to neg-entropy function"); } Matrix W = new Matrix(X.getNumRows(), X.getNumRows()); for (int i = 0; i < X.getNumRows(); i++) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Component " + (i + 1)); + TetradLogger.getInstance().log("Component " + (i + 1)); } Vector w = wInit.getRow(i); @@ -525,7 +525,7 @@ private Matrix icaDeflation(Matrix X, _tolerance = abs(abs(_tolerance) - 1.0); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Iteration " + it + " tol = " + _tolerance); + TetradLogger.getInstance().log("Iteration " + it + " tol = " + _tolerance); } w = w1; @@ -615,7 +615,7 @@ private Matrix icaParallel(Matrix X, int numComponents, int it = 0; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Symmetric FastICA using logcosh approx. to neg-entropy function"); + TetradLogger.getInstance().log("Symmetric FastICA using logcosh approx. to neg-entropy function"); } while (_tolerance > tolerance && it < maxIterations) { @@ -672,7 +672,7 @@ private Matrix icaParallel(Matrix X, int numComponents, W = W1; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Iteration " + (it + 1) + " tol = " + _tolerance); + TetradLogger.getInstance().log("Iteration " + (it + 1) + " tol = " + _tolerance); } it++; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java index b2a11edaf1..6614236b05 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fci.java @@ -184,8 +184,8 @@ public Graph search() { Fas fas = new Fas(getIndependenceTest()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting FCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting FCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } fas.setKnowledge(getKnowledge()); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java index bf6e207433..3f3bc474c5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java @@ -153,8 +153,8 @@ public Graph search() { Fas fas = new Fas(getIndependenceTest()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting FCI-Max algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting FCI-Max algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } fas.setKnowledge(getKnowledge()); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java index f64d2f07c3..6200fc6a10 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java @@ -269,7 +269,7 @@ public Graph search() { this.elapsedTime = endTime - start; if (verbose) { - this.logger.forceLogMessage("Elapsed time = " + (elapsedTime) / 1000. + " s"); + this.logger.log("Elapsed time = " + (elapsedTime) / 1000. + " s"); } this.modelScore = scoreDag(GraphTransforms.dagFromCpdag(graph, null), true); @@ -767,7 +767,7 @@ public EvalPair call() { } } catch (InterruptedException | ExecutionException e) { Thread.currentThread().interrupt(); - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); return; } } @@ -875,7 +875,7 @@ private void insert(Node x, Node y, Set T, double bump) { if (verbose) { final String message = graph.getNumEdges() + ". INSERT " + graph.getEdge(x, y) + " " + T + " " + bump + " degree = " + GraphUtils.getDegree(graph) + " indegree = " + GraphUtils.getIndegree(graph) + " cond = " + cond; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -885,7 +885,7 @@ private void insert(Node x, Node y, Set T, double bump) { if (verbose) { String message = "--- Directing " + graph.getEdge(_t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -947,7 +947,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeA, nodeB); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB)); } } } @@ -970,7 +970,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -981,7 +981,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -995,7 +995,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -1005,7 +1005,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java index 427e0afa3b..672f50ee9b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java @@ -341,7 +341,7 @@ public Graph search(List targets) { this.elapsedTime = endTime - start; if (verbose) { - this.logger.forceLogMessage("Elapsed time = " + (elapsedTime) / 1000. + " s"); + this.logger.log("Elapsed time = " + (elapsedTime) / 1000. + " s"); } this.modelScore = scoreDag(GraphTransforms.dagFromCpdag(graph, null), true); @@ -1021,7 +1021,7 @@ private void insert(Node x, Node y, Set T, double bump) { + " " + T + " " + bump + " degree = " + GraphUtils.getDegree(graph) + " indegree = " + GraphUtils.getIndegree(graph) + " cond = " + cond; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Node _t : T) { @@ -1030,7 +1030,7 @@ private void insert(Node x, Node y, Set T, double bump) { if (verbose) { String message = "--- Directing " + graph.getEdge(_t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1088,7 +1088,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeA, nodeB); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB)); } } } @@ -1110,7 +1110,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -1121,7 +1121,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -1135,7 +1135,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } @@ -1145,7 +1145,7 @@ private void addRequiredEdges(Graph graph) { graph.addDirectedEdge(nodeB, nodeA); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); + TetradLogger.getInstance().log("Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA)); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fofc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fofc.java index d9672adbf6..51bb5979fe 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fofc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fofc.java @@ -1189,7 +1189,7 @@ private Set unionPure(Set> pureClusters) { */ private void log(String s) { if (this.verbose) { - TetradLogger.getInstance().forceLogMessage(s); + TetradLogger.getInstance().log(s); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ftfc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ftfc.java index fecc3cbf8c..f4e26d8b27 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ftfc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ftfc.java @@ -1080,7 +1080,7 @@ private Set unionPure(Set> pureClusters) { */ private void log(String s, boolean toLog) { if (toLog) { - TetradLogger.getInstance().forceLogMessage(s); + TetradLogger.getInstance().log(s); // System.out.println(s); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java index 88bb5d5c81..840048e1ce 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/GFci.java @@ -143,8 +143,8 @@ public Graph search() { List nodes = getIndependenceTest().getVariables(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting GFCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting GFCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } Graph graph; 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 e78d4c1ac5..fe8ac42d67 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 @@ -219,11 +219,11 @@ public List bestOrder(@NotNull List order) { long stop = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Final order = " + this.scorer.getPi()); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (stop - start) / 1000.0 + " s"); + TetradLogger.getInstance().log("Final order = " + this.scorer.getPi()); + TetradLogger.getInstance().log("Elapsed time = " + (stop - start) / 1000.0 + " s"); } - return bestPerm; + return new ArrayList<>(bestPerm); } /** @@ -437,10 +437,10 @@ private List grasp(@NotNull TeyssierScorer scorer) { } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("# Edges = " + scorer.getNumEdges() - + " Score = " + scorer.score() - + " (GRaSP)" - + " Elapsed " + ((MillisecondTimes.timeMillis() - this.start) / 1000.0 + " s")); + TetradLogger.getInstance().log("# Edges = " + scorer.getNumEdges() + + " Score = " + scorer.score() + + " (GRaSP)" + + " Elapsed " + ((MillisecondTimes.timeMillis() - this.start) / 1000.0 + " s")); } return scorer.getPi(); 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 ac1407c7f8..cf31936b78 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 @@ -158,8 +158,8 @@ public Graph search() { } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting Grasp-FCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + this.independenceTest + "."); + TetradLogger.getInstance().log("Starting Grasp-FCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + this.independenceTest + "."); } // Run GRaSP to get a CPDAG (like GFCI with FGES)... diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingD.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingD.java index 6dc2a721d0..c9e975d6c9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingD.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingD.java @@ -128,15 +128,15 @@ public static Matrix estimateW(DataSet data, int fastIcaMaxIter, double fastIcaT double[][] _data = data.getDoubleData().transpose().toArray(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Anderson Darling P-values Per Variables (p < alpha means Non-Gaussian)"); - TetradLogger.getInstance().forceLogMessage(""); + TetradLogger.getInstance().log("Anderson Darling P-values Per Variables (p < alpha means Non-Gaussian)"); + TetradLogger.getInstance().log(""); for (int i = 0; i < _data.length; i++) { Node node = data.getVariable(i); AndersonDarlingTest test = new AndersonDarlingTest(_data[i]); double p = test.getP(); NumberFormat nf = new DecimalFormat("0.000"); - TetradLogger.getInstance().forceLogMessage(node.getName() + ": p = " + nf.format(p)); + TetradLogger.getInstance().log(node.getName() + ": p = " + nf.format(p)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingam.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingam.java index c7ca3c4fde..d0286e365c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingam.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/IcaLingam.java @@ -152,7 +152,7 @@ class Record { } else if (!existsDirectedCycle()) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Effective threshold = " + coef.coef); + TetradLogger.getInstance().log("Effective threshold = " + coef.coef); } trimmed = scaledBHat; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ida.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ida.java index f99936c7cf..4602e990b5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ida.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Ida.java @@ -187,7 +187,7 @@ public LinkedList getTotalEffects(Node x, Node y) { totalEffects.add(beta); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Lofs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Lofs.java index e184182b76..f154263207 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Lofs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Lofs.java @@ -473,10 +473,10 @@ private void ruleR1(Graph skeleton, Graph graph, List nodes) { for (double score : scoreReports.keySet()) { String message = "For " + node + " parents = " + scoreReports.get(score) + " score = " + -score; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } - TetradLogger.getInstance().forceLogMessage(""); + TetradLogger.getInstance().log(""); if (parents == null) { continue; @@ -549,7 +549,7 @@ private void ruleR2(Graph skeleton, Graph graph) { * @param strong Indicates whether to use strong or weak restrictions. */ private void resolveOneEdgeMax2(Graph graph, Node x, Node y, boolean strong) { - TetradLogger.getInstance().forceLogMessage("\nEDGE " + x + " --- " + y); + TetradLogger.getInstance().log("\nEDGE " + x + " --- " + y); SortedMap scoreReports = new TreeMap<>(); @@ -753,7 +753,7 @@ private void resolveOneEdgeMax2(Graph graph, Node x, Node y, boolean strong) { for (double score : scoreReports.keySet()) { String message = scoreReports.get(score); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } graph.removeEdges(x, y); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index e1c8098ce4..11a38ed396 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -103,7 +103,7 @@ public LvDumb(Score score) { */ private void reorientWithCircles(Graph pag) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient all edges in PAG as o-o:"); + TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); } pag.reorientAllWith(Endpoint.CIRCLE); } @@ -121,11 +121,11 @@ public Graph search() { } if (verbose) { - TetradLogger.getInstance().forceLogMessage("===Starting LV-Lite==="); + TetradLogger.getInstance().log("===Starting LV-Lite==="); } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Running BOSS to get CPDAG and best order."); + TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); } // BOSS seems to be doing better here. @@ -144,7 +144,7 @@ public Graph search() { var best = permutationSearch.getOrder(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Best order: " + best); + TetradLogger.getInstance().log("Best order: " + best); } var scorer = new TeyssierScorer(null, score); @@ -152,8 +152,8 @@ public Graph search() { scorer.bookmark(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Initializing PAG to BOSS CPDAG."); - TetradLogger.getInstance().forceLogMessage("Initializing scorer with BOSS best order."); + TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); } var dag = scorer.getGraph(false); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 777345cec8..24bb16acfd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -120,7 +120,7 @@ public LvLite(Score score) { */ private void reorientWithCircles(Graph pag) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient all edges in PAG as o-o:"); + TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); } pag.reorientAllWith(Endpoint.CIRCLE); } @@ -138,11 +138,11 @@ public Graph search() { } if (verbose) { - TetradLogger.getInstance().forceLogMessage("===Starting LV-Lite==="); + TetradLogger.getInstance().log("===Starting LV-Lite==="); } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Running BOSS to get CPDAG and best order."); + TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); } // BOSS seems to be doing better here. @@ -160,7 +160,7 @@ public Graph search() { var best = permutationSearch.getOrder(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Best order: " + best); + TetradLogger.getInstance().log("Best order: " + best); } var scorer = new TeyssierScorer(null, score); @@ -168,8 +168,8 @@ public Graph search() { scorer.bookmark(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Initializing PAG to BOSS CPDAG."); - TetradLogger.getInstance().forceLogMessage("Initializing scorer with BOSS best order."); + TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); } var cpdag = scorer.getGraph(true); @@ -186,7 +186,7 @@ public Graph search() { fciOrient.setVerbose(verbose); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Collider orientation and edge removal."); + TetradLogger.getInstance().log("Collider orientation and edge removal."); } // The main procedure. @@ -305,7 +305,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< pag.removeEdge(x, y); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } @@ -346,7 +346,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< unshieldedColliders.add(new Triple(x, b, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } else if (allowTucks && pag.isAdjacentTo(x, y)) { @@ -364,7 +364,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< if (pag.removeEdge(x, y)) { if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); } } @@ -416,7 +416,7 @@ && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(y, b, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } @@ -436,7 +436,7 @@ && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(y, b, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } @@ -465,7 +465,7 @@ && colliderAllowed(pag, x, a, y)) { unshieldedColliders.add(new Triple(x, a, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } @@ -486,7 +486,7 @@ && colliderAllowed(pag, x, a, y)) { unshieldedColliders.add(new Triple(x, a, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } @@ -518,7 +518,7 @@ private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { */ private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient required edges in PAG:"); + TetradLogger.getInstance().log("Orient required edges in PAG:"); } fciOrient.fciOrientbk(knowledge, pag, best); @@ -573,7 +573,7 @@ private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { */ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Final Orientation:"); + TetradLogger.getInstance().log("Final Orientation:"); } do { @@ -799,7 +799,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -810,7 +810,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.TAIL); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index e79a19c193..778fd112b2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -186,7 +186,7 @@ public LvLiteDsepFriendly(@NotNull IndependenceTest test, Score score) { */ private void reorientWithCircles(Graph pag) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient all edges in PAG as o-o:"); + TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); } pag.reorientAllWith(Endpoint.CIRCLE); } @@ -204,11 +204,11 @@ public Graph search() { } if (verbose) { - TetradLogger.getInstance().forceLogMessage("===Starting LV-Lite==="); + TetradLogger.getInstance().log("===Starting LV-Lite==="); } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Running BOSS to get CPDAG and best order."); + TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); } test.setVerbose(false); @@ -239,7 +239,7 @@ public Graph search() { grasp.getGraph(true); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Best order: " + best); + TetradLogger.getInstance().log("Best order: " + best); } var scorer = new TeyssierScorer(test, score); @@ -248,8 +248,8 @@ public Graph search() { scorer.bookmark(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Initializing PAG to BOSS CPDAG."); - TetradLogger.getInstance().forceLogMessage("Initializing scorer with BOSS best order."); + TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); } var cpdag = scorer.getGraph(true); @@ -272,7 +272,7 @@ public Graph search() { fciOrient.setVerbose(verbose); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Collider orientation and edge removal."); + TetradLogger.getInstance().log("Collider orientation and edge removal."); } // The main procedure. @@ -345,7 +345,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< pag.removeEdge(x, y); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } @@ -386,7 +386,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< unshieldedColliders.add(new Triple(x, b, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } else if (allowTucks && pag.isAdjacentTo(x, y)) { @@ -404,7 +404,7 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< if (pag.removeEdge(x, y)) { if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); } } @@ -456,7 +456,7 @@ && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(y, b, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } @@ -476,7 +476,7 @@ && colliderAllowed(pag, x, b, y)) { pag.setEndpoint(y, b, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } @@ -505,7 +505,7 @@ && colliderAllowed(pag, x, a, y)) { unshieldedColliders.add(new Triple(x, a, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } @@ -526,7 +526,7 @@ && colliderAllowed(pag, x, a, y)) { unshieldedColliders.add(new Triple(x, a, y)); if (verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } @@ -572,7 +572,7 @@ private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { */ private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient required edges in PAG:"); + TetradLogger.getInstance().log("Orient required edges in PAG:"); } fciOrient.fciOrientbk(knowledge, pag, best); @@ -614,7 +614,7 @@ private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { */ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Final Orientation:"); + TetradLogger.getInstance().log("Final Orientation:"); } do { @@ -840,7 +840,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -851,7 +851,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.TAIL); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java index 01c5943374..af9b1fa41e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java @@ -20,7 +20,6 @@ import java.io.BufferedWriter; import java.io.FileWriter; import java.io.IOException; -import java.lang.reflect.Array; import java.text.DecimalFormat; import java.text.NumberFormat; import java.util.*; @@ -1213,7 +1212,7 @@ public Pair, Set> call() { msep.addAll(setPair.getFirst()); mconn.addAll(setPair.getSecond()); } catch (InterruptedException | ExecutionException e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); } } @@ -1314,7 +1313,7 @@ private void addResults(Set resultsIndep, Set nodes) { */ public Graph search(IFas fas, Set nodes) { if (verbose) { - this.logger.forceLogMessage("Starting PC algorithm"); - this.logger.forceLogMessage("Independence test = " + getIndependenceTest() + "."); + this.logger.log("Starting PC algorithm"); + this.logger.log("Independence test = " + getIndependenceTest() + "."); } long startTime = MillisecondTimes.timeMillis(); @@ -209,8 +209,8 @@ public Graph search(IFas fas, Set nodes) { this.elapsedTime = MillisecondTimes.timeMillis() - startTime; if (verbose) { - this.logger.forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - this.logger.forceLogMessage("Finishing PC Algorithm."); + this.logger.log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + this.logger.log("Finishing PC Algorithm."); this.logger.flush(); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java index d2edc0c3c1..508504c928 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PcMb.java @@ -178,13 +178,13 @@ public Graph search(List targets) { this.targets = targets; - TetradLogger.getInstance().forceLogMessage("Target = " + targets); + TetradLogger.getInstance().log("Target = " + targets); // Some statistics. this.maxRemainingAtDepth = new int[20]; Arrays.fill(this.maxRemainingAtDepth, -1); - TetradLogger.getInstance().forceLogMessage("targets = " + getTargets()); + TetradLogger.getInstance().log("targets = " + getTargets()); Graph graph = new EdgeListGraph(); @@ -199,7 +199,7 @@ public Graph search(List targets) { this.a = new HashSet<>(); // Step 1. Get associates for the targets. - TetradLogger.getInstance().forceLogMessage("BEGINNING step 1 (prune targets)."); + TetradLogger.getInstance().log("BEGINNING step 1 (prune targets)."); for (Node target : getTargets()) { if (target == null) throw new NullPointerException("Target not specified"); @@ -207,15 +207,15 @@ public Graph search(List targets) { graph.addNode(target); constructFan(target, graph); - TetradLogger.getInstance().forceLogMessage("After step 1 (prune targets)" + graph); - TetradLogger.getInstance().forceLogMessage("After step 1 (prune targets)" + graph); + TetradLogger.getInstance().log("After step 1 (prune targets)" + graph); + TetradLogger.getInstance().log("After step 1 (prune targets)" + graph); } // Step 2. Get associates for each variable adjacent to the targets, // removing edges based on those associates where possible. After this // step, adjacencies to the targets are parents or children of the targets. // Call this set PC. - TetradLogger.getInstance().forceLogMessage("BEGINNING step 2 (prune PC)."); + TetradLogger.getInstance().log("BEGINNING step 2 (prune PC)."); if (findMb) { for (Node target : getTargets()) { @@ -266,13 +266,13 @@ public Graph search(List targets) { } } - TetradLogger.getInstance().forceLogMessage("After step 2 (prune PC)" + graph); + TetradLogger.getInstance().log("After step 2 (prune PC)" + graph); // Step 3. Get associates for each node now two links away from the // targets, removing edges based on those associates where possible. // After this step, adjacencies to adjacencies of the targets are parents // or children of adjacencies to the targets. Call this set PCPC. - TetradLogger.getInstance().forceLogMessage("BEGINNING step 3 (prune PCPC)."); + TetradLogger.getInstance().log("BEGINNING step 3 (prune PCPC)."); for (Node v : graph.getAdjacentNodes(target)) { for (Node w : graph.getAdjacentNodes(v)) { @@ -286,9 +286,9 @@ public Graph search(List targets) { } } - TetradLogger.getInstance().forceLogMessage("After step 3 (prune PCPC)" + graph); + TetradLogger.getInstance().log("After step 3 (prune PCPC)" + graph); - TetradLogger.getInstance().forceLogMessage("BEGINNING step 4 (PC Orient)."); + TetradLogger.getInstance().log("BEGINNING step 4 (PC Orient)."); GraphSearchUtils.pcOrientbk(this.knowledge, graph, graph.getNodes(), verbose); @@ -300,10 +300,10 @@ public Graph search(List targets) { meekRules.setKnowledge(this.knowledge); meekRules.orientImplied(graph); - TetradLogger.getInstance().forceLogMessage("After step 4 (PC Orient)" + graph); + TetradLogger.getInstance().log("After step 4 (PC Orient)" + graph); - TetradLogger.getInstance().forceLogMessage("BEGINNING step 5 (Trim graph to {T} U PC U " + - "{Parents(Children(T))})."); + TetradLogger.getInstance().log("BEGINNING step 5 (Trim graph to {T} U PC U " + + "{Parents(Children(T))})."); if (findMb) { Set mb = new HashSet<>(); @@ -338,7 +338,7 @@ public Graph search(List targets) { } } - TetradLogger.getInstance().forceLogMessage("After step 6 (Remove edges among P and P of C)" + graph); + TetradLogger.getInstance().log("After step 6 (Remove edges among P and P of C)" + graph); finishUp(start, graph); @@ -586,8 +586,8 @@ private void prune(Node node, Graph graph) { * @param depth The maximum number of conditioning variables. */ private void prune(Node node, Graph graph, int depth) { - TetradLogger.getInstance().forceLogMessage("Trying to remove edges adjacent to node " + node + - ", depth = " + depth + "."); + TetradLogger.getInstance().log("Trying to remove edges adjacent to node " + node + + ", depth = " + depth + "."); // Otherwise, try removing all other edges adjacent node. Return // true if more edges could be removed at the next depth. @@ -644,9 +644,9 @@ private void finishUp(long start, Graph graph) { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); String message = "PC-MB took " + nf.format(seconds) + " seconds."; - TetradLogger.getInstance().forceLogMessage(message); - TetradLogger.getInstance().forceLogMessage("Number of independence tests performed = " + - getNumIndependenceTests()); + TetradLogger.getInstance().log(message); + TetradLogger.getInstance().log("Number of independence tests performed = " + + getNumIndependenceTests()); this.resultGraph = graph; } @@ -703,7 +703,7 @@ private void noteMaxAtDepth(int depth, int numAdjacents) { * @param nodes the specific nodes to orient triples for (if null, all nodes in the graph will be considered) */ private void orientUnshieldedTriples(Knowledge knowledge, Graph graph, int depth, List nodes) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); this.ambiguousTriples = new HashSet<>(); @@ -740,22 +740,22 @@ private void orientUnshieldedTriples(Knowledge knowledge, Graph graph, int depth graph.setEndpoint(x, y, Endpoint.ARROW); graph.setEndpoint(z, y, Endpoint.ARROW); String message = "Collider oriented: " + Triple.pathString(graph, x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } else if (type == TripleType.AMBIGUOUS) { Triple triple = new Triple(x, y, z); this.ambiguousTriples.add(triple); graph.addAmbiguousTriple(triple.getX(), triple.getY(), triple.getZ()); String message = "tripleClassifications: " + Triple.pathString(graph, x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "tripleClassifications: " + Triple.pathString(graph, x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pcd.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pcd.java index 34a6a80a4a..081c2a8bbc 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pcd.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Pcd.java @@ -254,9 +254,9 @@ public Graph search(List nodes) { public Graph search(IFas fas, List nodes) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting PC algorithm"); + TetradLogger.getInstance().log("Starting PC algorithm"); String message = "Independence test = " + getIndependenceTest() + "."; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } long startTime = MillisecondTimes.timeMillis(); @@ -294,8 +294,8 @@ public Graph search(IFas fas, List nodes) { this.elapsedTime = MillisecondTimes.timeMillis() - startTime; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing PC Algorithm."); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing PC Algorithm."); } return this.graph; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java index 0df5fd2495..7b00caa66f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Rfci.java @@ -168,8 +168,8 @@ public Graph search(IFas fas, List nodes) { independenceTest.setVerbose(verbose); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting RFCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting RFCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } setMaxPathLength(this.maxPathLength); @@ -204,8 +204,8 @@ public Graph search(IFas fas, List nodes) { long stop2 = MillisecondTimes.timeMillis(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time adjacency search = " + (stop1 - start1) / 1000L + "s"); - TetradLogger.getInstance().forceLogMessage("Elapsed time orientation search = " + (stop2 - start2) / 1000L + "s"); + TetradLogger.getInstance().log("Elapsed time adjacency search = " + (stop1 - start1) / 1000L + "s"); + TetradLogger.getInstance().log("Elapsed time orientation search = " + (stop2 - start2) / 1000L + "s"); } return this.graph; 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 934d57367a..c36f02371f 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 @@ -138,8 +138,8 @@ public Graph search() { List nodes = getIndependenceTest().getVariables(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting SP-FCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting SP-FCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } Sp subAlg = new Sp(this.score); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFas.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFas.java index d8ce0857a4..37711902f7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFas.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarFas.java @@ -125,7 +125,7 @@ public SvarFas(IndependenceTest test) { * @return a SepSet, which indicates which variables are independent conditional on which other variables */ public Graph search() { - TetradLogger.getInstance().forceLogMessage("Starting Fast Adjacency Search."); + TetradLogger.getInstance().log("Starting Fast Adjacency Search."); this.graph.removeEdges(this.graph.getEdges()); this.sepset = new SepsetMap(); int _depth = this.depth; @@ -166,7 +166,7 @@ public Graph search() { } } - TetradLogger.getInstance().forceLogMessage("Finishing Fast Adjacency Search."); + TetradLogger.getInstance().log("Finishing Fast Adjacency Search."); return this.graph; } @@ -356,7 +356,7 @@ private boolean searchAtDepth0(List nodes, IndependenceTest test, Map(); @@ -1447,18 +1447,18 @@ private boolean insert(Node x, Node y, Set T, double bump) { if (this.verbose) { String label = this.trueGraph != null && trueEdge != null ? "*" : ""; String message = this.graph.getNumEdges() + ". INSERT " + this.graph.getEdge(x, y) + " " + T + " " + bump + " " + label; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } int numEdges = this.graph.getNumEdges(); if (verbose) { - if (numEdges % 1000 == 0) TetradLogger.getInstance().forceLogMessage("Num edges added: " + numEdges); + if (numEdges % 1000 == 0) TetradLogger.getInstance().log("Num edges added: " + numEdges); } if (this.verbose) { String label = this.trueGraph != null && trueEdge != null ? "*" : ""; - TetradLogger.getInstance().forceLogMessage(this.graph.getNumEdges() + ". INSERT " + this.graph.getEdge(x, y) + " " + T + " " + bump + " " + label + " degree = " + GraphUtils.getDegree(this.graph) + " indegree = " + GraphUtils.getIndegree(this.graph)); + TetradLogger.getInstance().log(this.graph.getNumEdges() + ". INSERT " + this.graph.getEdge(x, y) + " " + T + " " + bump + " " + label + " degree = " + GraphUtils.getDegree(this.graph) + " indegree = " + GraphUtils.getIndegree(this.graph)); } for (Node _t : T) { @@ -1477,7 +1477,7 @@ private boolean insert(Node x, Node y, Set T, double bump) { if (this.verbose) { String message = "--- Directing " + this.graph.getEdge(_t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -1516,13 +1516,13 @@ private boolean delete(Node x, Node y, Set H, double bump, Set naYX) int numEdges = this.graph.getNumEdges(); if (verbose) { - if (numEdges % 1000 == 0) TetradLogger.getInstance().forceLogMessage("Num edges (backwards) = " + numEdges); + if (numEdges % 1000 == 0) TetradLogger.getInstance().log("Num edges (backwards) = " + numEdges); } if (this.verbose) { String label = this.trueGraph != null && trueEdge != null ? "*" : ""; String message = (this.graph.getNumEdges()) + ". DELETE " + x + "-->" + y + " H = " + H + " NaYX = " + naYX + " diff = " + diff + " (" + bump + ") " + label; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Node h : H) { @@ -1540,7 +1540,7 @@ private boolean delete(Node x, Node y, Set H, double bump, Set naYX) if (this.verbose) { String message = "--- Directing " + oldyh + " to " + this.graph.getEdge(y, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } Edge oldxh = this.graph.getEdge(x, h); @@ -1557,7 +1557,7 @@ private boolean delete(Node x, Node y, Set H, double bump, Set naYX) if (this.verbose) { String message = "--- Directing " + oldxh + " to " + this.graph.getEdge(x, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1661,7 +1661,7 @@ private void addRequiredEdges(Graph graph) { if (verbose) { String message = "Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1684,7 +1684,7 @@ private void addRequiredEdges(Graph graph) { if (verbose) { String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1696,7 +1696,7 @@ private void addRequiredEdges(Graph graph) { if (verbose) { String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1711,7 +1711,7 @@ private void addRequiredEdges(Graph graph) { if (verbose) { String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1722,7 +1722,7 @@ private void addRequiredEdges(Graph graph) { if (verbose) { String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarGfci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarGfci.java index fb46e43402..ccee65234f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarGfci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/SvarGfci.java @@ -108,8 +108,8 @@ public Graph search() { independenceTest.setVerbose(verbose); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting svarGFCI algorithm."); - TetradLogger.getInstance().forceLogMessage("Independence test = " + this.independenceTest + "."); + TetradLogger.getInstance().log("Starting svarGFCI algorithm."); + TetradLogger.getInstance().log("Independence test = " + this.independenceTest + "."); } this.graph = new EdgeListGraph(independenceTest.getVariables()); @@ -335,7 +335,7 @@ private void modifiedR0(Graph fgesGraph) { */ private void fciOrientbk(Knowledge knowledge, Graph graph, List variables) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting BK Orientation."); + TetradLogger.getInstance().log("Starting BK Orientation."); } for (Iterator it = knowledge.forbiddenEdgesIterator(); it.hasNext(); ) { @@ -359,7 +359,7 @@ private void fciOrientbk(Knowledge knowledge, Graph graph, List variables) if (verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -383,12 +383,12 @@ private void fciOrientbk(Knowledge knowledge, Graph graph, List variables) if (verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing BK Orientation."); + TetradLogger.getInstance().log("Finishing BK Orientation."); } } @@ -479,8 +479,8 @@ private void orientSimilarPairs(Graph graph, Knowledge knowledge, Node x, Node y graph.setEndpoint(x1, y1, Endpoint.ARROW); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Orient edge " + graph.getEdge(x1, y1).toString()); - TetradLogger.getInstance().forceLogMessage(" by structure knowledge as: " + graph.getEdge(x1, y1).toString()); + TetradLogger.getInstance().log("Orient edge " + graph.getEdge(x1, y1).toString()); + TetradLogger.getInstance().log(" by structure knowledge as: " + graph.getEdge(x1, y1).toString()); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/SemBicScore.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/SemBicScore.java index a22ee14c13..1a121c5e80 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/SemBicScore.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/score/SemBicScore.java @@ -570,7 +570,7 @@ public boolean determines(List z, Node y) { try { localScore(i, k); } catch (RuntimeException e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); return true; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ConditionalCorrelationIndependence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ConditionalCorrelationIndependence.java index e4e73d30cf..d01bfcae4d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ConditionalCorrelationIndependence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ConditionalCorrelationIndependence.java @@ -149,7 +149,7 @@ public double isIndependent(Node x, Node y, Set _z) { return score; } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); return 0; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestChiSquare.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestChiSquare.java index 22eb277e62..a7f79d6de5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestChiSquare.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestChiSquare.java @@ -236,7 +236,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (verbose) { if (result.isIndep()) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } @@ -316,7 +316,7 @@ public boolean determines(List z, Node x) { sb.append("}"); - TetradLogger.getInstance().forceLogMessage(sb.toString()); + TetradLogger.getInstance().log(sb.toString()); } return countDetermined; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalCorrelation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalCorrelation.java index 71fa833266..05033567d0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalCorrelation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalCorrelation.java @@ -141,7 +141,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, p)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java index 027b5569d1..a664451297 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java @@ -181,7 +181,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java index 312e5d0d44..33063cd5fe 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java @@ -271,7 +271,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java index 7acf3be1a2..1c046abb8c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java @@ -87,7 +87,7 @@ public final class IndTestFisherZ implements IndependenceTest, RowsSettable { */ private DataSet dataSet; /** - * Matrix from of the data. + * Matrix from of the data.a */ private Matrix data; /** @@ -266,7 +266,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, p)); } } @@ -365,7 +365,7 @@ private IndependenceResult checkIndependencePseudoinverse(Node xVar, Node yVar, if (this.verbose) { if (p > alpha) { - TetradLogger.getInstance().forceLogMessage(LogUtilsSearch.independenceFactMsg(xVar, yVar, _z, p)); + TetradLogger.getInstance().log(LogUtilsSearch.independenceFactMsg(xVar, yVar, _z, p)); } } @@ -643,7 +643,7 @@ private boolean determinesPseudoinverse(List zList, Node xVar) { sb.append(" SSE = ").append(NumberFormatUtil.getInstance().getNumberFormat().format(SSE)); if (verbose) { - TetradLogger.getInstance().forceLogMessage(sb.toString()); + TetradLogger.getInstance().log(sb.toString()); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZConcatenateResiduals.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZConcatenateResiduals.java index e7f911a708..4ee7883ba2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZConcatenateResiduals.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZConcatenateResiduals.java @@ -187,7 +187,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZFisherPValue.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZFisherPValue.java index 032578b3f4..62c9cedb0c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZFisherPValue.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZFisherPValue.java @@ -191,7 +191,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, p)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestGSquare.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestGSquare.java index 62da0796d2..67dfe90f1c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestGSquare.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestGSquare.java @@ -204,7 +204,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (result.isIndep()) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, getPValue())); } } @@ -311,7 +311,7 @@ public boolean determines(Set _z, Node x) { sb.append("}"); - TetradLogger.getInstance().forceLogMessage(sb.toString()); + TetradLogger.getInstance().log(sb.toString()); } return determined; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestHsic.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestHsic.java index f6b89ceaee..424686bc43 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestHsic.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestHsic.java @@ -334,7 +334,7 @@ public IndependenceResult checkIndependence(Node y, Node x, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestIndependenceFacts.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestIndependenceFacts.java index 51961f9b9c..00a55db487 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestIndependenceFacts.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestIndependenceFacts.java @@ -98,7 +98,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set __z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, __z, getPValue())); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMulti.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMulti.java index 54425dcf5e..05cf64c289 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMulti.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMulti.java @@ -108,10 +108,10 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (independent) { String message = "In aggregate independent: " + LogUtilsSearch.independenceFact(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "In aggregate dependent: " + LogUtilsSearch.independenceFact(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } IndependenceResult result = new IndependenceResult(new IndependenceFact(x, y, z), independent, diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMvpLrt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMvpLrt.java index 765b9b1403..62e89b0de3 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMvpLrt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestMvpLrt.java @@ -158,12 +158,12 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { try { p_0 = 1.0 - new ChiSquaredDistribution(dof_0).cumulativeProbability(2.0 * lik_0); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); } try { p_1 = 1.0 - new ChiSquaredDistribution(dof_1).cumulativeProbability(2.0 * lik_1); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); } double pValue = FastMath.min(p_0, p_1); @@ -177,7 +177,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestProbabilistic.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestProbabilistic.java index 3e51435c2a..c74e1291c1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestProbabilistic.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestProbabilistic.java @@ -237,7 +237,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Node... z) { if (this.verbose) { if (ind) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, GraphUtils.asSet(z), p)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestRegression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestRegression.java index 80367779fc..70813e49e7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestRegression.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestRegression.java @@ -158,16 +158,16 @@ public IndependenceResult checkIndependence(Node xVar, Node yVar, Set zLis if (this.verbose) { if (independent) { String message = LogUtilsSearch.independenceFactMsg(xVar, yVar, zList, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = LogUtilsSearch.dependenceFactMsg(xVar, yVar, zList, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(xVar, yVar, zList, p)); } } @@ -290,7 +290,7 @@ public boolean determines(List zList, Node xVar) { sb.append("}"); - TetradLogger.getInstance().forceLogMessage(sb.toString()); + TetradLogger.getInstance().log(sb.toString()); } return determined; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java index bbc1d0c545..077ba4865e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java @@ -172,8 +172,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -183,8 +183,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/Kci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/Kci.java index f47470adce..2efd9c82cd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/Kci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/Kci.java @@ -170,9 +170,9 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { double p = result.getPValue(); if (result.isIndependent()) { - TetradLogger.getInstance().forceLogMessage(fact + " INDEPENDENT p = " + p); + TetradLogger.getInstance().log(fact + " INDEPENDENT p = " + p); } else { - TetradLogger.getInstance().forceLogMessage(fact + " dependent p = " + p); + TetradLogger.getInstance().log(fact + " dependent p = " + p); } } @@ -242,10 +242,10 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { double p = result.getPValue(); if (result.isIndependent()) { - TetradLogger.getInstance().forceLogMessage(fact + " INDEPENDENT p = " + p); + TetradLogger.getInstance().log(fact + " INDEPENDENT p = " + p); } else { - TetradLogger.getInstance().forceLogMessage(fact + " dependent p = " + p); + TetradLogger.getInstance().log(fact + " dependent p = " + p); } } @@ -467,7 +467,7 @@ private IndependenceResult isIndependentUnconditional(Node x, Node y, Independen return theorem4(kx, ky, fact, N); } } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); IndependenceResult result = new IndependenceResult(fact, false, 0.0, getAlpha()); this.facts.put(fact, result); return result; @@ -499,7 +499,7 @@ private IndependenceResult isIndependentConditional(Node x, Node y, Set _z return proposition5(kx, ky, fact, N); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage(e.getMessage()); + TetradLogger.getInstance().log(e.getMessage()); boolean indep = false; IndependenceResult result = new IndependenceResult(fact, indep, 0.0, getAlpha()); this.facts.put(fact, result); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/MsepTest.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/MsepTest.java index b8edf38925..d850a3dfbe 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/MsepTest.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/MsepTest.java @@ -263,7 +263,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (mSeparated) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, 1.0)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ScoreIndTest.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ScoreIndTest.java index d99a2aa18c..dce71c0b36 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ScoreIndTest.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/ScoreIndTest.java @@ -129,7 +129,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (independent) { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFact(x, y, z) + " score = " + nf.format(v)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Bes.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Bes.java index 9bb93c9916..3f11005ecb 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Bes.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Bes.java @@ -179,7 +179,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr int cond = diff.size() + graph.getParents(y).size(); String message = (graph.getNumEdges()) + ". DELETE " + x + " --> " + y + " H = " + H + " NaYX = " + naYX + " degree = " + GraphUtils.getDegree(graph) + " indegree = " + GraphUtils.getIndegree(graph) + " diff = " + diff + " (" + bump + ") " + " cond = " + cond; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Node h : H) { @@ -194,7 +194,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr graph.addEdge(directedEdge(y, h)); if (verbose) { - TetradLogger.getInstance().forceLogMessage("--- Directing " + oldyh + " to " + graph.getEdge(y, h)); + TetradLogger.getInstance().log("--- Directing " + oldyh + " to " + graph.getEdge(y, h)); } Edge oldxh = graph.getEdge(x, h); @@ -205,7 +205,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr graph.addEdge(directedEdge(x, h)); if (verbose) { - TetradLogger.getInstance().forceLogMessage("--- Directing " + oldxh + " to " + graph.getEdge(x, h)); + TetradLogger.getInstance().log("--- Directing " + oldxh + " to " + graph.getEdge(x, h)); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java index 56aa361277..64a0336b9e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java @@ -162,7 +162,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr int cond = diff.size() + graph.getParents(y).size(); String message = (graph.getNumEdges()) + ". DELETE " + x + " --> " + y + " H = " + H + " NaYX = " + naYX + " degree = " + GraphUtils.getDegree(graph) + " indegree = " + GraphUtils.getIndegree(graph) + " diff = " + diff + " (" + bump + ") " + " cond = " + cond; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Node h : H) { @@ -177,7 +177,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr graph.addEdge(directedEdge(y, h)); if (verbose) { - TetradLogger.getInstance().forceLogMessage("--- Directing " + oldyh + " to " + graph.getEdge(y, h)); + TetradLogger.getInstance().log("--- Directing " + oldyh + " to " + graph.getEdge(y, h)); } Edge oldxh = graph.getEdge(x, h); @@ -188,7 +188,7 @@ private void delete(Node x, Node y, Set H, double bump, Set naYX, Gr graph.addEdge(directedEdge(x, h)); if (verbose) { - TetradLogger.getInstance().forceLogMessage("--- Directing " + oldxh + " to " + graph.getEdge(x, h)); + TetradLogger.getInstance().log("--- Directing " + oldxh + " to " + graph.getEdge(x, h)); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java index 13a6c6107e..4eb5e38ec5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java @@ -106,8 +106,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -117,8 +117,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java index fa46ce5225..528ceb31f0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java @@ -184,8 +184,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -195,8 +195,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterSignificance.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterSignificance.java index 2ed7f937bc..90be2c8e81 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterSignificance.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterSignificance.java @@ -111,11 +111,11 @@ public void printClusterPValues(Set> clusters) { try { double p = clusterSignificance.significance(new ArrayList<>(_out)); - TetradLogger.getInstance().forceLogMessage("OUT: " + variablesForIndices(new ArrayList<>(_out), variables) - + " p = " + nf.format(p)); + TetradLogger.getInstance().log("OUT: " + variablesForIndices(new ArrayList<>(_out), variables) + + " p = " + nf.format(p)); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("OUT: " + variablesForIndices(new ArrayList<>(_out), variables) - + " p = EXCEPTION"); + TetradLogger.getInstance().log("OUT: " + variablesForIndices(new ArrayList<>(_out), variables) + + " p = EXCEPTION"); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterUtils.java index 37a335c840..407f9e3989 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ClusterUtils.java @@ -264,7 +264,7 @@ public static void logClusters(Set> clusters, List variables) buf.append("\n"); } - TetradLogger.getInstance().forceLogMessage(buf.toString()); + TetradLogger.getInstance().log(buf.toString()); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java index 15306b6261..5a990b716e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java @@ -232,20 +232,20 @@ public static boolean isArrowheadAllowed(Node x, Node y, Graph graph, Knowledge */ public Graph orient(Graph graph) { if (verbose) { - this.logger.forceLogMessage("Starting FCI orientation."); + this.logger.log("Starting FCI orientation."); } ruleR0(graph); if (this.verbose) { - logger.forceLogMessage("R0"); + logger.log("R0"); } // Step CI D. (Zhang's step F4.) doFinalOrientation(graph); if (this.verbose) { - this.logger.forceLogMessage("Returning graph: " + graph); + this.logger.log("Returning graph: " + graph); } return graph; @@ -349,7 +349,7 @@ public void ruleR0(Graph graph) { graph.setEndpoint(a, b, Endpoint.ARROW); graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { - this.logger.forceLogMessage(LogUtilsSearch.colliderOrientedMsg(a, b, c)); + this.logger.log(LogUtilsSearch.colliderOrientedMsg(a, b, c)); } } } @@ -396,7 +396,7 @@ public void spirtesFinalOrientation(Graph graph) { } if (this.verbose) { - logger.forceLogMessage("Epoch"); + logger.log("Epoch"); } } } @@ -422,7 +422,7 @@ public void zhangFinalOrientation(Graph graph) { } if (this.verbose) { - logger.forceLogMessage("Epoch"); + logger.log("Epoch"); } } @@ -515,7 +515,7 @@ public void ruleR1(Node a, Node b, Node c, Graph graph) { this.changeFlag = true; if (this.verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R1: Away from collider", graph.getEdge(b, c))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R1: Away from collider", graph.getEdge(b, c))); } } } @@ -543,7 +543,7 @@ public void ruleR2(Node a, Node b, Node c, Graph graph) { graph.setEndpoint(a, c, Endpoint.ARROW); if (this.verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R2: Away from ancestor", graph.getEdge(a, c))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R2: Away from ancestor", graph.getEdge(a, c))); } this.changeFlag = true; @@ -596,7 +596,7 @@ public void ruleR3(Graph graph) { graph.setEndpoint(d, b, Endpoint.ARROW); if (this.verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R3: Double triangle", graph.getEdge(d, b))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R3: Double triangle", graph.getEdge(d, b))); } this.changeFlag = true; @@ -799,7 +799,7 @@ public void ruleR5(Graph graph) { graph.setEndpoint(b, a, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg( + this.logger.log(LogUtilsSearch.edgeOrientedMsg( "R5: Orient circle path", graph.getEdge(a, b))); } @@ -855,7 +855,7 @@ public void ruleR6R7(Graph graph) { graph.setEndpoint(c, b, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg( + this.logger.log(LogUtilsSearch.edgeOrientedMsg( "R6: Single tails (tail)", graph.getEdge(c, b))); } @@ -868,7 +868,7 @@ public void ruleR6R7(Graph graph) { graph.setEndpoint(c, b, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R7: Single tails (tail)", graph.getEdge(c, b))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R7: Single tails (tail)", graph.getEdge(c, b))); } // We know A--oBo-*C and A,C nonadjacent: R7 applies! @@ -984,7 +984,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path } if (this.verbose) { - logger.forceLogMessage("Sepset for e = " + e + " and c = " + c + " = " + sepset); + logger.log("Sepset for e = " + e + " and c = " + c + " = " + sepset); } boolean collider = !sepset.contains(b); @@ -995,7 +995,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -1006,7 +1006,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.TAIL); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -1031,7 +1031,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { - this.logger.forceLogMessage( + this.logger.log( "R4: Definite discriminating path collider rule d = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -1040,7 +1040,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(c, b, Endpoint.TAIL); if (this.verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg( + this.logger.log(LogUtilsSearch.edgeOrientedMsg( "R4: Definite discriminating path tail rule d = " + e, graph.getEdge(b, c))); } @@ -1070,8 +1070,8 @@ public void orientTailPath(List path, Graph graph) { this.changeFlag = true; if (verbose) { - this.logger.forceLogMessage("R8: Orient circle undirectedPaths " + - GraphUtils.pathString(graph, n1, n2)); + this.logger.log("R8: Orient circle undirectedPaths " + + GraphUtils.pathString(graph, n1, n2)); } } } @@ -1117,7 +1117,7 @@ public boolean ruleR8(Node a, Node c, Graph graph) { graph.setEndpoint(c, a, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R8: ", graph.getEdge(c, a))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R8: ", graph.getEdge(c, a))); } this.changeFlag = true; @@ -1161,7 +1161,7 @@ public boolean ruleR9(Node a, Node c, Graph graph) { graph.setEndpoint(c, a, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R9: ", graph.getEdge(c, a))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R9: ", graph.getEdge(c, a))); } this.changeFlag = true; @@ -1180,7 +1180,7 @@ public boolean ruleR9(Node a, Node c, Graph graph) { */ public void fciOrientbk(Knowledge bk, Graph graph, List variables) { if (verbose) { - this.logger.forceLogMessage("Starting BK Orientation."); + this.logger.log("Starting BK Orientation."); } for (Iterator it @@ -1212,7 +1212,7 @@ public void fciOrientbk(Knowledge bk, Graph graph, List variables) { this.changeFlag = true; if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(to, from))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(to, from))); } } @@ -1245,12 +1245,12 @@ public void fciOrientbk(Knowledge bk, Graph graph, List variables) { this.changeFlag = true; if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to))); } } if (verbose) { - this.logger.forceLogMessage("Finishing BK Orientation."); + this.logger.log("Finishing BK Orientation."); } } @@ -1381,7 +1381,7 @@ public void ruleR10(Node a, Node c, Graph graph) { graph.setEndpoint(c, a, Endpoint.TAIL); if (verbose) { - this.logger.forceLogMessage(LogUtilsSearch.edgeOrientedMsg("R10: ", graph.getEdge(c, a))); + this.logger.log(LogUtilsSearch.edgeOrientedMsg("R10: ", graph.getEdge(c, a))); } this.changeFlag = true; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FgesOrienter.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FgesOrienter.java index 622076b77f..4d30313599 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FgesOrienter.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FgesOrienter.java @@ -328,7 +328,7 @@ public Graph search() { this.elapsedTime = endTime - start; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); } return graph; @@ -681,7 +681,7 @@ protected Boolean compute() { * @param graph The graph in the state prior to the forward equivalence search. */ private void fes(Graph graph) { - TetradLogger.getInstance().forceLogMessage("** FORWARD EQUIVALENCE SEARCH"); + TetradLogger.getInstance().log("** FORWARD EQUIVALENCE SEARCH"); while (!this.sortedArrows.isEmpty()) { Arrow arrow = this.sortedArrows.first(); @@ -746,7 +746,7 @@ private Set adjNodes(Graph graph, Node x, Node y) { * @param graph The graph in the state after the forward equivalence search. */ private void bes(Graph graph) { - TetradLogger.getInstance().forceLogMessage("** BACKWARD EQUIVALENCE SEARCH"); + TetradLogger.getInstance().log("** BACKWARD EQUIVALENCE SEARCH"); initializeArrowsBackward(graph); @@ -1105,7 +1105,7 @@ private void insert(Node x, Node y, Set t, Graph graph, double bump) { String label = this.trueGraph != null && trueEdge != null ? "*" : ""; String message = graph.getNumEdges() + ". INSERT " + graph.getEdge(x, y) + " " + t + " " + bump + " " + label; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } int numEdges = graph.getNumEdges(); @@ -1128,7 +1128,7 @@ private void insert(Node x, Node y, Set t, Graph graph, double bump) { if (this.log && this.verbose) { String message = "--- Directing " + oldEdge + " to " + graph.getEdge(_t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); this.out.println("--- Directing " + oldEdge + " to " + graph.getEdge(_t, y)); } @@ -1158,7 +1158,7 @@ private void delete(Node x, Node y, Set subset, Graph graph, double bump) String label = this.trueGraph != null && trueEdge != null ? "*" : ""; String message = (graph.getNumEdges() - 1) + ". DELETE " + oldEdge + " " + subset + " (" + bump + ") " + label; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); this.out.println((graph.getNumEdges()) + ". DELETE " + oldEdge + " " + subset + " (" + bump + ") " + label); } @@ -1172,7 +1172,7 @@ private void delete(Node x, Node y, Set subset, Graph graph, double bump) if (this.log) { String message = "--- Directing " + oldEdge + " to " + graph.getEdge(y, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } if (this.verbose) { @@ -1194,8 +1194,8 @@ private void delete(Node x, Node y, Set subset, Graph graph, double bump) graph.addDirectedEdge(x, h); if (this.log) { - TetradLogger.getInstance().forceLogMessage("--- Directing " + oldEdge + " to " + - edge); + TetradLogger.getInstance().log("--- Directing " + oldEdge + " to " + + edge); } if (this.verbose) { @@ -1255,7 +1255,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeA, nodeB); String message = "Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } for (Edge edge : graph.getEdges()) { @@ -1271,7 +1271,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -1280,7 +1280,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } else if (this.knowledge.isForbidden(B, A)) { @@ -1292,7 +1292,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } if (!graph.isChildOf(nodeA, nodeB) && getKnowledge().isForbidden(nodeA.getName(), nodeB.getName())) { @@ -1300,7 +1300,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -1369,7 +1369,7 @@ private Set rebuildCPDAGRestricted(Graph graph, Node x, Node y) { visited.addAll(reorientNode(graph, y)); if (true) { - TetradLogger.getInstance().forceLogMessage("Rebuilt CPDAG = " + graph); + TetradLogger.getInstance().log("Rebuilt CPDAG = " + graph); } return visited; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphSearchUtils.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphSearchUtils.java index b88e495c38..b142767634 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphSearchUtils.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphSearchUtils.java @@ -69,7 +69,7 @@ private GraphSearchUtils() { */ public static void pcOrientbk(Knowledge bk, Graph graph, List nodes, boolean verbose) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting BK Orientation."); + TetradLogger.getInstance().log("Starting BK Orientation."); } for (Iterator it = bk.forbiddenEdgesIterator(); it.hasNext(); ) { @@ -112,11 +112,11 @@ public static void pcOrientbk(Knowledge bk, Graph graph, List nodes, boole graph.addDirectedEdge(from, to); String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing BK Orientation."); + TetradLogger.getInstance().log("Finishing BK Orientation."); } } @@ -130,7 +130,7 @@ public static void pcOrientbk(Knowledge bk, Graph graph, List nodes, boole * @param graph a {@link edu.cmu.tetrad.graph.Graph} object */ public static void pcdOrientC(IndependenceTest test, Knowledge knowledge, Graph graph) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); List nodes = graph.getNodes(); @@ -193,11 +193,11 @@ public static void pcdOrientC(IndependenceTest test, Knowledge knowledge, Graph System.out.println(LogUtilsSearch.colliderOrientedMsg(x, y, z) + " sepset = " + sepset); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } private static Set sepset(Graph graph, Node a, Node c, Set containing, Set notContaining, IndependenceTest independenceTest) { @@ -242,7 +242,7 @@ private static Set sepset(Graph graph, Node a, Node c, Set containin */ public static void orientCollidersUsingSepsets(SepsetMap set, Knowledge knowledge, Graph graph, boolean verbose, boolean enforceCpdag) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); List nodes = graph.getNodes(); for (Node b : nodes) { @@ -292,13 +292,13 @@ public static void orientCollidersUsingSepsets(SepsetMap set, Knowledge knowledg graph.addDirectedEdge(c, b); String message = LogUtilsSearch.colliderOrientedMsg(a, b, c, sepset); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } @@ -805,7 +805,7 @@ public static CpcTripleType getCpcTripleType(Node x, Node y, Node z, List _nodes = new ArrayList<>(graph.getAdjacentNodes(x)); _nodes.remove(z); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); int _depth = depth; if (_depth == -1) { @@ -836,7 +836,7 @@ public static CpcTripleType getCpcTripleType(Node x, Node y, Node z, _nodes = new ArrayList<>(graph.getAdjacentNodes(z)); _nodes.remove(x); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); _depth = FastMath.min(_depth, _nodes.size()); @@ -888,11 +888,11 @@ public static int structuralHammingDistance(Graph trueGraph, Graph estGraph) { // Will check mixedness later. if (trueGraph.paths().existsDirectedCycle()) { - TetradLogger.getInstance().forceLogMessage("SHD failed: True graph couldn't be converted to a CPDAG"); + TetradLogger.getInstance().log("SHD failed: True graph couldn't be converted to a CPDAG"); } if (estGraph.paths().existsDirectedCycle()) { - TetradLogger.getInstance().forceLogMessage("SHD failed: Estimated graph couldn't be converted to a CPDAG"); + TetradLogger.getInstance().log("SHD failed: Estimated graph couldn't be converted to a CPDAG"); return -99; } @@ -907,12 +907,12 @@ public static int structuralHammingDistance(Graph trueGraph, Graph estGraph) { Edge e2 = estGraph.getEdge(n1, n2); if (e1 != null && !(Edges.isDirectedEdge(e1) || Edges.isUndirectedEdge(e1))) { - TetradLogger.getInstance().forceLogMessage("SHD failed: True graph couldn't be converted to a CPDAG"); + TetradLogger.getInstance().log("SHD failed: True graph couldn't be converted to a CPDAG"); return -99; } if (e2 != null && !(Edges.isDirectedEdge(e2) || Edges.isUndirectedEdge(e2))) { - TetradLogger.getInstance().forceLogMessage("SHD failed: Estimated graph couldn't be converted to a CPDAG"); + TetradLogger.getInstance().log("SHD failed: Estimated graph couldn't be converted to a CPDAG"); return -99; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphoidAxioms.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphoidAxioms.java index e3b35e50e3..1907f08d67 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphoidAxioms.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/GraphoidAxioms.java @@ -245,7 +245,7 @@ public boolean symmetry() { } } - TetradLogger.getInstance().forceLogMessage("Symmetry fails for " + fact); + TetradLogger.getInstance().log("Symmetry fails for " + fact); return false; } @@ -290,13 +290,13 @@ public boolean decomposition() { GraphoidIndFact fact1 = new GraphoidIndFact(X, Y, Z); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Decomposition fails:" + - " Have " + textSpecs.get(fact) + - "; Missing " + fact1); + TetradLogger.getInstance().log("Decomposition fails:" + + " Have " + textSpecs.get(fact) + + "; Missing " + fact1); } else { - TetradLogger.getInstance().forceLogMessage("Decomposition fails:" + - " Have " + fact + - "; Missing " + fact1); + TetradLogger.getInstance().log("Decomposition fails:" + + " Have " + fact + + "; Missing " + fact1); } found0 = true; @@ -314,13 +314,13 @@ public boolean decomposition() { GraphoidIndFact fact1 = new GraphoidIndFact(X, W, Z); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Decomposition fails:" + - " Have " + textSpecs.get(fact) + - "; Missing " + fact1); + TetradLogger.getInstance().log("Decomposition fails:" + + " Have " + textSpecs.get(fact) + + "; Missing " + fact1); } else { - TetradLogger.getInstance().forceLogMessage("Decomposition fails:" + - " Have " + fact + - "; Missing " + fact1); + TetradLogger.getInstance().log("Decomposition fails:" + + " Have " + fact + + "; Missing " + fact1); } found0 = true; @@ -371,13 +371,13 @@ public boolean weakUnion() { GraphoidIndFact newFact = new GraphoidIndFact(X, Y, ZW); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Weak Union fails:" + - " Have " + textSpecs.get(fact) + - "; Missing " + newFact); + TetradLogger.getInstance().log("Weak Union fails:" + + " Have " + textSpecs.get(fact) + + "; Missing " + newFact); } else { - TetradLogger.getInstance().forceLogMessage("Weak Union fails:" + - " Have " + fact + - "; Missing " + newFact); + TetradLogger.getInstance().log("Weak Union fails:" + + " Have " + fact + + "; Missing " + newFact); } found0 = true; @@ -429,13 +429,13 @@ public boolean contraction() { GraphoidIndFact newFact = new GraphoidIndFact(X, YW, Z); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Contraction fails:" + - " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + - "; Missing " + newFact); + TetradLogger.getInstance().log("Contraction fails:" + + " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + + "; Missing " + newFact); } else { - TetradLogger.getInstance().forceLogMessage("Contraction fails:" + - " Have " + fact1 + " and " + fact2 + - "; Missing " + newFact); + TetradLogger.getInstance().log("Contraction fails:" + + " Have " + fact1 + " and " + fact2 + + "; Missing " + newFact); } found0 = true; @@ -501,13 +501,13 @@ public boolean intersection() { GraphoidIndFact newFact = new GraphoidIndFact(X, YW, Z); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Intersection fails:" + - " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + - "; Missing " + newFact); + TetradLogger.getInstance().log("Intersection fails:" + + " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + + "; Missing " + newFact); } else { - TetradLogger.getInstance().forceLogMessage("Intersection fails:" + - " Have " + fact1 + " and " + fact2 + - "; Missing " + newFact); + TetradLogger.getInstance().log("Intersection fails:" + + " Have " + fact1 + " and " + fact2 + + "; Missing " + newFact); } found0 = true; @@ -553,13 +553,13 @@ public boolean composition() { GraphoidIndFact newFact = new GraphoidIndFact(X, YW, Z); if (textSpecs != null) { - TetradLogger.getInstance().forceLogMessage("Composition fails:" + - " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + - "; Missing " + newFact); + TetradLogger.getInstance().log("Composition fails:" + + " Have " + textSpecs.get(fact1) + " and " + textSpecs.get(fact2) + + "; Missing " + newFact); } else { - TetradLogger.getInstance().forceLogMessage("Composition fails:" + - " Have " + fact1 + " and " + fact2 + - "; Missing " + newFact); + TetradLogger.getInstance().log("Composition fails:" + + " Have " + fact1 + " and " + fact2 + + "; Missing " + newFact); } found0 = true; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/LogUtilsSearch.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/LogUtilsSearch.java index ce0695be3c..bdb0bfa708 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/LogUtilsSearch.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/LogUtilsSearch.java @@ -298,7 +298,7 @@ public static void stampWithBic(Graph graph, DataModel dataModel) { try { graph.addAttribute("BIC", new BicEst().getValue(null, graph, dataModel)); } catch (Exception e) { - TetradLogger.getInstance().forceLogMessage("Error computing BIC: " + e.getMessage()); + TetradLogger.getInstance().log("Error computing BIC: " + e.getMessage()); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MeekRules.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MeekRules.java index cec282c1aa..92d80a02d6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MeekRules.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/MeekRules.java @@ -83,7 +83,7 @@ public Set orientImplied(Graph graph) { Set visited = new HashSet<>(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting Orientation Step D."); + TetradLogger.getInstance().log("Starting Orientation Step D."); } if (this.revertToUnshieldedColliders) { @@ -113,7 +113,7 @@ public Set orientImplied(Graph graph) { } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing Orientation Step D."); + TetradLogger.getInstance().log("Finishing Orientation Step D."); } return visited; @@ -352,7 +352,7 @@ private void revertToUnshieldedColliders(Node y, Graph graph, Set visited) private void log(String message) { if (this.verbose) { - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java index e7e14e514b..ca67cb1131 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/PcCommon.java @@ -174,7 +174,7 @@ public static void orientCollider(Node x, Node y, Node z, ConflictRule conflictR private static void forceLogMessage(String s, boolean verbose) { if (verbose) { - TetradLogger.getInstance().forceLogMessage(s); + TetradLogger.getInstance().log(s); } } @@ -244,8 +244,8 @@ public Graph search(List nodes) { nodes = new ArrayList<>(nodes); if (verbose) { - this.logger.forceLogMessage("Starting algorithm"); - this.logger.forceLogMessage("Independence test = " + getIndependenceTest() + "."); + this.logger.log("Starting algorithm"); + this.logger.log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ResolveSepsets.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ResolveSepsets.java index 598a4756e1..b2fff035ef 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ResolveSepsets.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/ResolveSepsets.java @@ -475,12 +475,12 @@ private static boolean isIndependentMajorityFdr(List independe if (independent) { String message = "***FDR judges " + LogUtilsSearch.independenceFact(x, y, condSet) + " independent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "###FDR judges " + LogUtilsSearch.independenceFact(x, y, condSet) + " dependent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } - TetradLogger.getInstance().forceLogMessage("c = " + c); + TetradLogger.getInstance().log("c = " + c); return independent; } @@ -526,12 +526,12 @@ private static boolean isIndependentMajorityIndep(List indepen if (independent) { String message = "***Majority = " + LogUtilsSearch.independenceFact(x, y, condSet) + " independent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "###Majority = " + LogUtilsSearch.independenceFact(x, y, condSet) + " dependent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } - TetradLogger.getInstance().forceLogMessage("c = " + c); + TetradLogger.getInstance().log("c = " + c); return independent; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java index 4ebf4cfbd3..5573b2801d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java @@ -221,8 +221,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -232,8 +232,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java index e086f52481..4dec5dbce2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/SvarFciOrient.java @@ -96,7 +96,7 @@ public SvarFciOrient(SepsetProducer sepsets, IndependenceTest independenceTest) public Graph orient(Graph graph) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting SVar-FCI orientation."); + TetradLogger.getInstance().log("Starting SVar-FCI orientation."); } ruleR0(graph); @@ -110,7 +110,7 @@ public Graph orient(Graph graph) { doFinalOrientation(graph); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Returning graph: " + graph); + TetradLogger.getInstance().log("Returning graph: " + graph); } return graph; @@ -220,7 +220,7 @@ public void ruleR0(Graph graph) { graph.setEndpoint(c, b, Endpoint.ARROW); if (this.verbose) { String message = LogUtilsSearch.colliderOrientedMsg(a, b, c); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.colliderOrientedMsg(a, b, c)); printWrongColliderMessage(a, b, c, graph); } @@ -370,7 +370,7 @@ private void ruleR1(Node a, Node b, Node c, Graph graph) { if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Away from collider", graph.getEdge(b, c)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.edgeOrientedMsg("Away from collider", graph.getEdge(b, c))); } this.orientSimilarPairs(graph, this.getKnowledge(), c, b, Endpoint.TAIL); @@ -397,7 +397,7 @@ private void ruleR2(Node a, Node b, Node c, Graph graph) { this.orientSimilarPairs(graph, this.getKnowledge(), a, c, Endpoint.ARROW); if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Away from ancestor", graph.getEdge(a, c)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.edgeOrientedMsg("Away from ancestor", graph.getEdge(a, c))); } @@ -459,7 +459,7 @@ public void ruleR3(Graph graph) { this.orientSimilarPairs(graph, this.getKnowledge(), D, B, Endpoint.ARROW); if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Double triangle", graph.getEdge(D, B)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.edgeOrientedMsg("Double triangle", graph.getEdge(D, B))); } @@ -615,7 +615,7 @@ private boolean doDdpOrientation(Node d, Node a, Node b, Node c, Map this.orientSimilarPairs(graph, this.getKnowledge(), c, b, Endpoint.TAIL); if (this.verbose) { String message = LogUtilsSearch.edgeOrientedMsg("Definite discriminating path d = " + d, graph.getEdge(b, c)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.edgeOrientedMsg("Definite discriminating path d = " + d, graph.getEdge(b, c))); } @@ -634,7 +634,7 @@ private boolean doDdpOrientation(Node d, Node a, Node b, Node c, Map this.orientSimilarPairs(graph, this.getKnowledge(), c, b, Endpoint.ARROW); if (this.verbose) { String message = LogUtilsSearch.colliderOrientedMsg("Definite discriminating path.. d = " + d, a, b, c); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(LogUtilsSearch.colliderOrientedMsg("Definite discriminating path.. d = " + d, a, b, c)); } @@ -688,7 +688,7 @@ public void ruleR5(Graph graph) { // We know u is as required: R5 applies! String message = LogUtilsSearch.edgeOrientedMsg("Orient circle path", graph.getEdge(a, b)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); graph.setEndpoint(a, b, Endpoint.TAIL); this.orientSimilarPairs(graph, this.getKnowledge(), a, b, Endpoint.TAIL); @@ -733,7 +733,7 @@ public void ruleR6R7(Graph graph) { graph.setEndpoint(c, b, Endpoint.TAIL); this.orientSimilarPairs(graph, this.getKnowledge(), c, b, Endpoint.TAIL); String message = LogUtilsSearch.edgeOrientedMsg("Single tails (tail)", graph.getEdge(c, b)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); this.changeFlag = true; } @@ -742,7 +742,7 @@ public void ruleR6R7(Graph graph) { // if (graph.isAdjacentTo(a, c)) continue; String message = LogUtilsSearch.edgeOrientedMsg("Single tails (tail)", graph.getEdge(c, b)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); // We know A--oBo-*C and A,C nonadjacent: R7 applies! graph.setEndpoint(c, b, Endpoint.TAIL); @@ -803,7 +803,7 @@ private void orientTailPath(List path, Graph graph) { this.changeFlag = true; String message = LogUtilsSearch.edgeOrientedMsg("Orient circle undirectedPaths", graph.getEdge(n1, n2)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -835,7 +835,7 @@ private boolean ruleR8(Node a, Node c, Graph graph) { // We have A-->B-->C or A--oB-->C: R8 applies! String message = LogUtilsSearch.edgeOrientedMsg("R8", graph.getEdge(c, a)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); graph.setEndpoint(c, a, Endpoint.TAIL); this.orientSimilarPairs(graph, this.getKnowledge(), c, a, Endpoint.TAIL); @@ -867,7 +867,7 @@ private boolean ruleR9(Node a, Node c, Graph graph) { // We know u is as required: R9 applies! String message = LogUtilsSearch.edgeOrientedMsg("R9", graph.getEdge(c, a)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); graph.setEndpoint(c, a, Endpoint.TAIL); this.orientSimilarPairs(graph, this.getKnowledge(), c, a, Endpoint.TAIL); @@ -916,7 +916,7 @@ private void ruleR10(Node a, Node c, Graph graph) { // We know B,D,u1,u2 as required: R10 applies! String message = LogUtilsSearch.edgeOrientedMsg("R10", graph.getEdge(c, a)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); graph.setEndpoint(c, a, Endpoint.TAIL); this.changeFlag = true; @@ -934,7 +934,7 @@ private void ruleR10(Node a, Node c, Graph graph) { */ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting BK Orientation."); + TetradLogger.getInstance().log("Starting BK Orientation."); } for (Iterator it = @@ -959,7 +959,7 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { graph.setEndpoint(from, to, Endpoint.CIRCLE); this.changeFlag = true; String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Iterator it = @@ -982,11 +982,11 @@ private void fciOrientbk(Knowledge bk, Graph graph, List variables) { graph.setEndpoint(from, to, Endpoint.ARROW); this.changeFlag = true; String message = LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to)); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } if (verbose) { - TetradLogger.getInstance().forceLogMessage("Finishing BK Orientation."); + TetradLogger.getInstance().log("Finishing BK Orientation."); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TetradTestContinuous.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TetradTestContinuous.java index 89720ee17a..1b34554f2a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TetradTestContinuous.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TetradTestContinuous.java @@ -573,9 +573,9 @@ private void bollenEvalTetradDifference(int i, int j, int k, int l) { this.deltaTest.calcChiSquare(new Tetrad(ci, cj, ck, cl)); this.prob[0] = this.deltaTest.getPValue(); - TetradLogger.getInstance().forceLogMessage(new Tetrad(this.variables.get(i), + TetradLogger.getInstance().log(new Tetrad(this.variables.get(i), this.variables.get(j), this.variables.get(k), this.variables.get(l)) - + " = 0, p = " + this.prob[0]); + + " = 0, p = " + this.prob[0]); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java index cd0a5d6a11..9258cd4b11 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/TsDagToPag.java @@ -186,7 +186,7 @@ public static boolean existsInducingPathVisitts(Graph graph, Node a, Node b, Nod * @return a {@link edu.cmu.tetrad.graph.Graph} object */ public Graph convert() { - TetradLogger.getInstance().forceLogMessage("Starting DAG to PAG_of_the_true_DAG."); + TetradLogger.getInstance().log("Starting DAG to PAG_of_the_true_DAG."); // System.out.println("Knowledge is = " + knowledge); if (this.verbose) { System.out.println("DAG to PAG_of_the_true_DAG: Starting adjacency search"); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasDci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasDci.java index 0377bc8470..d62b8518d4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasDci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasDci.java @@ -155,7 +155,7 @@ public FasDci(Graph graph, IndependenceTest independenceTest, * @return a SepSet, which indicates which variables are independent conditional on which other variables */ public SepsetMapDci search() { - TetradLogger.getInstance().forceLogMessage("Starting Fast Adjacency Search (DCI)."); + TetradLogger.getInstance().log("Starting Fast Adjacency Search (DCI)."); // Remove edges forbidden both ways. Set edges = this.graph.getEdges(); @@ -169,8 +169,8 @@ public SepsetMapDci search() { this.knowledge.isForbidden(name2, name1)) { this.graph.removeEdge(_edge); - TetradLogger.getInstance().forceLogMessage("Removed " + _edge + " because it was " + - "forbidden by background knowledge."); + TetradLogger.getInstance().log("Removed " + _edge + " because it was " + + "forbidden by background knowledge."); } } @@ -194,7 +194,7 @@ public SepsetMapDci search() { // verifySepsetIntegrity(sepset); - TetradLogger.getInstance().forceLogMessage("Finishing Fast Adjacency Search."); + TetradLogger.getInstance().log("Finishing Fast Adjacency Search."); return sepset; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasFdr.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasFdr.java index 7f31de6581..3108d63be5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasFdr.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/FasFdr.java @@ -97,7 +97,7 @@ public FasFdr(IndependenceTest test, int numIndependenceTests) { * @return a SepSet, which indicates which variables are independent conditional on which other variables */ public Graph search() { - TetradLogger.getInstance().forceLogMessage("Starting Fast Adjacency Search."); + TetradLogger.getInstance().log("Starting Fast Adjacency Search."); this.graph.removeEdges(this.graph.getEdges()); this.sepset = new SepsetMap(); @@ -150,7 +150,7 @@ public Graph search() { } } - TetradLogger.getInstance().forceLogMessage("Finishing Fast Adjacency Search."); + TetradLogger.getInstance().log("Finishing Fast Adjacency Search."); return this.graph; } @@ -379,7 +379,7 @@ private boolean forbiddenEdge(Node x, Node y) { this.knowledge.isForbidden(name2, name1)) { String message = "Removed " + Edges.undirectedEdge(x, y) + " because it was " + "forbidden by background knowledge."; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); return true; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java index ba29e84c92..3a14d43782 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java @@ -147,8 +147,8 @@ public List bestOrder(@NotNull List order) { long stop = MillisecondTimes.timeMillis(); if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("Final order = " + this.scorer.getPi()); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (stop - start) / 1000.0 + " s"); + TetradLogger.getInstance().log("Final order = " + this.scorer.getPi()); + TetradLogger.getInstance().log("Elapsed time = " + (stop - start) / 1000.0 + " s"); } return bestPerm; @@ -310,10 +310,10 @@ public List grasp(@NotNull TeyssierScorer scorer) { } if (this.verbose) { - TetradLogger.getInstance().forceLogMessage("# Edges = " + scorer.getNumEdges() - + " Score = " + scorer.score() - + " (GRaSP)" - + " Elapsed " + ((MillisecondTimes.timeMillis() - this.start) / 1000.0 + " s")); + TetradLogger.getInstance().log("# Edges = " + scorer.getNumEdges() + + " Score = " + scorer.score() + + " (GRaSP)" + + " Elapsed " + ((MillisecondTimes.timeMillis() - this.start) / 1000.0 + " s")); } return scorer.getPi(); @@ -393,7 +393,7 @@ private void graspDfsTol(@NotNull TeyssierScorer scorer, double sOld, int[] dept if (this.verbose) { String s = String.format("Edges: %d \t|\t Score Improvement: %f \t|\t Tucks Performed: %s %s", scorer.getNumEdges(), sNew - sOld, tucks, tuck); - TetradLogger.getInstance().forceLogMessage(s); + TetradLogger.getInstance().log(s); // System.out.printf("Edges: %d \t|\t Score Improvement: %f \t|\t Tucks Performed: %s %s \n", // scorer.getNumEdges(), sNew - sOld, tucks, tuck); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsBeam.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsBeam.java index 1cd1482cde..10a7de9c72 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsBeam.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsBeam.java @@ -335,12 +335,12 @@ public Graph removeZeroEdges(Graph bestGraph) { if (getKnowledge().isRequired(edge.getNode1().getName(), edge.getNode2().getName())) { System.out.println("Not removing " + edge + " because it is required."); - TetradLogger.getInstance().forceLogMessage("Not removing " + edge + " because it is required."); + TetradLogger.getInstance().log("Not removing " + edge + " because it is required."); continue; } System.out.println("Removing edge " + edge + " because it has p = " + p); - TetradLogger.getInstance().forceLogMessage("Removing edge " + edge + " because it has p = " + p); + TetradLogger.getInstance().log("Removing edge " + edge + " because it has p = " + p); graph.removeEdge(edge); changed = true; } @@ -592,7 +592,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdge(nodeA, nodeB); graph.addDirectedEdge(nodeA, nodeB); String message = "Adding edge by knowledge: " + graph.getEdge(nodeA, nodeB); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } for (Iterator it = @@ -617,7 +617,7 @@ private void addRequiredEdges(Graph graph) { graph.removeEdges(nodeA, nodeB); graph.addDirectedEdge(nodeB, nodeA); String message = "Adding edge by knowledge: " + graph.getEdge(nodeB, nodeA); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsGes.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsGes.java index d2e2cc66c4..08da79e2a6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsGes.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/HbsmsGes.java @@ -288,10 +288,10 @@ public Graph search() { } private double fes(Graph graph, double score) { - TetradLogger.getInstance().forceLogMessage("** FORWARD EQUIVALENCE SEARCH"); + TetradLogger.getInstance().log("** FORWARD EQUIVALENCE SEARCH"); double bestScore = score; String message = "Initial Score = " + this.nf.format(bestScore); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); Node x, y; Set t = new HashSet<>(); @@ -337,8 +337,8 @@ private double fes(Graph graph, double score) { double evalScore = scoreGraph(graph2).getScore(); - TetradLogger.getInstance().forceLogMessage("Trying to add " + _x + "-->" + _y + " evalScore = " + - evalScore); + TetradLogger.getInstance().log("Trying to add " + _x + "-->" + _y + " evalScore = " + + evalScore); if (!(evalScore > bestScore && evalScore > score)) { continue; @@ -372,9 +372,9 @@ private double fes(Graph graph, double score) { } private void bes(Graph graph, double initialScore) { - TetradLogger.getInstance().forceLogMessage("** BACKWARD ELIMINATION SEARCH"); + TetradLogger.getInstance().log("** BACKWARD ELIMINATION SEARCH"); String message = "Initial Score = " + this.nf.format(initialScore); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); double bestScore = initialScore; Node x, y; Set t = new HashSet<>(); @@ -464,7 +464,7 @@ private void tryInsert(Node x, Node y, Set subset, Graph graph) { String message = "--- Directing " + oldEdge + " to " + graph.getEdge(t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -482,7 +482,7 @@ private void tryDelete(Node x, Node y, Set subset, Graph graph) { Edge oldEdge = graph.getEdge(x, h); String message = "--- Directing " + oldEdge + " to " + graph.getEdge(x, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } if (Edges.isUndirectedEdge(graph.getEdge(y, h))) { @@ -492,7 +492,7 @@ private void tryDelete(Node x, Node y, Set subset, Graph graph) { Edge oldEdge = graph.getEdge(y, h); String message = "--- Directing " + oldEdge + " to " + graph.getEdge(y, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -516,7 +516,7 @@ private void insert(Node x, Node y, Set subset, Graph graph) { String message = "--- Directing " + oldEdge + " to " + graph.getEdge(t, y); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } @@ -542,7 +542,7 @@ private void delete(Node x, Node y, Set subset, Graph graph) { Edge oldEdge = graph.getEdge(x, h); String message = "--- Directing " + oldEdge + " to " + graph.getEdge(x, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } if (Edges.isUndirectedEdge(graph.getEdge(y, h))) { @@ -552,7 +552,7 @@ private void delete(Node x, Node y, Set subset, Graph graph) { Edge oldEdge = graph.getEdge(y, h); String message = "--- Directing " + oldEdge + " to " + graph.getEdge(y, h); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } } @@ -630,7 +630,7 @@ private void rebuildCPDAG(Graph graph) { addRequiredEdges(graph); pdagWithBk(graph, getKnowledge()); - TetradLogger.getInstance().forceLogMessage("Rebuilt CPDAG = " + graph); + TetradLogger.getInstance().log("Rebuilt CPDAG = " + graph); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestCramerT.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestCramerT.java index 20f7356740..5f2402084c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestCramerT.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestCramerT.java @@ -265,7 +265,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZPercentIndependent.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZPercentIndependent.java index 921459683b..10727abf2e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZPercentIndependent.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZPercentIndependent.java @@ -207,7 +207,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZRecursive.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZRecursive.java index e9c8c11797..91e15cd668 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZRecursive.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestFisherZRecursive.java @@ -214,7 +214,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, getPValue())); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMixedMultipleTTest.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMixedMultipleTTest.java index 7d88ade984..f11f94e2ee 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMixedMultipleTTest.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMixedMultipleTTest.java @@ -375,7 +375,7 @@ private IndependenceResult isIndependentMultinomialLogisticRegression(Node x, No if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, getPValue())); } } @@ -470,7 +470,7 @@ private IndependenceResult isIndependentRegression(Node x, Node y, Set z) if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, getPValue())); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMnlrLr.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMnlrLr.java index d54c70e22b..8b5549ecd9 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMnlrLr.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMnlrLr.java @@ -166,7 +166,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set _z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, _z, pValue)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMultinomialLogisticRegression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMultinomialLogisticRegression.java index 69608fad58..004a731fb0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMultinomialLogisticRegression.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestMultinomialLogisticRegression.java @@ -263,7 +263,7 @@ private IndependenceResult isIndependentMultinomialLogisticRegression(Node x, No if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, p)); } } @@ -326,10 +326,10 @@ private IndependenceResult isIndependentRegression(Node x, Node y, Set z) if (this.verbose) { if (indep) { String message = LogUtilsSearch.independenceFactMsg(x, y, z, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = LogUtilsSearch.dependenceFactMsg(x, y, z, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestSepsetDci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestSepsetDci.java index 919181e93f..75705e9e91 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestSepsetDci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/IndTestSepsetDci.java @@ -140,7 +140,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { String message = LogUtilsSearch.independenceFactMsg(x, y, z, pValue); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } independent = true; break; @@ -151,7 +151,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Set z) { if (this.verbose) { if (independent) { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFact(x, y, z) + " score = " + LogUtilsSearch.independenceFactMsg(x, y, z, getPValue())); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Ion.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Ion.java index 3c56b4c69e..1413008ba7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Ion.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Ion.java @@ -208,9 +208,9 @@ public void setKnowledge(Knowledge knowledge) { public List search() { long start = MillisecondTimes.timeMillis(); - TetradLogger.getInstance().forceLogMessage("Starting ION Search."); + TetradLogger.getInstance().log("Starting ION Search."); logGraphs("\nInitial Pags: ", this.input); - TetradLogger.getInstance().forceLogMessage("Transfering local information."); + TetradLogger.getInstance().log("Transfering local information."); long steps = MillisecondTimes.timeMillis(); /* @@ -233,7 +233,7 @@ public List search() { graph.addEdge(new Edge(pair.getFirst(), pair.getSecond(), Endpoint.CIRCLE, Endpoint.CIRCLE)); } String message3 = "Steps 1-2: " + (MillisecondTimes.timeMillis() - steps) / 1000. + "s"; - TetradLogger.getInstance().forceLogMessage(message3); + TetradLogger.getInstance().log(message3); System.out.println("step2"); System.out.println(graph); @@ -270,14 +270,14 @@ public List search() { // iterates over path length, then adjacencies for (int l = pl; l < numNodes; l++) { if (this.pathLengthSearch) { - TetradLogger.getInstance().forceLogMessage("Braching over path lengths: " + l + " of " + (numNodes - 1)); + TetradLogger.getInstance().log("Braching over path lengths: " + l + " of " + (numNodes - 1)); } int seps = this.separations.size(); final int currentSep = 1; int numAdjacencies = this.separations.size(); for (IonIndependenceFacts fact : this.separations) { if (this.doAdjacencySearch) { - TetradLogger.getInstance().forceLogMessage("Braching over path nonadjacencies: " + currentSep + " of " + numAdjacencies); + TetradLogger.getInstance().log("Braching over path nonadjacencies: " + currentSep + " of " + numAdjacencies); } seps--; // uses two queues to keep up with which PAGs are being iterated and which have been @@ -474,7 +474,7 @@ public List search() { } } String message2 = "Step 3: " + (MillisecondTimes.timeMillis() - steps) / 1000. + "s"; - TetradLogger.getInstance().forceLogMessage(message2); + TetradLogger.getInstance().log(message2); Queue step3Pags = new LinkedList<>(step3PagsSet); /* @@ -552,7 +552,7 @@ public List search() { // outputPags = applyKnowledge(outputPags); String message1 = "Step 4: " + (MillisecondTimes.timeMillis() - steps) / 1000. + "s"; - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); /* * Step 5 @@ -596,7 +596,7 @@ public List search() { this.output.addAll(outputSet); String message = "Step 5: " + (MillisecondTimes.timeMillis() - steps) / 1000. + "s"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); this.runtime = ((MillisecondTimes.timeMillis() - start) / 1000.); logGraphs("\nReturning output (" + this.output.size() + " Graphs):", this.output); double currentUsage = Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory(); @@ -708,11 +708,11 @@ public String getStats() { */ private void logGraphs(String message, List graphs) { if (message != null) { - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } for (Graph graph : graphs) { String message1 = graph.toString(); - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Kpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Kpc.java index c108f65442..32318beac9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Kpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Kpc.java @@ -244,9 +244,9 @@ public Graph search(List nodes) { nodes = new ArrayList<>(nodes); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting kPC algorithm"); + TetradLogger.getInstance().log("Starting kPC algorithm"); String message = "Independence test = " + getIndependenceTest() + "."; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } long startTime = MillisecondTimes.timeMillis(); @@ -282,8 +282,8 @@ public Graph search(List nodes) { this.elapsedTime = MillisecondTimes.timeMillis() - startTime; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing PC Algorithm."); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing PC Algorithm."); } return this.graph; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Mmmb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Mmmb.java index 237adfe695..f3fa2f7dff 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Mmmb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Mmmb.java @@ -107,7 +107,7 @@ public Mmmb(IndependenceTest test, int depth, boolean symmetric) { * Searches for the Markov blanket of the node by the given name. */ public Set findMb(Node target) { - TetradLogger.getInstance().forceLogMessage("target = " + target); + TetradLogger.getInstance().log("target = " + target); this.numIndTests = 0; long time = MillisecondTimes.timeMillis(); @@ -117,9 +117,9 @@ public Set findMb(Node target) { Set nodes = mmmb(target); long time2 = MillisecondTimes.timeMillis() - time; - TetradLogger.getInstance().forceLogMessage("Number of seconds: " + (time2 / 1000.0)); - TetradLogger.getInstance().forceLogMessage("Number of independence tests performed: " + - this.numIndTests); + TetradLogger.getInstance().log("Number of seconds: " + (time2 / 1000.0)); + TetradLogger.getInstance().log("Number of independence tests performed: " + + this.numIndTests); // System.out.println("Number of calls to mmpc = " + pc.size()); return nodes; @@ -237,7 +237,7 @@ private List mmpc(Node t) { // Phase 2. backwardsConditioning(pc, t); - TetradLogger.getInstance().forceLogMessage("PC(" + t + ") = " + pc); + TetradLogger.getInstance().log("PC(" + t + ") = " + pc); // System.out.println("PC(" + t + ") = " + pc); return pc; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ProbabilisticMapIndependence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ProbabilisticMapIndependence.java index 9c47a6d23e..351905a313 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ProbabilisticMapIndependence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ProbabilisticMapIndependence.java @@ -150,7 +150,7 @@ public IndependenceResult checkIndependence(Node x, Node y, Node... z) { if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, GraphUtils.asSet(z), p)); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ResolveSepsetsDci.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ResolveSepsetsDci.java index 0a1e07d95b..bc6e5a9f0b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ResolveSepsetsDci.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/ResolveSepsetsDci.java @@ -670,12 +670,12 @@ private static boolean isIndependentMajorityFdr(List independe if (independent) { String message = "***FDR judges " + LogUtilsSearch.independenceFact(x, y, condSet) + " independent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "###FDR judges " + LogUtilsSearch.independenceFact(x, y, condSet) + " dependent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } - TetradLogger.getInstance().forceLogMessage("c = " + c); + TetradLogger.getInstance().log("c = " + c); return independent; } @@ -722,12 +722,12 @@ private static boolean isIndependentMajorityIndep(List indepen if (independent) { String message = "***Majority = " + LogUtilsSearch.independenceFact(x, y, condSet) + " independent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = "###Majority = " + LogUtilsSearch.independenceFact(x, y, condSet) + " dependent"; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } - TetradLogger.getInstance().forceLogMessage("c = " + c); + TetradLogger.getInstance().log("c = " + c); return independent; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpc.java index 0150c77ca0..58c6039e6f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpc.java @@ -357,8 +357,8 @@ public Set getDefiniteNonadjacencies() { public Graph search() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting VCCPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting VCCPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); @@ -742,11 +742,11 @@ public Graph search() { System.out.println("# of Definite Nonadj: " + this.definitelyNonadjacencies.size()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("Disambiguated CPDAGs: " + CPDAGs); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); + TetradLogger.getInstance().log("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); + TetradLogger.getInstance().log("Disambiguated CPDAGs: " + CPDAGs); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); logTriples(); } @@ -806,30 +806,30 @@ private Set future(Node x, Graph graph) { private void logTriples() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("\nCollider triples:"); + TetradLogger.getInstance().log("\nCollider triples:"); for (Triple triple : this.colliderTriples) { - TetradLogger.getInstance().forceLogMessage("Collider: " + triple); + TetradLogger.getInstance().log("Collider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nNoncollider triples:"); + TetradLogger.getInstance().log("\nNoncollider triples:"); for (Triple triple : this.noncolliderTriples) { - TetradLogger.getInstance().forceLogMessage("Noncollider: " + triple); + TetradLogger.getInstance().log("Noncollider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nAmbiguous triples (i.e. list of triples for which " + - "\nthere is ambiguous data about whether they are colliders or not):"); + TetradLogger.getInstance().log("\nAmbiguous triples (i.e. list of triples for which " + + "\nthere is ambiguous data about whether they are colliders or not):"); for (Triple triple : getAmbiguousTriples()) { - TetradLogger.getInstance().forceLogMessage("Ambiguous: " + triple); + TetradLogger.getInstance().log("Ambiguous: " + triple); } } } private void orientUnshieldedTriples(Knowledge knowledge, IndependenceTest test, int depth) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); // System.out.println("orientUnshieldedTriples 1"); @@ -864,7 +864,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, graph.setEndpoint(z, y, Endpoint.ARROW); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } colliderTriples.add(new Triple(x, y, z)); @@ -880,7 +880,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } private boolean colliderAllowed(Node x, Node y, Node z, Knowledge knowledge) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpcFast.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpcFast.java index 1045ab8494..beff55018d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpcFast.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/SampleVcpcFast.java @@ -369,8 +369,8 @@ public Set getDefiniteNonadjacencies() { public Graph search() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting VCCPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting VCCPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); @@ -685,11 +685,11 @@ public Graph search() { System.out.println("# of Definite Nonadj: " + this.definitelyNonadjacencies.size()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("Disambiguated CPDAGs: " + CPDAGs); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); + TetradLogger.getInstance().log("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); + TetradLogger.getInstance().log("Disambiguated CPDAGs: " + CPDAGs); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); logTriples(); } @@ -750,30 +750,30 @@ private Set future(Node x, Graph graph) { private void logTriples() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("\nCollider triples:"); + TetradLogger.getInstance().log("\nCollider triples:"); for (Triple triple : this.colliderTriples) { - TetradLogger.getInstance().forceLogMessage("Collider: " + triple); + TetradLogger.getInstance().log("Collider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nNoncollider triples:"); + TetradLogger.getInstance().log("\nNoncollider triples:"); for (Triple triple : this.noncolliderTriples) { - TetradLogger.getInstance().forceLogMessage("Noncollider: " + triple); + TetradLogger.getInstance().log("Noncollider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nAmbiguous triples (i.e. list of triples for which " + - "\nthere is ambiguous data about whether they are colliders or not):"); + TetradLogger.getInstance().log("\nAmbiguous triples (i.e. list of triples for which " + + "\nthere is ambiguous data about whether they are colliders or not):"); for (Triple triple : getAmbiguousTriples()) { - TetradLogger.getInstance().forceLogMessage("Ambiguous: " + triple); + TetradLogger.getInstance().log("Ambiguous: " + triple); } } } private void orientUnshieldedTriples(Knowledge knowledge, IndependenceTest test, int depth) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); // System.out.println("orientUnshieldedTriples 1"); @@ -808,7 +808,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, graph.setEndpoint(z, y, Endpoint.ARROW); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } colliderTriples.add(new Triple(x, y, z)); @@ -824,7 +824,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } private boolean colliderAllowed(Node x, Node y, Node z, Knowledge knowledge) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java index cb55f2ccf2..0eb1023815 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java @@ -268,8 +268,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -279,8 +279,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcFas.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcFas.java index 20be5c5388..b5c686d9a9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcFas.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcFas.java @@ -106,7 +106,7 @@ public VcFas(IndependenceTest test) { * @return a SepSet, which indicates which variables are independent conditional on which other variables */ public Graph search() { - TetradLogger.getInstance().forceLogMessage("Starting Fast Adjacency Search."); + TetradLogger.getInstance().log("Starting Fast Adjacency Search."); this.graph.removeEdges(this.graph.getEdges()); // sepset = new SepsetMap(); @@ -153,7 +153,7 @@ public Graph search() { // System.out.println("Finished constructing Graph."); - TetradLogger.getInstance().forceLogMessage("Finishing Fast Adjacency Search."); + TetradLogger.getInstance().log("Finishing Fast Adjacency Search."); return this.graph; } @@ -278,7 +278,7 @@ private boolean forbiddenEdge(Node x, Node y) { this.knowledge.isForbidden(name2, name1)) { String message = "Removed " + Edges.undirectedEdge(x, y) + " because it was " + "forbidden by background knowledge."; - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); return true; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPc.java index d1e77c28f3..1490b376c9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPc.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPc.java @@ -338,8 +338,8 @@ public Graph search() { IndependenceTest independenceTest = getIndependenceTest(); if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting VCCPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + independenceTest + "."); + TetradLogger.getInstance().log("Starting VCCPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + independenceTest + "."); } this.ambiguousTriples = new HashSet<>(); @@ -545,10 +545,10 @@ public Graph search() { System.out.println("# of Definite Nonadj: " + this.definitelyNonadjacencies.size()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); + TetradLogger.getInstance().log("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); } return this.graph; @@ -583,7 +583,7 @@ private Set future(Node x, Graph graph) { private void orientUnshieldedTriples(Knowledge knowledge, IndependenceTest test, int depth) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); // System.out.println("orientUnshieldedTriples 1"); @@ -619,7 +619,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, this.graph.setEndpoint(z, y, Endpoint.ARROW); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } this.colliderTriples.add(new Triple(x, y, z)); @@ -635,7 +635,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } /** @@ -664,7 +664,7 @@ public CpcTripleType getPopulationTripleType(Node x, Node y, Node z, List _nodes = new ArrayList<>(graph.getAdjacentNodes(x)); _nodes.remove(z); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); int _depth = depth; if (_depth == -1) { @@ -704,7 +704,7 @@ public CpcTripleType getPopulationTripleType(Node x, Node y, Node z, _nodes = new ArrayList<>(graph.getAdjacentNodes(z)); _nodes.remove(x); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); _depth = depth; if (_depth == -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcAlt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcAlt.java index 9fca989fbb..4144ce2e1d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcAlt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcAlt.java @@ -283,8 +283,8 @@ public Set getNoncolliderTriples() { public Graph search() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting VCCPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting VCCPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); @@ -497,18 +497,18 @@ public Graph search() { System.out.println(edge); } - TetradLogger.getInstance().forceLogMessage("\n Apparent Non-adjacencies" + apparentlyNonadjacencies); + TetradLogger.getInstance().log("\n Apparent Non-adjacencies" + apparentlyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); + TetradLogger.getInstance().log("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("Disambiguated Patterns: " + patterns); + TetradLogger.getInstance().log("Disambiguated Patterns: " + patterns); long endTime = MillisecondTimes.timeMillis(); this.elapsedTime = endTime - startTime; if (verbose) { - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); logTriples(); } @@ -545,30 +545,30 @@ private Set future(Node x, Graph graph) { private void logTriples() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("\nCollider triples:"); + TetradLogger.getInstance().log("\nCollider triples:"); for (Triple triple : this.colliderTriples) { - TetradLogger.getInstance().forceLogMessage("Collider: " + triple); + TetradLogger.getInstance().log("Collider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nNoncollider triples:"); + TetradLogger.getInstance().log("\nNoncollider triples:"); for (Triple triple : this.noncolliderTriples) { - TetradLogger.getInstance().forceLogMessage("Noncollider: " + triple); + TetradLogger.getInstance().log("Noncollider: " + triple); } - TetradLogger.getInstance().forceLogMessage("\nAmbiguous triples (i.e. list of triples for which " + - "\nthere is ambiguous data about whether they are colliders or not):"); + TetradLogger.getInstance().log("\nAmbiguous triples (i.e. list of triples for which " + + "\nthere is ambiguous data about whether they are colliders or not):"); for (Triple triple : getAmbiguousTriples()) { - TetradLogger.getInstance().forceLogMessage("Ambiguous: " + triple); + TetradLogger.getInstance().log("Ambiguous: " + triple); } } } private void orientUnshieldedTriples(Knowledge knowledge, IndependenceTest test, int depth) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); this.colliderTriples = new HashSet<>(); this.noncolliderTriples = new HashSet<>(); @@ -602,7 +602,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, graph.setEndpoint(z, y, Endpoint.ARROW); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } colliderTriples.add(new Triple(x, y, z)); @@ -618,7 +618,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } private boolean colliderAllowed(Node x, Node y, Node z, Knowledge knowledge) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcFast.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcFast.java index 4497f06f01..1fff0cf4ef 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcFast.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/VcPcFast.java @@ -325,8 +325,8 @@ public Set getDefiniteNonadjacencies() { public Graph search() { if (verbose) { - TetradLogger.getInstance().forceLogMessage("Starting VCCPC algorithm"); - TetradLogger.getInstance().forceLogMessage("Independence test = " + getIndependenceTest() + "."); + TetradLogger.getInstance().log("Starting VCCPC algorithm"); + TetradLogger.getInstance().log("Independence test = " + getIndependenceTest() + "."); } this.ambiguousTriples = new HashSet<>(); @@ -541,10 +541,10 @@ public Graph search() { System.out.println("# of Definite Nonadj: " + this.definitelyNonadjacencies.size()); if (verbose) { - TetradLogger.getInstance().forceLogMessage("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); - TetradLogger.getInstance().forceLogMessage("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); - TetradLogger.getInstance().forceLogMessage("Finishing CPC algorithm."); + TetradLogger.getInstance().log("\n Apparent Non-adjacencies" + this.apparentlyNonadjacencies); + TetradLogger.getInstance().log("\n Definite Non-adjacencies" + this.definitelyNonadjacencies); + TetradLogger.getInstance().log("Elapsed time = " + (this.elapsedTime) / 1000. + " s"); + TetradLogger.getInstance().log("Finishing CPC algorithm."); } return this.graph; @@ -579,7 +579,7 @@ private Set future(Node x, Graph graph) { private void orientUnshieldedTriples(Knowledge knowledge, IndependenceTest test, int depth) { - TetradLogger.getInstance().forceLogMessage("Starting Collider Orientation:"); + TetradLogger.getInstance().log("Starting Collider Orientation:"); // System.out.println("orientUnshieldedTriples 1"); @@ -615,7 +615,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, this.graph.setEndpoint(z, y, Endpoint.ARROW); String message = LogUtilsSearch.colliderOrientedMsg(x, y, z); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } this.colliderTriples.add(new Triple(x, y, z)); @@ -631,7 +631,7 @@ private void orientUnshieldedTriples(Knowledge knowledge, } } - TetradLogger.getInstance().forceLogMessage("Finishing Collider Orientation."); + TetradLogger.getInstance().log("Finishing Collider Orientation."); } /** @@ -667,7 +667,7 @@ public CpcTripleType getPopulationTripleType(Node x, Node y, Node z, _nodes.remove(z); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); int _depth = depth; if (_depth == -1) { @@ -708,7 +708,7 @@ public CpcTripleType getPopulationTripleType(Node x, Node y, Node z, _nodes = new ArrayList<>(graph.getAdjacentNodes(z)); _nodes.remove(x); - TetradLogger.getInstance().forceLogMessage("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); + TetradLogger.getInstance().log("Adjacents for " + x + "--" + y + "--" + z + " = " + _nodes); _depth = depth; if (_depth == -1) { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java index 25597eb44a..5d1582b10d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java @@ -335,8 +335,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -346,8 +346,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java index 40d98116d3..68656a5ec8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java @@ -1071,8 +1071,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1082,8 +1082,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java index cdd4e1f753..92c4a55ed5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java @@ -179,8 +179,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -190,8 +190,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java index 0c8f59ad69..01802f374d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java @@ -152,8 +152,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -163,8 +163,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java index a5bcea7dfb..ef7f54bc27 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java @@ -305,8 +305,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -316,8 +316,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java index f2880ace2f..a48d840100 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java @@ -144,8 +144,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -155,8 +155,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java index cc24073df3..4b6ddd7454 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java @@ -226,15 +226,15 @@ public SemIm estimate() { NumberFormat nf = NumberFormatUtil.getInstance().getNumberFormat(); // TetradLogger.getInstance().log("stats", "Final Score = " + nf.format(semIm.getScore())); - TetradLogger.getInstance().forceLogMessage("Sample Size = " + semIm.getSampleSize()); + TetradLogger.getInstance().log("Sample Size = " + semIm.getSampleSize()); String message3 = "Model Chi Square = " + nf.format(semIm.getChiSquare()); - TetradLogger.getInstance().forceLogMessage(message3); + TetradLogger.getInstance().log(message3); String message2 = "Model DOF = " + nf.format(this.semPm.getDof()); - TetradLogger.getInstance().forceLogMessage(message2); + TetradLogger.getInstance().log(message2); String message1 = "Model P Value = " + nf.format(semIm.getPValue()); - TetradLogger.getInstance().forceLogMessage(message1); + TetradLogger.getInstance().log(message1); String message = "Model BIC = " + nf.format(semIm.getBicScore()); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); System.out.println(this.estimatedSem); @@ -446,8 +446,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -457,8 +457,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java index 91d49b2b24..15839cb8ad 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java @@ -537,8 +537,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -548,8 +548,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java index 6828c2301e..01fbd0b929 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java @@ -179,8 +179,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -190,8 +190,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java index b80727c86f..52701e9f13 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java @@ -275,8 +275,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -286,8 +286,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } 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 b993534b53..155a20df50 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 @@ -2313,8 +2313,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -2324,8 +2324,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java index d21fe9c0cb..5ab0be2925 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java @@ -208,8 +208,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -219,8 +219,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerEm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerEm.java index da1493c1dd..9962dadb1c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerEm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerEm.java @@ -176,7 +176,7 @@ public void optimize(SemIm semIm) { SemIm _sem = semIm; for (int count = 0; count < this.numRestarts; count++) { - TetradLogger.getInstance().forceLogMessage("Trial " + (count + 1)); + TetradLogger.getInstance().log("Trial " + (count + 1)); SemIm _sem2 = new SemIm(semIm); List freeParameters = _sem2.getFreeParameters(); @@ -196,7 +196,7 @@ public void optimize(SemIm semIm) { optimize2(_sem2); double chisq = _sem2.getChiSquare(); - TetradLogger.getInstance().forceLogMessage("chisq = " + chisq); + TetradLogger.getInstance().log("chisq = " + chisq); if (chisq < min) { min = chisq; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRegression.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRegression.java index 2a9461ab49..ebafe70e1b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRegression.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRegression.java @@ -110,7 +110,7 @@ public void optimize(SemIm semIm) { List nodes = new ArrayList<>(semIm.getVariableNodes()); nodes.removeIf(node -> node.getNodeType() == NodeType.ERROR); - TetradLogger.getInstance().forceLogMessage("FML = " + semIm.getScore()); + TetradLogger.getInstance().log("FML = " + semIm.getScore()); for (Node n : nodes) { int i = nodes.indexOf(n); @@ -143,7 +143,7 @@ public void optimize(SemIm semIm) { } String message = "FML = " + semIm.getScore(); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRicf.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRicf.java index 5d2a2b9cc1..f4b41a72db 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRicf.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerRicf.java @@ -86,7 +86,7 @@ public void optimize(SemIm semIm) { throw new IllegalArgumentException("Please remove or impute missing values."); } - TetradLogger.getInstance().forceLogMessage("Trying EM..."); + TetradLogger.getInstance().log("Trying EM..."); // new SemOptimizerEm().optimize(semIm); CovarianceMatrix cov = new CovarianceMatrix(semIm.getMeasuredNodes(), diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerScattershot.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerScattershot.java index f036db37cf..1b8b6fe794 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerScattershot.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemOptimizerScattershot.java @@ -84,8 +84,8 @@ public void optimize(SemIm semIm) { if (this.numRestarts < 1) this.numRestarts = 1; - TetradLogger.getInstance().forceLogMessage("Trying EM..."); - TetradLogger.getInstance().forceLogMessage("Trying scattershot..."); + TetradLogger.getInstance().log("Trying EM..."); + TetradLogger.getInstance().log("Trying scattershot..."); double min = Double.POSITIVE_INFINITY; SemIm _sem = null; @@ -93,7 +93,7 @@ public void optimize(SemIm semIm) { // With local search on points in the width 1 iteration, multiple iterations of the whole search // doesn't seem necessary. for (int i = 0; i < this.numRestarts + 1; i++) { - TetradLogger.getInstance().forceLogMessage("Trial " + (i + 1)); + TetradLogger.getInstance().log("Trial " + (i + 1)); // System.out.println("Trial " + (i + 1)); SemIm _sem2 = new SemIm(semIm); optimize2(_sem2); @@ -230,7 +230,7 @@ private boolean findLowerRandom(FittingFunction fcn, double[] p, if (f < fP) { System.arraycopy(pTemp, 0, p, 0, pTemp.length); - TetradLogger.getInstance().forceLogMessage("Cube width = " + width + " FML = " + f); + TetradLogger.getInstance().log("Cube width = " + width + " FML = " + f); return true; } } @@ -265,7 +265,7 @@ private boolean findLowerRandomLocal(FittingFunction fcn, double[] p) { if (f < fP) { System.arraycopy(pTemp, 0, p, 0, pTemp.length); - TetradLogger.getInstance().forceLogMessage("Cube width = " + 0.2 + " FML = " + f); + TetradLogger.getInstance().log("Cube width = " + 0.2 + " FML = " + f); return true; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java index 710c52f6ad..7699ad3380 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java @@ -672,8 +672,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -683,8 +683,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java index c54d5b6266..b36707a959 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java @@ -201,8 +201,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -212,8 +212,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java index a3531963cb..92bda2f2a2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java @@ -252,8 +252,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -263,8 +263,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java index bba89dba5d..367821656a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java @@ -1050,8 +1050,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -1061,8 +1061,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java index 9c6502d3ea..cbe5ecb86a 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java @@ -91,8 +91,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -102,8 +102,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java index dd96eeb36a..e912b3053c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java @@ -311,8 +311,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -322,8 +322,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java index 7eef7e6271..94d5565e9a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java @@ -161,8 +161,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -172,8 +172,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java index 2713466e45..3297e898a3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java @@ -290,8 +290,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -301,8 +301,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java index 6dc4acf67b..d1db22bd89 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java @@ -243,8 +243,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -254,8 +254,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java index 8b35a290d6..e682ab3979 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java @@ -239,8 +239,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -250,8 +250,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java index 4228c36bb8..f3b14e53b1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java @@ -130,8 +130,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -141,8 +141,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java index 0041019298..3e9a48f25d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java @@ -104,8 +104,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -115,8 +115,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java index ba135da92f..1e26b5503b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java @@ -160,8 +160,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -171,8 +171,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java index c04ba88fb6..cd0c986265 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java @@ -185,8 +185,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -196,8 +196,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java index df13af9197..640678d5da 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java @@ -980,8 +980,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -991,8 +991,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java index ee1a5b54fb..76bdd8507b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java @@ -72,8 +72,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -83,8 +83,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java index 8a3478913f..e779a7384a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java @@ -375,8 +375,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -386,8 +386,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/AlgorithmDescriptions.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/AlgorithmDescriptions.java index 5eb81fb251..ab5b9a779b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/AlgorithmDescriptions.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/AlgorithmDescriptions.java @@ -61,7 +61,7 @@ private AlgorithmDescriptions() { } }); } catch (IOException ex) { - TetradLogger.getInstance().forceLogMessage("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); + TetradLogger.getInstance().log("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/IndependenceTestDescriptions.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/IndependenceTestDescriptions.java index b3bcc6a43b..412d4b7cec 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/IndependenceTestDescriptions.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/IndependenceTestDescriptions.java @@ -60,7 +60,7 @@ private IndependenceTestDescriptions() { } }); } catch (IOException ex) { - TetradLogger.getInstance().forceLogMessage("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); + TetradLogger.getInstance().log("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); // IndependenceTestDescriptions.LOGGER.error("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar.", ex); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java index a8d82d06e1..492649a3e2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java @@ -634,8 +634,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -645,8 +645,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ParamDescriptions.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ParamDescriptions.java index 5f08c6ddc1..46cc902901 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ParamDescriptions.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ParamDescriptions.java @@ -53,7 +53,7 @@ private ParamDescriptions() { doc = Jsoup.parse(inputStream, "UTF-8", ""); } } catch (IOException ex) { - TetradLogger.getInstance().forceLogMessage("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); + TetradLogger.getInstance().log("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); // ParamDescriptions.LOGGER.error("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar.", ex); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java index 91dff3c902..518899a579 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java @@ -351,8 +351,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -362,8 +362,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java index 1e397d727f..a514ca2993 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java @@ -132,8 +132,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -143,8 +143,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ScoreDescriptions.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ScoreDescriptions.java index ae66c361b7..655f2d5b59 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ScoreDescriptions.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/ScoreDescriptions.java @@ -60,7 +60,7 @@ private ScoreDescriptions() { } }); } catch (IOException ex) { - TetradLogger.getInstance().forceLogMessage("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); + TetradLogger.getInstance().log("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar."); // ScoreDescriptions.LOGGER.error("Failed to read tetrad HTML manual 'maunal/index.html' file from within the jar.", ex); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/TetradLogger.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/TetradLogger.java index 13debf9eef..ccf4318933 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/TetradLogger.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/TetradLogger.java @@ -255,7 +255,7 @@ public void error(String message) { * * @param message a {@link java.lang.String} object */ - public void forceLogMessage(String message) { + public void log(String message) { if (this.logging) { if (!this.writers.containsKey(System.out)) { System.out.println(message); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java index 18a1ea005d..e5d7af0b94 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java @@ -264,8 +264,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -275,8 +275,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } 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 5430edaab1..14116fe2f9 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 @@ -306,8 +306,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -317,8 +317,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java index 3b3190117e..fb802f336d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java @@ -148,8 +148,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -159,8 +159,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java index 6474a3f147..32c1ada925 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java @@ -160,8 +160,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -171,8 +171,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java index 8f9e6b8497..2767efd4f4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java @@ -191,8 +191,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -202,8 +202,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java index a66aa9a0af..77dd4b4613 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java @@ -181,8 +181,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -192,8 +192,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java index f230f0e9fd..b2fec107df 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java @@ -162,8 +162,8 @@ private void writeObject(ObjectOutputStream out) throws IOException { try { out.defaultWriteObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to serialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to serialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } @@ -173,8 +173,8 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE try { in.defaultReadObject(); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Failed to deserialize object: " + getClass().getCanonicalName() - + ", " + e.getMessage()); + TetradLogger.getInstance().log("Failed to deserialize object: " + getClass().getCanonicalName() + + ", " + e.getMessage()); throw e; } } diff --git a/tetrad-lib/src/main/java/edu/pitt/csb/mgm/IndTestMultinomialLogisticRegressionWald.java b/tetrad-lib/src/main/java/edu/pitt/csb/mgm/IndTestMultinomialLogisticRegressionWald.java index 45eda18530..9b1e1c0009 100644 --- a/tetrad-lib/src/main/java/edu/pitt/csb/mgm/IndTestMultinomialLogisticRegressionWald.java +++ b/tetrad-lib/src/main/java/edu/pitt/csb/mgm/IndTestMultinomialLogisticRegressionWald.java @@ -275,10 +275,10 @@ private IndependenceResult isIndependentMultinomialLogisticRegression(Node x, No if (independent) { String message = LogUtilsSearch.independenceFactMsg(x, y, z, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } else { String message = LogUtilsSearch.dependenceFactMsg(x, y, z, p); - TetradLogger.getInstance().forceLogMessage(message); + TetradLogger.getInstance().log(message); } return new IndependenceResult(new IndependenceFact(x, y, z), independent, p, alpha - p); @@ -296,7 +296,7 @@ private IndependenceResult isIndependentMultinomialLogisticRegression(Node x, No if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, p)); } } @@ -392,7 +392,7 @@ private IndependenceResult isIndependentRegression(Node x, Node y, Set z) if (this.verbose) { if (independent) { - TetradLogger.getInstance().forceLogMessage( + TetradLogger.getInstance().log( LogUtilsSearch.independenceFactMsg(x, y, z, p)); } } 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 6b581937d6..9cecf0be49 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 @@ -531,7 +531,7 @@ public void testCites() { CPDAG = GraphUtils.replaceNodes(CPDAG, trueGraph.getNodes()); assertEquals(trueGraph, CPDAG); } catch (IOException e) { - TetradLogger.getInstance().forceLogMessage("Error in testCites"); + TetradLogger.getInstance().log("Error in testCites"); } } From f8b824e3ed2157a2f66af1305059fb41562fa279 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 07:03:55 -0400 Subject: [PATCH 12/29] Refactor LvLite and LvLiteDsepFriendly classes The LvLite and LvLiteDsepFriendly classes have been streamlined and cleaned up for clarity and performance. This includes removing unnecessary conditionals and repetitions, consolidating duplicate code into a helper function, and optimizing how common adjacents are processed. --- .../java/edu/cmu/tetrad/search/LvLite.java | 106 +++++-------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 145 +++++------------- 2 files changed, 75 insertions(+), 176 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 24bb16acfd..fdd5f19e69 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -378,15 +378,6 @@ private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer return; } - - - if (pag.getEdge(x, y).pointsTowards(y)) { - var r = x; - x = y; - y = r; - } - - // Find possible d-connecting common adjacents of x and y. List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); commonAdj.retainAll(pag.getAdjacentNodes(y)); @@ -396,22 +387,33 @@ private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer commonAdj.removeAll(commonChildren); - boolean oriented = false; + TetradLogger.getInstance().log("Common adjacents for " + x + " and " + y + ": " + commonAdj); - if (!pag.isDefCollider(x, b, y)) { + scorer.goToBookmark(); + scorer.tuck(b, x); - // Tuck x before b. - scorer.goToBookmark(); + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { + if (colliderAllowed(pag, x, b, y)) { + if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + + if (verbose) { + TetradLogger.getInstance().log( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } - for (Node node : pag.getParents(x)) { - scorer.tuck(node, x); + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); + commonAdj.remove(b); + } } + } - scorer.tuck(b, x); + scorer.tuck(b, x); - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) - && colliderAllowed(pag, x, b, y)) { + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { + if (colliderAllowed(pag, x, b, y)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -422,79 +424,51 @@ && colliderAllowed(pag, x, b, y)) { toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); - - oriented = true; - } - - if (!oriented) { - scorer.tuck(b, y); - scorer.tuck(b, x); - - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) - && colliderAllowed(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } - - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); - - oriented = true; - } + commonAdj.remove(b); } } - // But check all other possible d-connecting common adjacents of x and y - for (Node a : commonAdj) { - if (a == b) continue; - - // Tuck those too, one at a time + for (Node a : new ArrayList<>(commonAdj)) { scorer.tuck(a, x); // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) - && colliderAllowed(pag, x, a, y)) { - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y)) { + if (colliderAllowed(pag, x, a, y)) { + pag.setEndpoint(x, a, Endpoint.ARROW); + pag.setEndpoint(y, a, Endpoint.ARROW); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, a, y)); + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, a, y)); + commonAdj.remove(a); - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); + if (verbose) { + TetradLogger.getInstance().log( + "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); + } } - - oriented = true; } - if (!oriented) { - scorer.tuck(a, y); - scorer.tuck(a, x); + scorer.tuck(a, y); - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) - && colliderAllowed(pag, x, a, y)) { + // If we can now copy the collider from the scorer, do so. + if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y)) { + if (colliderAllowed(pag, x, a, y)) { pag.setEndpoint(x, a, Endpoint.ARROW); pag.setEndpoint(y, a, Endpoint.ARROW); toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, a, y)); + commonAdj.remove(a); if (verbose) { TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); } - - oriented = true; } } } } + /** * Determines if the collider is allowed. * diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 778fd112b2..fec1923085 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -31,7 +31,6 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.List; /** * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the @@ -44,9 +43,8 @@ */ public final class LvLiteDsepFriendly implements IGraphSearch { /** - * This variable represents a list of nodes that store different variables. - * It is declared as private and final, hence it cannot be modified or accessed from outside - * the class where it is declared. + * This variable represents a list of nodes that store different variables. It is declared as private and final, + * hence it cannot be modified or accessed from outside the class where it is declared. */ private final ArrayList variables; /** @@ -335,7 +333,9 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< adj.sort(Comparator.comparingInt(reverse::indexOf)); for (int i = 0; i < adj.size(); i++) { - for (int j = i + 1; j < adj.size(); j++) { + for (int j = 0; j < adj.size(); j++) { + if (i == j) continue; + var x = adj.get(i); var y = adj.get(j); @@ -366,28 +366,23 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); - boolean lookAt = x.getName().equals("X1") && y.getName().equals("X12"); - - // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - boolean unshieldedTriple = unshieldedTriple(pag, x, b, y); - boolean unshieldedCollider = scorer.unshieldedCollider(x, b, y); - boolean colliderAllowed = colliderAllowed(pag, x, b, y); + boolean unshieldedColliderCpdag = unshieldedCollider(cpdag, x, b, y); + boolean unshieldedTriplePAG = unshieldedTriple(pag, x, b, y); + boolean colliderAllowedPag = colliderAllowed(pag, x, b, y); - if (lookAt) { - System.out.println("R0: " + x + " " + b + " " + y); - } + if (unshieldedTriplePAG && unshieldedColliderCpdag) { + if (colliderAllowedPag) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (unshieldedTriple && unshieldedCollider && colliderAllowed) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - unshieldedColliders.add(new Triple(x, b, y)); + unshieldedColliders.add(new Triple(x, b, y)); - if (verbose) { - TetradLogger.getInstance().log( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + if (verbose) { + TetradLogger.getInstance().log( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } } } else if (allowTucks && pag.isAdjacentTo(x, y)) { triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); @@ -418,15 +413,6 @@ private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer return; } - - - if (pag.getEdge(x, y).pointsTowards(y)) { - var r = x; - x = y; - y = r; - } - - // Find possible d-connecting common adjacents of x and y. List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); commonAdj.retainAll(pag.getAdjacentNodes(y)); @@ -436,42 +422,29 @@ private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer commonAdj.removeAll(commonChildren); - boolean oriented = false; + TetradLogger.getInstance().log("Common adjacents for " + x + " and " + y + ": " + commonAdj); - if (!pag.isDefCollider(x, b, y)) { - - // Tuck x before b. - scorer.goToBookmark(); - - for (Node node : pag.getParents(x)) { - scorer.tuck(node, x); - } - - scorer.tuck(b, x); - - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) - && colliderAllowed(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); + scorer.goToBookmark(); + scorer.tuck(b, x); + copyCollider(x, b, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + scorer.tuck(b, x); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); + copyCollider(x, b, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); - oriented = true; - } + for (Node a : new ArrayList<>(commonAdj)) { + scorer.tuck(a, x); + copyCollider(x, a, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); - if (!oriented) { - scorer.tuck(b, y); - scorer.tuck(b, x); + scorer.tuck(a, y); + copyCollider(x, a, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); + } + } - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y) - && colliderAllowed(pag, x, b, y)) { + private void copyCollider(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove, List commonAdj) { + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { + if (colliderAllowed(pag, x, b, y)) { + if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(pag, x, b, y)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -482,55 +455,7 @@ && colliderAllowed(pag, x, b, y)) { toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); - - oriented = true; - } - } - } - - // But check all other possible d-connecting common adjacents of x and y - for (Node a : commonAdj) { - if (a == b) continue; - - // Tuck those too, one at a time - scorer.tuck(a, x); - - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) - && colliderAllowed(pag, x, a, y)) { - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); - - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, a, y)); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); - } - - oriented = true; - } - - if (!oriented) { - scorer.tuck(a, y); - scorer.tuck(a, x); - - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y) - && colliderAllowed(pag, x, a, y)) { - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); - - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, a, y)); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); - } - - oriented = true; + commonAdj.remove(b); } } } From 9a8bc7b3cf5ed271ed17fb87a8f59f7189e3977f Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 08:47:27 -0400 Subject: [PATCH 13/29] Refactor LvLite and LvLiteDsepFriendly classes for better readability Refactored LvLite and LvLiteDsepFriendly classes to improve code readability and maintainability. The code was restructured by extracting methods and better organizing code logic. In addition, adjustments were made to enhance efficiency during traversal and manipulation of graph elements. --- .../java/edu/cmu/tetrad/search/LvLite.java | 189 +++++++----------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 158 +++++++-------- 2 files changed, 153 insertions(+), 194 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index fdd5f19e69..8942663209 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -26,6 +26,7 @@ import edu.cmu.tetrad.search.utils.FciOrient; import edu.cmu.tetrad.search.utils.TeyssierScorer; import edu.cmu.tetrad.util.TetradLogger; +import org.jetbrains.annotations.NotNull; import java.util.*; @@ -284,35 +285,50 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var reverse = new ArrayList<>(best); Collections.reverse(reverse); - Set toRemove = new HashSet<>(); - // Copy al the unshielded triples from the old PAG to the new PAG where adjacencies still exist. + recallUnshieldedTriples(pag, unshieldedColliders, reverse); + mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove); + removeEdges(pag, toRemove); + } + + private void removeEdges(Graph pag, Set toRemove) { + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); + + boolean _adj = pag.isAdjacentTo(x, y); + + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().log( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } + } + + private void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, ArrayList reverse, Set toRemove) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); - - // Sort adj in the order of reverse - adj.sort(Comparator.comparingInt(reverse::indexOf)); +// adj.sort(Comparator.comparingInt(reverse::indexOf)); for (int i = 0; i < adj.size(); i++) { - for (int j = i + 1; j < adj.size(); j++) { + for (int j = 0; j < adj.size(); j++) { + if (i == j) continue; + var x = adj.get(i); var y = adj.get(j); - if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - pag.removeEdge(x, y); - - if (verbose) { - TetradLogger.getInstance().log( - "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); - } + if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders)) { + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); } } } } + } + private void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -326,144 +342,85 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); - boolean lookAt = x.getName().equals("X1") && y.getName().equals("X12"); - - - // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, - // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - boolean unshieldedTriple = unshieldedTriple(pag, x, b, y); - boolean unshieldedCollider = scorer.unshieldedCollider(x, b, y); - boolean colliderAllowed = colliderAllowed(pag, x, b, y); - - if (lookAt) { - System.out.println("R0: " + x + " " + b + " " + y); - } - - if (unshieldedTriple && unshieldedCollider && colliderAllowed) { + if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); - - unshieldedColliders.add(new Triple(x, b, y)); + pag.removeEdge(x, y); if (verbose) { TetradLogger.getInstance().log( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } - } else if (allowTucks && pag.isAdjacentTo(x, y)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); } } } } - - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); - - boolean _adj = pag.isAdjacentTo(x, y); - - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().log( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); - } - } - } } private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove) { + scorer.goToBookmark(); - if (x == b || x == y || b == y) { - return; - } + scorer.tuck(b, x); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - // Find possible d-connecting common adjacents of x and y. - List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); - commonAdj.retainAll(pag.getAdjacentNodes(y)); + scorer.tuck(b, y); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); - commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); + List commonNoncolliders = commonNoncolliders(x, y, pag); + commonNoncolliders.remove(b); - commonAdj.removeAll(commonChildren); + for (Node a : new ArrayList<>(commonNoncolliders)) { + scorer.tuck(a, x); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); - TetradLogger.getInstance().log("Common adjacents for " + x + " and " + y + ": " + commonAdj); + scorer.tuck(a, y); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); + } + } - scorer.goToBookmark(); - scorer.tuck(b, x); + private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { + List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); + commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); + List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); + commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); + commonNoncolliders.removeAll(commonChildren); + return commonNoncolliders; + } - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { + private boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders) { + if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { if (colliderAllowed(pag, x, b, y)) { - if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + unshieldedColliders.add(new Triple(x, b, y)); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); - commonAdj.remove(b); + if (verbose) { + TetradLogger.getInstance().log( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } + + return true; } } - scorer.tuck(b, x); + return false; + } + private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove) { if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { if (colliderAllowed(pag, x, b, y)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } - toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); - commonAdj.remove(b); - } - } - - for (Node a : new ArrayList<>(commonAdj)) { - scorer.tuck(a, x); - - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y)) { - if (colliderAllowed(pag, x, a, y)) { - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, a, y)); - commonAdj.remove(a); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); - } - } - } - - scorer.tuck(a, y); - - // If we can now copy the collider from the scorer, do so. - if (triple(pag, x, a, y) && scorer.unshieldedCollider(x, a, y)) { - if (colliderAllowed(pag, x, a, y)) { - pag.setEndpoint(x, a, Endpoint.ARROW); - pag.setEndpoint(y, a, Endpoint.ARROW); - - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, a, y)); - commonAdj.remove(a); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + a + " <-* " + y + " from CPDAG to PAG."); - } + if (verbose) { + TetradLogger.getInstance().log( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index fec1923085..99380d205c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -176,6 +176,15 @@ public LvLiteDsepFriendly(@NotNull IndependenceTest test, Score score) { this.variables = new ArrayList<>(score.getVariables()); } + private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { + List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); + commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); + List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); + commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); + commonNoncolliders.removeAll(commonChildren); + return commonNoncolliders; + } + /** * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given * Graph following the PAG (Partially Ancestral Graph) structure. @@ -322,15 +331,33 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var reverse = new ArrayList<>(best); Collections.reverse(reverse); - Set toRemove = new HashSet<>(); - // Copy al the unshielded triples from the old PAG to the new PAG where adjacencies still exist. + recallUnshieldedTriples(pag, unshieldedColliders, reverse); + mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove); + removeEdges(pag, toRemove); + } + + private void removeEdges(Graph pag, Set toRemove) { + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); + + boolean _adj = pag.isAdjacentTo(x, y); + + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().log( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } + } + + private void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, ArrayList reverse, Set toRemove) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); - - // Sort adj in the order of reverse - adj.sort(Comparator.comparingInt(reverse::indexOf)); + Collections.reverse(adj); for (int i = 0; i < adj.size(); i++) { for (int j = 0; j < adj.size(); j++) { @@ -339,20 +366,15 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); - if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - pag.removeEdge(x, y); - - if (verbose) { - TetradLogger.getInstance().log( - "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); - } + if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders)) { + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); } } } } + } + private void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -366,96 +388,76 @@ private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List< var x = adj.get(i); var y = adj.get(j); - // If you can copy the unshielded collider from the scorer, do so. Otherwise, if x *-* y im the PAG, - // and tucking yields the collider, copy this collider x *-> b <-* y into the PAG as well. - boolean unshieldedColliderCpdag = unshieldedCollider(cpdag, x, b, y); - boolean unshieldedTriplePAG = unshieldedTriple(pag, x, b, y); - boolean colliderAllowedPag = colliderAllowed(pag, x, b, y); - - if (unshieldedTriplePAG && unshieldedColliderCpdag) { - if (colliderAllowedPag) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - unshieldedColliders.add(new Triple(x, b, y)); + if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); + pag.removeEdge(x, y); - if (verbose) { - TetradLogger.getInstance().log( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + if (verbose) { + TetradLogger.getInstance().log( + "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } - } else if (allowTucks && pag.isAdjacentTo(x, y)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); } } } } - - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); - - boolean _adj = pag.isAdjacentTo(x, y); - - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().log( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); - } - } - } } private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove) { + scorer.goToBookmark(); - if (x == b || x == y || b == y) { - return; - } - - // Find possible d-connecting common adjacents of x and y. - List commonAdj = new ArrayList<>(pag.getAdjacentNodes(x)); - commonAdj.retainAll(pag.getAdjacentNodes(y)); + scorer.tuck(b, x); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); - commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); + scorer.tuck(b, y); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - commonAdj.removeAll(commonChildren); + List commonNoncolliders = commonNoncolliders(x, y, pag); + commonNoncolliders.remove(b); - TetradLogger.getInstance().log("Common adjacents for " + x + " and " + y + ": " + commonAdj); + for (Node a : new ArrayList<>(commonNoncolliders)) { + scorer.tuck(a, x); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); - scorer.goToBookmark(); - scorer.tuck(b, x); - copyCollider(x, b, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); + scorer.tuck(a, y); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); + } + } - scorer.tuck(b, x); + private boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders) { + if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { + if (colliderAllowed(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - copyCollider(x, b, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); + unshieldedColliders.add(new Triple(x, b, y)); - for (Node a : new ArrayList<>(commonAdj)) { - scorer.tuck(a, x); - copyCollider(x, a, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); + if (verbose) { + TetradLogger.getInstance().log( + "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); + } - scorer.tuck(a, y); - copyCollider(x, a, y, pag, scorer, unshieldedColliders, toRemove, commonAdj); + return true; + } } + + return false; } - private void copyCollider(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Set toRemove, List commonAdj) { + private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove) { if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { if (colliderAllowed(pag, x, b, y)) { - if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } + toRemove.add(new NodePair(x, y)); + unshieldedColliders.add(new Triple(x, b, y)); - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); - commonAdj.remove(b); + if (verbose) { + TetradLogger.getInstance().log( + "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } } } From 99ac24c937c26e9ceb9029746f952c79eb8d1ff7 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 4 Jun 2024 15:29:22 -0400 Subject: [PATCH 14/29] Refactor and optimize LvLite and LvLiteDsepFriendly classes Primarily, refactored the 'reorientWithCircles', 'search', 'setKnowledge', 'setCompleteRuleSetUsed', 'setVerbose', 'setNumStarts', 'setDoDiscriminatingPathTailRule', 'setDoDiscriminatingPathColliderRule', and 'setUseBes' methods, and made them more efficient. Also, removed the unused 'score' and 'start' variables and unnecessary methods in LvLiteDsepFriendly. Also, optimized the 'search' method and updated the verbose logs for better clarity. --- .../java/edu/cmu/tetrad/search/Grasp.java | 2 +- .../java/edu/cmu/tetrad/search/LvLite.java | 440 +++++++------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 536 +----------------- 3 files changed, 241 insertions(+), 737 deletions(-) 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 fe8ac42d67..94d65068e2 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 @@ -153,7 +153,7 @@ public Grasp(@NotNull IndependenceTest test) { public Grasp(@NotNull IndependenceTest test, Score score) { this.test = test; this.score = score; - this.variables = new ArrayList<>(score.getVariables()); + this.variables = new ArrayList<>(test.getVariables()); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 8942663209..e316e4ae58 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -119,155 +119,13 @@ public LvLite(Score score) { * * @param pag The Graph to be reoriented. */ - private void reorientWithCircles(Graph pag) { + private static void reorientWithCircles(Graph pag, boolean verbose) { if (verbose) { TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); } pag.reorientAllWith(Endpoint.CIRCLE); } - /** - * Run the search and return s a PAG. - * - * @return The PAG. - */ - public Graph search() { - List nodes = this.score.getVariables(); - - if (nodes == null) { - throw new NullPointerException("Nodes from test were null."); - } - - if (verbose) { - TetradLogger.getInstance().log("===Starting LV-Lite==="); - } - - if (verbose) { - TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); - } - - // BOSS seems to be doing better here. - var suborderSearch = new Boss(score); - suborderSearch.setKnowledge(knowledge); - suborderSearch.setResetAfterBM(true); - suborderSearch.setResetAfterRS(true); - suborderSearch.setVerbose(false); - suborderSearch.setUseBes(useBes); - suborderSearch.setUseDataOrder(useDataOrder); - suborderSearch.setNumStarts(numStarts); - var permutationSearch = new PermutationSearch(suborderSearch); - permutationSearch.setKnowledge(knowledge); - permutationSearch.search(); - var best = permutationSearch.getOrder(); - - if (verbose) { - TetradLogger.getInstance().log("Best order: " + best); - } - - var scorer = new TeyssierScorer(null, score); - scorer.score(best); - scorer.bookmark(); - - if (verbose) { - TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); - TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); - } - - var cpdag = scorer.getGraph(true); - var pag = new EdgeListGraph(cpdag); - scorer.score(best); - - FciOrient fciOrient = new FciOrient(null); - - fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); - fciOrient.setDoDiscriminatingPathColliderRule(false); - fciOrient.setDoDiscriminatingPathTailRule(false); - fciOrient.setMaxPathLength(maxPathLength); - fciOrient.setKnowledge(knowledge); - fciOrient.setVerbose(verbose); - - if (verbose) { - TetradLogger.getInstance().log("Collider orientation and edge removal."); - } - - // The main procedure. - Set unshieldedColliders = new HashSet<>(); - Set _unshieldedColliders; - - do { - _unshieldedColliders = new HashSet<>(unshieldedColliders); - orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag); - } while (!unshieldedColliders.equals(_unshieldedColliders)); - - finalOrientation(fciOrient, pag, scorer); - - return GraphUtils.replaceNodes(pag, this.score.getVariables()); - } - - /** - * Sets the knowledge used in search. - * - * @param knowledge This knowledge. - */ - public void setKnowledge(Knowledge knowledge) { - this.knowledge = new Knowledge(knowledge); - } - - /** - * Sets whether the complete rule set should be used during the search algorithm. By default, the complete rule set - * is not used. - * - * @param completeRuleSetUsed true if the complete rule set should be used, false otherwise - */ - public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { - this.completeRuleSetUsed = completeRuleSetUsed; - } - - /** - * Sets the verbosity level of the search algorithm. - * - * @param verbose true to enable verbose mode, false to disable it - */ - public void setVerbose(boolean verbose) { - this.verbose = verbose; - } - - /** - * Sets the number of starts for BOSS. - * - * @param numStarts The number of starts. - */ - public void setNumStarts(int numStarts) { - this.numStarts = numStarts; - } - - /** - * Sets whether the discriminating path tail rule should be used. - * - * @param doDiscriminatingPathTailRule True, if so. - */ - public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { - this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; - } - - /** - * Sets whether the discriminating path collider rule should be used. - * - * @param doDiscriminatingPathColliderRule True, if so. - */ - public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { - this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; - } - - /** - * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. - * - * @param useBes true to use the BES algorithm, false otherwise - */ - public void setUseBes(boolean useBes) { - this.useBes = useBes; - } - /** * Orients and removes edges in a graph according to specified rules. Edges are removed in the course of the * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the @@ -278,21 +136,21 @@ public void setUseBes(boolean useBes) { * @param best The list of best nodes. * @param scorer The scorer used to evaluate edge orientations. */ - private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, - Set unshieldedColliders, Graph cpdag) { - reorientWithCircles(pag); - doRequiredOrientations(fciOrient, pag, best); + public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, + Set unshieldedColliders, Graph cpdag, Knowledge knowledge, boolean verbose) { + reorientWithCircles(pag, verbose); + doRequiredOrientations(fciOrient, pag, best, knowledge, verbose); var reverse = new ArrayList<>(best); Collections.reverse(reverse); Set toRemove = new HashSet<>(); - recallUnshieldedTriples(pag, unshieldedColliders, reverse); - mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove); - removeEdges(pag, toRemove); + recallUnshieldedTriples(pag, unshieldedColliders, reverse, verbose); + mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove, knowledge, verbose); + removeEdges(pag, toRemove, verbose); } - private void removeEdges(Graph pag, Set toRemove) { + private static void removeEdges(Graph pag, Set toRemove, boolean verbose) { for (NodePair remove : toRemove) { Node x = remove.getFirst(); Node y = remove.getSecond(); @@ -308,10 +166,11 @@ private void removeEdges(Graph pag, Set toRemove) { } } - private void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, ArrayList reverse, Set toRemove) { + private static void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, + ArrayList reverse, Set toRemove, Knowledge knowledge, boolean verbose) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); -// adj.sort(Comparator.comparingInt(reverse::indexOf)); + Collections.reverse(adj); for (int i = 0; i < adj.size(); i++) { for (int j = 0; j < adj.size(); j++) { @@ -320,15 +179,15 @@ private void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedCo var x = adj.get(i); var y = adj.get(j); - if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); + if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, knowledge, verbose)) { + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); } } } } } - private void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse) { + private static void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse, boolean verbose) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -357,40 +216,46 @@ private void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, } } - private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove) { + private static void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove, Knowledge knowledge, boolean verbose) { scorer.goToBookmark(); - scorer.tuck(b, x); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); + if (!unshieldedTriple(pag, x, b, y)) { + scorer.tuck(b, x); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + } + + if (!unshieldedTriple(pag, x, b, y)) { + scorer.tuck(b, y); + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + } - scorer.tuck(b, y); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); + scorer.goToBookmark(); List commonNoncolliders = commonNoncolliders(x, y, pag); commonNoncolliders.remove(b); for (Node a : new ArrayList<>(commonNoncolliders)) { - scorer.tuck(a, x); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); + if (!unshieldedTriple(pag, x, a, y)) { + scorer.tuck(a, x); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + } - scorer.tuck(a, y); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); + if (!unshieldedTriple(pag, x, a, y)) { + scorer.tuck(a, y); + copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + } } } - private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { - List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); - commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); - List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); - commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); - commonNoncolliders.removeAll(commonChildren); - return commonNoncolliders; - } + private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders, + Knowledge knowledge, boolean verbose) { + if (unshieldedColliders.contains(new Triple(x, b, y))) { + return true; + } - private boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders) { if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { - if (colliderAllowed(pag, x, b, y)) { + if (colliderAllowed(pag, x, b, y, knowledge)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -408,10 +273,14 @@ private boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y return false; } - private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove) { + private static void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove, Knowledge knowledge, boolean verbose) { + if (unshieldedColliders.contains(new Triple(x, b, y))) { + return; + } + if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { - if (colliderAllowed(pag, x, b, y)) { + if (colliderAllowed(pag, x, b, y, knowledge)) { pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -426,6 +295,19 @@ private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScore } } + /** + * Checks if three nodes are connected in a graph. + * + * @param graph the graph to check for connectivity + * @param a the first node + * @param b the second node + * @param c the third node + * @return {@code true} if all three nodes are connected, {@code false} otherwise + */ + private static boolean triple(Graph graph, Node a, Node b, Node c) { + return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + } + /** * Determines if the collider is allowed. * @@ -435,7 +317,7 @@ private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScore * @param y The Node object representing the third node. * @return true if the collider is allowed, false otherwise. */ - private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { + private static boolean colliderAllowed(Graph pag, Node x, Node b, Node y, Knowledge knowledge) { return FciOrient.isArrowheadAllowed(x, b, pag, knowledge) && FciOrient.isArrowheadAllowed(y, b, pag, knowledge); } @@ -447,7 +329,8 @@ private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { * @param pag The Graph representing the PAG. * @param best The list of Node objects representing the best nodes. */ - private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best) { + private static void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best, Knowledge knowledge, + boolean verbose) { if (verbose) { TetradLogger.getInstance().log("Orient required edges in PAG:"); } @@ -465,23 +348,10 @@ private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List b * @param c The third node in the triple. * @return {@code true} if the nodes form an unshielded triple, {@code false} otherwise. */ - private boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { + private static boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); } - /** - * Checks if three nodes are connected in a graph. - * - * @param graph the graph to check for connectivity - * @param a the first node - * @param b the second node - * @param c the third node - * @return {@code true} if all three nodes are connected, {@code false} otherwise - */ - private boolean triple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); - } - /** * Checks if the given nodes are unshielded colliders when considering the given graph. * @@ -491,10 +361,19 @@ private boolean triple(Graph graph, Node a, Node b, Node c) { * @param c the third node * @return true if the nodes are unshielded colliders, false otherwise */ - private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { + private static boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { return a != c && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); } + private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { + List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); + commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); + List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); + commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); + commonNoncolliders.removeAll(commonChildren); + return commonNoncolliders; + } + /** * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. * @@ -502,7 +381,8 @@ private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { * @param pag The Graph object for which the final orientation is determined. * @param scorer The scorer object used in the score-based discriminating path rule. */ - private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { + public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer, boolean completeRuleSetUsed, + boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule, boolean verbose) { if (verbose) { TetradLogger.getInstance().log("Final Orientation:"); } @@ -513,7 +393,7 @@ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer sco } else { fciOrient.spirtesFinalOrientation(pag); } - } while (discriminatingPathRule(pag, scorer)); // Score-based discriminating path rule + } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule)); } /** @@ -533,9 +413,8 @@ private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer sco * * @param graph a {@link Graph} object */ - private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { - if (!doDiscriminatingPathTailRule) return false; - + private static boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer, + boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule) { List nodes = graph.getNodes(); boolean oriented = false; @@ -569,7 +448,7 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { continue; } - boolean _oriented = ddpOrient(a, b, c, graph, scorer); + boolean _oriented = ddpOrient(a, b, c, graph, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule); if (_oriented) oriented = true; } @@ -589,7 +468,8 @@ private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { * @param c a {@link Node} object * @param graph a {@link Graph} object */ - private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { + private static boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer, + boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule) { Queue Q = new ArrayDeque<>(20); Set V = new HashSet<>(); @@ -640,7 +520,8 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc } if (!graph.isAdjacentTo(d, c)) { - if (doDdpOrientation(d, a, b, c, path, graph, scorer)) { + if (doDdpOrientation(d, a, b, c, path, graph, scorer, + doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, false)) { return true; } } @@ -684,8 +565,9 @@ private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer sc * @return true if the orientation is determined, false otherwise * @throws IllegalArgumentException if 'e' is adjacent to 'c' */ - private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph - graph, TeyssierScorer scorer) { + private static boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph graph, + TeyssierScorer scorer, boolean doDiscriminatingPathTailRule, + boolean doDiscriminatingPathColliderRule, boolean verbose) { if (graph.getEndpoint(b, c) != Endpoint.ARROW) { return false; @@ -729,7 +611,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path graph.setEndpoint(a, b, Endpoint.ARROW); graph.setEndpoint(c, b, Endpoint.ARROW); - if (this.verbose) { + if (verbose) { TetradLogger.getInstance().log( "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -740,7 +622,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path if (doDiscriminatingPathTailRule) { graph.setEndpoint(c, b, Endpoint.TAIL); - if (this.verbose) { + if (verbose) { TetradLogger.getInstance().log( "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } @@ -752,6 +634,148 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path return false; } + /** + * Run the search and return s a PAG. + * + * @return The PAG. + */ + public Graph search() { + List nodes = this.score.getVariables(); + + if (nodes == null) { + throw new NullPointerException("Nodes from test were null."); + } + + if (verbose) { + TetradLogger.getInstance().log("===Starting LV-Lite==="); + } + + if (verbose) { + TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); + } + + // BOSS seems to be doing better here. + var suborderSearch = new Boss(score); + suborderSearch.setKnowledge(knowledge); + suborderSearch.setResetAfterBM(true); + suborderSearch.setResetAfterRS(true); + suborderSearch.setVerbose(false); + suborderSearch.setUseBes(useBes); + suborderSearch.setUseDataOrder(useDataOrder); + suborderSearch.setNumStarts(numStarts); + var permutationSearch = new PermutationSearch(suborderSearch); + permutationSearch.setKnowledge(knowledge); + permutationSearch.search(); + var best = permutationSearch.getOrder(); + + if (verbose) { + TetradLogger.getInstance().log("Best order: " + best); + } + + var scorer = new TeyssierScorer(null, score); + scorer.score(best); + scorer.bookmark(); + + if (verbose) { + TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); + } + + var cpdag = scorer.getGraph(true); + var pag = new EdgeListGraph(cpdag); + scorer.score(best); + + FciOrient fciOrient = new FciOrient(null); + + fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); + fciOrient.setDoDiscriminatingPathColliderRule(false); + fciOrient.setDoDiscriminatingPathTailRule(false); + fciOrient.setMaxPathLength(maxPathLength); + fciOrient.setKnowledge(knowledge); + fciOrient.setVerbose(verbose); + + if (verbose) { + TetradLogger.getInstance().log("Collider orientation and edge removal."); + } + + // The main procedure. + Set unshieldedColliders = new HashSet<>(); + Set _unshieldedColliders; + + do { + _unshieldedColliders = new HashSet<>(unshieldedColliders); + orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, verbose); + } while (!unshieldedColliders.equals(_unshieldedColliders)); + + finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose); + + return GraphUtils.replaceNodes(pag, this.score.getVariables()); + } + + /** + * Sets the knowledge used in search. + * + * @param knowledge This knowledge. + */ + public void setKnowledge(Knowledge knowledge) { + this.knowledge = new Knowledge(knowledge); + } + + /** + * Sets whether the complete rule set should be used during the search algorithm. By default, the complete rule set + * is not used. + * + * @param completeRuleSetUsed true if the complete rule set should be used, false otherwise + */ + public void setCompleteRuleSetUsed(boolean completeRuleSetUsed) { + this.completeRuleSetUsed = completeRuleSetUsed; + } + + /** + * Sets the verbosity level of the search algorithm. + * + * @param verbose true to enable verbose mode, false to disable it + */ + public void setVerbose(boolean verbose) { + this.verbose = verbose; + } + + /** + * Sets the number of starts for BOSS. + * + * @param numStarts The number of starts. + */ + public void setNumStarts(int numStarts) { + this.numStarts = numStarts; + } + + /** + * Sets whether the discriminating path tail rule should be used. + * + * @param doDiscriminatingPathTailRule True, if so. + */ + public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule) { + this.doDiscriminatingPathTailRule = doDiscriminatingPathTailRule; + } + + /** + * Sets whether the discriminating path collider rule should be used. + * + * @param doDiscriminatingPathColliderRule True, if so. + */ + public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { + this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; + } + + /** + * Sets whether to use the BES (Backward Elimination Search) algorithm during the search. + * + * @param useBes true to use the BES algorithm, false otherwise + */ + public void setUseBes(boolean useBes) { + this.useBes = useBes; + } + /** * Sets the allowTucks flag to the specified value. * diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 99380d205c..34490679f0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -54,7 +54,7 @@ public final class LvLiteDsepFriendly implements IGraphSearch { /** * The independence test. */ - private IndependenceTest test; + private final IndependenceTest test; /** * The score. */ @@ -104,14 +104,6 @@ public final class LvLiteDsepFriendly implements IGraphSearch { * tucks are enabled or disabled. */ private boolean allowTucks = true; - /** - * The scorer to be used. - */ - private TeyssierScorer scorer; - /** - * The time at which the algorithm started. - */ - private long start; /** * Whether to impose an ordering on the three GRaSP algorithms. */ @@ -141,17 +133,6 @@ public final class LvLiteDsepFriendly implements IGraphSearch { */ private int maxPathLength = -1; - /** - * Constructor for a score. - * - * @param score The score to use. - */ - public LvLiteDsepFriendly(@NotNull Score score) { - this.score = score; - this.variables = new ArrayList<>(score.getVariables()); - this.useScore = true; - } - /** * Constructor for a test. * @@ -173,29 +154,7 @@ public LvLiteDsepFriendly(@NotNull IndependenceTest test) { public LvLiteDsepFriendly(@NotNull IndependenceTest test, Score score) { this.test = test; this.score = score; - this.variables = new ArrayList<>(score.getVariables()); - } - - private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { - List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); - commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); - List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); - commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); - commonNoncolliders.removeAll(commonChildren); - return commonNoncolliders; - } - - /** - * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given - * Graph following the PAG (Partially Ancestral Graph) structure. - * - * @param pag The Graph to be reoriented. - */ - private void reorientWithCircles(Graph pag) { - if (verbose) { - TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); - } - pag.reorientAllWith(Endpoint.CIRCLE); + this.variables = new ArrayList<>(test.getVariables()); } /** @@ -204,18 +163,18 @@ private void reorientWithCircles(Graph pag) { * @return The PAG. */ public Graph search() { - List nodes = this.score.getVariables(); + List nodes = this.test.getVariables(); if (nodes == null) { throw new NullPointerException("Nodes from test were null."); } if (verbose) { - TetradLogger.getInstance().log("===Starting LV-Lite==="); + TetradLogger.getInstance().log("===Starting LV-Lite-DSEP friendly==="); } if (verbose) { - TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); + TetradLogger.getInstance().log("Running GRaSP to get CPDAG and best order."); } test.setVerbose(false); @@ -224,9 +183,6 @@ public Graph search() { edu.cmu.tetrad.search.Grasp grasp = new edu.cmu.tetrad.search.Grasp(test, score); grasp.setSeed(seed); -// grasp.setDepth(depth); -// grasp.setUncoveredDepth(uncoveredDepth); -// grasp.setNonSingularDepth(nonSingularDepth); grasp.setDepth(3); grasp.setUncoveredDepth(1); grasp.setNonSingularDepth(1); @@ -288,10 +244,11 @@ public Graph search() { do { _unshieldedColliders = new HashSet<>(unshieldedColliders); - orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag); + LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, verbose); } while (!unshieldedColliders.equals(_unshieldedColliders)); - finalOrientation(fciOrient, pag, scorer); + LvLite.finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, + doDiscriminatingPathColliderRule, verbose); return GraphUtils.replaceNodes(pag, this.score.getVariables()); } @@ -314,481 +271,6 @@ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColl this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } - /** - * Orients and removes edges in a graph according to specified rules. Edges are removed in the course of the - * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the - * possibility that the removal of an edge may allow for further removals or orientations. - * - * @param pag The original graph. - * @param fciOrient The orientation rules to be applied. - * @param best The list of best nodes. - * @param scorer The scorer used to evaluate edge orientations. - */ - private void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, - Set unshieldedColliders, Graph cpdag) { - reorientWithCircles(pag); - doRequiredOrientations(fciOrient, pag, best); - - var reverse = new ArrayList<>(best); - Collections.reverse(reverse); - Set toRemove = new HashSet<>(); - - recallUnshieldedTriples(pag, unshieldedColliders, reverse); - mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove); - removeEdges(pag, toRemove); - } - - private void removeEdges(Graph pag, Set toRemove) { - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); - - boolean _adj = pag.isAdjacentTo(x, y); - - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().log( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); - } - } - } - } - - private void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, ArrayList reverse, Set toRemove) { - for (Node b : reverse) { - var adj = pag.getAdjacentNodes(b); - Collections.reverse(adj); - - for (int i = 0; i < adj.size(); i++) { - for (int j = 0; j < adj.size(); j++) { - if (i == j) continue; - - var x = adj.get(i); - var y = adj.get(j); - - if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove); - } - } - } - } - } - - private void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse) { - for (Node b : reverse) { - var adj = pag.getAdjacentNodes(b); - - // Sort adj in the order of reverse - adj.sort(Comparator.comparingInt(reverse::indexOf)); - - for (int i = 0; i < adj.size(); i++) { - for (int j = 0; j < adj.size(); j++) { - if (i == j) continue; - - var x = adj.get(i); - var y = adj.get(j); - - if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - pag.removeEdge(x, y); - - if (verbose) { - TetradLogger.getInstance().log( - "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); - } - } - } - } - } - } - - private void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove) { - scorer.goToBookmark(); - - scorer.tuck(b, x); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - - scorer.tuck(b, y); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove); - - List commonNoncolliders = commonNoncolliders(x, y, pag); - commonNoncolliders.remove(b); - - for (Node a : new ArrayList<>(commonNoncolliders)) { - scorer.tuck(a, x); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); - - scorer.tuck(a, y); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove); - } - } - - private boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders) { - if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { - if (colliderAllowed(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - unshieldedColliders.add(new Triple(x, b, y)); - - if (verbose) { - TetradLogger.getInstance().log( - "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } - - return true; - } - } - - return false; - } - - private void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove) { - if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { - if (colliderAllowed(pag, x, b, y)) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - - toRemove.add(new NodePair(x, y)); - unshieldedColliders.add(new Triple(x, b, y)); - - if (verbose) { - TetradLogger.getInstance().log( - "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); - } - } - } - } - - /** - * Checks if three nodes are connected in a graph. - * - * @param graph the graph to check for connectivity - * @param a the first node - * @param b the second node - * @param c the third node - * @return {@code true} if all three nodes are connected, {@code false} otherwise - */ - private boolean triple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); - } - - /** - * Determines if the collider is allowed. - * - * @param pag The Graph representing the PAG. - * @param x The Node object representing the first node. - * @param b The Node object representing the second node. - * @param y The Node object representing the third node. - * @return true if the collider is allowed, false otherwise. - */ - private boolean colliderAllowed(Graph pag, Node x, Node b, Node y) { - return FciOrient.isArrowheadAllowed(x, b, pag, knowledge) - && FciOrient.isArrowheadAllowed(y, b, pag, knowledge); - } - - /** - * Orient required edges in PAG. - * - * @param fciOrient The FciOrient object used for orienting the edges. - * @param pag The Graph representing the PAG. - * @param best The list of Node objects representing the best nodes. - */ - private void doRequiredOrientations(FciOrient fciOrient, Graph pag, List best) { - if (verbose) { - TetradLogger.getInstance().log("Orient required edges in PAG:"); - } - - fciOrient.fciOrientbk(knowledge, pag, best); - } - - /** - * Checks if three nodes in a graph form an unshielded triple. An unshielded triple is a configuration where node a - * is adjacent to node b, node b is adjacent to node c, but node a is not adjacent to node c. - * - * @param graph The graph in which the nodes reside. - * @param a The first node in the triple. - * @param b The second node in the triple. - * @param c The third node in the triple. - * @return {@code true} if the nodes form an unshielded triple, {@code false} otherwise. - */ - private boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); - } - - /** - * Checks if the given nodes are unshielded colliders when considering the given graph. - * - * @param graph the graph to consider - * @param a the first node - * @param b the second node - * @param c the third node - * @return true if the nodes are unshielded colliders, false otherwise - */ - private boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { - return a != c && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); - } - - /** - * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. - * - * @param fciOrient The FciOrient object used to determine the final orientation. - * @param pag The Graph object for which the final orientation is determined. - * @param scorer The scorer object used in the score-based discriminating path rule. - */ - private void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer) { - if (verbose) { - TetradLogger.getInstance().log("Final Orientation:"); - } - - do { - if (completeRuleSetUsed) { - fciOrient.zhangFinalOrientation(pag); - } else { - fciOrient.spirtesFinalOrientation(pag); - } - } while (discriminatingPathRule(pag, scorer)); // Score-based discriminating path rule - } - - /** - * This is a score-based discriminating path rule. - *

    - * The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where - * the dots are a collider path from E to A with each node on the path (except L) a parent of C. - *

    -     *          B
    -     *         xo           x is either an arrowhead or a circle
    -     *        /  \
    -     *       v    v
    -     * E....A --> C
    -     * 
    - *

    - * This is Zhang's rule R4, discriminating paths. - * - * @param graph a {@link Graph} object - */ - private boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer) { - if (!doDiscriminatingPathTailRule) return false; - - List nodes = graph.getNodes(); - boolean oriented = false; - - for (Node b : nodes) { - if (Thread.currentThread().isInterrupted()) { - break; - } - - // potential A and C candidate pairs are only those - // that look like this: A<-*Bo-*C - List possA = graph.getNodesOutTo(b, Endpoint.ARROW); - List possC = graph.getNodesInTo(b, Endpoint.CIRCLE); - - for (Node a : possA) { - if (Thread.currentThread().isInterrupted()) { - break; - } - - for (Node c : possC) { - if (Thread.currentThread().isInterrupted()) { - break; - } - - if (a == c) continue; - - if (!graph.isParentOf(a, c)) { - continue; - } - - if (graph.getEndpoint(b, c) != Endpoint.ARROW) { - continue; - } - - boolean _oriented = ddpOrient(a, b, c, graph, scorer); - - if (_oriented) oriented = true; - } - } - } - - return oriented; - } - - /** - * A method to search "back from a" to find a DDP. It is called with a reachability list (first consisting only of - * a). This is breadth-first, using "reachability" concept from Geiger, Verma, and Pearl 1990. The body of a DDP - * consists of colliders that are parents of c. - * - * @param a a {@link Node} object - * @param b a {@link Node} object - * @param c a {@link Node} object - * @param graph a {@link Graph} object - */ - private boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer) { - Queue Q = new ArrayDeque<>(20); - Set V = new HashSet<>(); - - Node e = null; - - Map previous = new HashMap<>(); - List path = new ArrayList<>(); - - List cParents = graph.getParents(c); - - Q.offer(a); - V.add(a); - V.add(b); - previous.put(a, b); - - while (!Q.isEmpty()) { - if (Thread.currentThread().isInterrupted()) { - break; - } - - Node t = Q.poll(); - - if (e == null || e == t) { - e = t; - } - - List nodesInTo = graph.getNodesInTo(t, Endpoint.ARROW); - - for (Node d : nodesInTo) { - if (Thread.currentThread().isInterrupted()) { - break; - } - - if (V.contains(d)) { - continue; - } - - Node p = previous.get(t); - - if (!graph.isDefCollider(d, t, p)) { - continue; - } - - previous.put(d, t); - - if (!path.contains(t)) { - path.add(t); - } - - if (!graph.isAdjacentTo(d, c)) { - if (doDdpOrientation(d, a, b, c, path, graph, scorer)) { - return true; - } - } - - if (cParents.contains(d)) { - Q.offer(d); - V.add(d); - } - } - } - - return false; - } - - /** - * Determines the orientation for the nodes in a Directed Acyclic Graph (DAG) based on the Discriminating Path Rule - * Here, we insist that the sepset for D and B contain all the nodes along the collider path. - *

    - * Reminder: - *

    -     *      The triangles that must be oriented this way (won't be done by another rule) all look like the ones below, where
    -     *      the dots are a collider path from E to A with each node on the path (except L) a parent of C.
    -     *      
    -     *               B
    -     *              xo           x is either an arrowhead or a circle
    -     *             /  \
    -     *            v    v
    -     *      E....A --> C
    -     *
    -     *      This is Zhang's rule R4, discriminating paths. The "collider path" here is all of the collider nodes
    -     *      along the E...A path (all parents of C), including A. The idea is that is we know that E is independent
    -     *      of C given all of nodes on the collider path plus perhaps some other nodes, then there should be a collider
    -     *      at B; otherwise, there should be a noncollider at B.
    -     * 
    - * - * @param e the 'e' node - * @param a the 'a' node - * @param b the 'b' node - * @param c the 'c' node - * @param graph the graph representation - * @return true if the orientation is determined, false otherwise - * @throws IllegalArgumentException if 'e' is adjacent to 'c' - */ - private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path, Graph - graph, TeyssierScorer scorer) { - - if (graph.getEndpoint(b, c) != Endpoint.ARROW) { - return false; - } - - if (graph.getEndpoint(c, b) != Endpoint.CIRCLE) { - return false; - } - - if (graph.getEndpoint(a, c) != Endpoint.ARROW) { - return false; - } - - if (graph.getEndpoint(b, a) != Endpoint.ARROW) { - return false; - } - - if (graph.getEndpoint(c, a) != Endpoint.TAIL) { - return false; - } - - if (!path.contains(a)) { - throw new IllegalArgumentException("Path does not contain a"); - } - - for (Node n : path) { - if (!graph.isParentOf(n, c)) { - throw new IllegalArgumentException("Node " + n + " is not a parent of " + c); - } - } - - scorer.goToBookmark(); - scorer.tuck(b, c); - scorer.tuck(b, e); - scorer.tuck(c, e); - - boolean collider = !scorer.adjacent(e, c); - - if (collider) { - if (doDiscriminatingPathColliderRule) { - graph.setEndpoint(a, b, Endpoint.ARROW); - graph.setEndpoint(c, b, Endpoint.ARROW); - - if (this.verbose) { - TetradLogger.getInstance().log( - "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); - } - - return true; - } - } else { - if (doDiscriminatingPathTailRule) { - graph.setEndpoint(c, b, Endpoint.TAIL); - - if (this.verbose) { - TetradLogger.getInstance().log( - "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); - } - - return true; - } - } - - return false; - } - /** * Sets the allowTucks flag to the specified value. * @@ -798,7 +280,6 @@ public void setAllowTucks(boolean allowTucks) { this.allowTucks = allowTucks; } - /** * Sets the knowledge used in search. * @@ -910,7 +391,6 @@ public void setDepth(int depth) { this.depth = depth; } - /** * Sets the maximum length of any discriminating path. * From 9e751d499cb48b30b257fe67bc397d84c86fb296 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Wed, 5 Jun 2024 15:39:58 -0400 Subject: [PATCH 15/29] Refactor collider orientation and remove unused parameters The collider orientation logic in the LvLite.java and LvLiteDsepFriendly.java files is refactored and made more concise. Unnecessary parameters and methods related to depth settings for search algorithms in these files are also removed. The default value for 'doDiscriminatingPathColliderRule' is now set to true in the manual index.html file. --- .../cmu/tetradapp/model/GridSearchModel.java | 2 +- .../oracle/pag/LvLiteDsepFriendly.java | 9 ++-- .../java/edu/cmu/tetrad/search/LvLite.java | 54 ++++++++++--------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 48 +---------------- .../src/main/resources/docs/manual/index.html | 2 +- 5 files changed, 36 insertions(+), 79 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java index 6dd0623eb3..8ee9fe0ca1 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java @@ -463,7 +463,7 @@ public void runComparison(java.io.PrintStream localOut) { // Making a copy of the parameters to send to Comparison since Comparison iterates // over the parameters and modifies them. - String outputFileName = "Comparison"; + String outputFileName = "Comparison.txt"; comparison.compareFromSimulations(resultsPath, simulations, outputFileName, localOut, algorithms, getSelectedStatistics(), new Parameters(parameters)); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java index 6ebe9c23f3..b1e3abd7bf 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -114,8 +114,6 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { // GRaSP search.setSeed(parameters.getLong(Params.SEED)); - search.setSingularDepth(parameters.getInt(Params.GRASP_SINGULAR_DEPTH)); - search.setNonSingularDepth(parameters.getInt(Params.GRASP_NONSINGULAR_DEPTH)); search.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG)); search.setAllowInternalRandomness(parameters.getBoolean(Params.ALLOW_INTERNAL_RANDOMNESS)); search.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE)); @@ -124,7 +122,6 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setNumStarts(parameters.getInt(Params.NUM_STARTS)); // FCI - search.setDepth(parameters.getInt(Params.DEPTH)); search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); @@ -180,9 +177,9 @@ public List getParameters() { List params = new ArrayList<>(); // GRaSP - params.add(Params.GRASP_DEPTH); - params.add(Params.GRASP_SINGULAR_DEPTH); - params.add(Params.GRASP_NONSINGULAR_DEPTH); +// params.add(Params.GRASP_DEPTH); +// params.add(Params.GRASP_SINGULAR_DEPTH); +// params.add(Params.GRASP_NONSINGULAR_DEPTH); params.add(Params.GRASP_ORDERED_ALG); params.add(Params.GRASP_USE_RASKUTTI_UHLER); params.add(Params.USE_DATA_ORDER); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index e316e4ae58..70b557fc9f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -137,7 +137,8 @@ private static void reorientWithCircles(Graph pag, boolean verbose) { * @param scorer The scorer used to evaluate edge orientations. */ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, - Set unshieldedColliders, Graph cpdag, Knowledge knowledge, boolean verbose) { + Set unshieldedColliders, Graph cpdag, Knowledge knowledge, + boolean allowTucks, boolean verbose) { reorientWithCircles(pag, verbose); doRequiredOrientations(fciOrient, pag, best, knowledge, verbose); @@ -146,28 +147,7 @@ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, Set toRemove = new HashSet<>(); recallUnshieldedTriples(pag, unshieldedColliders, reverse, verbose); - mainLoop(pag, scorer, unshieldedColliders, cpdag, reverse, toRemove, knowledge, verbose); - removeEdges(pag, toRemove, verbose); - } - - private static void removeEdges(Graph pag, Set toRemove, boolean verbose) { - for (NodePair remove : toRemove) { - Node x = remove.getFirst(); - Node y = remove.getSecond(); - - boolean _adj = pag.isAdjacentTo(x, y); - - if (pag.removeEdge(x, y)) { - if (verbose && _adj && !pag.isAdjacentTo(x, y)) { - TetradLogger.getInstance().log( - "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); - } - } - } - } - private static void mainLoop(Graph pag, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, - ArrayList reverse, Set toRemove, Knowledge knowledge, boolean verbose) { for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); Collections.reverse(adj); @@ -180,11 +160,29 @@ private static void mainLoop(Graph pag, TeyssierScorer scorer, Set unshi var y = adj.get(j); if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, knowledge, verbose)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, allowTucks, verbose); } } } } + + removeEdges(pag, toRemove, verbose); + } + + private static void removeEdges(Graph pag, Set toRemove, boolean verbose) { + for (NodePair remove : toRemove) { + Node x = remove.getFirst(); + Node y = remove.getSecond(); + + boolean _adj = pag.isAdjacentTo(x, y); + + if (pag.removeEdge(x, y)) { + if (verbose && _adj && !pag.isAdjacentTo(x, y)) { + TetradLogger.getInstance().log( + "TUCKING: Removed adjacency " + x + " *-* " + y + " in the PAG."); + } + } + } } private static void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse, boolean verbose) { @@ -217,7 +215,9 @@ private static void recallUnshieldedTriples(Graph pag, Set unshieldedCol } private static void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove, Knowledge knowledge, boolean verbose) { + Set toRemove, Knowledge knowledge, boolean allowTucks, boolean verbose) { + if (!allowTucks) return; + scorer.goToBookmark(); if (!unshieldedTriple(pag, x, b, y)) { @@ -352,6 +352,10 @@ private static boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); } + private static boolean defCollider(Graph graph, Node a, Node b, Node c) { + return graph.isDefCollider(a, b, c); + } + /** * Checks if the given nodes are unshielded colliders when considering the given graph. * @@ -704,7 +708,7 @@ public Graph search() { do { _unshieldedColliders = new HashSet<>(unshieldedColliders); - orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, verbose); + orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose); } while (!unshieldedColliders.equals(_unshieldedColliders)); finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 34490679f0..0676a302c1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -60,7 +60,7 @@ public final class LvLiteDsepFriendly implements IGraphSearch { */ private Score score; /** - * Indicates whether or not the score should be used. + * Indicates whether the score should be used. */ private boolean useScore; /** @@ -108,18 +108,6 @@ public final class LvLiteDsepFriendly implements IGraphSearch { * Whether to impose an ordering on the three GRaSP algorithms. */ private boolean ordered = false; - /** - * The maximum depth of the depth-first search for tucks. - */ - private int uncoveredDepth = 1; - /** - * The maximum depth of the depth-first search for uncovered tucks. - */ - private int nonSingularDepth = 1; - /** - * The maximum depth of the depth-first search for singular tucks. - */ - private int depth = 3; /** * Specifies whether internal randomness is allowed. */ @@ -186,9 +174,6 @@ public Graph search() { grasp.setDepth(3); grasp.setUncoveredDepth(1); grasp.setNonSingularDepth(1); - grasp.setDepth(depth); - grasp.setUncoveredDepth(uncoveredDepth); - grasp.setNonSingularDepth(nonSingularDepth); grasp.setOrdered(ordered); grasp.setUseScore(useScore); grasp.setUseRaskuttiUhler(useRaskuttiUhler); @@ -244,7 +229,7 @@ public Graph search() { do { _unshieldedColliders = new HashSet<>(unshieldedColliders); - LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, verbose); + LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose); } while (!unshieldedColliders.equals(_unshieldedColliders)); LvLite.finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, @@ -344,26 +329,6 @@ public void setUseScore(boolean useScore) { this.useScore = useScore; } - /** - * Sets depth for singular tucks. - * - * @param uncoveredDepth The depth for singular tucks. - */ - public void setSingularDepth(int uncoveredDepth) { - if (uncoveredDepth < -1) throw new IllegalArgumentException("Uncovered depth should be >= -1."); - this.uncoveredDepth = uncoveredDepth; - } - - /** - * Sets depth for non-singular tucks. - * - * @param nonSingularDepth The depth for non-singular tucks. - */ - public void setNonSingularDepth(int nonSingularDepth) { - if (nonSingularDepth < -1) throw new IllegalArgumentException("Non-singular depth should be >= -1."); - this.nonSingularDepth = nonSingularDepth; - } - /** * Sets whether to use the ordered version of GRaSP. * @@ -382,15 +347,6 @@ public void setSeed(long seed) { this.seed = seed; } - /** - * Sets the depth for the search algorithm. - * - * @param depth The depth value to set for the search algorithm. - */ - public void setDepth(int depth) { - this.depth = depth; - } - /** * Sets the maximum length of any discriminating path. * diff --git a/tetrad-lib/src/main/resources/docs/manual/index.html b/tetrad-lib/src/main/resources/docs/manual/index.html index 223b63570a..6063f0500d 100755 --- a/tetrad-lib/src/main/resources/docs/manual/index.html +++ b/tetrad-lib/src/main/resources/docs/manual/index.html @@ -5198,7 +5198,7 @@

    coefLow

    should be done, No if not
  • Default Value: false
  • + id="doDiscriminatingPathColliderRule_default_value">true
  • Lower Bound:
  • Upper Bound: Date: Thu, 6 Jun 2024 02:52:59 -0400 Subject: [PATCH 16/29] Refactor and optimize LvLite and related classes Revamped the recallUnshieldedTriples method in LvLite to clean up its operations, improving its efficiency. Enhanced LvLiteDsepFriendly by altering various parameters for better performance. The DagToPag has been revised with more extensive inline documentation and notes. The FciOrient class was updated to ensure that every endpoint and edge changing operation correctly sets the change flag for better responsiveness to alterations. --- .../java/edu/cmu/tetrad/search/LvLite.java | 118 +++++++++--------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 16 +-- .../edu/cmu/tetrad/search/utils/DagToPag.java | 28 +++-- .../cmu/tetrad/search/utils/FciOrient.java | 17 ++- 4 files changed, 98 insertions(+), 81 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 70b557fc9f..85b9bb62c2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -142,15 +142,14 @@ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, reorientWithCircles(pag, verbose); doRequiredOrientations(fciOrient, pag, best, knowledge, verbose); + recallUnshieldedTriples(pag, unshieldedColliders, verbose); + var reverse = new ArrayList<>(best); Collections.reverse(reverse); Set toRemove = new HashSet<>(); - recallUnshieldedTriples(pag, unshieldedColliders, reverse, verbose); - for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); - Collections.reverse(adj); for (int i = 0; i < adj.size(); i++) { for (int j = 0; j < adj.size(); j++) { @@ -185,30 +184,25 @@ private static void removeEdges(Graph pag, Set toRemove, boolean verbo } } - private static void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, ArrayList reverse, boolean verbose) { - for (Node b : reverse) { - var adj = pag.getAdjacentNodes(b); - - // Sort adj in the order of reverse - adj.sort(Comparator.comparingInt(reverse::indexOf)); - - for (int i = 0; i < adj.size(); i++) { - for (int j = 0; j < adj.size(); j++) { - if (i == j) continue; + private static void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, boolean verbose) { + for (Triple triple : unshieldedColliders) { + Node x = triple.getX(); + Node z = triple.getZ(); + pag.removeEdge(x, z); + } - var x = adj.get(i); - var y = adj.get(j); + for (Triple triple : unshieldedColliders) { + Node x = triple.getX(); + Node b = triple.getY(); + Node y = triple.getZ(); - if (triple(pag, x, b, y) && unshieldedColliders.contains(new Triple(x, b, y))) { - pag.setEndpoint(x, b, Endpoint.ARROW); - pag.setEndpoint(y, b, Endpoint.ARROW); - pag.removeEdge(x, y); + if (triple(pag, x, b, y)) { + pag.setEndpoint(x, b, Endpoint.ARROW); + pag.setEndpoint(y, b, Endpoint.ARROW); - if (verbose) { - TetradLogger.getInstance().log( - "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); - } - } + if (verbose) { + TetradLogger.getInstance().log( + "Recalled " + x + " *-> " + b + " <-* " + y + " from previous PAG."); } } } @@ -220,40 +214,37 @@ private static void triangleReasoning(Node x, Node b, Node y, Graph pag, Teyssie scorer.goToBookmark(); - if (!unshieldedTriple(pag, x, b, y)) { + if (triangle(pag, x, b, y)) { scorer.tuck(b, x); + scorer.tuck(x, y); copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); } - if (!unshieldedTriple(pag, x, b, y)) { - scorer.tuck(b, y); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); - } + List commonAdjacents = commonAdjacents(x, y, pag); + commonAdjacents.remove(b); - scorer.goToBookmark(); + boolean changed = true; - List commonNoncolliders = commonNoncolliders(x, y, pag); - commonNoncolliders.remove(b); + while (changed) { + changed = false; + scorer.goToBookmark(); + Collections.shuffle(commonAdjacents); - for (Node a : new ArrayList<>(commonNoncolliders)) { - if (!unshieldedTriple(pag, x, a, y)) { - scorer.tuck(a, x); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); - } + for (Node a : new ArrayList<>(commonAdjacents)) { + scorer.goToBookmark(); - if (!unshieldedTriple(pag, x, a, y)) { - scorer.tuck(a, y); - copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + if (triangle(pag, x, a, y)) { + scorer.tuck(a, x); + scorer.tuck(x, y); + commonAdjacents.remove(a); + changed = changed || copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + } } } } private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders, Knowledge knowledge, boolean verbose) { - if (unshieldedColliders.contains(new Triple(x, b, y))) { - return true; - } - if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { if (colliderAllowed(pag, x, b, y, knowledge)) { pag.setEndpoint(x, b, Endpoint.ARROW); @@ -273,12 +264,8 @@ private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, return false; } - private static void copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove, Knowledge knowledge, boolean verbose) { - if (unshieldedColliders.contains(new Triple(x, b, y))) { - return; - } - + private static boolean copyColliderScorer(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, + Set toRemove, Knowledge knowledge, boolean verbose) { if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { if (colliderAllowed(pag, x, b, y, knowledge)) { pag.setEndpoint(x, b, Endpoint.ARROW); @@ -291,8 +278,12 @@ private static void copyColliderScorer(Node x, Node b, Node y, Graph pag, Teyssi TetradLogger.getInstance().log( "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } + + return true; } } + + return false; } /** @@ -305,7 +296,13 @@ private static void copyColliderScorer(Node x, Node b, Node y, Graph pag, Teyssi * @return {@code true} if all three nodes are connected, {@code false} otherwise */ private static boolean triple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + return a != b && b != c && a != c + && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c); + } + + private static boolean triangle(Graph graph, Node a, Node b, Node c) { + return a != b && b != c && a != c + && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && graph.isAdjacentTo(a, c); } /** @@ -349,7 +346,8 @@ private static void doRequiredOrientations(FciOrient fciOrient, Graph pag, List< * @return {@code true} if the nodes form an unshielded triple, {@code false} otherwise. */ private static boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { - return graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); + return a != b && b != c && a != c + && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); } private static boolean defCollider(Graph graph, Node a, Node b, Node c) { @@ -366,16 +364,14 @@ private static boolean defCollider(Graph graph, Node a, Node b, Node c) { * @return true if the nodes are unshielded colliders, false otherwise */ private static boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { - return a != c && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); + return a != b && b != c && a != c + && unshieldedTriple(graph, a, b, c) && graph.isDefCollider(a, b, c); } - private static @NotNull List commonNoncolliders(Node x, Node y, Graph pag) { - List commonNoncolliders = new ArrayList<>(pag.getAdjacentNodes(x)); - commonNoncolliders.retainAll(pag.getAdjacentNodes(y)); - List commonChildren = pag.getNodesOutTo(x, Endpoint.ARROW); - commonChildren.retainAll(pag.getNodesOutTo(y, Endpoint.ARROW)); - commonNoncolliders.removeAll(commonChildren); - return commonNoncolliders; + private static @NotNull List commonAdjacents(Node x, Node y, Graph pag) { + List commonAdjacents = new ArrayList<>(pag.getAdjacentNodes(x)); + commonAdjacents.retainAll(pag.getAdjacentNodes(y)); + return commonAdjacents; } /** @@ -391,6 +387,8 @@ public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScor TetradLogger.getInstance().log("Final Orientation:"); } + fciOrient.setVerbose(verbose); + do { if (completeRuleSetUsed) { fciOrient.zhangFinalOrientation(pag); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 0676a302c1..ca41af6008 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -22,6 +22,8 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.*; +import edu.cmu.tetrad.search.score.GraphScore; +import edu.cmu.tetrad.search.score.IndTestScore; import edu.cmu.tetrad.search.score.Score; import edu.cmu.tetrad.search.test.MsepTest; import edu.cmu.tetrad.search.utils.DagSepsets; @@ -165,13 +167,12 @@ public Graph search() { TetradLogger.getInstance().log("Running GRaSP to get CPDAG and best order."); } - test.setVerbose(false); - test.setVerbose(verbose); + edu.cmu.tetrad.search.Grasp grasp = new edu.cmu.tetrad.search.Grasp(test, score); grasp.setSeed(seed); - grasp.setDepth(3); + grasp.setDepth(25); grasp.setUncoveredDepth(1); grasp.setNonSingularDepth(1); grasp.setOrdered(ordered); @@ -184,7 +185,8 @@ public Graph search() { grasp.setNumStarts(numStarts); grasp.setKnowledge(this.knowledge); List best = grasp.bestOrder(variables); - grasp.getGraph(true); + Graph cpdag = grasp.getGraph(true); + var pag = new EdgeListGraph(cpdag); if (verbose) { TetradLogger.getInstance().log("Best order: " + best); @@ -200,8 +202,7 @@ public Graph search() { TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); } - var cpdag = scorer.getGraph(true); - var pag = new EdgeListGraph(cpdag); + scorer.score(best); FciOrient fciOrient; @@ -229,7 +230,8 @@ public Graph search() { do { _unshieldedColliders = new HashSet<>(unshieldedColliders); - LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose); + LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, + allowTucks, verbose); } while (!unshieldedColliders.equals(_unshieldedColliders)); LvLite.finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java index 22f29a8ad8..13d061b26b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/DagToPag.java @@ -39,13 +39,26 @@ * @version $Id: $Id */ public final class DagToPag { - -// private static final WeakHashMap history = new WeakHashMap<>(); - private final Graph dag; /** - * The logger to use. + * The variable 'dag' represents a directed acyclic graph (DAG) that is stored in a private final field. + * A DAG is a finite directed graph with no directed cycles. This means that there is no way to start at some vertex and + * follow a sequence of directed edges that eventually loops back to the same vertex. In other words, there are no + * cyclic dependencies in the graph. + * + * The 'dag' variable is used within the containing class 'DagToPag' for various purposes related to the conversion of + * a DAG to a partially directed acyclic graph (PAG). The methods in 'DagToPag' utilize this variable to perform + * operations such as checking for inducing paths between nodes, converting the DAG to a PAG, and orienting + * unshielded colliders in the graph. + * + * The 'dag' variable has private access, meaning it can only be accessed and modified within the 'DagToPag' class. + * It is declared as 'final', indicating that its value cannot be changed after it is assigned in the constructor or + * initialization block. This ensures that the reference to the DAG remains consistent throughout the lifetime of the + * 'DagToPag' object. + * + * @see DagToPag + * @see Graph */ - private final TetradLogger logger = TetradLogger.getInstance(); + private final Graph dag; /* * The background knowledge. */ @@ -91,7 +104,6 @@ public static boolean existsInducingPathInto(Node x, Node y, Graph graph) { for (Node b : graph.getAdjacentNodes(x)) { Edge edge = graph.getEdge(x, b); if (edge.getProximalEndpoint(x) != Endpoint.ARROW) continue; -// if (!edge.pointsTowards(x)) continue; if (graph.paths().existsInducingPathVisit(x, b, x, y, path)) { return true; @@ -107,8 +119,6 @@ public static boolean existsInducingPathInto(Node x, Node y, Graph graph) { * @return Returns the converted PAG. */ public Graph convert() { -// if (history.get(dag) != null) return history.get(dag); - if (this.verbose) { System.out.println("DAG to PAG_of_the_true_DAG: Starting adjacency search"); } @@ -139,8 +149,6 @@ public Graph convert() { System.out.println("Finishing final orientation"); } -// history.put(dag, graph); - return graph; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java index 5a990b716e..7cc641dfa1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/FciOrient.java @@ -348,9 +348,12 @@ public void ruleR0(Graph graph) { graph.setEndpoint(a, b, Endpoint.ARROW); graph.setEndpoint(c, b, Endpoint.ARROW); + if (this.verbose) { this.logger.log(LogUtilsSearch.colliderOrientedMsg(a, b, c)); } + + this.changeFlag = true; } } } @@ -512,11 +515,12 @@ public void ruleR1(Node a, Node b, Node c, Graph graph) { graph.setEndpoint(c, b, Endpoint.TAIL); graph.setEndpoint(b, c, Endpoint.ARROW); - this.changeFlag = true; if (this.verbose) { this.logger.log(LogUtilsSearch.edgeOrientedMsg("R1: Away from collider", graph.getEdge(b, c))); } + + this.changeFlag = true; } } @@ -999,6 +1003,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path "R4: Definite discriminating path collider rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } + this.changeFlag = true; return true; } } else { @@ -1010,6 +1015,7 @@ private boolean doDdpOrientation(Node e, Node a, Node b, Node c, List path "R4: Definite discriminating path tail rule e = " + e + " " + GraphUtils.pathString(graph, a, b, c)); } + this.changeFlag = true; return true; } } @@ -1067,12 +1073,13 @@ public void orientTailPath(List path, Graph graph) { graph.setEndpoint(n1, n2, Endpoint.TAIL); graph.setEndpoint(n2, n1, Endpoint.TAIL); - this.changeFlag = true; if (verbose) { this.logger.log("R8: Orient circle undirectedPaths " + GraphUtils.pathString(graph, n1, n2)); } + + this.changeFlag = true; } } @@ -1209,11 +1216,12 @@ public void fciOrientbk(Knowledge bk, Graph graph, List variables) { // Orient to*->from graph.setEndpoint(to, from, Endpoint.ARROW); - this.changeFlag = true; if (verbose) { this.logger.log(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(to, from))); } + + this.changeFlag = true; } for (Iterator it @@ -1242,11 +1250,12 @@ public void fciOrientbk(Knowledge bk, Graph graph, List variables) { graph.setEndpoint(to, from, Endpoint.TAIL); graph.setEndpoint(from, to, Endpoint.ARROW); - this.changeFlag = true; if (verbose) { this.logger.log(LogUtilsSearch.edgeOrientedMsg("Knowledge", graph.getEdge(from, to))); } + + this.changeFlag = true; } if (verbose) { From 2b7b9d3cc1e776e7991cf991da175afacfcf2a94 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Thu, 6 Jun 2024 06:28:52 -0400 Subject: [PATCH 17/29] Refactor type conversion and remove readResolve method The code has been refactored to include type checking before doing a type conversion, improving error handling. Unnecessary import statements have been removed. Additionally, white spaces and line alignment have been corrected for better readability. The readResolve method in the NodeType class, which was not being used, has also been removed. --- .../java/edu/cmu/tetrad/search/LvLite.java | 42 +++++++++---------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index 85b9bb62c2..ccf23cfcd1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -220,27 +220,27 @@ private static void triangleReasoning(Node x, Node b, Node y, Graph pag, Teyssie copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); } - List commonAdjacents = commonAdjacents(x, y, pag); - commonAdjacents.remove(b); - - boolean changed = true; - - while (changed) { - changed = false; - scorer.goToBookmark(); - Collections.shuffle(commonAdjacents); - - for (Node a : new ArrayList<>(commonAdjacents)) { - scorer.goToBookmark(); - - if (triangle(pag, x, a, y)) { - scorer.tuck(a, x); - scorer.tuck(x, y); - commonAdjacents.remove(a); - changed = changed || copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); - } - } - } +// List commonAdjacents = commonAdjacents(x, y, pag); +// commonAdjacents.remove(b); +// +// boolean changed = true; +// +// while (changed) { +// changed = false; +// scorer.goToBookmark(); +// Collections.shuffle(commonAdjacents); +// +// for (Node a : new ArrayList<>(commonAdjacents)) { +// scorer.goToBookmark(); +// +// if (triangle(pag, x, a, y)) { +// scorer.tuck(a, x); +// scorer.tuck(x, y); +// commonAdjacents.remove(a); +// changed = changed || copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); +// } +// } +// } } private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders, From dd9b1bebed4e7bf8ec3188818bec78aa5b60b8c9 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sat, 8 Jun 2024 05:18:01 -0400 Subject: [PATCH 18/29] Add equality threshold and optimize performance in LV-Lite In the LV-Lite algorithm, the equalityThreshold variable has been added to control the score drop after the tucking process. Also, the algorithm computation process has been optimized to reduce unnecessary thread creation. In PermutationSearch, a new method of managing the Knowledge object's tiers and variables has been implemented. Minor adjustments have also been made in miscellaneous parts of the code to improve overall algorithm performance and functionality. --- .../src/main/resources/config/devConfig.xml | 11 ++ .../src/main/resources/config/prodConfig.xml | 11 ++ .../algorithm/oracle/pag/LvLite.java | 2 + .../oracle/pag/LvLiteDsepFriendly.java | 6 +- .../java/edu/cmu/tetrad/search/LvLite.java | 155 ++++++++++-------- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 18 +- .../cmu/tetrad/search/PermutationSearch.java | 14 +- .../tetrad/search/utils/BesPermutation.java | 39 +++-- .../main/java/edu/cmu/tetrad/util/Params.java | 4 + .../src/main/resources/docs/manual/index.html | 26 +++ 10 files changed, 198 insertions(+), 88 deletions(-) diff --git a/tetrad-gui/src/main/resources/config/devConfig.xml b/tetrad-gui/src/main/resources/config/devConfig.xml index 6d06480190..5f95c1ea28 100644 --- a/tetrad-gui/src/main/resources/config/devConfig.xml +++ b/tetrad-gui/src/main/resources/config/devConfig.xml @@ -968,6 +968,17 @@ edu.cmu.tetradapp.editor.BayesUpdaterEditor + + + + + + edu.cmu.tetradapp.model.JunctionTreeWrapper + + edu.cmu.tetradapp.editor.BayesUpdaterEditor + + diff --git a/tetrad-gui/src/main/resources/config/prodConfig.xml b/tetrad-gui/src/main/resources/config/prodConfig.xml index cb45081f09..97e032011c 100644 --- a/tetrad-gui/src/main/resources/config/prodConfig.xml +++ b/tetrad-gui/src/main/resources/config/prodConfig.xml @@ -968,6 +968,17 @@ edu.cmu.tetradapp.editor.BayesUpdaterEditor + + + + + + edu.cmu.tetradapp.model.JunctionTreeWrapper + + edu.cmu.tetradapp.editor.BayesUpdaterEditor + + diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java index 6401cdaad5..c1f19f9f69 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java @@ -128,6 +128,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setAllowTucks(parameters.getBoolean(Params.ALLOW_TUCKS)); + search.setEqualityThreshold(parameters.getDouble(Params.EQUALITY_THRESHOLD)); // General search.setVerbose(parameters.getBoolean(Params.VERBOSE)); @@ -189,6 +190,7 @@ public List getParameters() { // LV-Lite params.add(Params.ALLOW_TUCKS); + params.add(Params.EQUALITY_THRESHOLD); // General params.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java index b1e3abd7bf..40c8bd2bfa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -121,13 +121,14 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER)); search.setNumStarts(parameters.getInt(Params.NUM_STARTS)); - // FCI + // LV-Lite search.setMaxPathLength(parameters.getInt(Params.MAX_PATH_LENGTH)); search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); + search.setEqualityThreshold(parameters.getDouble(Params.EQUALITY_THRESHOLD)); - // Gene + // General search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.setKnowledge(this.knowledge); @@ -192,6 +193,7 @@ public List getParameters() { params.add(Params.COMPLETE_RULE_SET_USED); params.add(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE); params.add(Params.DO_DISCRIMINATING_PATH_TAIL_RULE); + params.add(Params.EQUALITY_THRESHOLD); // General params.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index ccf23cfcd1..c38719dba4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -30,6 +30,8 @@ import java.util.*; +import static java.lang.Math.abs; + /** * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the * structure of a graphical model from observational data. @@ -97,6 +99,10 @@ public final class LvLite implements IGraphSearch { * The maximum length of a discriminating path. */ private int maxPathLength; + /** + * The threshold for equality, a fraction of abs(BIC). + */ + private double equalityThreshold = 0.0005; /** * LV-Lite constructor. Initializes a new object of LvLite search algorithm with the given IndependenceTest and @@ -131,23 +137,26 @@ private static void reorientWithCircles(Graph pag, boolean verbose) { * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the * possibility that the removal of an edge may allow for further removals or orientations. * - * @param pag The original graph. - * @param fciOrient The orientation rules to be applied. - * @param best The list of best nodes. - * @param scorer The scorer used to evaluate edge orientations. - */ - public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, - Set unshieldedColliders, Graph cpdag, Knowledge knowledge, - boolean allowTucks, boolean verbose) { + * @param pag The original graph. + * @param fciOrient The orientation rules to be applied. + * @param best The list of best nodes. + * @param scorer The scorer used to evaluate edge orientations. + * @param equalityThreshold The threshold for equality. (This is not used for Oracle scoring.) + */ + public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, + Set unshieldedColliders, Graph cpdag, Knowledge knowledge, + boolean allowTucks, boolean verbose, double equalityThreshold) { reorientWithCircles(pag, verbose); - doRequiredOrientations(fciOrient, pag, best, knowledge, verbose); - recallUnshieldedTriples(pag, unshieldedColliders, verbose); + doRequiredOrientations(fciOrient, pag, best, knowledge, verbose); + var reverse = new ArrayList<>(best); Collections.reverse(reverse); Set toRemove = new HashSet<>(); + boolean oriented = false; + for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -158,14 +167,39 @@ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, var x = adj.get(i); var y = adj.get(j); - if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, knowledge, verbose)) { - triangleReasoning(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, allowTucks, verbose); + if (unshieldedCollider(pag, x, b, y)) { + continue; + } + + boolean b1 = copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, toRemove, knowledge, verbose); + + oriented = oriented || b1; + + if (!b1) { + if (allowTucks) { + if (!unshieldedCollider(pag, x, b, y)) { + scorer.goToBookmark(); + + double score1 = scorer.score(); + + scorer.tuck(b, x); + scorer.tuck(x, y); + + double score2 = scorer.score(); + + if (Double.isNaN(equalityThreshold) || score2 > score1 - equalityThreshold * abs(score1)) { + boolean b2 = copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); + oriented = oriented || b2; + } + } + } } } } } removeEdges(pag, toRemove, verbose); + return oriented; } private static void removeEdges(Graph pag, Set toRemove, boolean verbose) { @@ -185,12 +219,6 @@ private static void removeEdges(Graph pag, Set toRemove, boolean verbo } private static void recallUnshieldedTriples(Graph pag, Set unshieldedColliders, boolean verbose) { - for (Triple triple : unshieldedColliders) { - Node x = triple.getX(); - Node z = triple.getZ(); - pag.removeEdge(x, z); - } - for (Triple triple : unshieldedColliders) { Node x = triple.getX(); Node b = triple.getY(); @@ -208,48 +236,20 @@ private static void recallUnshieldedTriples(Graph pag, Set unshieldedCol } } - private static void triangleReasoning(Node x, Node b, Node y, Graph pag, TeyssierScorer scorer, Set unshieldedColliders, - Set toRemove, Knowledge knowledge, boolean allowTucks, boolean verbose) { - if (!allowTucks) return; - - scorer.goToBookmark(); - - if (triangle(pag, x, b, y)) { - scorer.tuck(b, x); - scorer.tuck(x, y); - copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); - } - -// List commonAdjacents = commonAdjacents(x, y, pag); -// commonAdjacents.remove(b); -// -// boolean changed = true; -// -// while (changed) { -// changed = false; -// scorer.goToBookmark(); -// Collections.shuffle(commonAdjacents); -// -// for (Node a : new ArrayList<>(commonAdjacents)) { -// scorer.goToBookmark(); -// -// if (triangle(pag, x, a, y)) { -// scorer.tuck(a, x); -// scorer.tuck(x, y); -// commonAdjacents.remove(a); -// changed = changed || copyColliderScorer(x, a, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); -// } -// } -// } - } - private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Node y, Set unshieldedColliders, - Knowledge knowledge, boolean verbose) { + Set toRemove, Knowledge knowledge, boolean verbose) { if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { if (colliderAllowed(pag, x, b, y, knowledge)) { + boolean oriented = false; + + if (!pag.isDefCollider(x, b, y)) { + oriented = true; + } + pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); + toRemove.add(new NodePair(x, y)); unshieldedColliders.add(new Triple(x, b, y)); if (verbose) { @@ -257,7 +257,7 @@ private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, "Copied " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } - return true; + return oriented; } } @@ -268,6 +268,12 @@ private static boolean copyColliderScorer(Node x, Node b, Node y, Graph pag, Tey Set toRemove, Knowledge knowledge, boolean verbose) { if (triple(pag, x, b, y) && scorer.unshieldedCollider(x, b, y)) { if (colliderAllowed(pag, x, b, y, knowledge)) { + boolean oriented = false; + + if (!pag.isDefCollider(x, b, y)) { + oriented = true; + } + pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -279,7 +285,7 @@ private static boolean copyColliderScorer(Node x, Node b, Node y, Graph pag, Tey "FROM TUCKING oriented " + x + " *-> " + b + " <-* " + y + " from CPDAG to PAG."); } - return true; + return oriented; } } @@ -395,7 +401,7 @@ public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScor } else { fciOrient.spirtesFinalOrientation(pag); } - } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule)); + } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose)); } /** @@ -416,7 +422,9 @@ public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScor * @param graph a {@link Graph} object */ private static boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer, - boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule) { + boolean doDiscriminatingPathTailRule, + boolean doDiscriminatingPathColliderRule, + boolean verbose) { List nodes = graph.getNodes(); boolean oriented = false; @@ -450,7 +458,8 @@ private static boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer continue; } - boolean _oriented = ddpOrient(a, b, c, graph, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule); + boolean _oriented = ddpOrient(a, b, c, graph, scorer, doDiscriminatingPathTailRule, + doDiscriminatingPathColliderRule, verbose); if (_oriented) oriented = true; } @@ -471,7 +480,8 @@ private static boolean discriminatingPathRule(Graph graph, TeyssierScorer scorer * @param graph a {@link Graph} object */ private static boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierScorer scorer, - boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule) { + boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule, + boolean verbose) { Queue Q = new ArrayDeque<>(20); Set V = new HashSet<>(); @@ -523,7 +533,7 @@ private static boolean ddpOrient(Node a, Node b, Node c, Graph graph, TeyssierSc if (!graph.isAdjacentTo(d, c)) { if (doDdpOrientation(d, a, b, c, path, graph, scorer, - doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, false)) { + doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose)) { return true; } } @@ -702,12 +712,12 @@ public Graph search() { // The main procedure. Set unshieldedColliders = new HashSet<>(); - Set _unshieldedColliders; - do { - _unshieldedColliders = new HashSet<>(unshieldedColliders); - orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose); - } while (!unshieldedColliders.equals(_unshieldedColliders)); + while (true) { + if (!orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose, equalityThreshold)) { + break; + } + } finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose); @@ -808,4 +818,17 @@ public void setMaxPathLength(int maxPathLength) { this.maxPathLength = maxPathLength; } + + /** + * Sets the equality threshold used for comparing values, a fraction of abs(BIC). + * + * @param equalityThreshold the new equality threshold value + */ + public void setEqualityThreshold(double equalityThreshold) { + if (equalityThreshold < 0) { + throw new IllegalArgumentException("Equality threshold must be >= 0: " + equalityThreshold); + } + + this.equalityThreshold = equalityThreshold; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index ca41af6008..49d6483283 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -22,8 +22,6 @@ import edu.cmu.tetrad.data.Knowledge; import edu.cmu.tetrad.graph.*; -import edu.cmu.tetrad.search.score.GraphScore; -import edu.cmu.tetrad.search.score.IndTestScore; import edu.cmu.tetrad.search.score.Score; import edu.cmu.tetrad.search.test.MsepTest; import edu.cmu.tetrad.search.utils.DagSepsets; @@ -122,6 +120,11 @@ public final class LvLiteDsepFriendly implements IGraphSearch { * The maximum path length. */ private int maxPathLength = -1; + /** + * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. + * This is not used for MSEP tests. + */ + private double equalityThreshold; /** * Constructor for a test. @@ -227,11 +230,12 @@ public Graph search() { // The main procedure. Set unshieldedColliders = new HashSet<>(); Set _unshieldedColliders; + double equalityThreshold = test instanceof MsepTest ? Double.NaN : this.equalityThreshold; do { _unshieldedColliders = new HashSet<>(unshieldedColliders); LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, - allowTucks, verbose); + allowTucks, verbose, equalityThreshold); } while (!unshieldedColliders.equals(_unshieldedColliders)); LvLite.finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, @@ -365,4 +369,12 @@ public void setMaxPathLength(int maxPathLength) { public void setAllowInternalRandomness(boolean allowInternalRandomness) { this.allowInternalRandomness = allowInternalRandomness; } + + /** + * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. + * This is not used for MSEP tests. + */ + public void setEqualityThreshold(double equalityThreshold) { + this.equalityThreshold = equalityThreshold; + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PermutationSearch.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PermutationSearch.java index 195c0415d1..6f249b845f 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PermutationSearch.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/PermutationSearch.java @@ -145,12 +145,24 @@ public Graph search() { RandomUtil.getInstance().setSeed(this.seed); } + List notInTier = new ArrayList<>(); + for (Node node : variables) { + notInTier.add(node.getName()); + } + + for (int i = 0; i < this.knowledge.getNumTiers(); i++) { + List tier = this.knowledge.getTier(i); + notInTier.removeAll(tier); + } + List prefix; - if (!this.knowledge.isEmpty() && this.knowledge.getVariablesNotInTiers().isEmpty()) { + if (!this.knowledge.isEmpty() && notInTier.isEmpty()) { +// if (!this.knowledge.isEmpty() && this.knowledge.getVariablesNotInTiers().isEmpty()) { List order = new ArrayList<>(this.order); this.order.clear(); int start = 0; List suborder; + for (int i = 0; i < this.knowledge.getNumTiers(); i++) { prefix = new ArrayList<>(this.order); List tier = this.knowledge.getTier(i); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java index 64a0336b9e..5ed80185a5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BesPermutation.java @@ -10,7 +10,10 @@ import org.jetbrains.annotations.NotNull; import java.util.*; -import java.util.concurrent.*; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentSkipListSet; +import java.util.concurrent.ForkJoinPool; +import java.util.concurrent.RecursiveTask; import static edu.cmu.tetrad.graph.Edges.directedEdge; import static org.apache.commons.math3.util.FastMath.min; @@ -415,21 +418,25 @@ protected Boolean compute() { for (Node r : toProcess) { List adjacentNodes = new ArrayList<>(toProcess); - int parallelism = Runtime.getRuntime().availableProcessors(); - ForkJoinPool pool = new ForkJoinPool(parallelism); - - try { - pool.invoke(new BackwardTask(r, adjacentNodes, getChunkSize(adjacentNodes.size()), 0, - adjacentNodes.size(), hashIndices, sortedArrowsBack, arrowsMapBackward)); - } catch (Exception e) { - Thread.currentThread().interrupt(); - throw e; - } - - if (!pool.awaitQuiescence(1, TimeUnit.DAYS)) { - Thread.currentThread().interrupt(); - return; - } +// int parallelism = Runtime.getRuntime().availableProcessors(); +// ForkJoinPool pool = new ForkJoinPool(parallelism); + + // Too many threads are being created, so we will so these all in the current thread. + // jdramsey 2024-6-67 +// try { + new BackwardTask(r, adjacentNodes, getChunkSize(adjacentNodes.size()), 0, + adjacentNodes.size(), hashIndices, sortedArrowsBack, arrowsMapBackward).compute(); +// pool.invoke(new BackwardTask(r, adjacentNodes, getChunkSize(adjacentNodes.size()), 0, +// adjacentNodes.size(), hashIndices, sortedArrowsBack, arrowsMapBackward)); +// } catch (Exception e) { +// Thread.currentThread().interrupt(); +// throw e; +// } + +// if (!pool.awaitQuiescence(1, TimeUnit.DAYS)) { +// Thread.currentThread().interrupt(); +// return; +// } } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java index f8b9300bb3..be5cdb4f56 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java @@ -890,6 +890,10 @@ public final class Params { * Constant MIN_SAMPLE_SIZE_PER_CELL="minSampleSizePerCell" */ public static final String ALLOW_TUCKS = "allowTucks"; + /** + * Constant ALLOW_TUCKS="allowTucks + */ + public static final String EQUALITY_THRESHOLD = "equalityThreshold"; // All parameters that are found in HTML manual documentation private static final Set ALL_PARAMS_IN_HTML_MANUAL = new HashSet<>(Arrays.asList( diff --git a/tetrad-lib/src/main/resources/docs/manual/index.html b/tetrad-lib/src/main/resources/docs/manual/index.html index 6063f0500d..ed1941b683 100755 --- a/tetrad-lib/src/main/resources/docs/manual/index.html +++ b/tetrad-lib/src/main/resources/docs/manual/index.html @@ -6434,6 +6434,32 @@

    ia

    id="allowTucks_value_type">Boolean
+

equalityThreshold

+
    +
  • Short Description: + Score equality threshold for the LV-Lite procedure +
  • +
  • Long Description: + In LV-Lite, after tucking, scores should not drop much from the + the score of the best order. This ensures scores don't drop more + than equality_threshold * abs(score of best model). +
  • +
  • Default Value: 0.0005
  • +
  • Lower Bound: 0
  • +
  • Upper + Bound: Infinity
  • +
  • Value + Type: Double
  • +
+

intervalBetweenRecordings

    Date: Sat, 8 Jun 2024 17:32:56 -0400 Subject: [PATCH 19/29] Add node selection feature to MarkovCheckEditor and remove parameters from LvLiteDsepFriendly In the MarkovCheckEditor class, a new selection box is added to allow the user to select specific nodes from the table view. Additionally, the code has been modified to sort the names of nodes in a specific order. In the LvLiteDsepFriendly.java, some parameters related to GRaSP have been removed to simplify the structure. These parameters seemed to no longer be in use. --- .../tetradapp/editor/MarkovCheckEditor.java | 61 ++++++++++++++++++- .../oracle/pag/LvLiteDsepFriendly.java | 3 - 2 files changed, 58 insertions(+), 6 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java index 0d02bd1493..6119ab17ee 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java @@ -841,6 +841,60 @@ private void addFilterPanel(MarkovCheckIndTestModel model, AbstractTableModel ta TableRowSorter sorter = new TableRowSorter<>(tableModel); table.setRowSorter(sorter); + Box nodeSelectionBox = Box.createHorizontalBox(); + nodeSelectionBox.add(new JLabel("Node Selection:")); + JComboBox nodeSelection = new JComboBox<>(); + nodeSelection.addItem("All"); + + List names = new ArrayList<>(); + + for (Node node : model.getGraph().getNodes()) { + names.add(node.getName()); + } + + names.sort((o1, o2) -> { + // If o1 ends with an integer, find that integer. + // If o2 ends with an integer, find that integer. + // If both end with an integer, compare the integers. + + String[] split1 = o1.split("(?<=\\D)(?=\\d)"); + String[] split2 = o2.split("(?<=\\D)(?=\\d)"); + + if (split1.length == 2 && split2.length == 2) { + String prefix1 = split1[0]; + String prefix2 = split2[0]; + + if (prefix1.equals(prefix2)) { + return Integer.compare(Integer.parseInt(split1[1]), Integer.parseInt(split2[1])); + } else { + return prefix1.compareTo(prefix2); + } + } else if (split1.length == 2) { + return -1; + } else if (split2.length == 2) { + return 1; + } else { + return o1.compareTo(o2); + } + }); + + for (String name : names) { + nodeSelection.addItem(name); + } + + nodeSelection.addActionListener(e -> { + String selectedNode = (String) nodeSelection.getSelectedItem(); + if (selectedNode.equals("All")) { + sorter.setRowFilter(null); + } else { + sorter.setRowFilter(RowFilter.regexFilter("\\(" + selectedNode + "|" + selectedNode + "\\)")); + } + }); + + nodeSelectionBox.add(nodeSelection); + nodeSelectionBox.add(Box.createHorizontalGlue()); + + // Create the text field JLabel regexLabel = new JLabel("Regexes (semicolon separated):"); JTextField filterText = new JTextField(15); @@ -860,9 +914,10 @@ private void addFilterPanel(MarkovCheckIndTestModel model, AbstractTableModel ta scroll.setPreferredSize(new Dimension(550, 400)); Box filterBox = Box.createHorizontalBox(); - filterBox.add(regexLabel); - filterBox.add(filterText); - filterBox.add(flipEscapes); +// filterBox.add(regexLabel); +// filterBox.add(filterText); + filterBox.add(nodeSelectionBox); +// filterBox.add(flipEscapes); panel.add(filterBox); panel.add(scroll); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java index 40c8bd2bfa..5ef726ccfa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -178,9 +178,6 @@ public List getParameters() { List params = new ArrayList<>(); // GRaSP -// params.add(Params.GRASP_DEPTH); -// params.add(Params.GRASP_SINGULAR_DEPTH); -// params.add(Params.GRASP_NONSINGULAR_DEPTH); params.add(Params.GRASP_ORDERED_ALG); params.add(Params.GRASP_USE_RASKUTTI_UHLER); params.add(Params.USE_DATA_ORDER); From b201f740aa83ce044cf15c18600a058a2abcb8f5 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sun, 9 Jun 2024 01:56:10 -0400 Subject: [PATCH 20/29] Improve regex filter and enable graph manipulation items Updated the regex filter in the MarkovCheckEditor for better node selection handling. Also uncommented the code in GraphCard to enable the addition of graph manipulation items to the graph context menu. This provides users more controls to manipulate the graph. --- .../main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java | 4 +++- .../main/java/edu/cmu/tetradapp/editor/search/GraphCard.java | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java index 6119ab17ee..8fb8e371ac 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java @@ -887,7 +887,9 @@ private void addFilterPanel(MarkovCheckIndTestModel model, AbstractTableModel ta if (selectedNode.equals("All")) { sorter.setRowFilter(null); } else { - sorter.setRowFilter(RowFilter.regexFilter("\\(" + selectedNode + "|" + selectedNode + "\\)")); + String a = selectedNode; + String regex = String.format("(\\(%s,)|(, %s \\|)|(, %s\\)^)", a, a, a); + sorter.setRowFilter(RowFilter.regexFilter(regex)); } }); diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/GraphCard.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/GraphCard.java index 77e4456f70..1d3f9809ac 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/GraphCard.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/search/GraphCard.java @@ -39,6 +39,8 @@ import java.io.Serial; import java.net.URL; +import static edu.cmu.tetradapp.util.GraphUtils.addGraphManipItems; + /** * Apr 15, 2019 4:49:15 PM * @@ -130,7 +132,7 @@ JMenuBar menuBar() { graph.add(GraphUtils.getHighlightMenu(this.workbench)); graph.add(GraphUtils.getCheckGraphMenu(this.workbench)); -// addGraphManipItems(graph, this.workbench); + addGraphManipItems(graph, this.workbench); graph.addSeparator(); graph.add(GraphUtils.addPagEdgeSpecializationsItems(this.workbench)); From bfbacb10502654546545cc3e5a4b3c0db333b03f Mon Sep 17 00:00:00 2001 From: jdramsey Date: Sun, 9 Jun 2024 03:08:14 -0400 Subject: [PATCH 21/29] Update model observer list and adjust GUI size The MarkovCheckEditor's preferred size has been adjusted for better usability. Also, the observer list in the MarkovCheck class has been updated to allow for more efficient model change notifications. Additionally, several methods in the MarkovCheck class have been refactored for improved readability and flexibility. --- .../tetradapp/editor/MarkovCheckEditor.java | 2 + .../edu/cmu/tetrad/search/MarkovCheck.java | 81 +++++++++++++------ 2 files changed, 58 insertions(+), 25 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java index 8fb8e371ac..565c2bdbb7 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/MarkovCheckEditor.java @@ -216,6 +216,8 @@ public MarkovCheckEditor(MarkovCheckIndTestModel model) { throw new NullPointerException("Expecting a model"); } + setPreferredSize(new Dimension(1100, 600)); + conditioningSetTypeJComboBox.addItem("Parents(X) (Local Markov)"); conditioningSetTypeJComboBox.addItem("Parents(X) for a Valid Order (Ordered Local Markov)"); conditioningSetTypeJComboBox.addItem("MarkovBlanket(X)"); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java index af9b1fa41e..11f65ee305 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java @@ -64,6 +64,10 @@ public class MarkovCheck { * True, just in case the given graph is a CPDAG (completed partially directed acyclic graph). */ private final boolean isCpdag; + /** + * List of observers to be notified when changes are made to the model. + */ + private final List observers = new ArrayList<>(); /** * The independence test. */ @@ -266,6 +270,7 @@ public List getLocalPValues(IndependenceTest independenceTest, List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodes(Ind } /** - * Get accepts and rejects nodes for all nodes from Anderson-Darling test and generate the plot data for confusion statistics. + * Get accepts and rejects nodes for all nodes from Anderson-Darling test and generate the plot data for confusion + * statistics. + *

    + * Confusion statistics were calculated using Adjacency (AdjacencyPrecision, AdjacencyRecall) and Arrowhead + * (ArrowheadPrecision, ArrowheadRecall) * - * Confusion statistics were calculated using Adjacency (AdjacencyPrecision, AdjacencyRecall) and Arrowhead (ArrowheadPrecision, ArrowheadRecall) * @param independenceTest * @param estimatedCpdag * @param trueGraph @@ -494,9 +502,12 @@ public List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlot } /** - * Get accepts and rejects nodes for all nodes from Anderson-Darling test and generate the plot data for confusion statistics. + * Get accepts and rejects nodes for all nodes from Anderson-Darling test and generate the plot data for confusion + * statistics. + *

    + * Confusion statistics were calculated using Local Graph Precision and Recall (LocalGraphPrecision, + * LocalGraphRecall). * - * Confusion statistics were calculated using Local Graph Precision and Recall (LocalGraphPrecision, LocalGraphRecall). * @param independenceTest * @param estimatedCpdag * @param trueGraph @@ -643,9 +654,8 @@ public List getPrecisionAndRecallOnMarkovBlanketGraphPlotData(Node x, Gr } /** - * Calculates the precision and recall using LocalGraphConfusion - * (which calculates the combination of Adjacency and ArrowHead) on the Markov Blanket graph for a given node. - * Prints the statistics to the console. + * Calculates the precision and recall using LocalGraphConfusion (which calculates the combination of Adjacency and + * ArrowHead) on the Markov Blanket graph for a given node. Prints the statistics to the console. * * @param x The target node. * @param estimatedGraph The estimated graph. @@ -664,7 +674,7 @@ public void getPrecisionAndRecallOnMarkovBlanketGraph2(Node x, Graph estimatedGr NumberFormat nf = new DecimalFormat("0.00"); System.out.println("Node " + x + "'s statistics: " + " \n" + - " LocalGraphPrecision = " + nf.format(lgp) + " LocalGraphRecall = " + nf.format(lgr) + " \n"); + " LocalGraphPrecision = " + nf.format(lgp) + " LocalGraphRecall = " + nf.format(lgr) + " \n"); } public List getPrecisionAndRecallOnMarkovBlanketGraphPlotData2(Node x, Graph estimatedGraph, Graph trueGraph) { @@ -1272,9 +1282,15 @@ private void addResults(Set resultsIndep, Set= min) { if (msep) { resultsIndep.add(new IndependenceResult(fact, indep, pValue, Double.NaN)); } else { @@ -1336,12 +1352,23 @@ private void calcStats(boolean indep) { } List pValues = getPValues(results); - GeneralAndersonDarlingTest generalAndersonDarlingTest = new GeneralAndersonDarlingTest(pValues, new UniformRealDistribution(0, 1)); - double aSquared = generalAndersonDarlingTest.getASquared(); - double aSquaredStar = generalAndersonDarlingTest.getASquaredStar(); + + double min = 0.0; + + // Optionally let the minimum of the uniform range be the minimum p-value. This is useful if we ignore + // p-values less than alpha. This is hard-coded for now. + if (false) { + min = Double.POSITIVE_INFINITY; + for (double pValue : pValues) { + if (pValue < min) { + min = pValue; + } + } + } if (indep) { fractionDependentIndep = dependent / (double) results.size(); + if (pValues.size() < 2) { ksPValueIndep = Double.NaN; binomialPIndep = Double.NaN; @@ -1349,14 +1376,19 @@ private void calcStats(boolean indep) { aSquaredStarIndep = Double.NaN; andersonDarlingPIndep = Double.NaN; } else { - ksPValueIndep = UniformityTest.getKsPValue(pValues, 0.0, 1.0); + GeneralAndersonDarlingTest _generalAndersonDarlingTest = new GeneralAndersonDarlingTest(pValues, new UniformRealDistribution(min, 1)); + double _aSquared = _generalAndersonDarlingTest.getASquared(); + double _aSquaredStar = _generalAndersonDarlingTest.getASquaredStar(); + + ksPValueIndep = UniformityTest.getKsPValue(pValues, min, 1.0); binomialPIndep = getBinomialPValue(pValues, independenceTest.getAlpha()); - aSquaredIndep = aSquared; - aSquaredStarIndep = aSquaredStar; - andersonDarlingPIndep = 1. - generalAndersonDarlingTest.getProbTail(pValues.size(), aSquaredStar); + aSquaredIndep = _aSquared; + aSquaredStarIndep = _aSquaredStar; + andersonDarlingPIndep = 1. - _generalAndersonDarlingTest.getProbTail(pValues.size(), _aSquaredStar); } } else { fractionDependentDep = dependent / (double) results.size(); + if (pValues.size() < 2) { ksPValueDep = Double.NaN; binomialPDep = Double.NaN; @@ -1365,11 +1397,15 @@ private void calcStats(boolean indep) { andersonDarlingPDep = Double.NaN; } else { + GeneralAndersonDarlingTest _generalAndersonDarlingTest = new GeneralAndersonDarlingTest(pValues, new UniformRealDistribution(min, 1)); + double _aSquared = _generalAndersonDarlingTest.getASquared(); + double _aSquaredStar = _generalAndersonDarlingTest.getASquaredStar(); + ksPValueDep = UniformityTest.getKsPValue(pValues, 0.0, 1.0); binomialPDep = getBinomialPValue(pValues, independenceTest.getAlpha()); - aSquaredDep = aSquared; - aSquaredStarDep = aSquaredStar; - andersonDarlingPDep = 1. - generalAndersonDarlingTest.getProbTail(pValues.size(), aSquaredStar); + aSquaredDep = _aSquared; + aSquaredStarDep = _aSquaredStar; + andersonDarlingPDep = 1. - _generalAndersonDarlingTest.getProbTail(pValues.size(), _aSquaredStar); } } } @@ -1514,11 +1550,6 @@ public double getAndersonDarlingPValue(List visiblePairs) { return 1. - generalAndersonDarlingTest.getProbTail(pValues.size(), aSquaredStar); } - /** - * List of observers to be notified when changes are made to the model. - */ - private final List observers = new ArrayList<>(); - /** * Adds a ModelObserver to the list of observers. * From ebd0168d3c1a9ad805adebb283ce4fd7db7ad136 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Mon, 10 Jun 2024 11:46:11 -0400 Subject: [PATCH 22/29] Refactor LvLite.java: Add option to choose initial CPDAG algorithm, remove unused methods The LvLite.java class has been updated to include an option to choose the initial CPDAG algorithm. The options are now BOSS and GRASP. Methods that were previously unused or duplicated in this file have been removed for improved code clarity and efficiency. The reorientation of edges and determination of the final orientation of the graph have been restructured and moved to improve readability. Other minor code restructuring and reordering have also been done for better organization of the class functions. --- .../algorithm/oracle/pag/LvDumb.java | 2 +- .../algorithm/oracle/pag/LvLite.java | 9 + .../oracle/pag/LvLiteDsepFriendly.java | 2 +- .../java/edu/cmu/tetrad/search/Grasp.java | 17 +- .../java/edu/cmu/tetrad/search/LvDumb.java | 14 +- .../java/edu/cmu/tetrad/search/LvLite.java | 207 +++++++++++------- .../main/java/edu/cmu/tetrad/util/Params.java | 27 ++- .../src/main/resources/docs/manual/index.html | 24 ++ 8 files changed, 187 insertions(+), 115 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java index 03a848d20d..ce8760e5d1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java @@ -124,7 +124,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { // FCI-ORIENT search.setCompleteRuleSetUsed(parameters.getBoolean(Params.COMPLETE_RULE_SET_USED)); - // LV-Lite + // DAG to PAG search.setDoDiscriminatingPathTailRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_TAIL_RULE)); search.setDoDiscriminatingPathColliderRule(parameters.getBoolean(Params.DO_DISCRIMINATING_PATH_COLLIDER_RULE)); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java index c1f19f9f69..7ae2ad98a6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLite.java @@ -130,6 +130,14 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { search.setAllowTucks(parameters.getBoolean(Params.ALLOW_TUCKS)); search.setEqualityThreshold(parameters.getDouble(Params.EQUALITY_THRESHOLD)); + if (parameters.getInt(Params.LV_LITE_STARTS_WITH) == 1) { + search.setStartWith(edu.cmu.tetrad.search.LvLite.START_WITH.BOSS); + } else if (parameters.getInt(Params.LV_LITE_STARTS_WITH) == 2) { + search.setStartWith(edu.cmu.tetrad.search.LvLite.START_WITH.GRASP); + } else { + throw new IllegalArgumentException("Unknown start with option: " + parameters.getInt(Params.LV_LITE_STARTS_WITH)); + } + // General search.setVerbose(parameters.getBoolean(Params.VERBOSE)); search.setKnowledge(this.knowledge); @@ -191,6 +199,7 @@ public List getParameters() { // LV-Lite params.add(Params.ALLOW_TUCKS); params.add(Params.EQUALITY_THRESHOLD); + params.add(Params.LV_LITE_STARTS_WITH); // General params.add(Params.TIME_LAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java index 5ef726ccfa..1093ef1647 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvLiteDsepFriendly.java @@ -26,6 +26,7 @@ import java.io.Serial; import java.util.ArrayList; import java.util.List; +import java.util.Set; /** @@ -200,7 +201,6 @@ public List getParameters() { return params; } - /** * Retrieves the knowledge object associated with this method. * 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 94d65068e2..87fff72807 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 @@ -128,7 +128,7 @@ public class Grasp { */ public Grasp(@NotNull Score score) { this.score = score; - this.variables = new ArrayList<>(score.getVariables()); + this.variables = getVariables(null, score); this.useScore = true; } @@ -139,7 +139,7 @@ public Grasp(@NotNull Score score) { */ public Grasp(@NotNull IndependenceTest test) { this.test = test; - this.variables = new ArrayList<>(test.getVariables()); + variables = getVariables(test, null); this.useScore = false; this.useRaskuttiUhler = true; } @@ -150,10 +150,19 @@ public Grasp(@NotNull IndependenceTest test) { * @param test The test to use. * @param score The score to use. */ - public Grasp(@NotNull IndependenceTest test, Score score) { + public Grasp(IndependenceTest test, Score score) { + if (test == null && score == null) throw new IllegalArgumentException("Test and score cannot both be null."); this.test = test; this.score = score; - this.variables = new ArrayList<>(test.getVariables()); + this.variables = getVariables(test, score); + } + + private List getVariables(IndependenceTest test, Score score) { + if (test != null) { + return new ArrayList<>(test.getVariables()); + } else { + return new ArrayList<>(score.getVariables()); + } } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java index 11a38ed396..6144d37bf3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java @@ -95,19 +95,6 @@ public LvDumb(Score score) { this.score = score; } - /** - * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given - * Graph following the PAG (Partially Ancestral Graph) structure. - * - * @param pag The Graph to be reoriented. - */ - private void reorientWithCircles(Graph pag) { - if (verbose) { - TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); - } - pag.reorientAllWith(Endpoint.CIRCLE); - } - /** * Run the search and return s a PAG. * @@ -162,6 +149,7 @@ public Graph search() { dagToPag.setKnowledge(knowledge); dagToPag.setCompleteRuleSetUsed(completeRuleSetUsed); dagToPag.setDoDiscriminatingPathTailRule(doDiscriminatingPathTailRule); + dagToPag.setDoDiscriminatingPathColliderRule(doDiscriminatingPathColliderRule); return dagToPag.convert(); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index c38719dba4..f251afed71 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -42,6 +42,7 @@ * @author josephramsey */ public final class LvLite implements IGraphSearch { + /** * The score. */ @@ -103,6 +104,10 @@ public final class LvLite implements IGraphSearch { * The threshold for equality, a fraction of abs(BIC). */ private double equalityThreshold = 0.0005; + /** + * The algorithm to use to obtain the initial CPDAG. + */ + private START_WITH startWith = START_WITH.BOSS; /** * LV-Lite constructor. Initializes a new object of LvLite search algorithm with the given IndependenceTest and @@ -119,19 +124,6 @@ public LvLite(Score score) { this.score = score; } - /** - * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given - * Graph following the PAG (Partially Ancestral Graph) structure. - * - * @param pag The Graph to be reoriented. - */ - private static void reorientWithCircles(Graph pag, boolean verbose) { - if (verbose) { - TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); - } - pag.reorientAllWith(Endpoint.CIRCLE); - } - /** * Orients and removes edges in a graph according to specified rules. Edges are removed in the course of the * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the @@ -143,7 +135,7 @@ private static void reorientWithCircles(Graph pag, boolean verbose) { * @param scorer The scorer used to evaluate edge orientations. * @param equalityThreshold The threshold for equality. (This is not used for Oracle scoring.) */ - public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, + public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, Set unshieldedColliders, Graph cpdag, Knowledge knowledge, boolean allowTucks, boolean verbose, double equalityThreshold) { reorientWithCircles(pag, verbose); @@ -155,8 +147,6 @@ public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrie Collections.reverse(reverse); Set toRemove = new HashSet<>(); - boolean oriented = false; - for (Node b : reverse) { var adj = pag.getAdjacentNodes(b); @@ -171,11 +161,7 @@ public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrie continue; } - boolean b1 = copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, toRemove, knowledge, verbose); - - oriented = oriented || b1; - - if (!b1) { + if (!copyColliderCpdag(pag, cpdag, x, b, y, unshieldedColliders, toRemove, knowledge, verbose)) { if (allowTucks) { if (!unshieldedCollider(pag, x, b, y)) { scorer.goToBookmark(); @@ -188,8 +174,7 @@ public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrie double score2 = scorer.score(); if (Double.isNaN(equalityThreshold) || score2 > score1 - equalityThreshold * abs(score1)) { - boolean b2 = copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); - oriented = oriented || b2; + copyColliderScorer(x, b, y, pag, scorer, unshieldedColliders, toRemove, knowledge, verbose); } } } @@ -199,7 +184,43 @@ public static boolean orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrie } removeEdges(pag, toRemove, verbose); - return oriented; + } + + /** + * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. + * + * @param fciOrient The FciOrient object used to determine the final orientation. + * @param pag The Graph object for which the final orientation is determined. + * @param scorer The scorer object used in the score-based discriminating path rule. + */ + public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer, boolean completeRuleSetUsed, + boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule, boolean verbose) { + if (verbose) { + TetradLogger.getInstance().log("Final Orientation:"); + } + + fciOrient.setVerbose(verbose); + + do { + if (completeRuleSetUsed) { + fciOrient.zhangFinalOrientation(pag); + } else { + fciOrient.spirtesFinalOrientation(pag); + } + } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose)); + } + + /** + * Reorients all edges in a Graph as o-o. This method is used to apply the o-o orientation to all edges in the given + * Graph following the PAG (Partially Ancestral Graph) structure. + * + * @param pag The Graph to be reoriented. + */ + private static void reorientWithCircles(Graph pag, boolean verbose) { + if (verbose) { + TetradLogger.getInstance().log("Orient all edges in PAG as o-o:"); + } + pag.reorientAllWith(Endpoint.CIRCLE); } private static void removeEdges(Graph pag, Set toRemove, boolean verbose) { @@ -240,11 +261,7 @@ private static boolean copyColliderCpdag(Graph pag, Graph cpdag, Node x, Node b, Set toRemove, Knowledge knowledge, boolean verbose) { if (unshieldedTriple(pag, x, b, y) && unshieldedCollider(cpdag, x, b, y)) { if (colliderAllowed(pag, x, b, y, knowledge)) { - boolean oriented = false; - - if (!pag.isDefCollider(x, b, y)) { - oriented = true; - } + boolean oriented = !pag.isDefCollider(x, b, y); pag.setEndpoint(x, b, Endpoint.ARROW); pag.setEndpoint(y, b, Endpoint.ARROW); @@ -356,10 +373,6 @@ private static boolean unshieldedTriple(Graph graph, Node a, Node b, Node c) { && graph.isAdjacentTo(a, b) && graph.isAdjacentTo(b, c) && !graph.isAdjacentTo(a, c); } - private static boolean defCollider(Graph graph, Node a, Node b, Node c) { - return graph.isDefCollider(a, b, c); - } - /** * Checks if the given nodes are unshielded colliders when considering the given graph. * @@ -380,30 +393,6 @@ private static boolean unshieldedCollider(Graph graph, Node a, Node b, Node c) { return commonAdjacents; } - /** - * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. - * - * @param fciOrient The FciOrient object used to determine the final orientation. - * @param pag The Graph object for which the final orientation is determined. - * @param scorer The scorer object used in the score-based discriminating path rule. - */ - public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer, boolean completeRuleSetUsed, - boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule, boolean verbose) { - if (verbose) { - TetradLogger.getInstance().log("Final Orientation:"); - } - - fciOrient.setVerbose(verbose); - - do { - if (completeRuleSetUsed) { - fciOrient.zhangFinalOrientation(pag); - } else { - fciOrient.spirtesFinalOrientation(pag); - } - } while (discriminatingPathRule(pag, scorer, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose)); - } - /** * This is a score-based discriminating path rule. *

    @@ -652,39 +641,73 @@ private static boolean doDdpOrientation(Node e, Node a, Node b, Node c, List nodes = this.score.getVariables(); - - if (nodes == null) { - throw new NullPointerException("Nodes from test were null."); - } + List nodes = new ArrayList<>(this.score.getVariables()); if (verbose) { TetradLogger.getInstance().log("===Starting LV-Lite==="); } + Graph cpdag; + List best; + + // BOSS seems to be doing better here. + if (startWith == START_WITH.BOSS) { + var suborderSearch = new Boss(score); + suborderSearch.setKnowledge(knowledge); + suborderSearch.setResetAfterBM(true); + suborderSearch.setResetAfterRS(true); + suborderSearch.setVerbose(false); + suborderSearch.setUseBes(useBes); + suborderSearch.setUseDataOrder(useDataOrder); + suborderSearch.setNumStarts(numStarts); + var permutationSearch = new PermutationSearch(suborderSearch); + permutationSearch.setKnowledge(knowledge); + cpdag = permutationSearch.search(); + best = permutationSearch.getOrder(); + + if (verbose) { + TetradLogger.getInstance().log("Initializing PAG to BOSS CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); + } + } else if (startWith == START_WITH.GRASP) { + edu.cmu.tetrad.search.Grasp grasp = new edu.cmu.tetrad.search.Grasp(null, score); + + grasp.setSeed(-1); + grasp.setDepth(25); + grasp.setUncoveredDepth(1); + grasp.setNonSingularDepth(1); + grasp.setOrdered(true); + grasp.setUseScore(true); + grasp.setUseRaskuttiUhler(false); + grasp.setUseDataOrder(useDataOrder); + grasp.setAllowInternalRandomness(true); + grasp.setVerbose(false); + + grasp.setNumStarts(numStarts); + grasp.setKnowledge(this.knowledge); + best = grasp.bestOrder(nodes); + cpdag = grasp.getGraph(true); + + if (verbose) { + TetradLogger.getInstance().log("Initializing PAG to GRaSP CPDAG."); + TetradLogger.getInstance().log("Initializing scorer with GRaSP best order."); + } + } else { + throw new IllegalArgumentException("Unknown startWith algorithm: " + startWith); + } + if (verbose) { - TetradLogger.getInstance().log("Running BOSS to get CPDAG and best order."); + TetradLogger.getInstance().log("Best order: " + best); } - // BOSS seems to be doing better here. - var suborderSearch = new Boss(score); - suborderSearch.setKnowledge(knowledge); - suborderSearch.setResetAfterBM(true); - suborderSearch.setResetAfterRS(true); - suborderSearch.setVerbose(false); - suborderSearch.setUseBes(useBes); - suborderSearch.setUseDataOrder(useDataOrder); - suborderSearch.setNumStarts(numStarts); - var permutationSearch = new PermutationSearch(suborderSearch); - permutationSearch.setKnowledge(knowledge); - permutationSearch.search(); - var best = permutationSearch.getOrder(); + var pag = new EdgeListGraph(cpdag); if (verbose) { TetradLogger.getInstance().log("Best order: " + best); } var scorer = new TeyssierScorer(null, score); + scorer.setUseScore(true); scorer.score(best); scorer.bookmark(); @@ -693,12 +716,10 @@ public Graph search() { TetradLogger.getInstance().log("Initializing scorer with BOSS best order."); } - var cpdag = scorer.getGraph(true); - var pag = new EdgeListGraph(cpdag); + scorer.score(best); FciOrient fciOrient = new FciOrient(null); - fciOrient.setCompleteRuleSetUsed(completeRuleSetUsed); fciOrient.setDoDiscriminatingPathColliderRule(false); fciOrient.setDoDiscriminatingPathTailRule(false); @@ -712,18 +733,30 @@ public Graph search() { // The main procedure. Set unshieldedColliders = new HashSet<>(); + Set _unshieldedColliders; + double equalityThreshold = this.equalityThreshold; - while (true) { - if (!orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, allowTucks, verbose, equalityThreshold)) { - break; - } - } + do { + _unshieldedColliders = new HashSet<>(unshieldedColliders); + LvLite.orientCollidersAndRemoveEdges(pag, fciOrient, best, scorer, unshieldedColliders, cpdag, knowledge, + allowTucks, verbose, equalityThreshold); + } while (!unshieldedColliders.equals(_unshieldedColliders)); - finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, doDiscriminatingPathColliderRule, verbose); + LvLite.finalOrientation(fciOrient, pag, scorer, completeRuleSetUsed, doDiscriminatingPathTailRule, + doDiscriminatingPathColliderRule, verbose); return GraphUtils.replaceNodes(pag, this.score.getVariables()); } + /** + * Sets the algorithm to use to obtain the initial CPDAG. + * + * @param startWith the algorithm to use to obtain the initial CPDAG. + */ + public void setStartWith(START_WITH startWith) { + this.startWith = startWith; + } + /** * Sets the knowledge used in search. * @@ -831,4 +864,8 @@ public void setEqualityThreshold(double equalityThreshold) { this.equalityThreshold = equalityThreshold; } + + public enum START_WITH { + BOSS, GRASP + } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java index be5cdb4f56..906078b4dd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java @@ -894,6 +894,22 @@ public final class Params { * Constant ALLOW_TUCKS="allowTucks */ public static final String EQUALITY_THRESHOLD = "equalityThreshold"; + /** + * Constant MIN_COUNT_PER_CELL="minCountPerCell" + */ + public static String MIN_COUNT_PER_CELL = "minCountPerCell"; + /** + * Constant PC_HEURISTIC="pcHeuristic" + */ + public static String PC_HEURISTIC = "pcHeuristic"; + /** + * Constant LV_LITE_STARTS_WITGH="LvLiteStartsWith" + */ + public static String LV_LITE_STARTS_WITH = "lvLiteStartsWith"; + + private Params() { + } + // All parameters that are found in HTML manual documentation private static final Set ALL_PARAMS_IN_HTML_MANUAL = new HashSet<>(Arrays.asList( @@ -942,17 +958,6 @@ public final class Params { Params.SAVE_BOOTSTRAP_GRAPHS, Params.SEED )); - /** - * Constant MIN_COUNT_PER_CELL="minCountPerCell" - */ - public static String MIN_COUNT_PER_CELL = "minCountPerCell"; - /** - * Constant PC_HEURISTIC="pcHeuristic" - */ - public static String PC_HEURISTIC = "pcHeuristic"; - - private Params() { - } /** *

    getAlgorithmParameters.

    diff --git a/tetrad-lib/src/main/resources/docs/manual/index.html b/tetrad-lib/src/main/resources/docs/manual/index.html index ed1941b683..5e26a607d4 100755 --- a/tetrad-lib/src/main/resources/docs/manual/index.html +++ b/tetrad-lib/src/main/resources/docs/manual/index.html @@ -6434,6 +6434,30 @@

    ia

    id="allowTucks_value_type">Boolean
+

lvLiteStartsWith

+
    +
  • Short Description: + The algorithm to find the initial CPDAG: 1 = BOSS, 2 = GRaSP +
  • +
  • Long Description: + The algorithm to find the initial CPDAG: 1 = BOSS, 2 = GRaSP +
  • +
  • Default Value: 1
  • +
  • Lower Bound: 1
  • +
  • Upper + Bound: 2
  • +
  • Value + Type: Integer
  • +
+

equalityThreshold

    Date: Mon, 10 Jun 2024 13:16:55 -0400 Subject: [PATCH 23/29] Update thread interruption checks Replaced calls to Thread.interrupted() with Thread.currentThread().isInterrupted() to correctly check the interruption status of the current thread. This change has been applied across multiple files and methods, improving thread safety and termination. --- tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java | 8 ++++---- .../src/main/java/edu/cmu/tetrad/search/FgesMb.java | 6 +++--- tetrad-lib/src/main/java/edu/cmu/tetrad/search/Grasp.java | 2 +- .../edu/cmu/tetrad/search/work_in_progress/GraspTol.java | 6 +++--- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java index 6200fc6a10..b7d7eab777 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/Fges.java @@ -595,7 +595,7 @@ private AdjTask(List nodes, int from, int to) { @Override public Boolean call() { for (int _y = from; _y < to; _y++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; Node y = nodes.get(_y); @@ -725,7 +725,7 @@ public EvalTask(List> Ts, int from, int to, ConcurrentMap maxBump) { @@ -1582,7 +1582,7 @@ class NodeTaskEmptyGraph implements Callable { @Override public Boolean call() { for (int i = from; i < to; i++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; if ((i + 1) % 1000 == 0) { count[0] += 1000; out.println("Initializing effect edges: " + (count[0])); @@ -1591,7 +1591,7 @@ public Boolean call() { Node y = nodes.get(i); for (int j = i + 1; j < nodes.size(); j++) { - if (Thread.interrupted()) { + if (Thread.currentThread().isInterrupted()) { pool.shutdownNow(); throw new RuntimeException("Interrupted"); } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java index 672f50ee9b..5cdb1c16e1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FgesMb.java @@ -722,7 +722,7 @@ private AdjTask(List nodes, int from, int to) { @Override public Boolean call() { for (int _y = from; _y < to; _y++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; Node y = nodes.get(_y); @@ -859,7 +859,7 @@ public EvalTask(List> Ts, int from, int to, ConcurrentMap maxBump) { @@ -1592,7 +1592,7 @@ class NodeTaskEmptyGraph implements Callable { @Override public Boolean call() { for (int i = from; i < to; i++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; if ((i + 1) % 1000 == 0) { count[0] += 1000; out.println("Initializing effect edges: " + (count[0])); 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 87fff72807..8131f5cfe9 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 @@ -199,7 +199,7 @@ public List bestOrder(@NotNull List order) { this.scorer.score(order); for (int r = 0; r < this.numStarts; r++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; if ((r == 0 && !this.useDataOrder) || r > 0) { RandomUtil.shuffle(order); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java index 3a14d43782..f491ec4291 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/GraspTol.java @@ -117,7 +117,7 @@ public List bestOrder(@NotNull List order) { this.scorer.score(order); for (int r = 0; r < this.numStarts; r++) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; if ((r == 0 && !this.useDataOrder) || r > 0) { shuffle(order); @@ -332,7 +332,7 @@ private void graspDfsTol(@NotNull TeyssierScorer scorer, double sOld, int[] dept } for (Node y : variables) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; Set ancestors = scorer.getAncestors(y); List parents = new ArrayList<>(scorer.getParents(y)); @@ -342,7 +342,7 @@ private void graspDfsTol(@NotNull TeyssierScorer scorer, double sOld, int[] dept } for (Node x : parents) { - if (Thread.interrupted()) break; + if (Thread.currentThread().isInterrupted()) break; boolean covered = scorer.coveredEdge(x, y); boolean singular = true; From 3211c77bf66f6a3499c8ff9127335e3bbdf94d18 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 11 Jun 2024 00:17:10 -0400 Subject: [PATCH 24/29] Update LvLite class and improve description in TrueDagRecallArrows Removed setting knowledge in LvLite's BOSS initialization. This change simplifies the code and avoids redundancy. Additionally, the description in TrueDagRecallArrows class was updated for better clarity. The new description provides clearer information on the graph's directional relationship between X and Y. --- .../cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java | 2 +- tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java index d645eba13a..b4525fd1ef 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/TrueDagRecallArrows.java @@ -38,7 +38,7 @@ public String getAbbreviation() { */ @Override public String getDescription() { - return "Proportion of where there is no directed(Y, X) in the true for which and X*->Y in the estimated graph"; + return "Proportion of where Y is not an ancestor of X in the true graph where there is an arrow X *-> Y"; } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index f251afed71..de42e400e0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -653,7 +653,6 @@ public Graph search() { // BOSS seems to be doing better here. if (startWith == START_WITH.BOSS) { var suborderSearch = new Boss(score); - suborderSearch.setKnowledge(knowledge); suborderSearch.setResetAfterBM(true); suborderSearch.setResetAfterRS(true); suborderSearch.setVerbose(false); From 98370d8f27283cf44d1298b8122f706dbf4a9cb4 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Tue, 11 Jun 2024 03:56:37 -0400 Subject: [PATCH 25/29] Rename LvDumb to BossPag in Algorithm and Search classes This commit renames LvDumb to BossPag throughout the algorithm and search classes. The change includes the renaming of class file, class constructors, and class name references used within these classes. This update reflects the new name of the algorithm being used in the code. --- .../oracle/pag/{LvDumb.java => BossPag.java} | 14 +++++++------- .../tetrad/search/{LvDumb.java => BossPag.java} | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) rename tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/{LvDumb.java => BossPag.java} (94%) rename tetrad-lib/src/main/java/edu/cmu/tetrad/search/{LvDumb.java => BossPag.java} (97%) diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BossPag.java similarity index 94% rename from tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java rename to tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BossPag.java index ce8760e5d1..1b5f38b40e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/pag/BossPag.java @@ -34,13 +34,13 @@ * @author josephramsey */ @edu.cmu.tetrad.annotation.Algorithm( - name = "LV-Dumb", - command = "lv-dumb", + name = "BOSS-PAG", + command = "boss-pag", algoType = AlgType.allow_latent_common_causes ) @Bootstrapping @Experimental -public class LvDumb extends AbstractBootstrapAlgorithm implements Algorithm, UsesScoreWrapper, +public class BossPag extends AbstractBootstrapAlgorithm implements Algorithm, UsesScoreWrapper, HasKnowledge, ReturnsBootstrapGraphs, TakesCovarianceMatrix { @Serial @@ -68,7 +68,7 @@ public class LvDumb extends AbstractBootstrapAlgorithm implements Algorithm, Use * @see AbstractBootstrapAlgorithm * @see Algorithm */ - public LvDumb() { + public BossPag() { // Used for reflection; do not delete. } @@ -85,7 +85,7 @@ public LvDumb() { * @see AbstractBootstrapAlgorithm * @see Algorithm */ - public LvDumb(ScoreWrapper score) { + public BossPag(ScoreWrapper score) { this.score = score; } @@ -114,7 +114,7 @@ public Graph runSearch(DataModel dataModel, Parameters parameters) { } Score score = this.score.getScore(dataModel, parameters); - edu.cmu.tetrad.search.LvDumb search = new edu.cmu.tetrad.search.LvDumb(score); + edu.cmu.tetrad.search.BossPag search = new edu.cmu.tetrad.search.BossPag(score); // BOSS search.setUseDataOrder(parameters.getBoolean(Params.USE_DATA_ORDER)); @@ -154,7 +154,7 @@ public Graph getComparisonGraph(Graph graph) { */ @Override public String getDescription() { - return "LV-Dumb (BOSS followed by DAG to PAG) using " + this.score.getDescription(); + return "BOSS-PAG (BOSS followed by DAG to PAG) using " + this.score.getDescription(); } /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java similarity index 97% rename from tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java rename to tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java index 6144d37bf3..eeba015a72 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvDumb.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java @@ -30,13 +30,13 @@ import java.util.*; /** - * LvDumb is a class that implements the IGraphSearch interface. The LV-Dumb algorithm finds the BOSS DAG for + * BOSS-PAG is a class that implements the IGraphSearch interface. The BOSS-PAG algorithm finds the BOSS DAG for * the dataset and then simply reports the PAG (Partially Ancestral Graph) structure of the BOSS DAG, without * doing any further laten variable reasoning. * * @author josephramsey */ -public final class LvDumb implements IGraphSearch { +public final class BossPag implements IGraphSearch { /** * The score. */ @@ -87,7 +87,7 @@ public final class LvDumb implements IGraphSearch { * @param score The Score object to be used for scoring DAGs. * @throws NullPointerException if score is null. */ - public LvDumb(Score score) { + public BossPag(Score score) { if (score == null) { throw new NullPointerException(); } From 92b0c22cc07a08756524640f8261797f8849af28 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Wed, 12 Jun 2024 15:22:02 -0400 Subject: [PATCH 26/29] Improve error handling code and remove unused code blocks Revised error handling code for file selection in multiple modules to provide user friendly messages instead of console print statements. Additionally, numerous unused code blocks across several modules, mostly involving showAlgorithmIndices and showSimulationIndices, were removed to clean up the code base. The output directory creation process was also streamlined. --- .../tetradapp/editor/GridSearchEditor.java | 47 ++++---- .../edu/cmu/tetradapp/editor/LoadGraph.java | 3 +- .../tetradapp/editor/LoadGraphAmatCpdag.java | 3 +- .../tetradapp/editor/LoadGraphAmatPag.java | 3 +- .../cmu/tetradapp/editor/LoadGraphJson.java | 3 +- .../cmu/tetradapp/editor/LoadGraphTxt.java | 3 +- .../cmu/tetradapp/model/GridSearchModel.java | 61 +++++++---- .../cmu/tetrad/algcomparison/Comparison.java | 101 +++++------------- .../algcomparison/TimeoutComparison.java | 74 +++---------- .../examples/ExampleCompareFromFiles.java | 2 - .../examples/ExampleCompareSimulation.java | 3 - .../examples/ExampleCompareSimulation2.java | 3 - .../examples/ExampleNonlinearSave.java | 1 - .../algcomparison/examples/ExampleSave.java | 1 - .../examples/MVPCompareFromFiles.java | 2 - .../tetrad/algcomparison/examples/Save.java | 1 - .../examples/SaveDGSimulations.java | 1 - .../algcomparison/examples/TestBoss.java | 3 - .../examples/TestDegenerateGaussian.java | 3 - .../java/edu/cmu/tetrad/search/BossPag.java | 2 - .../edu/cmu/tetrad/search/MarkovCheck.java | 2 +- .../conditions/BryanSensitivityStudy.java | 3 - .../conditions/ExampleCompareFromFiles.java | 2 - .../conditions/ExampleCompareSimulation.java | 3 - .../ExampleCompareSimulationDiscrete.java | 3 - .../conditions/ExampleFirstInflection.java | 3 - .../examples/conditions/ExampleStars.java | 3 - .../examples/conditions/LingamStudy.java | 3 - .../test/SpecialExampleSimulationClark.java | 3 - .../TestConditionalGaussianSimulation.java | 3 - .../java/edu/cmu/tetrad/test/TestCopy.java | 3 - .../tetrad/test/TestGenerateMixedData.java | 3 - .../java/edu/cmu/tetrad/test/TestGrasp.java | 18 ---- .../cmu/tetrad/test/TestImagesSimulation.java | 3 - .../tetrad/test/TestKunMeasurementError.java | 3 - .../cmu/tetrad/test/TestSimulatedFmri.java | 9 -- .../cmu/tetrad/test/TestSimulatedFmri2.java | 3 - .../cmu/tetrad/test/TestSimulatedFmri3.java | 6 -- 38 files changed, 118 insertions(+), 278 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java index 61ce184181..a944cb5c2e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java @@ -6,12 +6,16 @@ import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; import edu.cmu.tetrad.algcomparison.simulation.Simulation; import edu.cmu.tetrad.algcomparison.simulation.Simulations; +import edu.cmu.tetrad.algcomparison.simulation.SingleDatasetSimulation; import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper; import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper; import edu.cmu.tetrad.annotation.AnnotatedClass; import edu.cmu.tetrad.annotation.Score; import edu.cmu.tetrad.annotation.TestOfIndependence; +import edu.cmu.tetrad.data.DataSet; import edu.cmu.tetrad.data.DataType; +import edu.cmu.tetrad.data.Knowledge; +import edu.cmu.tetrad.graph.Graph; import edu.cmu.tetrad.util.*; import edu.cmu.tetradapp.editor.simulation.ParameterTab; import edu.cmu.tetradapp.model.GridSearchModel; @@ -155,8 +159,6 @@ public GridSearchEditor(GridSearchModel model) { model.getParameters().set("algcomparisonSaveGraphs", model.getParameters().getBoolean("algcomparisonSaveGraphs", true)); model.getParameters().set("algcomparisonSaveCPDAGs", model.getParameters().getBoolean("algcomparisonSaveCPDAGs", false)); model.getParameters().set("algcomparisonSavePAGs", model.getParameters().getBoolean("algcomparisonSavePAGs", false)); - model.getParameters().set("algcomparisonShowAlgorithmIndices", model.getParameters().getBoolean("algcomparisonShowAlgorithmIndices", true)); - model.getParameters().set("algcomparisonShowSimulationIndices", model.getParameters().getBoolean("algcomparisonShowSimulationIndices", true)); model.getParameters().set("algcomparisonSortByUtility", model.getParameters().getBoolean("algcomparisonSortByUtility", false)); model.getParameters().set("algcomparisonShowUtilities", model.getParameters().getBoolean("algcomparisonShowUtilities", false)); model.getParameters().set("algcomparisonSetAlgorithmKnowledge", model.getParameters().getBoolean("algcomparisonSetAlgorithmKnowledge", false)); @@ -1299,16 +1301,6 @@ private void addComparisonTab(JTabbedPane tabbedPane) { horiz2c.add(Box.createHorizontalGlue()); horiz2c.add(getBooleanSelectionBox("algcomparisonSavePAGs", model.getParameters(), false)); - Box horiz3 = Box.createHorizontalBox(); - horiz3.add(new JLabel("Show Algorithm Indices:")); - horiz3.add(Box.createHorizontalGlue()); - horiz3.add(getBooleanSelectionBox("algcomparisonShowAlgorithmIndices", model.getParameters(), false)); - - Box horiz4 = Box.createHorizontalBox(); - horiz4.add(new JLabel("Show Simulation Indices:")); - horiz4.add(Box.createHorizontalGlue()); - horiz4.add(getBooleanSelectionBox("algcomparisonShowSimulationIndices", model.getParameters(), false)); - Box horiz4a = Box.createHorizontalBox(); horiz4a.add(new JLabel("Sort by Utility:")); horiz4a.add(Box.createHorizontalGlue()); @@ -1354,8 +1346,6 @@ private void addComparisonTab(JTabbedPane tabbedPane) { parameterBox.add(horiz2); parameterBox.add(horiz2b); parameterBox.add(horiz2c); - parameterBox.add(horiz3); - parameterBox.add(horiz4); parameterBox.add(horiz4a); parameterBox.add(horiz4b); parameterBox.add(horiz4c); @@ -2032,13 +2022,34 @@ private void setSimulationText() { Simulations selectedSimulations = model.getSelectedSimulations(); List simulations = selectedSimulations.getSimulations(); + DataSet dataSet = model.getSuppliedData(); + + if (dataSet != null) { + simulationChoiceTextArea.append("A data set has been supplied with " + dataSet.getNumColumns() + " variables and " + dataSet.getNumRows() + " rows."); + simulationChoiceTextArea.append("\n\nThe variables for the data are as follow: " + dataSet.getVariableNames() + "\n\n"); + } + + Graph graph = model.getSuppliedGraph(); + + if (graph != null) { + simulationChoiceTextArea.append("A graph has been supplied with " + graph.getNumNodes() + " nodes and " + graph.getNumEdges() + " edges."); + simulationChoiceTextArea.append("\n\nThe nodes for the graph are as follow: " + graph.getNodeNames() + "\n\n"); + } + + Knowledge knowledge = model.getKnowledge(); + + if (knowledge != null) { + simulationChoiceTextArea.append("Knowledge has been set, as follows:"); + simulationChoiceTextArea.append("\n\n" + knowledge + "\n\n"); + } + if (simulations.isEmpty()) { simulationChoiceTextArea.append(""" ** No simulations have been selected. Please select at least one simulation using the Add Simulation button below. ** """); return; } else if (simulations.size() == 1) { - simulationChoiceTextArea.setText(""" + simulationChoiceTextArea.append(""" The following simulation has been selected. This simulations will be run with the selected algorithms. """); @@ -2049,7 +2060,7 @@ private void setSimulationText() { simulationChoiceTextArea.append("Selected graph type = " + (randomGraphClass == null ? "None" : randomGraphClass.getSimpleName() + "\n")); simulationChoiceTextArea.append("Selected simulation type = " + simulationClass.getSimpleName() + "\n"); } else { - simulationChoiceTextArea.setText(""" + simulationChoiceTextArea.append(""" The following simulations have been selected. These simulations will be run with the selected algorithms. """); for (int i = 0; i < simulations.size(); i++) { @@ -2075,7 +2086,7 @@ private void setAlgorithmText() { """); return; } else if (selectedAlgorithms.size() == 1) { - algorithmChoiceTextArea.setText(""" + algorithmChoiceTextArea.append(""" The following algorithm has been selected. This algorithm will be run with the selected simulations. """); @@ -2092,7 +2103,7 @@ private void setAlgorithmText() { } } else { - algorithmChoiceTextArea.setText(""" + algorithmChoiceTextArea.append(""" The following algorithms have been selected. These algorithms will be run with the selected simulations. """); for (int i = 0; i < selectedAlgorithms.size(); i++) { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraph.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraph.java index 8559070cbc..0eb2288008 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraph.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraph.java @@ -81,7 +81,8 @@ public void actionPerformed(ActionEvent e) { File file = chooser.getSelectedFile(); if (file == null) { - System.out.println("File was null."); + JOptionPane.showMessageDialog((Component) this.graphEditable, + "No file was selected.", "Error", JOptionPane.ERROR_MESSAGE); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatCpdag.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatCpdag.java index fd965f270d..08826990f9 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatCpdag.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatCpdag.java @@ -82,7 +82,8 @@ public void actionPerformed(ActionEvent e) { File file = chooser.getSelectedFile(); if (file == null) { - System.out.println("File was null."); + JOptionPane.showMessageDialog((Component) this.graphEditable, + "No file was selected.", "Error", JOptionPane.ERROR_MESSAGE); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatPag.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatPag.java index 6c4394ec3e..8e58a158bb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatPag.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphAmatPag.java @@ -89,7 +89,8 @@ public void actionPerformed(ActionEvent e) { File file = chooser.getSelectedFile(); if (file == null) { - System.out.println("File was null."); + JOptionPane.showMessageDialog((Component) this.graphEditable, + "No file was selected.", "Error", JOptionPane.ERROR_MESSAGE); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphJson.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphJson.java index 1eb42663cc..bedf077fda 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphJson.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphJson.java @@ -62,7 +62,8 @@ public void actionPerformed(ActionEvent e) { File file = chooser.getSelectedFile(); if (file == null) { - System.out.println("File was null."); + JOptionPane.showMessageDialog((Component) this.graphEditable, + "No file was selected.", "Error", JOptionPane.ERROR_MESSAGE); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphTxt.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphTxt.java index 6f711eb6f8..eb3e9582ca 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphTxt.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/LoadGraphTxt.java @@ -82,7 +82,8 @@ public void actionPerformed(ActionEvent e) { File file = chooser.getSelectedFile(); if (file == null) { - System.out.println("File was null."); + JOptionPane.showMessageDialog((Component) this.graphEditable, + "No file was selected.", "Error", JOptionPane.ERROR_MESSAGE); return; } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java index 8ee9fe0ca1..925bddf76b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java @@ -77,28 +77,8 @@ public class GridSearchModel implements SessionModel { * The result path for the GridSearchModel. */ private final String resultsRoot = System.getProperty("user.home"); - /** - * Represents the variable "knowledge" in the GridSearchModel class. This variable is of type Knowledge and is - * private and final. - */ private final Knowledge knowledge; - /** - * The suppliedData variable represents a dataset that can be used in place of a simulated dataset for analysis. It - * can be set to null if no dataset is supplied. - *

    - * Using a supplied dataset restricts the analysis to only those statistics that do not require a true graph. - *

    - * Example usage: - *

    -     * DataSet dataset = new DataSet();
    -     * suppliedData = dataset;
    -     * 
    - */ private DataSet suppliedData = null; - /** - * The suppliedGraph variable represents a graph that can be supplied by the user. This graph will be given as an - * option in the user interface. - */ private Graph suppliedGraph = null; /** * The list of statistic names. @@ -166,6 +146,8 @@ public GridSearchModel(Parameters parameters) { this.parameters = parameters; this.knowledge = null; + this.suppliedData = null; + this.suppliedGraph = null; initializeIfNull(); } @@ -187,6 +169,8 @@ public GridSearchModel(KnowledgeBoxModel knowledge, Parameters parameters) { this.parameters = parameters; this.knowledge = knowledge.getKnowledge(); + this.suppliedData = null; + this.suppliedGraph = null; initializeIfNull(); } @@ -209,6 +193,7 @@ public GridSearchModel(GraphSource graphSource, Parameters parameters) { this.parameters = parameters; this.knowledge = null; this.suppliedGraph = graphSource.getGraph(); + this.suppliedData = null; initializeIfNull(); } @@ -258,6 +243,7 @@ public GridSearchModel(DataWrapper dataWrapper, Parameters parameters) { this.parameters = parameters; this.knowledge = null; this.suppliedData = (DataSet) dataWrapper.getSelectedDataModel(); + this.suppliedGraph = null; initializeIfNull(); } @@ -285,6 +271,9 @@ public GridSearchModel(DataWrapper dataWrapper, KnowledgeBoxModel knowledge, Par this.parameters = parameters; this.knowledge = knowledge.getKnowledge(); this.suppliedData = (DataSet) dataWrapper.getSelectedDataModel(); + + System.out.println("Variables names = " + this.suppliedData.getVariableNames()); + initializeIfNull(); } @@ -429,8 +418,6 @@ public void runComparison(java.io.PrintStream localOut) { comparison.setSaveGraphs(parameters.getBoolean("algcomparisonSaveGraphs")); comparison.setSaveCPDAGs(parameters.getBoolean("algcomparisonSaveCPDAGs")); comparison.setSavePags(parameters.getBoolean("algcomparisonSavePAGs")); - comparison.setShowAlgorithmIndices(parameters.getBoolean("algcomparisonShowAlgorithmIndices")); - comparison.setShowSimulationIndices(parameters.getBoolean("algcomparisonShowSimulationIndices")); comparison.setSortByUtility(parameters.getBoolean("algcomparisonSortByUtility")); comparison.setShowUtilities(parameters.getBoolean("algcomparisonShowUtilities")); comparison.setSetAlgorithmKnowledge(parameters.getBoolean("algcomparisonSetAlgorithmKnowledge")); @@ -549,7 +536,8 @@ public void addAlgorithm(AlgorithmSpec algorithm) { */ public void removeLastAlgorithm() { initializeIfNull(); - if (!getSelectedSimulationsSpecs().isEmpty()) { + LinkedList selectedSimulationsSpecs = getSelectedAlgorithmSpecs(); + if (!selectedSimulationsSpecs.isEmpty()) { getSelectedAlgorithmSpecs().removeLast(); } } @@ -1025,6 +1013,9 @@ public void setLastSimulationChoice(String selectedItem) { } /** + * The suppliedGraph variable represents a graph that can be supplied by the user. This graph will be given as an + * option in the user interface. + */ /** * The user may supply a graph, which will be given as an option in the UI. */ public Graph getSuppliedGraph() { @@ -1075,6 +1066,30 @@ private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundE } } + /** + * Represents the variable "knowledge" in the GridSearchModel class. This variable is of type Knowledge and is + * private and final. + */ + public Knowledge getKnowledge() { + return knowledge; + } + + /** + * The suppliedData variable represents a dataset that can be used in place of a simulated dataset for analysis. It + * can be set to null if no dataset is supplied. + *

    + * Using a supplied dataset restricts the analysis to only those statistics that do not require a true graph. + *

    + * Example usage: + *

    +     * DataSet dataset = new DataSet();
    +     * suppliedData = dataset;
    +     * 
    + */ + public DataSet getSuppliedData() { + return suppliedData; + } + /** * This class represents the comparison graph type for graph-based comparison algorithms. ComparisonGraphType is an * enumeration type that represents different types of comparison graphs. The available types are DAG (Directed diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java index 73915dc677..29d9e68f8b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/Comparison.java @@ -31,7 +31,10 @@ import edu.cmu.tetrad.algcomparison.score.ScoreWrapper; import edu.cmu.tetrad.algcomparison.simulation.Simulation; import edu.cmu.tetrad.algcomparison.simulation.Simulations; -import edu.cmu.tetrad.algcomparison.statistic.*; +import edu.cmu.tetrad.algcomparison.statistic.ElapsedCpuTime; +import edu.cmu.tetrad.algcomparison.statistic.ParameterColumn; +import edu.cmu.tetrad.algcomparison.statistic.Statistic; +import edu.cmu.tetrad.algcomparison.statistic.Statistics; import edu.cmu.tetrad.algcomparison.utils.HasKnowledge; import edu.cmu.tetrad.algcomparison.utils.HasParameterValues; import edu.cmu.tetrad.algcomparison.utils.HasParameters; @@ -88,16 +91,6 @@ public class Comparison implements TetradSerializable { */ private boolean saveGraphs; - /** - * Whether to show the simulation indices. - */ - private boolean showSimulationIndices; - - /** - * Whether to show the algorithm indices. - */ - private boolean showAlgorithmIndices; - /** * Whether to show the utility calculations. */ @@ -157,15 +150,13 @@ public class Comparison implements TetradSerializable { /** * Initializes a new instance of the Comparison class. *

    - * By default, the saveGraphs property is set to true. The showSimulationIndices, showAlgorithmIndices, - * showUtilities, and sortByUtility properties are all set to false. + * By default, the saveGraphs property is set to true. The showUtilities and sortByUtility properties are set + * to false. *

    * Usage: Comparison comparison = new Comparison(); */ public Comparison() { this.saveGraphs = true; - this.showSimulationIndices = false; - this.showAlgorithmIndices = false; this.showUtilities = false; this.sortByUtility = false; } @@ -451,7 +442,7 @@ public void compareFromSimulations(String resultsPath, Simulations simulations, try { numStats = allStats[0][0].length - 1; } catch (Exception e) { - throw new RuntimeException("It seems that not results were recorded. Please double-check the comparison setup."); + throw new RuntimeException("It seems that no results were recorded. Please double-check the comparison setup."); } double[][][] statTables = calcStatTables(allStats, Mode.Average, numTables, algorithmSimulationWrappers, numStats, statistics); @@ -1116,42 +1107,6 @@ private double[][][][] calcStats(List algorithmSimul return allStats; } - /** - * Checks if the simulation indices are currently being shown. - * - * @return true if the simulation indices are being shown, false otherwise - */ - public boolean isShowSimulationIndices() { - return this.showSimulationIndices; - } - - /** - * Sets whether to show simulation indices or not. - * - * @param showSimulationIndices true to show simulation indices, false otherwise - */ - public void setShowSimulationIndices(boolean showSimulationIndices) { - this.showSimulationIndices = showSimulationIndices; - } - - /** - * Indicates whether the algorithm indices should be shown. - * - * @return {@code true} if the algorithm indices should be shown, {@code false} otherwise. - */ - public boolean isShowAlgorithmIndices() { - return this.showAlgorithmIndices; - } - - /** - * Sets whether to show algorithm indices. - * - * @param showAlgorithmIndices true to show algorithm indices, false otherwise - */ - public void setShowAlgorithmIndices(boolean showAlgorithmIndices) { - this.showAlgorithmIndices = showAlgorithmIndices; - } - /** * Checks if the utilities are currently being shown. * @@ -1345,7 +1300,6 @@ private void doRun(List algorithmSimulationWrappers, try { Algorithm algorithm = algorithmWrapper.getAlgorithm(); - Simulation simulation = simulationWrapper.getSimulation(); if (setAlgorithmKnowledge && algorithm instanceof HasKnowledge && knowledge != null) { ((HasKnowledge) algorithm).setKnowledge(knowledge); @@ -1393,12 +1347,13 @@ private void doRun(List algorithmSimulationWrappers, } int simIndex = simulationWrappers.indexOf(simulationWrapper) + 1; + int algIndex = algorithmSimulationWrappers.indexOf(algorithmSimulationWrapper) + 1; long endTime = threadMXBean.getCurrentThreadCpuTime(); long taskCpuTime = (endTime - startTime) / 1000; - saveGraph(this.resultsPath, graphOut, run.runIndex(), simIndex, algorithmWrapper, taskCpuTime, stdout); + saveGraph(this.resultsPath, graphOut, run.runIndex(), simIndex, algIndex, taskCpuTime, stdout); if (trueGraph != null) { graphOut = GraphUtils.replaceNodes(graphOut, trueGraph.getNodes()); @@ -1515,23 +1470,25 @@ private void doRun(List algorithmSimulationWrappers, } } - private void saveGraph(String resultsPath, Graph graph, int i, int simIndex, AlgorithmWrapper algorithmWrapper, long elapsed, PrintStream stdout) { + private void saveGraph(String resultsPath, Graph graph, int i, int simIndex, int algIndex, long elapsed, PrintStream stdout) { if (!this.saveGraphs) { return; } try { - String description = algorithmWrapper.getDescription().replace(" ", "_"); + String description = simIndex + "." + algIndex; + +// String description = algorithmWrapper.getDescription().replace(" ", "_"); File file; File fileElapsed; - File dir = new File(resultsPath, "results/" + description + "/" + simIndex); + File dir = new File(resultsPath, "results/" + description);// + "/" + simIndex); if (!dir.mkdirs()) { // TetradLogger.getInstance().forceLogMessage("Directory already exists: " + dir); } - File dirElapsed = new File(resultsPath, "elapsed/" + description + "/" + simIndex); + File dirElapsed = new File(resultsPath, "elapsed/" + description);// + "/" + simIndex); if (!dirElapsed.mkdirs()) { // TetradLogger.getInstance().forceLogMessage("Directory already exists: " + dirElapsed); } @@ -1667,35 +1624,31 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod } int rows = algorithmSimulationWrappers.size() + 1; - int cols = (isShowSimulationIndices() ? 1 : 0) + (isShowAlgorithmIndices() ? 1 : 0) + numStats + (isShowUtilities() ? 1 : 0); + int cols = (1) + (1) + numStats + (isShowUtilities() ? 1 : 0); TextTable table = new TextTable(rows, cols); table.setDelimiter(tabDelimitedTables ? TextTable.Delimiter.TAB : TextTable.Delimiter.JUSTIFIED); int initialColumn = 0; - if (isShowSimulationIndices()) { - table.setToken(0, initialColumn, "Sim"); + table.setToken(0, initialColumn, "Sim"); - for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { - Simulation simulation = algorithmSimulationWrappers.get(newOrder[t]).getSimulationWrapper(); - table.setToken(t + 1, initialColumn, "" + (simulationWrappers.indexOf(simulation) + 1)); - } - - initialColumn++; + for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { + Simulation simulation = algorithmSimulationWrappers.get(newOrder[t]).getSimulationWrapper(); + table.setToken(t + 1, initialColumn, "" + (simulationWrappers.indexOf(simulation) + 1)); } - if (isShowAlgorithmIndices()) { - table.setToken(0, initialColumn, "Alg"); + initialColumn++; - for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { - AlgorithmWrapper algorithm = algorithmSimulationWrappers.get(newOrder[t]).getAlgorithmWrapper(); - table.setToken(t + 1, initialColumn, "" + (algorithmWrappers.indexOf(algorithm) + 1)); - } + table.setToken(0, initialColumn, "Alg"); - initialColumn++; + for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { + AlgorithmWrapper algorithm = algorithmSimulationWrappers.get(newOrder[t]).getAlgorithmWrapper(); + table.setToken(t + 1, initialColumn, "" + (algorithmWrappers.indexOf(algorithm) + 1)); } + initialColumn++; + for (int statIndex = 0; statIndex < numStats; statIndex++) { String statLabel = statistics.getStatistics().get(statIndex).getAbbreviation(); table.setToken(0, initialColumn + statIndex, statLabel); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/TimeoutComparison.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/TimeoutComparison.java index 98307d5278..0cd323e786 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/TimeoutComparison.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/TimeoutComparison.java @@ -86,14 +86,6 @@ public class TimeoutComparison { * Whether to copy the data (or using the original). */ private boolean copyData; - /** - * Whether to show the simulation indices. - */ - private boolean showSimulationIndices; - /** - * Whether to show the algorithm indices. - */ - private boolean showAlgorithmIndices; /** * Whether to show the utilities. */ @@ -941,42 +933,6 @@ private void shutdownAndAwaitTermination(ForkJoinPool pool) { } } - /** - *

    isShowSimulationIndices.

    - * - * @return a boolean - */ - public boolean isShowSimulationIndices() { - return this.showSimulationIndices; - } - - /** - *

    Setter for the field showSimulationIndices.

    - * - * @param showSimulationIndices a boolean - */ - public void setShowSimulationIndices(boolean showSimulationIndices) { - this.showSimulationIndices = showSimulationIndices; - } - - /** - *

    isShowAlgorithmIndices.

    - * - * @return a boolean - */ - public boolean isShowAlgorithmIndices() { - return this.showAlgorithmIndices; - } - - /** - *

    Setter for the field showAlgorithmIndices.

    - * - * @param showAlgorithmIndices a boolean - */ - public void setShowAlgorithmIndices(boolean showAlgorithmIndices) { - this.showAlgorithmIndices = showAlgorithmIndices; - } - /** *

    isShowUtilities.

    * @@ -1493,7 +1449,7 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod } int rows = algorithmSimulationWrappers.size() + 1; - int cols = (isShowSimulationIndices() ? 1 : 0) + (isShowAlgorithmIndices() ? 1 : 0) + numStats + int cols = (1) + (1) + numStats + (isShowUtilities() ? 1 : 0); TextTable table = new TextTable(rows, cols); @@ -1501,29 +1457,25 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod int initialColumn = 0; - if (isShowSimulationIndices()) { - table.setToken(0, initialColumn, "Sim"); + table.setToken(0, initialColumn, "Sim"); - for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { - Simulation simulation = algorithmSimulationWrappers.get(newOrder[t]). - getSimulationWrapper(); - table.setToken(t + 1, initialColumn, "" + (simulationWrappers.indexOf(simulation) + 1)); - } - - initialColumn++; + for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { + Simulation simulation = algorithmSimulationWrappers.get(newOrder[t]). + getSimulationWrapper(); + table.setToken(t + 1, initialColumn, "" + (simulationWrappers.indexOf(simulation) + 1)); } - if (isShowAlgorithmIndices()) { - table.setToken(0, initialColumn, "Alg"); + initialColumn++; - for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { - AlgorithmWrapper algorithm = algorithmSimulationWrappers.get(newOrder[t]).getAlgorithmWrapper(); - table.setToken(t + 1, initialColumn, "" + (algorithmWrappers.indexOf(algorithm) + 1)); - } + table.setToken(0, initialColumn, "Alg"); - initialColumn++; + for (int t = 0; t < algorithmSimulationWrappers.size(); t++) { + AlgorithmWrapper algorithm = algorithmSimulationWrappers.get(newOrder[t]).getAlgorithmWrapper(); + table.setToken(t + 1, initialColumn, "" + (algorithmWrappers.indexOf(algorithm) + 1)); } + initialColumn++; + for (int statIndex = 0; statIndex < numStats; statIndex++) { String statLabel = statistics.getStatistics().get(statIndex).getAbbreviation(); table.setToken(0, initialColumn + statIndex, statLabel); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareFromFiles.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareFromFiles.java index becceb4676..8ed5b606e3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareFromFiles.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareFromFiles.java @@ -91,8 +91,6 @@ public static void main(String... args) { algorithms.add(new Pc(new FisherZ())); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(false); - comparison.setShowSimulationIndices(false); comparison.setSortByUtility(true); comparison.setShowUtilities(true); 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 918ed2335d..c26cd4d9ac 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 @@ -86,9 +86,6 @@ public static void main(String... args) { simulations.add(new SemSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(true); comparison.setShowUtilities(true); comparison.setSaveGraphs(true); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation2.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation2.java index 788d714779..908ae54f61 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation2.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleCompareSimulation2.java @@ -77,9 +77,6 @@ public static void main(String... args) { simulations.add(new BayesNetSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(true); comparison.setShowUtilities(true); comparison.setSaveGraphs(true); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleNonlinearSave.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleNonlinearSave.java index adfc1529fe..5fd8c748a3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleNonlinearSave.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleNonlinearSave.java @@ -77,7 +77,6 @@ public static void main(String... args) { Simulation simulation = new LinearSineSimulation(new RandomForward()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.saveToFiles("comparison", simulation, parameters); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleSave.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleSave.java index 044f7cd258..71dea83493 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleSave.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/ExampleSave.java @@ -56,7 +56,6 @@ public static void main(String... args) { Simulation simulation = new SemSimulation(new RandomForward()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.saveToFiles("comparison", simulation, parameters); } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/MVPCompareFromFiles.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/MVPCompareFromFiles.java index e79a1416b0..4b90e7de8c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/MVPCompareFromFiles.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/MVPCompareFromFiles.java @@ -87,8 +87,6 @@ public static void main(String... args) { algorithms.add(new Fges(new MVPBicScore())); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/Save.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/Save.java index 5fc326ea24..a9f3e23fde 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/Save.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/Save.java @@ -63,7 +63,6 @@ public static void main(String... args) { Simulation simulation = new LeeHastieSimulation(new RandomForward()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setSaveData(true); comparison.setSaveGraphs(true); comparison.saveToFiles("comparison", simulation, parameters); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/SaveDGSimulations.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/SaveDGSimulations.java index 81d83a9011..8f48c70b3a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/SaveDGSimulations.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/SaveDGSimulations.java @@ -62,7 +62,6 @@ public static void main(String... args) { Simulation simulation = new ConditionalGaussianSimulation(new RandomForward()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.saveToFiles("comparison-CG-measures", simulation, parameters); } } 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 7bd8fcf6fc..5b0ed00399 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 @@ -103,9 +103,6 @@ public static void main(String... args) { // simulations.add(new LeeHastieSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestDegenerateGaussian.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestDegenerateGaussian.java index 730b726800..846ab7aafa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestDegenerateGaussian.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/examples/TestDegenerateGaussian.java @@ -98,9 +98,6 @@ public static void main(String... args) { simulations.add(new LeeHastieSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java index eeba015a72..3d5060c5ee 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/BossPag.java @@ -117,14 +117,12 @@ public Graph search() { // BOSS seems to be doing better here. var suborderSearch = new Boss(score); - suborderSearch.setKnowledge(knowledge); suborderSearch.setResetAfterBM(true); suborderSearch.setResetAfterRS(true); suborderSearch.setVerbose(false); suborderSearch.setUseBes(useBes); suborderSearch.setUseDataOrder(useDataOrder); suborderSearch.setNumStarts(numStarts); - suborderSearch.setKnowledge(knowledge); var permutationSearch = new PermutationSearch(suborderSearch); permutationSearch.setKnowledge(knowledge); permutationSearch.search(); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java index 11f65ee305..0cd85ec0ee 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java @@ -203,7 +203,7 @@ public AllSubsetsIndependenceFacts getAllSubsetsIndependenceFacts() { Set z = GraphUtils.asSet(list, _other); if (!checkNodeIndependenceAndConditioning(x, y, z)) { - continue; + continue; } IndependenceFact fact = new IndependenceFact(x, y, z); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/BryanSensitivityStudy.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/BryanSensitivityStudy.java index 2d99736ed8..9bffc2fac5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/BryanSensitivityStudy.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/BryanSensitivityStudy.java @@ -81,9 +81,6 @@ public static void main(String... args) { // algorithms.add(new Fci(new FisherZ())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.PAG_of_the_true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareFromFiles.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareFromFiles.java index 2f456c5e1e..892ff6f896 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareFromFiles.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareFromFiles.java @@ -96,8 +96,6 @@ public static void main(String... args) { // algorithms.add(new Gfci(new ChiSquare(), new DiscreteBicScore()))); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(false); comparison.setSortByUtility(true); comparison.setShowUtilities(true); comparison.setSaveGraphs(true); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulation.java index 908a5d85c2..a11deb8394 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulation.java @@ -137,9 +137,6 @@ public static void main(String... args) { simulations.add(new SemSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(false); - comparison.setShowSimulationIndices(false); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulationDiscrete.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulationDiscrete.java index f60536b629..003e2cac0c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulationDiscrete.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleCompareSimulationDiscrete.java @@ -112,9 +112,6 @@ public static void main(String... args) { simulations.add(new BayesNetSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(true); // comparison.setShowUtilities(true); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleFirstInflection.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleFirstInflection.java index c65d3677ae..e4a7353b41 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleFirstInflection.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleFirstInflection.java @@ -130,9 +130,6 @@ public static void main(String... args) { simulations.add(new LinearFisherModel(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleStars.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleStars.java index 7fe362af78..66a52a73aa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleStars.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/ExampleStars.java @@ -135,9 +135,6 @@ public static void main(String... args) { simulations.add(new LinearFisherModel(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/LingamStudy.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/LingamStudy.java index bff0e14145..2e23011788 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/LingamStudy.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/examples/conditions/LingamStudy.java @@ -83,9 +83,6 @@ public static void main(String... args) { algorithms.add(new FaskOrig(new FisherZ(), new SemBicScore())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/SpecialExampleSimulationClark.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/SpecialExampleSimulationClark.java index e2597eaa16..d5ce128144 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/SpecialExampleSimulationClark.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/SpecialExampleSimulationClark.java @@ -51,9 +51,6 @@ public static void main(String... args) { simulations.add(new SpecialDataClark(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(true); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestConditionalGaussianSimulation.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestConditionalGaussianSimulation.java index 15ba381487..a4c252d4c0 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestConditionalGaussianSimulation.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestConditionalGaussianSimulation.java @@ -85,9 +85,6 @@ public void testBryan(String... args) { simulations.add(new ConditionalGaussianSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(true); comparison.setShowUtilities(true); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCopy.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCopy.java index f9e0051992..6e4c0cd58c 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCopy.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestCopy.java @@ -84,9 +84,6 @@ public static void main(String... args) { simulations.add(new SemSimulation(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(true); comparison.setShowUtilities(true); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGenerateMixedData.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGenerateMixedData.java index 817a17ba7f..96608a784e 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGenerateMixedData.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestGenerateMixedData.java @@ -63,9 +63,6 @@ public void test1() { LeeHastieSimulation simulation = new LeeHastieSimulation(new RandomForward()); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(false); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(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 76453df0ab..b51c073dc1 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 @@ -323,8 +323,6 @@ private void testPredictGoodStats() { Comparison comparison = new Comparison(); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); -// comparison.setSortByUtility(true); - comparison.setShowAlgorithmIndices(true); comparison.compareFromSimulations("grasp_boss_timing", simulations, algorithms, statistics, params); } @@ -464,7 +462,6 @@ public void doPaperRun(Parameters params, String dataPath, String resultsPath, b statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setSaveGraphs(true); comparison.setSavePags(true); comparison.setSaveData(false); @@ -558,7 +555,6 @@ private void testPaperSimulationsVisit(Parameters params, String type) { Comparison comparison = new Comparison(); comparison.setSaveData(false); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/varying_final2/testPaperSimulations_" @@ -703,7 +699,6 @@ public void doNewAgsHeadToHead(Parameters params, String dataPath, String result statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setSaveGraphs(true); comparison.setSavePags(true); comparison.setSaveData(false); @@ -772,7 +767,6 @@ public void testGraspForClark() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/testGraspForClark", @@ -836,7 +830,6 @@ public void testGrasp1Bryan() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/testGrasp1", @@ -883,7 +876,6 @@ public void testComparePearlGrowShrink() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/testComparePearlGrowShrink", @@ -934,7 +926,6 @@ public void testCompareGrasp1Grasp2() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/testCompareGrasp1Grasp2", @@ -1002,7 +993,6 @@ public void testGrasp2() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); comparison.setSaveData(false); @@ -1065,7 +1055,6 @@ public void testLuFigure3() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); comparison.setSaveData(false); @@ -1125,7 +1114,6 @@ public void testLuFigure6() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); comparison.setSaveData(false); @@ -1187,7 +1175,6 @@ public void testPaperSimulations() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/testPaperSimulations_" @@ -2008,7 +1995,6 @@ public void testClark() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations("/Users/josephramsey/Downloads/grasp/clark", simulations, @@ -2059,7 +2045,6 @@ public void testManyVarManyDegreeTest() { algorithms.add(new Grasp(new MSeparationTest(), new edu.cmu.tetrad.algcomparison.score.SemBicScore())); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setTabDelimitedTables(false); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); @@ -2557,7 +2542,6 @@ public void testFciAlgs() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations( @@ -2839,7 +2823,6 @@ public void testScores() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.true_DAG); comparison.compareFromSimulations( @@ -2902,7 +2885,6 @@ public void testScores2() { statistics.add(new ElapsedCpuTime()); Comparison comparison = new Comparison(); - comparison.setShowAlgorithmIndices(true); comparison.setComparisonGraph(Comparison.ComparisonGraph.CPDAG_of_the_true_DAG); comparison.compareFromSimulations( diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestImagesSimulation.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestImagesSimulation.java index 1da393761c..4efd8dfba8 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestImagesSimulation.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestImagesSimulation.java @@ -85,9 +85,6 @@ public void test1() { simulations.add(new LinearFisherModel(new RandomForward())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(false); comparison.setSortByUtility(false); comparison.setShowUtilities(false); // comparison.setSaveGraphs(true); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestKunMeasurementError.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestKunMeasurementError.java index 514dfdd7f7..e6d70eb9ff 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestKunMeasurementError.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestKunMeasurementError.java @@ -89,9 +89,6 @@ public void TestCycles_Data_fMRI_FASK() { algorithms.add(new Pcd()); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri.java index 7456f4f5a2..af6004c695 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri.java @@ -180,9 +180,6 @@ private void task() { algorithms.add(new FaskConcatenated(new SemBicScore(), new FisherZ())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); @@ -246,9 +243,6 @@ public void task2() { })); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); @@ -311,9 +305,6 @@ public void testTough() { new FisherZ())); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri2.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri2.java index 6bc8a8ae22..6fed8499dc 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri2.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri2.java @@ -123,9 +123,6 @@ public void TestCycles_Data_fMRI_FASK() { algorithms.add(new Fask(new SemBicScore())); // Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); diff --git a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri3.java b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri3.java index f868b35924..b8dc30568d 100644 --- a/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri3.java +++ b/tetrad-lib/src/test/java/edu/cmu/tetrad/test/TestSimulatedFmri3.java @@ -136,9 +136,6 @@ public void TestCycles_Data_fMRI_FASK() { algorithms.add(new Fask()); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); comparison.setSaveGraphs(false); @@ -222,9 +219,6 @@ public void TestMadelynDAta() { algorithms.add(new FaskConcatenated()); Comparison comparison = new Comparison(); - - comparison.setShowAlgorithmIndices(true); - comparison.setShowSimulationIndices(true); comparison.setSortByUtility(false); comparison.setShowUtilities(false); // comparison.setParallelized(false); From 7cda6c2eaed39f798fb6fa97739b118b260cc74b Mon Sep 17 00:00:00 2001 From: jdramsey Date: Wed, 12 Jun 2024 16:49:02 -0400 Subject: [PATCH 27/29] Add RowsSettable interface to IndTest classes The IndTestConditionalGaussianLrt and IndTestDegenerateGaussianLrt classes have been updated to implement the RowsSettable interface. This change allows users to set which rows are used in the test. Also, redundant spaces were removed from IndTestFisherZ, and parameter changes were made in DegenerateGaussianBic class. --- .../score/DegenerateGaussianBicScore.java | 5 +- .../test/IndTestConditionalGaussianLrt.java | 46 ++++++++++++++++++- .../test/IndTestDegenerateGaussianLrt.java | 46 ++++++++++++++++++- .../tetrad/search/test/IndTestFisherZ.java | 2 - 4 files changed, 93 insertions(+), 6 deletions(-) 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 ba2fdedba4..39fe05cd8e 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 @@ -71,9 +71,9 @@ public DegenerateGaussianBicScore() { public Score getScore(DataModel dataSet, Parameters parameters) { this.dataSet = dataSet; boolean precomputeCovariances = parameters.getBoolean(Params.PRECOMPUTE_COVARIANCES); -// DegenerateGaussianScoreOld degenerateGaussianScore = new DegenerateGaussianScoreOld(DataUtils.getMixedDataSet(dataSet)); DegenerateGaussianScore degenerateGaussianScore = new DegenerateGaussianScore(SimpleDataLoader.getMixedDataSet(dataSet), precomputeCovariances); - degenerateGaussianScore.setPenaltyDiscount(parameters.getDouble("penaltyDiscount")); + degenerateGaussianScore.setPenaltyDiscount(parameters.getDouble(Params.PENALTY_DISCOUNT)); + degenerateGaussianScore.setUsePseudoInverse(parameters.getBoolean(Params.USE_PSEUDOINVERSE)); return degenerateGaussianScore; } @@ -102,6 +102,7 @@ public List getParameters() { parameters.add(Params.PENALTY_DISCOUNT); parameters.add(Params.STRUCTURE_PRIOR); parameters.add(Params.PRECOMPUTE_COVARIANCES); + parameters.add(Params.USE_PSEUDOINVERSE); return parameters; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java index a664451297..3a1b688165 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestConditionalGaussianLrt.java @@ -46,7 +46,7 @@ * @author josephramsey * @version $Id: $Id */ -public class IndTestConditionalGaussianLrt implements IndependenceTest { +public class IndTestConditionalGaussianLrt implements IndependenceTest, RowsSettable { /** * The data set. */ @@ -79,6 +79,10 @@ public class IndTestConditionalGaussianLrt implements IndependenceTest { * The minimum sample size per cell for discretization. */ private int minSampleSizePerCell = 4; + /** + * The rows used in the test. + */ + private List rows = new ArrayList<>(); /** * Constructor. @@ -282,6 +286,10 @@ public void setNumCategoriesToDiscretize(int numCategoriesToDiscretize) { * @return A list of row indices. */ private List getRows(List allVars, Map nodeHash) { + if (this.rows != null) { + return this.rows; + } + List rows = new ArrayList<>(); K: @@ -299,6 +307,42 @@ private List getRows(List allVars, Map nodeHash) { return rows; } + /** + * Returns the rows used in the test. + * + * @return The rows used in the test. + */ + public List getRows() { + return rows; + } + + /** + * Allows the user to set which rows are used in the test. Otherwise, all rows are used, except those with missing + * values. + */ + public void setRows(List rows) { + if (data == null) { + return; + } + + List all = new ArrayList<>(); + for (int i = 0; i < data.getNumRows(); i++) all.add(i); + Collections.shuffle(all); + + List _rows = new ArrayList<>(); + for (int i = 0; i < data.getNumRows() / 2; i++) { + _rows.add(all.get(i)); + } + + for (Integer row : _rows) { + if (row < 0 || row >= data.getNumRows()) { + throw new IllegalArgumentException("Row index out of bounds."); + } + } + + this.rows = _rows; + } + /** * Sets the minimum sample size per cell for the independence test. * diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java index 33063cd5fe..88db02706d 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestDegenerateGaussianLrt.java @@ -50,7 +50,7 @@ * @author Bryan Andrews * @version $Id: $Id */ -public class IndTestDegenerateGaussianLrt implements IndependenceTest { +public class IndTestDegenerateGaussianLrt implements IndependenceTest, RowsSettable { /** * A constant. @@ -96,6 +96,10 @@ public class IndTestDegenerateGaussianLrt implements IndependenceTest { * True if verbose output should be printed. */ private boolean verbose; + /** + * The rows used in the test. + */ + private List rows = new ArrayList<>(); /** * Constructs the score using a covariance matrix. @@ -403,6 +407,10 @@ private Ret getlldof(List rows, int i, int... parents) { * @return A list of integers representing the row indices that satisfy the conditions. */ private List getRows(List allVars, Map nodesHash) { + if (this.rows != null) { + return this.rows; + } + List rows = new ArrayList<>(); K: @@ -459,6 +467,42 @@ private Matrix getCov(List rows, int[] cols) { return cov; } + /** + * Returns the rows used in the test. + * + * @return The rows used in the test. + */ + public List getRows() { + return rows; + } + + /** + * Allows the user to set which rows are used in the test. Otherwise, all rows are used, except those with missing + * values. + */ + public void setRows(List rows) { + if (dataSet == null) { + return; + } + + List all = new ArrayList<>(); + for (int i = 0; i < dataSet.getNumRows(); i++) all.add(i); + Collections.shuffle(all); + + List _rows = new ArrayList<>(); + for (int i = 0; i < dataSet.getNumRows() / 2; i++) { + _rows.add(all.get(i)); + } + + for (Integer row : _rows) { + if (row < 0 || row >= dataSet.getNumRows()) { + throw new IllegalArgumentException("Row index out of bounds."); + } + } + + this.rows = _rows; + } + /** * Stores a return value for a likelihood--i.e., a likelihood value and the degrees of freedom for it. */ diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java index 1c046abb8c..bcde559ce8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndTestFisherZ.java @@ -841,8 +841,6 @@ public void setRows(List rows) { _rows.add(all.get(i)); } - - for (Integer row : _rows) { if (row < 0 || row >= sampleSize()) { throw new IllegalArgumentException("Row index out of bounds."); From 9e1f267cea4fa7925a7116f2f575543e68a50acf Mon Sep 17 00:00:00 2001 From: jdramsey Date: Wed, 12 Jun 2024 18:12:52 -0400 Subject: [PATCH 28/29] Add resultsPath field to GridSearchModel A new field, resultsPath, has been added to the GridSearchModel class, along with its setter and getter methods. This field represents the path to the result folder. This is set after a comparison has been run, and used to add additional contents like simulation, algorithm, table columns, and verbose output to the comparison results. --- .../tetradapp/editor/GridSearchEditor.java | 40 +++++++++++++++++-- .../cmu/tetradapp/model/GridSearchModel.java | 20 ++++++++++ 2 files changed, 56 insertions(+), 4 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java index a944cb5c2e..ed7a4f16a2 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/editor/GridSearchEditor.java @@ -34,10 +34,7 @@ import javax.swing.table.TableRowSorter; import javax.swing.text.BadLocationException; import java.awt.*; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; +import java.io.*; import java.lang.reflect.InvocationTargetException; import java.nio.charset.StandardCharsets; import java.text.DecimalFormat; @@ -1425,6 +1422,41 @@ public void watch() { try { model.runComparison(ps); + + String resultsPath = model.getResultsPath(); + + if (resultsPath != null && simulationChoiceTextArea != null) { + // Write contents of simulation text area to a file at resultsPath + "/simulation.txt" + try (PrintWriter writer = new PrintWriter(resultsPath + "/simulation.txt")) { + writer.println(simulationChoiceTextArea.getText()); + } catch (FileNotFoundException ex) { + throw new RuntimeException(ex); + } + + // Write contents of algorithm text area to a file at resultsPath + "/algorithm.txt" + try (PrintWriter writer = new PrintWriter(resultsPath + "/algorithm.txt")) { + writer.println(algorithmChoiceTextArea.getText()); + } catch (FileNotFoundException ex) { + throw new RuntimeException(ex); + } + + // Write contents of table columns text area to a file at resultsPath + "/tableColumns.txt" + try (PrintWriter writer = new PrintWriter(resultsPath + "/tableColumns.txt")) { + writer.println(tableColumnsChoiceTextArea.getText()); + } catch (FileNotFoundException ex) { + throw new RuntimeException(ex); + } + + // Write contents of verbose output text area to a file at resultsPath + "/verboseOutput.txt" + try (PrintWriter writer = new PrintWriter(resultsPath + "/verboseOutput.txt")) { + writer.println(verboseOutputTextArea.getText()); + } catch (FileNotFoundException ex) { + throw new RuntimeException(ex); + } + + + } + } catch (Exception ex) { throw new RuntimeException(ex); } diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java index 925bddf76b..f2077c7548 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java @@ -133,6 +133,11 @@ public class GridSearchModel implements SessionModel { * The name of the GridSearchModel. */ private String name = "Grid Search"; + /** + * The variable resultsPath represents the path to the result folder. This is set after a comparison has been run + * and can be used to add additional files to the comparison results. + */ + private String resultsPath = null; /** * Constructs a new GridSearchModel with the specified parameters. @@ -453,6 +458,9 @@ public void runComparison(java.io.PrintStream localOut) { String outputFileName = "Comparison.txt"; comparison.compareFromSimulations(resultsPath, simulations, outputFileName, localOut, algorithms, getSelectedStatistics(), new Parameters(parameters)); + + this.resultsPath = resultsPath; + } private LinkedList getSelectedAlgorithmSpecs() { @@ -1090,6 +1098,18 @@ public DataSet getSuppliedData() { return suppliedData; } + public void setResultsPath(String resultsPath) { + this.resultsPath = resultsPath; + } + + /** + * The variable resultsPath represents the path to the result folder. This is set after a comparison has been run + * and can be used to add additional files to the comparison results. + */ + public String getResultsPath() { + return resultsPath; + } + /** * This class represents the comparison graph type for graph-based comparison algorithms. ComparisonGraphType is an * enumeration type that represents different types of comparison graphs. The available types are DAG (Directed From 7585c80a8d04ec7868eca55668e8286460b1cd67 Mon Sep 17 00:00:00 2001 From: jdramsey Date: Wed, 12 Jun 2024 22:56:17 -0400 Subject: [PATCH 29/29] Add serialization methods to various classes The serialization methods writeObject and readObject have been added to several classes for enhanced data persistence and transport. These methods handle the writing and reading of objects to and from an ObjectOutputStream and an ObjectInputStream, respectively. As a result, serialized objects can be stored and retrieved across different instantiations of the application. --- .../model/AbstractAlgorithmRunner.java | 20 +++++++ .../model/AbstractMBSearchRunner.java | 20 +++++++ .../model/ApproximateUpdaterWrapper.java | 20 +++++++ .../model/BayesEstimatorWrapper.java | 20 +++++++ .../cmu/tetradapp/model/BayesImWrapper.java | 20 +++++++ .../tetradapp/model/BayesImWrapperObs.java | 8 +++ .../cmu/tetradapp/model/BayesPmWrapper.java | 20 +++++++ .../model/BayesUpdaterClassifierWrapper.java | 20 +++++++ .../tetradapp/model/BooleanGlassGeneIm.java | 14 +++++ .../model/BootstrapSamplerWrapper.java | 20 +++++++ .../cmu/tetradapp/model/CPDAGFitModel.java | 14 +++++ .../tetradapp/model/CalculatorWrapper.java | 14 +++++ .../tetradapp/model/CheckKnowledgeModel.java | 14 +++++ .../model/CptInvariantUpdaterWrapper.java | 14 +++++ .../edu/cmu/tetradapp/model/DagWrapper.java | 14 +++++ .../edu/cmu/tetradapp/model/DataWrapper.java | 14 +++++ .../model/DirichletBayesImWrapper.java | 14 +++++ .../model/DirichletEstimatorWrapper.java | 14 +++++ .../model/EdgewiseComparisonModel.java | 14 +++++ .../model/EmBayesEstimatorWrapper.java | 14 +++++ .../model/GeneralAlgorithmRunner.java | 14 +++++ .../model/GeneralizedSemEstimatorWrapper.java | 14 +++++ .../model/GeneralizedSemImWrapper.java | 14 +++++ .../model/GeneralizedSemPmWrapper.java | 14 +++++ .../model/GraphComparisonParams.java | 14 +++++ .../model/GraphSelectionWrapper.java | 14 +++++ .../edu/cmu/tetradapp/model/GraphWrapper.java | 14 +++++ .../cmu/tetradapp/model/GridSearchModel.java | 14 +++++ .../model/IdentifiabilityWrapper.java | 14 +++++ .../model/IndependenceResultIndFacts.java | 14 +++++ .../model/LogisticRegressionRunner.java | 14 +++++ .../model/MeasurementModelWrapper.java | 14 +++++ .../tetradapp/model/Misclassifications.java | 14 +++++ .../model/MissingDataInjectorWrapper.java | 14 +++++ .../model/PValueImproverWrapper.java | 14 +++++ .../cmu/tetradapp/model/RegressionRunner.java | 14 +++++ .../ReplaceMissingWithRandomWrapper.java | 14 +++++ .../model/RowSummingExactWrapper.java | 14 +++++ .../tetradapp/model/ScoredGraphsWrapper.java | 14 +++++ .../tetradapp/model/SemEstimatorWrapper.java | 14 +++++ .../cmu/tetradapp/model/SemGraphWrapper.java | 14 +++++ .../edu/cmu/tetradapp/model/SemImWrapper.java | 14 +++++ .../edu/cmu/tetradapp/model/SemPmWrapper.java | 14 +++++ .../tetradapp/model/SemUpdaterWrapper.java | 14 +++++ .../tetradapp/model/SessionNodeWrapper.java | 14 +++++ .../cmu/tetradapp/model/SessionWrapper.java | 14 +++++ .../model/StandardizedSemImWrapper.java | 14 +++++ .../model/StructEmBayesSearchRunner.java | 14 +++++ .../tetradapp/model/TabularComparison.java | 14 +++++ .../cmu/tetradapp/model/TetradMetadata.java | 14 +++++ .../tetradapp/model/TimeLagGraphWrapper.java | 14 +++++ .../model/datamanip/DeterminismWraper.java | 14 +++++ .../datamanip/DiscretizationWrapper.java | 14 +++++ .../workbench/AbstractWorkbench.java | 14 +++++ .../tetradapp/workbench/GraphNodeError.java | 14 +++++ .../tetradapp/workbench/GraphNodeLatent.java | 14 +++++ .../tetradapp/workbench/GraphNodeLocked.java | 14 +++++ .../workbench/GraphNodeMeasured.java | 14 +++++ .../workbench/GraphNodeRandomized.java | 14 +++++ .../algcomparison/algorithm/Algorithms.java | 14 +++++ .../algcomparison/simulation/Simulations.java | 14 +++++ .../statistic/LocalGraphPrecision.java | 30 +++++++++++ .../statistic/LocalGraphRecall.java | 5 ++ .../algcomparison/statistic/Statistics.java | 14 +++++ .../statistic/utils/LocalGraphConfusion.java | 20 +++++++ .../cmu/tetrad/bayes/ApproximateUpdater.java | 14 +++++ .../edu/cmu/tetrad/bayes/BayesImProbs.java | 14 +++++ .../java/edu/cmu/tetrad/bayes/BayesPm.java | 14 +++++ .../bayes/CptInvariantMarginalCalculator.java | 14 +++++ .../cmu/tetrad/bayes/CptInvariantUpdater.java | 14 +++++ .../cmu/tetrad/bayes/DirichletBayesIm.java | 14 +++++ .../java/edu/cmu/tetrad/bayes/Evidence.java | 14 +++++ .../edu/cmu/tetrad/bayes/Identifiability.java | 14 +++++ .../tetrad/bayes/JunctionTreeAlgorithm.java | 14 +++++ .../cmu/tetrad/bayes/JunctionTreeUpdater.java | 14 +++++ .../edu/cmu/tetrad/bayes/Manipulation.java | 14 +++++ .../java/edu/cmu/tetrad/bayes/MlBayesIm.java | 14 +++++ .../edu/cmu/tetrad/bayes/MlBayesImObs.java | 14 +++++ .../edu/cmu/tetrad/bayes/Proposition.java | 14 +++++ .../edu/cmu/tetrad/bayes/StoredCellProbs.java | 14 +++++ .../java/edu/cmu/tetrad/data/BoxDataSet.java | 14 +++++ .../java/edu/cmu/tetrad/data/Clusters.java | 14 +++++ .../data/ContinuousDiscretizationSpec.java | 14 +++++ .../cmu/tetrad/data/ContinuousVariable.java | 14 +++++ .../data/CorrelationMatrixOnTheFly.java | 14 +++++ .../edu/cmu/tetrad/data/CovarianceMatrix.java | 14 +++++ .../tetrad/data/CovarianceMatrixOnTheFly.java | 14 +++++ .../edu/cmu/tetrad/data/DataModelList.java | 14 +++++ .../edu/cmu/tetrad/data/DelimiterType.java | 14 +++++ .../data/DiscreteDiscretizationSpec.java | 14 +++++ .../edu/cmu/tetrad/data/DiscreteVariable.java | 14 +++++ .../cmu/tetrad/data/DiscreteVariableType.java | 14 +++++ .../edu/cmu/tetrad/data/KnowledgeEdge.java | 14 +++++ .../edu/cmu/tetrad/data/KnowledgeGroup.java | 14 +++++ .../cmu/tetrad/data/NumberObjectDataSet.java | 14 +++++ .../edu/cmu/tetrad/data/SplitCasesSpec.java | 14 +++++ .../edu/cmu/tetrad/data/TimeSeriesData.java | 14 +++++ .../main/java/edu/cmu/tetrad/graph/Edge.java | 14 +++++ .../cmu/tetrad/graph/EdgeTypeProbability.java | 14 +++++ .../java/edu/cmu/tetrad/graph/Endpoint.java | 14 +++++ .../cmu/tetrad/graph/IndependenceFact.java | 14 +++++ .../edu/cmu/tetrad/graph/OrderedPair.java | 14 +++++ .../main/java/edu/cmu/tetrad/graph/Paths.java | 14 +++++ .../java/edu/cmu/tetrad/graph/Triple.java | 14 +++++ .../tetrad/regression/RegressionResult.java | 14 +++++ .../main/java/edu/cmu/tetrad/search/BFci.java | 2 + .../java/edu/cmu/tetrad/search/Cstar.java | 14 +++++ .../java/edu/cmu/tetrad/search/FciMax.java | 5 ++ .../java/edu/cmu/tetrad/search/LvLite.java | 47 +++++++++++++---- .../cmu/tetrad/search/LvLiteDsepFriendly.java | 28 ++++++---- .../edu/cmu/tetrad/search/MarkovCheck.java | 52 +++++++++++++------ .../search/test/IndependenceResult.java | 14 +++++ .../tetrad/search/utils/BpcAlgorithmType.java | 14 +++++ .../cmu/tetrad/search/utils/BpcTestType.java | 14 +++++ .../edu/cmu/tetrad/search/utils/Sextad.java | 14 +++++ .../search/work_in_progress/Sextad.java | 14 +++++ .../java/edu/cmu/tetrad/sem/DagScorer.java | 28 ++++++++++ .../edu/cmu/tetrad/sem/GeneralizedSemPm.java | 14 +++++ .../main/java/edu/cmu/tetrad/sem/Mapping.java | 14 +++++ .../edu/cmu/tetrad/sem/ParamComparison.java | 24 +++++++++ .../edu/cmu/tetrad/sem/ParamConstraint.java | 14 +++++ .../cmu/tetrad/sem/ParamConstraintType.java | 21 ++++++++ .../java/edu/cmu/tetrad/sem/ParamType.java | 23 ++++++++ .../java/edu/cmu/tetrad/sem/Parameter.java | 14 +++++ .../edu/cmu/tetrad/sem/ParameterPair.java | 14 +++++ .../java/edu/cmu/tetrad/sem/SemEstimator.java | 14 +++++ .../edu/cmu/tetrad/sem/SemEstimatorGibbs.java | 14 +++++ .../tetrad/sem/SemEstimatorGibbsParams.java | 14 +++++ .../java/edu/cmu/tetrad/sem/SemEvidence.java | 14 +++++ .../main/java/edu/cmu/tetrad/sem/SemIm.java | 14 +++++ .../edu/cmu/tetrad/sem/SemManipulation.java | 14 +++++ .../main/java/edu/cmu/tetrad/sem/SemPm.java | 14 +++++ .../edu/cmu/tetrad/sem/SemProposition.java | 14 +++++ .../java/edu/cmu/tetrad/sem/SemUpdater.java | 14 +++++ .../edu/cmu/tetrad/sem/StandardizedSemIm.java | 14 +++++ .../gene/graph/StoredLagGraphParams.java | 14 +++++ .../tetrad/gene/history/BooleanFunction.java | 14 +++++ .../gene/tetrad/gene/history/DishModel.java | 14 +++++ .../gene/tetrad/gene/history/GeneHistory.java | 14 +++++ .../gene/history/IndexedConnectivity.java | 14 +++++ .../tetrad/gene/history/IndexedLagGraph.java | 14 +++++ .../tetrad/gene/history/IndexedParent.java | 14 +++++ .../gene/tetrad/gene/history/LaggedEdge.java | 14 +++++ .../gene/tetrad/gene/history/Polynomial.java | 14 +++++ .../tetrad/gene/history/PolynomialTerm.java | 14 +++++ .../gene/simulation/MeasurementSimulator.java | 14 +++++ .../study/gene/tetradapp/model/GenePm.java | 14 +++++ .../model/MeasurementSimulatorParams.java | 14 +++++ .../main/java/edu/cmu/tetrad/util/Matrix.java | 14 +++++ .../java/edu/cmu/tetrad/util/Parameters.java | 14 +++++ .../main/java/edu/cmu/tetrad/util/Params.java | 2 +- .../java/edu/cmu/tetrad/util/PointXy.java | 14 +++++ .../main/java/edu/cmu/tetrad/util/Vector.java | 14 +++++ .../java/edu/cmu/tetrad/util/Version.java | 14 +++++ .../edu/cmu/tetrad/util/dist/ChiSquare.java | 14 +++++ .../java/edu/cmu/tetrad/util/dist/Normal.java | 14 +++++ .../java/edu/cmu/tetrad/util/dist/Split.java | 14 +++++ .../cmu/tetrad/util/dist/TruncatedNormal.java | 14 +++++ .../edu/cmu/tetrad/util/dist/Uniform.java | 14 +++++ 159 files changed, 2335 insertions(+), 38 deletions(-) diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java index 2610b8f52a..817bf7d4bc 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractAlgorithmRunner.java @@ -493,6 +493,18 @@ private void transferVarNamesToParams(List names) { getParams().set("varNames", names); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -504,6 +516,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java index c33d5dbf8e..fab4781393 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/AbstractMBSearchRunner.java @@ -217,6 +217,18 @@ IndependenceTest getIndependenceTest() { throw new IllegalStateException("Cannot find Independence for Data source."); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -228,6 +240,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java index df6837b0dc..c980c63252 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ApproximateUpdaterWrapper.java @@ -212,6 +212,18 @@ private DiscreteVariable discreteVariable(Evidence evidence, String nodeName) { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -224,6 +236,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java index 788ccc3f44..3fb5d6ea73 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesEstimatorWrapper.java @@ -276,6 +276,18 @@ public void setModelIndex(int modelIndex) { //======================== Private Methods ======================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -287,6 +299,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java index fe26a6535c..a2a23f043a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapper.java @@ -368,6 +368,18 @@ private void setBayesIm(BayesPm bayesPm, BayesIm oldBayesIm, MlBayesIm.Initializ this.bayesIms.add(new MlBayesIm(bayesPm, oldBayesIm, initializationMethod)); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -379,6 +391,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java index 9e18d1587b..73a6e0d793 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesImWrapperObs.java @@ -165,6 +165,14 @@ private void log(BayesIm im) { TetradLogger.getInstance().log(message); } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java index a7545a1618..590f85b661 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesPmWrapper.java @@ -511,6 +511,18 @@ private void setBayesPm(BayesPm b) { this.bayesPms.add(b); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -522,6 +534,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java index 8387d3d676..0dda984b6e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BayesUpdaterClassifierWrapper.java @@ -122,6 +122,18 @@ public ClassifierBayesUpdaterDiscrete getClassifier() { return this.classifier; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -133,6 +145,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java index 2aaf946aca..d8e582c82a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BooleanGlassGeneIm.java @@ -399,6 +399,12 @@ public Distribution getErrorDistribution(int factor) { return getBooleanGlassFunction().getErrorDistribution(factor); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -410,6 +416,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java index aad9b8f771..0d5eccbc47 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/BootstrapSamplerWrapper.java @@ -110,6 +110,18 @@ public DataSet getOutputDataset() { return this.outputDataSet; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -121,6 +133,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java index 96a991a1c5..b1028bc9df 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CPDAGFitModel.java @@ -260,6 +260,12 @@ public BayesIm getBayesIm(int i) { return this.bayesIms.get(i); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -271,6 +277,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java index 47cb8e351c..bbb46a063a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CalculatorWrapper.java @@ -127,6 +127,12 @@ private static DataSet copy(DataSet data) { return copy; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -138,6 +144,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java index 591334d384..29aabb1eb4 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CheckKnowledgeModel.java @@ -139,6 +139,12 @@ public String getComparisonString() { return sb.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -150,6 +156,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java index 5d76971e59..27386362ac 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/CptInvariantUpdaterWrapper.java @@ -193,6 +193,12 @@ private DiscreteVariable discreteVariable(Evidence evidence, String nodeName) { return evidence.getVariable(nodeName); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -204,6 +210,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java index e89dd97081..de61791eed 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DagWrapper.java @@ -292,6 +292,12 @@ private void log() { TetradLogger.getInstance().log(message); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -303,6 +309,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java index ad8f57f407..496352c606 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DataWrapper.java @@ -489,6 +489,12 @@ public List getVariables() { return this.getSelectedDataModel().getVariables(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -500,6 +506,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java index 3cce5c40bd..92c7048a77 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletBayesImWrapper.java @@ -133,6 +133,12 @@ public DirichletBayesIm getDirichletBayesIm() { return this.dirichletBayesIm; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -144,6 +150,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java index f2853211bc..1d59cc3ecc 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/DirichletEstimatorWrapper.java @@ -164,6 +164,12 @@ public DirichletBayesIm getEstimatedBayesIm() { return this.dirichletBayesIm; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -175,6 +181,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java index 3b9fb2a6e6..5d74bbdac1 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EdgewiseComparisonModel.java @@ -179,6 +179,12 @@ public String getComparisonString() { targetName, this.targetGraph); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -190,6 +196,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java index e9649b572f..7ea9204545 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/EmBayesEstimatorWrapper.java @@ -156,6 +156,12 @@ private void estimate(DataSet dataSet, BayesPm bayesPm, double thresh) { public DataSet getDataSet() { return this.dataSet; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -167,6 +173,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java index 3bf8a69663..17f4641f49 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralAlgorithmRunner.java @@ -709,6 +709,12 @@ private void transferVarNamesToParams(List names) { getParameters().set("varNames", names); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -720,6 +726,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java index c995c78119..9f38df41fb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemEstimatorWrapper.java @@ -131,6 +131,12 @@ public GeneralizedSemIm getSemIm() { return this.estIm; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -142,6 +148,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java index 09d2a3afea..7668f129ac 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemImWrapper.java @@ -146,6 +146,12 @@ public List getSemIms() { return this.semIms; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -157,6 +163,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java index 3167c04cdb..6cada1ae41 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GeneralizedSemPmWrapper.java @@ -393,6 +393,12 @@ public GeneralizedSemPm getSemPm() { return this.semPm; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -404,6 +410,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java index 940a037a41..a2e85451cf 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphComparisonParams.java @@ -225,6 +225,12 @@ public void setReferenceGraphName(String name) { this.referenceGraphName = name; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -236,6 +242,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java index 0379c3ae8c..8fd3d40263 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphSelectionWrapper.java @@ -981,6 +981,12 @@ private Set getEdgesFromPath(List path, Graph graph) { return edges; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -992,6 +998,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java index 1e7b616e4d..acc7f242eb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GraphWrapper.java @@ -425,6 +425,12 @@ public Parameters getParameters() { // TetradLogger.getInstance().log("graph", "" + getGraph()); // } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -436,6 +442,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java index f2077c7548..bad4c1b66e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/GridSearchModel.java @@ -1052,6 +1052,12 @@ public void setLastVerboseOutputText(String lastVerboseOutputText) { this.lastVerboseOutputText = lastVerboseOutputText; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1063,6 +1069,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IdentifiabilityWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IdentifiabilityWrapper.java index 342c37e5d5..52fa8c16e3 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IdentifiabilityWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IdentifiabilityWrapper.java @@ -176,6 +176,12 @@ private DiscreteVariable discreteVariable(Evidence evidence, String nodeName) { return evidence.getVariable(nodeName); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -187,6 +193,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IndependenceResultIndFacts.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IndependenceResultIndFacts.java index 286e899a7f..6988c5fb40 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IndependenceResultIndFacts.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/IndependenceResultIndFacts.java @@ -151,6 +151,12 @@ public enum Type { UNDETERMINED } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -162,6 +168,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/LogisticRegressionRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/LogisticRegressionRunner.java index bb00556825..ce583c77a0 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/LogisticRegressionRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/LogisticRegressionRunner.java @@ -407,6 +407,12 @@ public void setTargetName(String target) { this.targetName = target; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -418,6 +424,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java index 063a12398e..9f08f2583b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MeasurementModelWrapper.java @@ -176,6 +176,12 @@ public void setName(String name) { this.name = name; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -187,6 +193,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java index 9f6668195d..1173eeb0eb 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/Misclassifications.java @@ -181,6 +181,12 @@ public String getComparisonString() { "\n\n\n" + table; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -192,6 +198,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java index 01a2218849..c1f2f501a7 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/MissingDataInjectorWrapper.java @@ -98,6 +98,12 @@ public DataSet getOutputDataset() { return this.outputDataSet; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -109,6 +115,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java index bb94da8959..e6fb390b89 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/PValueImproverWrapper.java @@ -530,6 +530,12 @@ public DataSet simulateDataCholesky(int sampleSize, Matrix covar, List var return DataTransforms.restrictToMeasured(fullDataSet); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -541,6 +547,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java index 1df8a5b776..a5c4a252dd 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RegressionRunner.java @@ -394,6 +394,12 @@ public void setTargetName(String target) { this.targetName = target; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -405,6 +411,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java index c0fc8fa47c..1f0a9a87ac 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ReplaceMissingWithRandomWrapper.java @@ -79,6 +79,12 @@ public static PcRunner serializableInstance() { //==========================PUBLIC METHODS============================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -90,6 +96,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java index 258d160986..22aa121d64 100755 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/RowSummingExactWrapper.java @@ -228,6 +228,12 @@ private DiscreteVariable discreteVariable(Evidence evidence, String nodeName) { return evidence.getVariable(nodeName); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -239,6 +245,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java index 1220eadf02..cd2f93dbcd 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/ScoredGraphsWrapper.java @@ -212,6 +212,12 @@ private void log() { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -223,6 +229,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java index 1e41b6a6f5..33cb91e80a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemEstimatorWrapper.java @@ -259,6 +259,12 @@ private void log() { TetradLogger.getInstance().log(message); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -270,6 +276,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java index 8bc9300910..b46cb60c11 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemGraphWrapper.java @@ -377,6 +377,12 @@ private void log() { TetradLogger.getInstance().log(message); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -388,6 +394,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java index 2f1b4a1789..99a183c3d8 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemImWrapper.java @@ -248,6 +248,12 @@ private void log(int i, SemIm pm) { TetradLogger.getInstance().log(message); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -259,6 +265,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java index 524164db08..57b3a19dfe 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemPmWrapper.java @@ -285,6 +285,12 @@ private void setSemPm(SemPm oldSemPm) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -296,6 +302,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java index ef1da8581a..1c27615d73 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SemUpdaterWrapper.java @@ -100,6 +100,12 @@ public SemUpdater getSemUpdater() { return this.semUpdater; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -111,6 +117,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java index 979e124a29..be52dfcd4c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionNodeWrapper.java @@ -195,6 +195,12 @@ public String toString() { getSessionName() + ")"; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -206,6 +212,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java index 31bbbe9e3b..a07d348955 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/SessionWrapper.java @@ -737,6 +737,12 @@ public void setNewSession(boolean newSession) { this.session.setNewSession(newSession); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -748,6 +754,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java index 188dab4b67..7ee60128b4 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StandardizedSemImWrapper.java @@ -156,6 +156,12 @@ public void setShowErrors(boolean showErrors) { //======================== Private methods =======================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -167,6 +173,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java index 0a3273c1b5..a0c7d38781 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/StructEmBayesSearchRunner.java @@ -222,6 +222,12 @@ public DataSet getDataSet() { return this.dataSet; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -233,6 +239,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java index 90fc5a7fef..4ae775e94e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TabularComparison.java @@ -227,6 +227,12 @@ public void setName(String name) { //============================PRIVATE METHODS=========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -238,6 +244,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java index 28f8adfc78..a04a2b0f14 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TetradMetadata.java @@ -107,6 +107,12 @@ public Date getDate() { //============================PRIVATE METHODS=======================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -118,6 +124,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java index 4d3668ab8c..96f14cabdc 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/TimeLagGraphWrapper.java @@ -186,6 +186,12 @@ private void log() { TetradLogger.getInstance().log(this.graph + ""); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -197,6 +203,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java index 8f3c908afb..eb678376a5 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DeterminismWraper.java @@ -65,6 +65,12 @@ public static PcRunner serializableInstance() { return PcRunner.serializableInstance(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -76,6 +82,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java index bb63c74793..4eed9cb0f3 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/DiscretizationWrapper.java @@ -96,6 +96,12 @@ public static PcRunner serializableInstance() { return PcRunner.serializableInstance(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -107,6 +113,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java index 7325f95a10..308e685c3b 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/AbstractWorkbench.java @@ -2985,6 +2985,12 @@ public void propertyChange(PropertyChangeEvent e) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -2996,6 +3002,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java index 3c708cef35..fdc273507a 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeError.java @@ -155,6 +155,12 @@ else if (nodes != null) { return newName; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -166,6 +172,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java index befd2d0d0b..9ff54f7b6c 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLatent.java @@ -167,6 +167,12 @@ public void doDoubleClickAction() { doDoubleClickAction(new EdgeListGraph()); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -178,6 +184,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java index aa345ab50f..e550cbb00e 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeLocked.java @@ -166,6 +166,12 @@ public void doDoubleClickAction() { doDoubleClickAction(new EdgeListGraph()); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -177,6 +183,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java index c0a80f4c5a..3975fa1ab1 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeMeasured.java @@ -209,6 +209,12 @@ public void setEditExitingMeasuredVarsAllowed(boolean editExitingMeasuredVarsAll this.editExitingMeasuredVarsAllowed = editExitingMeasuredVarsAllowed; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -220,6 +226,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java index 844f53992a..f49b2605ae 100644 --- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java +++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphNodeRandomized.java @@ -166,6 +166,12 @@ public void doDoubleClickAction() { doDoubleClickAction(new EdgeListGraph()); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -177,6 +183,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java index 3e8ddb7511..394c8b4182 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/Algorithms.java @@ -51,6 +51,12 @@ public List getAlgorithms() { return new ArrayList<>(this.algorithms); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -62,6 +68,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java index 5a2794e05d..d2b117591c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/simulation/Simulations.java @@ -49,6 +49,12 @@ public List getSimulations() { return new ArrayList<>(this.simulations); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -60,6 +66,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphPrecision.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphPrecision.java index cdc2c3b57c..79df272a45 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphPrecision.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphPrecision.java @@ -4,17 +4,41 @@ import edu.cmu.tetrad.data.DataModel; import edu.cmu.tetrad.graph.Graph; +/** + * The LocalGraphPrecision class implements the Statistic interface and represents the Local Graph Precision statistic. + * It calculates the precision between the true graph and the estimated graph locally. + */ public class LocalGraphPrecision implements Statistic { + + /** + * This method returns the abbreviation for the statistic. + * + * @return The abbreviation for the statistic. + */ @Override public String getAbbreviation() { return "LGP"; } + /** + * Returns a short one-line description of this statistic. + * + * @return The description of the statistic. + */ @Override public String getDescription() { return "Local Graph Precision"; } + /** + * This method calculates the Local Graph Precision. + * It calculates the precision between the true graph and the estimated graph locally. + * + * @param trueGraph The true graph. + * @param estGraph The estimated graph. + * @param dataModel The data model. + * @return The local graph precision. + */ @Override public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) { LocalGraphConfusion lgConfusion = new LocalGraphConfusion(trueGraph, estGraph); @@ -23,6 +47,12 @@ public double getValue(Graph trueGraph, Graph estGraph, DataModel dataModel) { return lgTp / (double) (lgTp + lgFp); } + /** + * This method returns the normalized value of a given statistic. + * + * @param value The value of the statistic. + * @return The normalized value of the statistic. + */ @Override public double getNormValue(double value) { return value; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphRecall.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphRecall.java index 94b893d248..5fed2647e0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphRecall.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/LocalGraphRecall.java @@ -4,6 +4,11 @@ import edu.cmu.tetrad.data.DataModel; import edu.cmu.tetrad.graph.Graph; +/** + * LocalGraphRecall implements the Statistic interface and represents the local graph recall statistic. + * It calculates the recall of the estimated graph with respect to the true graph. The recall is defined as the ratio + * of true positives (TP) to the sum of true positives and false negatives (TP + FN). + */ public class LocalGraphRecall implements Statistic { @Override public String getAbbreviation() { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java index 5b32a76dca..f9df70d026 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/Statistics.java @@ -100,6 +100,12 @@ public int size() { return this.statistics.size(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -111,6 +117,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/LocalGraphConfusion.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/LocalGraphConfusion.java index c10e7c2da4..e7eab67d0c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/LocalGraphConfusion.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/statistic/utils/LocalGraphConfusion.java @@ -206,18 +206,38 @@ public LocalGraphConfusion(Graph trueGraph, Graph estGraph) { } } + /** + * Returns the true positives (TP) value of the LocalGraphConfusion object. + * + * @return The true positives (TP) value. + */ public int getTp() { return tp; } + /** + * Retrieves the value of true negatives (TN) from the LocalGraphConfusion object. + * + * @return The true negatives (TN) value. + */ public int getTn() { return tn; } + /** + * Retrieves the value of false positives (FP) from the LocalGraphConfusion object. + * + * @return The false positives (FP) value. + */ public int getFp() { return fp; } + /** + * Returns the false negatives (FN) value of the LocalGraphConfusion object. + * + * @return The false negatives (FN) value. + */ public int getFn() { return fn; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java index 2d19b7d17d..1a23b11ef8 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/ApproximateUpdater.java @@ -372,6 +372,12 @@ private Dag createManipulatedGraph(Graph graph) { return updatedGraph; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -383,6 +389,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java index 2ce649fa99..2d94e0ff99 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesImProbs.java @@ -285,6 +285,12 @@ public List getVariables() { return this.variables; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -296,6 +302,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java index b21b35cdae..7cb084b8e9 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/BayesPm.java @@ -576,6 +576,12 @@ private void initializeValues(int lowerBound, int upperBound) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -587,6 +593,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java index f4df08d42b..0f18ccd164 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantMarginalCalculator.java @@ -215,6 +215,12 @@ private boolean noModifiedCpts(int[] parents, int i) { return intersection.isEmpty(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -226,6 +232,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java index e558efd37b..2a0bde7dba 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/CptInvariantUpdater.java @@ -293,6 +293,12 @@ private Dag createManipulatedGraph(Graph graph) { return updatedGraph; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -304,6 +310,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java index 6b441d612a..5ebe897e2a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/DirichletBayesIm.java @@ -1173,6 +1173,12 @@ private int getUniqueCompatibleOldRow(int nodeIndex, int rowIndex, return oldBayesIm.getRowIndex(oldNodeIndex, oldParentValues); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1184,6 +1190,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java index dccc670de7..5b16ea8ecd 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Evidence.java @@ -340,6 +340,12 @@ public int hashCode() { return hashCode; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -351,6 +357,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java index 1f1704a25d..03303bce8d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Identifiability.java @@ -996,6 +996,12 @@ private Dag createManipulatedGraph(Graph graph) { ///////////////////////////////////////////////////////////////// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1007,6 +1013,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java index afdf665eaf..dfec59cca1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeAlgorithm.java @@ -996,6 +996,12 @@ public String toString() { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1007,6 +1013,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java index 97bca6bc8f..8b35c47a1b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/JunctionTreeUpdater.java @@ -327,6 +327,12 @@ private Dag createManipulatedGraph(Graph graph) { return updatedGraph; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -338,6 +344,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java index c2292c82af..e440745e2a 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Manipulation.java @@ -185,6 +185,12 @@ public boolean isManipulated(int nodeIndex) { return this.manipulated[nodeIndex]; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -196,6 +202,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java index 9f5ceaadb6..4d2a6be550 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesIm.java @@ -1398,6 +1398,12 @@ private void copyValuesFromOldToNew(int oldNodeIndex, int oldRowIndex, } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1409,6 +1415,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java index 3126f1a29b..664d1b9ae0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/MlBayesImObs.java @@ -1196,6 +1196,12 @@ private void initializeNode(int nodeIndex) { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1207,6 +1213,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java index 3e35240487..51c57fc54c 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/Proposition.java @@ -535,6 +535,12 @@ private int getMaxNumCategories() { return max; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -546,6 +552,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java index 3f340492b0..3575057cd9 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/bayes/StoredCellProbs.java @@ -407,6 +407,12 @@ private void setCellProbability(int[] variableValues, double probability) { this.probs[getOffset(variableValues)] = probability; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -418,6 +424,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java index ac017bed50..13d280404b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/BoxDataSet.java @@ -166,6 +166,12 @@ public static BoxDataSet serializableInstance() { return new BoxDataSet(new ShortDataBox(4, 4), vars); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -177,6 +183,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java index 29a1af20e7..9155ba5916 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/Clusters.java @@ -323,6 +323,12 @@ private int numClustersStored() { return max; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -334,6 +340,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java index 7ae03427ff..23ecb5c162 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousDiscretizationSpec.java @@ -154,6 +154,12 @@ public double[] getBreakpoints() { return this.breakpoints; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -165,6 +171,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java index 313d49f5a6..e94af1b0a3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/ContinuousVariable.java @@ -286,6 +286,12 @@ private PropertyChangeSupport getPcs() { return this.pcs; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -297,6 +303,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java index b794ca75a1..eb6152efdb 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CorrelationMatrixOnTheFly.java @@ -442,6 +442,12 @@ public void removeVariables(List remaining) { this.cov.removeVariables(remaining); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -453,6 +459,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java index 85788530c4..bae830f798 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrix.java @@ -560,6 +560,12 @@ private Set getSelectedVariables() { return this.selectedVariables; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -571,6 +577,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java index 4d1fd07a7d..67753e8c81 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/CovarianceMatrixOnTheFly.java @@ -859,6 +859,12 @@ private void checkMatrix() { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -870,6 +876,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java index 0720eb8908..b7e46f98c3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DataModelList.java @@ -347,6 +347,12 @@ public boolean equals(Object o) { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -358,6 +364,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java index ff07ae7501..b57c2c29aa 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DelimiterType.java @@ -119,6 +119,12 @@ Object readResolve() throws ObjectStreamException { return DelimiterType.TYPES[this.ordinal]; // Canonicalize. } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -130,6 +136,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java index 6d2a516bba..311b178251 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteDiscretizationSpec.java @@ -101,6 +101,12 @@ public int[] getRemap() { return this.remap; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -112,6 +118,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java index a44f180bcf..5c7040bec0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariable.java @@ -504,6 +504,12 @@ private PropertyChangeSupport getPcs() { return this.pcs; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -515,6 +521,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java index 9d83f4adf3..6d8f4bf892 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/DiscreteVariableType.java @@ -102,6 +102,12 @@ Object readResolve() throws ObjectStreamException { return DiscreteVariableType.TYPES[this.ordinal]; // Canonicalize. } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -113,6 +119,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java index 29ea7b7469..8bf9585914 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeEdge.java @@ -127,6 +127,12 @@ public String toString() { return this.from + "-->" + this.to; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -138,6 +144,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java index 2618bae63b..8dbe5c6d4d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/KnowledgeGroup.java @@ -223,6 +223,12 @@ public boolean equals(Object o) { } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -234,6 +240,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java index f75055fdce..2091a61fc5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/NumberObjectDataSet.java @@ -182,6 +182,12 @@ public static NumberObjectDataSet serializableInstance() { return new NumberObjectDataSet(0, new LinkedList<>()); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -193,6 +199,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java index f5d810bc81..f8f4fc78d7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/SplitCasesSpec.java @@ -100,6 +100,12 @@ public int[] getBreakpoints() { return this.breakpoints; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -111,6 +117,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java index 2f2fc01cf8..b675dc43a5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/data/TimeSeriesData.java @@ -248,6 +248,12 @@ public double getDatum(int row, int col) { return this.data2.get(row, col); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -259,6 +265,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java index 732bd4d4a8..75d793d5f3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Edge.java @@ -457,6 +457,12 @@ private boolean pointingLeft(Endpoint endpoint1, Endpoint endpoint2) { // ===========================PRIVATE METHODS===========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -468,6 +474,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java index 5dd7515568..467e1e99c5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/EdgeTypeProbability.java @@ -178,6 +178,12 @@ public enum EdgeType { tt } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -189,6 +195,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java index ab1703fdf6..2ebb92026d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Endpoint.java @@ -67,6 +67,12 @@ public enum Endpoint implements TetradSerializable { */ private static final long serialVersionUID = 23L; + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -78,6 +84,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java index 440e6b0d6c..f0ece5871c 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/IndependenceFact.java @@ -253,6 +253,12 @@ public int compareTo(IndependenceFact fact) { return 0; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -264,6 +270,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java index 4e1e3ddc80..bc7ef87d6a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/OrderedPair.java @@ -116,6 +116,12 @@ public String toString() { return "<" + this.first + ", " + this.second + ">"; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -127,6 +133,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java index 347a6327d4..098f9c2297 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Paths.java @@ -2605,6 +2605,12 @@ private static Set union(Set set, int element) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -2616,6 +2622,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java index ed70040453..bf483f8b54 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/graph/Triple.java @@ -175,6 +175,12 @@ public boolean alongPathIn(Graph graph) { return graph.isAdjacentTo(this.x, this.y) && graph.isAdjacentTo(this.y, this.z) && this.x != this.z; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -186,6 +192,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java index 2591f7eeab..99107c80b8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/regression/RegressionResult.java @@ -358,6 +358,12 @@ public Vector getResiduals() { return this.res; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -369,6 +375,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { 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 782701621e..48705cc112 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 @@ -281,6 +281,8 @@ public void setDoDiscriminatingPathTailRule(boolean doDiscriminatingPathTailRule /** * Sets whether the discriminating path collider rule should be used. + * + * @param doDiscriminatingPathColliderRule True if the discriminating path collider rule should be used, false. */ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; 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 d4a3d8e2b0..bcc0ff5b42 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 @@ -1038,6 +1038,12 @@ public double getMinBeta() { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1049,6 +1055,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java index 3f3bc474c5..de8ab640c0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/FciMax.java @@ -481,6 +481,11 @@ private void doNode(Graph graph, Map scores, Node b) { } } + /** + * Sets whether the discriminating path collider rule should be applied during the search. + * + * @param doDiscriminatingPathColliderRule True, if the rule should be applied. False otherwise. + */ public void setDoDiscriminatingPathColliderRule(boolean doDiscriminatingPathColliderRule) { this.doDiscriminatingPathColliderRule = doDiscriminatingPathColliderRule; } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java index de42e400e0..bdaa237aa2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLite.java @@ -129,15 +129,20 @@ public LvLite(Score score) { * algorithm, and the graph is modified in place. The call to this method may be repeated to account for the * possibility that the removal of an edge may allow for further removals or orientations. * - * @param pag The original graph. - * @param fciOrient The orientation rules to be applied. - * @param best The list of best nodes. - * @param scorer The scorer used to evaluate edge orientations. - * @param equalityThreshold The threshold for equality. (This is not used for Oracle scoring.) + * @param pag The original graph. + * @param fciOrient The orientation rules to be applied. + * @param best The list of best nodes. + * @param scorer The scorer used to evaluate edge orientations. + * @param unshieldedColliders The set of unshielded colliders. + * @param cpdag The CPDAG. + * @param knowledge The knowledge object. + * @param allowTucks A boolean value indicating whether tucks are allowed. + * @param equalityThreshold The threshold for equality. (This is not used for Oracle scoring.) + * @param verbose A boolean value indicating whether verbose output should be printed. */ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, List best, TeyssierScorer scorer, - Set unshieldedColliders, Graph cpdag, Knowledge knowledge, - boolean allowTucks, boolean verbose, double equalityThreshold) { + Set unshieldedColliders, Graph cpdag, Knowledge knowledge, + boolean allowTucks, boolean verbose, double equalityThreshold) { reorientWithCircles(pag, verbose); recallUnshieldedTriples(pag, unshieldedColliders, verbose); @@ -189,9 +194,19 @@ public static void orientCollidersAndRemoveEdges(Graph pag, FciOrient fciOrient, /** * Determines the final orientation of the graph using the given FciOrient object, Graph object, and scorer object. * - * @param fciOrient The FciOrient object used to determine the final orientation. - * @param pag The Graph object for which the final orientation is determined. - * @param scorer The scorer object used in the score-based discriminating path rule. + * @param fciOrient The FciOrient object used to determine the final orientation. + * @param pag The Graph object for which the final orientation is determined. + * @param scorer The scorer object used in the score-based discriminating path rule. + * @param doDiscriminatingPathTailRule A boolean value indicating whether the discriminating path tail rule + * should be applied. If set to true, the discriminating path tail rule will + * be applied. If set to false, the discriminating path tail rule will not + * be applied. + * @param doDiscriminatingPathColliderRule A boolean value indicating whether the discriminating path collider rule + * should be applied. If set to true, the discriminating path collider rule + * will be applied. If set to false, the discriminating path collider rule + * will not be applied. + * @param completeRuleSetUsed A boolean value indicating whether the complete rule set should be used. + * @param verbose A boolean value indicating whether verbose output should be printed. */ public static void finalOrientation(FciOrient fciOrient, Graph pag, TeyssierScorer scorer, boolean completeRuleSetUsed, boolean doDiscriminatingPathTailRule, boolean doDiscriminatingPathColliderRule, boolean verbose) { @@ -864,7 +879,17 @@ public void setEqualityThreshold(double equalityThreshold) { this.equalityThreshold = equalityThreshold; } + /** + * Enumeration representing different start options. + */ public enum START_WITH { - BOSS, GRASP + /** + * Start with BOSS. + */ + BOSS, + /** + * Start with GRaSP. + */ + GRASP } } diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java index 49d6483283..73bdd23ee6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/LvLiteDsepFriendly.java @@ -30,7 +30,10 @@ import edu.cmu.tetrad.util.TetradLogger; import org.jetbrains.annotations.NotNull; -import java.util.*; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; /** * The LV-Lite algorithm implements the IGraphSearch interface and represents a search algorithm for learning the @@ -47,14 +50,14 @@ public final class LvLiteDsepFriendly implements IGraphSearch { * hence it cannot be modified or accessed from outside the class where it is declared. */ private final ArrayList variables; - /** - * Indicates whether to use Raskutti Uhler feature. - */ - private boolean useRaskuttiUhler; /** * The independence test. */ private final IndependenceTest test; + /** + * Indicates whether to use Raskutti Uhler feature. + */ + private boolean useRaskuttiUhler; /** * The score. */ @@ -121,8 +124,8 @@ public final class LvLiteDsepFriendly implements IGraphSearch { */ private int maxPathLength = -1; /** - * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. - * This is not used for MSEP tests. + * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. This is not used for MSEP + * tests. */ private double equalityThreshold; @@ -366,13 +369,20 @@ public void setMaxPathLength(int maxPathLength) { this.maxPathLength = maxPathLength; } + /** + * Sets whether internal randomness is allowed in the search algorithm. + * + * @param allowInternalRandomness true to allow internal randomness, false otherwise + */ public void setAllowInternalRandomness(boolean allowInternalRandomness) { this.allowInternalRandomness = allowInternalRandomness; } /** - * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. - * This is not used for MSEP tests. + * The equality threshold, a fraction of abs(BIC) used to determine equality of scores. This is not used for MSEP + * tests. + * + * @param equalityThreshold the equality threshold */ public void setEqualityThreshold(double equalityThreshold) { this.equalityThreshold = equalityThreshold; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java index 0cd85ec0ee..b64b561f11 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/MarkovCheck.java @@ -203,7 +203,7 @@ public AllSubsetsIndependenceFacts getAllSubsetsIndependenceFacts() { Set z = GraphUtils.asSet(list, _other); if (!checkNodeIndependenceAndConditioning(x, y, z)) { - continue; + continue; } IndependenceFact fact = new IndependenceFact(x, y, z); @@ -271,10 +271,10 @@ public List getLocalPValues(IndependenceTest independenceTest, List> getLocalPValues(IndependenceTest independenceTest, List facts, Double shuffleThreshold) { // Shuffle to generate more data from the same graph. @@ -319,6 +319,7 @@ public Double checkAgainstAndersonDarlingTest(List pValues) { * @param independenceTest The independence test to be used for calculating p-values. * @param graph The graph containing the nodes for testing. * @param threshold The threshold value for classifying nodes. + * @param shuffleThreshold The threshold value for shuffling the data. * @return A list containing two lists: the first list contains the accepted nodes and the second list contains the * rejected nodes. */ @@ -355,12 +356,12 @@ public List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodes(Ind * Confusion statistics were calculated using Adjacency (AdjacencyPrecision, AdjacencyRecall) and Arrowhead * (ArrowheadPrecision, ArrowheadRecall) * - * @param independenceTest - * @param estimatedCpdag - * @param trueGraph - * @param threshold - * @param shuffleThreshold - * @return + * @param independenceTest The independence test to be used for calculating p-values. + * @param estimatedCpdag The estimated CPDAG. + * @param trueGraph The true graph. + * @param threshold The threshold value for classifying nodes. + * @param shuffleThreshold The threshold value for shuffling the data. + * @return A list containing two lists: the first list contains the accepted nodes and the second list contains the */ public List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlotData(IndependenceTest independenceTest, Graph estimatedCpdag, Graph trueGraph, Double threshold, Double shuffleThreshold) { // When calling, default reject null as <=0.05 @@ -508,12 +509,12 @@ public List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlot * Confusion statistics were calculated using Local Graph Precision and Recall (LocalGraphPrecision, * LocalGraphRecall). * - * @param independenceTest - * @param estimatedCpdag - * @param trueGraph - * @param threshold - * @param shuffleThreshold - * @return + * @param independenceTest The independence test to be used for calculating p-values. + * @param estimatedCpdag The estimated CPDAG. + * @param trueGraph The true graph. + * @param threshold The threshold value for classifying nodes. + * @param shuffleThreshold The threshold value for shuffling the data. + * @return A list containing two lists: the first list contains the accepted nodes and the second list contains the */ public List> getAndersonDarlingTestAcceptsRejectsNodesForAllNodesPlotData2(IndependenceTest independenceTest, Graph estimatedCpdag, Graph trueGraph, Double threshold, Double shuffleThreshold) { // When calling, default reject null as <=0.05 @@ -638,6 +639,15 @@ public void getPrecisionAndRecallOnMarkovBlanketGraph(Node x, Graph estimatedGra " ArrowHeadPrecision = " + nf.format(ahp) + " ArrowHeadRecall = " + nf.format(ahr)); } + /** + * Calculates the precision and recall on the markov blanket graph plot data. + * + * @param x the target node + * @param estimatedGraph the estimated graph + * @param trueGraph the true graph + * @return a list of doubles representing the precision and recall values: [adjacency precision, adjacency recall, + * arrowhead precision, arrowhead recall] + */ public List getPrecisionAndRecallOnMarkovBlanketGraphPlotData(Node x, Graph estimatedGraph, Graph trueGraph) { // Lookup graph is the same structure as trueGraph's structure but node objects replaced by estimated graph nodes. Graph lookupGraph = GraphUtils.replaceNodes(trueGraph, estimatedGraph.getNodes()); @@ -677,6 +687,14 @@ public void getPrecisionAndRecallOnMarkovBlanketGraph2(Node x, Graph estimatedGr " LocalGraphPrecision = " + nf.format(lgp) + " LocalGraphRecall = " + nf.format(lgr) + " \n"); } + /** + * This method calculates the precision and recall of a target node's Markov Blanket in the given estimated graph. + * + * @param x the target node for which the precision and recall are calculated + * @param estimatedGraph the estimated graph + * @param trueGraph the true graph + * @return a list of two doubles representing the precision and recall, respectively + */ public List getPrecisionAndRecallOnMarkovBlanketGraphPlotData2(Node x, Graph estimatedGraph, Graph trueGraph) { // Lookup graph is the same structure as trueGraph's structure but node objects replaced by estimated graph nodes. Graph lookupGraph = GraphUtils.replaceNodes(trueGraph, estimatedGraph.getNodes()); diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java index 077ba4865e..0c911758cb 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/test/IndependenceResult.java @@ -167,6 +167,12 @@ public boolean isValid() { return isValid; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -178,6 +184,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java index 4eb5e38ec5..4b00065bac 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcAlgorithmType.java @@ -101,6 +101,12 @@ public static BpcAlgorithmType[] getAlgorithmDescriptions() { }; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -112,6 +118,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java index 528ceb31f0..d14e1226cf 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/BpcTestType.java @@ -179,6 +179,12 @@ public static BpcTestType[] getTestDescriptions() { */ } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -190,6 +196,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java index 5573b2801d..ba5ba6e3a4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/utils/Sextad.java @@ -216,6 +216,12 @@ private void testDistinctness(int i, int j, int k, int l, int m, int n) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -227,6 +233,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java index 0eb1023815..14e47b56bd 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/search/work_in_progress/Sextad.java @@ -263,6 +263,12 @@ public List getNodes() { return nodes; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -274,6 +280,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java index 5d1582b10d..d86c025550 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/DagScorer.java @@ -330,6 +330,18 @@ public double getPValue() { return 1.0 - ProbUtils.chisqCdf(getChiSquare(), getDof()); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -341,6 +353,22 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java index 68656a5ec8..c62a73b9c6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/GeneralizedSemPm.java @@ -1066,6 +1066,12 @@ private List putErrorNodesLast(List parents) { return sortedNodes; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1077,6 +1083,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java index 92c4a55ed5..34c3fe2a05 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Mapping.java @@ -174,6 +174,12 @@ public String toString() { "[" + this.i + "][" + this.j + "]>"; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -185,6 +191,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamComparison.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamComparison.java index 64b4ce196d..febe89c98e 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamComparison.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamComparison.java @@ -25,9 +25,33 @@ * An enum of the types of the various comparisons a parameter may have with respect to one another for SEM estimation. */ public enum ParamComparison { + /** + * Represents the "Non-comparable" comparison type for a parameter in SEM estimation. + * + * This type of comparison indicates that the parameter is not comparable to any other parameter + * in the structural equation model. + */ NC("NC"), + /** + * An enum representing the "EQ" comparison type for a parameter in SEM estimation. + * + * This type of comparison indicates that the parameter is equal to another parameter + * in the structural equation model. + */ EQ("EQ"), + /** + * Represents the "LT" comparison type for a parameter in SEM estimation. + * + * This type of comparison indicates that the parameter is less than another parameter + * in the structural equation model. + */ LT("LT"), + /** + * An enum value representing the "LE" comparison type for a parameter in SEM estimation. + * + * This type of comparison indicates that the parameter is less than or equal to another parameter + * in the structural equation model. + */ LE("LE"); private final String name; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java index 01802f374d..f1e5f4f7ff 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraint.java @@ -147,6 +147,12 @@ public SemIm getSemIm() { return this.semIm; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -158,6 +164,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraintType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraintType.java index 90cf90aad5..3772ef1e33 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraintType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamConstraintType.java @@ -26,10 +26,31 @@ import java.io.*; +/** + * Enum for representing different types of parameter constraints. + */ public enum ParamConstraintType { + /** + * Represents a parameter constraint type LT (less than). + */ LT("LT"), + /** + * Represents a parameter constraint type GT (greater than). + */ GT("GT"), + /** + * The EQ represents a parameter constraint type EQ (equal). + * + * This enum value is used to represent the equality constraint on a parameter. It indicates that the parameter value + * should be equal to a specific value. + */ EQ("EQ"), + /** + * Represents a parameter constraint type NONE. + * + * This enum value is used to represent the absence of a constraint on a parameter. It indicates that there is no specific + * constraint on the parameter value. + */ NONE("NONE"); private final String name; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamType.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamType.java index 2e01b4e8fe..83bffe409a 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamType.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParamType.java @@ -30,10 +30,33 @@ * @version $Id: $Id */ public enum ParamType { + /** + * Enum representing the free parameter type for structural equation modeling (SEM) models. + * COEF free parameters are edge coefficients in the linear SEM model. + */ COEF("Linear Coefficient"), + /** + * Variable Mean parameter type for SEM models. + */ MEAN("Variable Mean"), + /** + * Represents the error variance parameter in a structural equation modeling (SEM) model. + */ VAR("Error Variance"), + /** + * Represents a free parameter type for structural equation modeling (SEM) models. Specifically, the COVAR free parameter type is used to represent non-variance covariances among + * the error terms in the SEM model. + * + * This enum type is a part of the ParamType enum, which is used to categorize different types of free parameters for SEM models. + * + * The COVAR free parameter type is associated with the description "Error Covariance". + */ COVAR("Error Covariance"), + /** + * Represents a free parameter type for structural equation modeling (SEM) models. + * Specifically, the DIST free parameter type is used to represent distribution parameters in the SEM model. + * It is associated with the description "Distribution Parameter". + */ DIST("Distribution Parameter"); private final String name; diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java index ef7f54bc27..2a7bdcf41b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/Parameter.java @@ -300,6 +300,12 @@ public void setInitializedRandomly(boolean initializedRandomly) { this.initializedRandomly = initializedRandomly; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -311,6 +317,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java index a48d840100..19625540c5 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/ParameterPair.java @@ -139,6 +139,12 @@ private void setPair(Parameter a, Parameter b) { this.b = b; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -150,6 +156,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java index 4b6ddd7454..edc15b480b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimator.java @@ -441,6 +441,12 @@ private void setMeans(SemIm semIm, DataSet dataSet) { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -452,6 +458,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java index 15839cb8ad..1087f7eed7 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbs.java @@ -532,6 +532,12 @@ public Matrix getDataSet() { return this.dataSet; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -543,6 +549,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java index 01fbd0b929..d91f223d48 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEstimatorGibbsParams.java @@ -174,6 +174,12 @@ public void setFlatPrior(boolean flatPrior) { this.flatPrior = flatPrior; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -185,6 +191,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java index 52701e9f13..0ab18f3c95 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemEvidence.java @@ -270,6 +270,12 @@ public int hashCode() { return hashCode; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -281,6 +287,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { 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 155a20df50..41c924b7cb 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 @@ -2308,6 +2308,12 @@ private double[] standardErrors() { return this.standardErrors; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -2319,6 +2325,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java index 5ab0be2925..3c1b214207 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemManipulation.java @@ -203,6 +203,12 @@ public int hashCode() { return hashCode; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -214,6 +220,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java index 7699ad3380..a7e76cd2b8 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemPm.java @@ -667,6 +667,12 @@ private String newBName() { return "B" + (++this.bIndex); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -678,6 +684,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java index b36707a959..2d47604076 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemProposition.java @@ -196,6 +196,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -207,6 +213,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java index 92bda2f2a2..7dc3eb00f3 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/SemUpdater.java @@ -247,6 +247,12 @@ private SemGraph createManipulatedGraph(Graph graph) { return updatedGraph; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -258,6 +264,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java index 367821656a..85435905c0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/sem/StandardizedSemIm.java @@ -1045,6 +1045,12 @@ public String toString() { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -1056,6 +1062,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java index cbe5ecb86a..231586af47 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/graph/StoredLagGraphParams.java @@ -86,6 +86,12 @@ public void setFilename(String filename) { this.filename = filename; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -97,6 +103,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java index e912b3053c..8e76d3c7ae 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/BooleanFunction.java @@ -306,6 +306,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -317,6 +323,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java index 94d5565e9a..065fa4d227 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/DishModel.java @@ -156,6 +156,12 @@ public void setDishBumpStDev(double dishBumpStDev) { this.dishBumpStDev = dishBumpStDev; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -167,6 +173,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java index 3297e898a3..30e793d9b6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/GeneHistory.java @@ -285,6 +285,12 @@ public void initialize() { this.step = -1; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -296,6 +302,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java index d1db22bd89..2929628ff2 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedConnectivity.java @@ -238,6 +238,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -249,6 +255,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java index e682ab3979..a02ee85ae6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedLagGraph.java @@ -234,6 +234,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -245,6 +251,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java index f3b14e53b1..e0765bb2e1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/IndexedParent.java @@ -125,6 +125,12 @@ public String toString() { return "IndexedParent, index = " + getIndex() + ", lag = " + getLag(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -136,6 +142,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java index 3e9a48f25d..3bd1eb779e 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/LaggedEdge.java @@ -99,6 +99,12 @@ public LaggedFactor getLaggedFactor() { return this.laggedFactor; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -110,6 +116,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java index 1e26b5503b..a2a3ca780b 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/Polynomial.java @@ -155,6 +155,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -166,6 +172,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java index cd0c986265..0b6ae64bc4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/history/PolynomialTerm.java @@ -180,6 +180,12 @@ public String toString() { return buf.toString(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -191,6 +197,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java index 640678d5da..f76c6fa0e2 100755 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetrad/gene/simulation/MeasurementSimulator.java @@ -975,6 +975,12 @@ class results in an inconsistent parameter set. jdramsey 12/22/01 becomes an issue. jdramsey 12/22/01 */ + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -986,6 +992,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java index 76bdd8507b..f636d84497 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/GenePm.java @@ -67,6 +67,12 @@ public LagGraph getLagGraph() { return this.lagGraph; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -78,6 +84,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java index e779a7384a..fbcf73a0d0 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/study/gene/tetradapp/model/MeasurementSimulatorParams.java @@ -370,6 +370,12 @@ public double[][][] getRawData() { return getSimulator().getRawData(); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -381,6 +387,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java index 492649a3e2..21ad683b99 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Matrix.java @@ -629,6 +629,12 @@ public String toString() { } } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -640,6 +646,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java index 518899a579..04aeb5e236 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Parameters.java @@ -346,6 +346,12 @@ public void remove(String parameter) { parameters.remove(parameter); } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -357,6 +363,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java index 906078b4dd..9d0942e379 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Params.java @@ -891,7 +891,7 @@ public final class Params { */ public static final String ALLOW_TUCKS = "allowTucks"; /** - * Constant ALLOW_TUCKS="allowTucks + * Constant ALLOW_TUCKS="allowTucks" */ public static final String EQUALITY_THRESHOLD = "equalityThreshold"; /** diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java index a514ca2993..687d4f90d4 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/PointXy.java @@ -127,6 +127,12 @@ public String toString() { return "Point<" + this.x + "," + this.y + ">"; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -138,6 +144,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java index e5d7af0b94..2a75c360cc 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/Vector.java @@ -259,6 +259,12 @@ public double dot(Vector v2) { return sum; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -270,6 +276,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { 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 14116fe2f9..0c529f6756 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 @@ -301,6 +301,12 @@ public String toString() { //===========================PRIVATE METHODS=========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -312,6 +318,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java index fb802f336d..d517141b5d 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/ChiSquare.java @@ -143,6 +143,12 @@ public String toString() { return "ChiSquare(" + this.df + ")"; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -154,6 +160,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java index 32c1ada925..7f284f5a01 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Normal.java @@ -155,6 +155,12 @@ public String toString() { //========================PRIVATE METHODS===========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -166,6 +172,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java index 2767efd4f4..3c1d3e36b1 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Split.java @@ -186,6 +186,12 @@ public int getNumParameters() { return 2; } + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -197,6 +203,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java index 77dd4b4613..f51a79a5f6 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/TruncatedNormal.java @@ -176,6 +176,12 @@ public String toString() { //========================PRIVATE METHODS===========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -187,6 +193,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try { diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java index b2fec107df..e050632f75 100644 --- a/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java +++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/util/dist/Uniform.java @@ -157,6 +157,12 @@ public String toString() { //========================PRIVATE METHODS===========================// + /** + * Writes the object to the specified ObjectOutputStream. + * + * @param out The ObjectOutputStream to write the object to. + * @throws IOException If an I/O error occurs. + */ @Serial private void writeObject(ObjectOutputStream out) throws IOException { try { @@ -168,6 +174,14 @@ private void writeObject(ObjectOutputStream out) throws IOException { } } + /** + * Reads the object from the specified ObjectInputStream. This method is used during deserialization + * to restore the state of the object. + * + * @param in The ObjectInputStream to read the object from. + * @throws IOException If an I/O error occurs. + * @throws ClassNotFoundException If the class of the serialized object cannot be found. + */ @Serial private void readObject(ObjectInputStream in) throws IOException, ClassNotFoundException { try {