names,
DataOutputStream d) {
int[] falsePosNeg = new int[2];
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/TimeSeriesWrapper.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/TimeSeriesWrapper.java
index f2f3c2f5ca..d355fc56ed 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/TimeSeriesWrapper.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/model/datamanip/TimeSeriesWrapper.java
@@ -35,7 +35,7 @@ public class TimeSeriesWrapper extends DataWrapper implements KnowledgeTransfera
static final long serialVersionUID = 23L;
@SuppressWarnings("FieldCanBeLocal")
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
/**
* Constructs a new time series dataset.
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LayoutEditable.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LayoutEditable.java
index e701e4d31e..85a3d4f899 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LayoutEditable.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LayoutEditable.java
@@ -21,7 +21,7 @@
package edu.cmu.tetradapp.util;
-import edu.cmu.tetrad.data.IKnowledge;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.Edge;
import edu.cmu.tetrad.graph.Graph;
import edu.cmu.tetrad.graph.Node;
@@ -52,7 +52,7 @@ public interface LayoutEditable {
/**
* @return the getModel knowledge.
*/
- IKnowledge getKnowledge();
+ Knowledge getKnowledge();
/**
* @return the source graph.
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LongTextField.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LongTextField.java
new file mode 100644
index 0000000000..eff045fd51
--- /dev/null
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/LongTextField.java
@@ -0,0 +1,208 @@
+///////////////////////////////////////////////////////////////////////////////
+// For information as to what this class does, see the Javadoc, below. //
+// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, //
+// 2007, 2008, 2009, 2010, 2014, 2015, 2022 by Peter Spirtes, Richard //
+// Scheines, Joseph Ramsey, and Clark Glymour. //
+// //
+// This program is free software; you can redistribute it and/or modify //
+// it under the terms of the GNU General Public License as published by //
+// the Free Software Foundation; either version 2 of the License, or //
+// (at your option) any later version. //
+// //
+// This program is distributed in the hope that it will be useful, //
+// but WITHOUT ANY WARRANTY; without even the implied warranty of //
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
+// GNU General Public License for more details. //
+// //
+// You should have received a copy of the GNU General Public License //
+// along with this program; if not, write to the Free Software //
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
+///////////////////////////////////////////////////////////////////////////////
+package edu.cmu.tetradapp.util;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.FocusAdapter;
+import java.awt.event.FocusEvent;
+
+/**
+ * A text field which is specialized for displaying longs. Handles otherwise
+ * annoying GUI-related functions like keeping the textbox the right size and
+ * listening to itself. A filter may be specified as a way of, e.g., forcing
+ * variables to be within a certain range; see the setFilter
+ * method.
+ *
+ * @author Kevin Bui
+ */
+public final class LongTextField extends JTextField {
+
+ /**
+ * The getModel value of the text field.
+ */
+ private long value;
+
+ /**
+ * If set, checks whether the given value should be accepted; otherwise, the
+ * old value will be reinstated. May be null.
+ */
+ private Filter filter;
+
+ //==========================CONSTRUCTORS=============================//
+ /**
+ * Constructs a new long text field displaying the given default value,
+ * restricting the value to [lowerBound, upperBound].
+ *
+ * @param value The initial value. Must be between lowerBound and
+ * upperBound.
+ * @param size the number of columns in the textfield.
+ */
+ public LongTextField(long value, int size) {
+ super(size);
+
+ setValue(value);
+ setText(Long.toString(value));
+
+ setHorizontalAlignment(SwingConstants.RIGHT);
+ addActionListener(new ActionListener() {
+
+ /**
+ * Reacts to somebody pressing the return key in this field by
+ * attempting to set the value displayed. If the value displayed
+ * cannot be set, the set value is reinstated.
+ */
+ public void actionPerformed(ActionEvent e) {
+ try {
+ long n = Long.parseLong(e.getActionCommand());
+ setValue(n);
+ } catch (NumberFormatException e1) {
+ setText(Long.toString(getValue()));
+ }
+ }
+ });
+
+ addFocusListener(new FocusAdapter() {
+ /**
+ * Nothing need be done when focus is gained, but this method is
+ * required by the FocusListener interface.
+ *
+ * @param e the event.
+ */
+ public void focusGained(FocusEvent e) {
+ LongTextField source = (LongTextField) e.getSource();
+ source.selectAll();
+ }
+
+ /**
+ * If focus is lost, attempt to store the text value being displayed
+ * as long; if this cannot be done, restore the previous value.
+ */
+ public void focusLost(FocusEvent e) {
+ try {
+ long n = Long.parseLong(getText());
+ setValue(n);
+ } catch (NumberFormatException e1) {
+ setText(Long.toString(getValue()));
+ }
+ }
+ });
+ }
+
+ //=============================PUBLIC METHODS=======================//
+ public void setUnfilteredValue(long value) {
+ setText(String.valueOf(value));
+ }
+
+ /**
+ * Sets the value of the text field to the given long value.
+ */
+ public void setValue(long value) {
+ if (value == this.value) {
+ return;
+ }
+
+ long newValue = filter(value, this.value);
+
+ if (newValue == this.value) {
+ setText(Long.toString(this.value));
+ } else {
+ this.value = newValue;
+ setText(Long.toString(this.value));
+ firePropertyChange("newValue", null, this.value);
+ }
+ }
+
+ /**
+ * @return the long value currently displayed.
+ */
+ public long getValue() {
+ return this.value;
+ }
+
+ /**
+ * Sets whether the given value should be accepted.
+ */
+ public void setFilter(Filter filter) {
+ this.filter = filter;
+ }
+
+ /**
+ * Convinces the text field to stay the right size in layouts that are
+ * trying to expand it like a balloon by returning the preferred size.
+ *
+ * @return the maximum size.
+ */
+ public Dimension getMaximumSize() {
+ return getPreferredSize();
+ }
+
+ /**
+ * Convinces the text field to stay the right size in layouts that are
+ * trying to shrink it.
+ *
+ * @return the maximum size.
+ */
+ public Dimension getMinimumSize() {
+ return getPreferredSize();
+ }
+
+ //==============================PRIVATE METHODS======================//
+ /**
+ * Determines whether the given value is a legal value for this text field.
+ * The default behavior is to constrain the value to be within a certain
+ * range--in other words, in the range [lower bound, upper bound]. For any
+ * other behavior, this method should be overridden. This method is called
+ * by default by the setLabel() method; it may become irrelevant if
+ * setLabel() is overridden in a way that doesn't make a call to
+ * checkValue().
+ */
+ private long filter(long value, long oldValue) {
+ if (this.filter == null) {
+ return value;
+ }
+
+ return this.filter.filter(value, oldValue);
+ }
+
+ //==============================Interfaces============================//
+ /**
+ * Filters the given value, returning the value that should actually be
+ * displayed. Typical use is to return either the value or the old value,
+ * depending on whether the value is in range, though more complicated uses
+ * are permitted. Side effects (such as storing the value in the process of
+ * filtering it) are permitted.
+ */
+ public interface Filter {
+
+ /**
+ * Filters the given value, returning the new value that should be
+ * displayed.
+ *
+ * @param value The value entered by the user.
+ * @param oldValue The value previously displayed, in case it needs to
+ * be reverted to.
+ */
+ long filter(long value, long oldValue);
+ }
+}
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/ParameterComponents.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/ParameterComponents.java
index 3e1e0992ca..cdeb362e3d 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/ParameterComponents.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/util/ParameterComponents.java
@@ -129,6 +129,35 @@ public static IntTextField getIntTextField(String parameter, Parameters paramete
return field;
}
+ public static LongTextField getLongTextField(String parameter, Parameters parameters,
+ long defaultValue, double lowerBound, double upperBound) {
+ LongTextField field = new LongTextField(parameters.getLong(parameter, defaultValue), 10);
+
+ field.setFilter((value, oldValue) -> {
+ if (value == field.getValue()) {
+ return oldValue;
+ }
+
+ if (value < lowerBound) {
+ return oldValue;
+ }
+
+ if (value > upperBound) {
+ return oldValue;
+ }
+
+ try {
+ parameters.set(parameter, value);
+ } catch (Exception e) {
+ // Ignore.
+ }
+
+ return value;
+ });
+
+ return field;
+ }
+
public static Box getBooleanSelectionBox(String parameter, Parameters parameters, boolean defaultValue) {
Box selectionBox = Box.createHorizontalBox();
@@ -203,6 +232,10 @@ private static Box createParameterComponent(String parameter, Parameters paramet
int lowerBoundInt = paramDesc.getLowerBoundInt();
int upperBoundInt = paramDesc.getUpperBoundInt();
component = ParameterComponents.getIntTextField(parameter, parameters, (Integer) defaultValue, lowerBoundInt, upperBoundInt);
+ } else if (defaultValue instanceof Long) {
+ int lowerBoundInt = paramDesc.getLowerBoundInt();
+ int upperBoundInt = paramDesc.getUpperBoundInt();
+ component = ParameterComponents.getLongTextField(parameter, parameters, (Long) defaultValue, lowerBoundInt, upperBoundInt);
} else if (defaultValue instanceof Boolean) {
component = ParameterComponents.getBooleanSelectionBox(parameter, parameters, (Boolean) defaultValue);
} else if (defaultValue instanceof String) {
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 eae2901f82..f9c0ca83d3 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
@@ -20,11 +20,10 @@
///////////////////////////////////////////////////////////////////////////////
package edu.cmu.tetradapp.workbench;
-import edu.cmu.tetrad.data.IKnowledge;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.*;
import edu.cmu.tetrad.util.JOptionUtils;
import edu.cmu.tetradapp.model.SessionWrapper;
-import edu.cmu.tetradapp.util.CopyLayoutAction;
import edu.cmu.tetradapp.util.LayoutEditable;
import edu.cmu.tetradapp.util.PasteLayoutAction;
@@ -523,7 +522,6 @@ public final void setEdgeLabel(Edge modelEdge, JComponent label) {
/**
* Node tooltip to show the node attributes - Added by Kong
- *
*/
public final void setNodeToolTip(Node modelNode, String toolTipText) {
if (modelNode == null) {
@@ -539,7 +537,6 @@ public final void setNodeToolTip(Node modelNode, String toolTipText) {
/**
* Edge tooltip to show the edge type and probabilities - Added by Zhou
- *
*/
public final void setEdgeToolTip(Edge modelEdge, String toolTipText) {
if (modelEdge == null) {
@@ -841,7 +838,7 @@ public void layoutByGraph(Graph layoutGraph) {
// setGraphWithoutNotify(graph);
}
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return null;
}
@@ -930,7 +927,7 @@ private void setGraphWithoutNotify(Graph graph) {
} else {
this.graph = graph;
- if (graph.isPag()) {
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
GraphUtils.addPagColoring(new EdgeListGraph(graph));
}
}
@@ -1178,7 +1175,9 @@ private void addEdge(Edge modelEdge) {
}
if (!getGraph().containsEdge(modelEdge)) {
- throw new IllegalArgumentException("Attempt to add edge not in model.");
+ System.out.println("Attempt to add edge not in model: " + modelEdge);
+ return;
+// throw new IllegalArgumentException("Attempt to add edge not in model.");
}
// construct a display edge for the model edge
@@ -1201,13 +1200,23 @@ private void addEdge(Edge modelEdge) {
displayEdge.setHighlighted(true);
}
- boolean bold = modelEdge.getProperties().contains(Edge.Property.dd) || modelEdge.isBold();
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
- Color lineColor = modelEdge.getProperties().contains(Edge.Property.nl) ? Color.green
- : this.graph.isHighlighted(modelEdge) ? displayEdge.getHighlightedColor() : modelEdge.getLineColor();
+ // visible edges.
+ boolean solid = modelEdge.getProperties().contains(Edge.Property.nl);
- displayEdge.setLineColor(lineColor);
- displayEdge.setBold(bold);
+ // definitely direct edges.
+ boolean thick = modelEdge.getProperties().contains(Edge.Property.dd);
+
+ // definitely direct edges.
+// Color green = Color.green.darker();
+// Color lineColor = modelEdge.getProperties().contains(Edge.Property.nl) ? green
+// : this.graph.isHighlighted(modelEdge) ? displayEdge.getHighlightedColor() : modelEdge.getLineColor();
+
+// displayEdge.setLineColor(lineColor);
+ displayEdge.setSolid(solid);
+ displayEdge.setThick(thick);
+ }
// Link the display edge to the model edge.
getModelEdgesToDisplay().put(modelEdge, displayEdge);
@@ -1783,6 +1792,10 @@ private void edgeClicked(Object source, MouseEvent e) {
graphEdge.setSelected(true);
}
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
}
private void nodeClicked(Object source, MouseEvent e) {
@@ -1805,6 +1818,10 @@ private void nodeClicked(Object source, MouseEvent e) {
selectConnectingEdges();
fireNodeSelection();
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
}
private void reorientEdge(Object source, MouseEvent e) {
@@ -1819,7 +1836,7 @@ private void reorientEdge(Object source, MouseEvent e) {
if (e.isShiftDown()) {
if (AbstractWorkbench.distance(point, pointA) < endpointRadius) {
toggleEndpoint(graphEdge, 1);
- firePropertyChange("modelChanged", null, null);
+ fireModelChanged();
} else if (AbstractWorkbench.distance(point, pointB) < endpointRadius) {
toggleEndpoint(graphEdge, 2);
firePropertyChange("modelChanged", null, null);
@@ -1833,6 +1850,14 @@ private void reorientEdge(Object source, MouseEvent e) {
firePropertyChange("modelChanged", null, null);
}
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
+ }
+
+ private void fireModelChanged() {
+ firePropertyChange("modelChanged", null, null);
}
private void handleMousePressed(MouseEvent e) {
@@ -1885,6 +1910,10 @@ private void handleMousePressed(MouseEvent e) {
break;
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
}
private void launchPopup(MouseEvent e) {
@@ -1926,6 +1955,10 @@ private void handleMouseReleased(MouseEvent e) {
finishEdge();
break;
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
}
private void handleMouseDragged(MouseEvent e) {
@@ -1951,6 +1984,10 @@ private void handleMouseDragged(MouseEvent e) {
dragNewEdge(source, newPoint);
break;
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
}
private void handleMouseEntered(MouseEvent e) {
@@ -1969,13 +2006,13 @@ private void handleMouseEntered(MouseEvent e) {
endpoint1 = "-";
break;
case "Arrow":
- endpoint1 = "<";
+ endpoint1 = "<";
break;
case "Circle":
endpoint1 = "o";
break;
case "Star":
- endpoint1 = "*";
+ endpoint1 = "*";
break;
case "Null":
endpoint1 = "Null";
@@ -1988,13 +2025,13 @@ private void handleMouseEntered(MouseEvent e) {
endpoint2 = "-";
break;
case "Arrow":
- endpoint2 = ">";
+ endpoint2 = ">";
break;
case "Circle":
endpoint2 = "o";
break;
case "Star":
- endpoint2 = "*";
+ endpoint2 = "*";
break;
case "Null":
endpoint2 = "Null";
@@ -2026,19 +2063,19 @@ private void handleMouseEntered(MouseEvent e) {
_type = "no edge";
break;
case ta:
- _type = "-->";
+ _type = "--?";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case at:
- _type = "<--";
+ _type = "<--";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case ca:
- _type = "o->";
+ _type = "o->";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case ac:
- _type = "<-o";
+ _type = "<-o";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case cc:
@@ -2046,7 +2083,7 @@ private void handleMouseEntered(MouseEvent e) {
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case aa:
- _type = "<->";
+ _type = "<->";
_type = nodes.get(0) + " " + _type + " " + nodes.get(1);
break;
case tt:
@@ -2236,17 +2273,28 @@ private void directEdge(IDisplayEdge graphEdge, int endpoint) {
try {
boolean added = getGraph().addEdge(newEdge);
+
if (!added) {
getGraph().addEdge(edge);
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(),
"Reorienting that edge would violate graph constraints.");
}
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
} catch (IllegalArgumentException e) {
getGraph().addEdge(edge);
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
+
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(),
"Reorienting that edge would violate graph constraints.");
}
+ revalidate();
repaint();
}
@@ -2290,6 +2338,11 @@ private void toggleEndpoint(IDisplayEdge graphEdge, int endpointNumber) {
boolean added = getGraph().addEdge(newEdge);
if (!added) {
getGraph().addEdge(edge);
+
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
+
return;
}
} catch (IllegalArgumentException e) {
@@ -2297,6 +2350,11 @@ private void toggleEndpoint(IDisplayEdge graphEdge, int endpointNumber) {
return;
}
+ if (graph.getGraphType() == EdgeListGraph.GraphType.PAG) {
+ GraphUtils.addPagColoring(new EdgeListGraph(graph));
+ }
+
+ revalidate();
repaint();
}
@@ -2350,6 +2408,15 @@ public void enableEditing(boolean enableEditing) {
setEnabled(enableEditing);
}
+ public void setPag(boolean pagColoring) {
+ if (pagColoring) {
+ this.graph.setGraphType(EdgeListGraph.GraphType.PAG);
+ } else {
+ this.graph.setGraphType(EdgeListGraph.GraphType.UNLABELED);
+ }
+ setGraph(graph);
+ }
+
/**
* This inner class is a simple wrapper for JComponents which are to serve
* as edge labels in the workbench. Its sole function is to make sure the
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/DisplayEdge.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/DisplayEdge.java
index 61b3b90b07..befe2b3a47 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/DisplayEdge.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/DisplayEdge.java
@@ -181,7 +181,7 @@ public class DisplayEdge extends JComponent implements IDisplayEdge {
/**
* The width of the stroke.
*/
- private float strokeWidth = 1f;
+ private float strokeWidth = 1.2f;
/**
* True iff this edge is highlighted.
@@ -198,7 +198,8 @@ public class DisplayEdge extends JComponent implements IDisplayEdge {
*/
private final PropertyChangeHandler propertyChangeHandler =
new PropertyChangeHandler();
- private boolean bold;
+ private boolean solid = true;
+ private boolean thick = false;
//==========================CONSTRUCTORS============================//
@@ -425,12 +426,16 @@ private void drawEdge(Graphics g) {
// width <= 1.0 seems to cause the problem, so we pick a stroke
// width slightly greater than 1.0. jdramsey 4/16/2005
// g2d.setStroke(new BasicStroke(1.000001f));
- BasicStroke s;
+ Stroke s;
+ float width = thick ? 2.5f : 1.1f;
- if (this.bold) {
- s = new BasicStroke(3.0f);
+ Stroke solid = new BasicStroke(width);
+ Stroke dashed = new BasicStroke(width, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL, 0, new float[]{9}, 0);
+
+ if (this.solid) {
+ s = solid;
} else {
- s = new BasicStroke(getStrokeWidth() + 0.000001f);
+ s = dashed;
}
g2d.setStroke(s);
@@ -1029,12 +1034,17 @@ public void setLineColor(Color lineColor) {
}
}
- public boolean getBold() {
- return this.bold;
+ public boolean getSolid() {
+ return this.solid;
+ }
+
+ public void setSolid(boolean solid) {
+ this.solid = solid;
}
- public void setBold(boolean bold) {
- this.bold = bold;
+ @Override
+ public void setThick(boolean thick) {
+ this.thick = thick;
}
public Color getSelectedColor() {
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphWorkbench.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphWorkbench.java
index bf9cff7d04..e86540d10d 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphWorkbench.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/GraphWorkbench.java
@@ -62,7 +62,7 @@ public GraphWorkbench() {
}
/**
- * Constructs a new workbench workbench for the given workbench model.
+ * Constructs a new workbench for the given graph model.
*/
public GraphWorkbench(Graph graph) {
super(graph);
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/IDisplayEdge.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/IDisplayEdge.java
index 478140fff5..6bcbff85c2 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/IDisplayEdge.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/IDisplayEdge.java
@@ -65,9 +65,11 @@ public interface IDisplayEdge {
void setLineColor(Color lineColor);
- boolean getBold();
+ boolean getSolid();
- void setBold(boolean bold);
+ void setSolid(boolean solid);
+
+ void setThick(boolean thick);
Color getSelectedColor();
diff --git a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/LayoutUtils.java b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/LayoutUtils.java
index a88e9f3161..7546d24b8f 100644
--- a/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/LayoutUtils.java
+++ b/tetrad-gui/src/main/java/edu/cmu/tetradapp/workbench/LayoutUtils.java
@@ -21,7 +21,7 @@
package edu.cmu.tetradapp.workbench;
-import edu.cmu.tetrad.data.IKnowledge;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.*;
import edu.cmu.tetrad.search.SearchGraphUtils;
import edu.cmu.tetrad.util.JOptionUtils;
@@ -485,7 +485,7 @@ public static void knowledgeLayout(LayoutEditable layoutEditable) {
}
}
- IKnowledge knowledge = layoutEditable.getKnowledge();
+ Knowledge knowledge = layoutEditable.getKnowledge();
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
layoutEditable.layoutByGraph(graph);
} catch (Exception e1) {
diff --git a/tetrad-gui/src/main/resources/config/devConfig.xml b/tetrad-gui/src/main/resources/config/devConfig.xml
index e28f884017..19b66b4e89 100644
--- a/tetrad-gui/src/main/resources/config/devConfig.xml
+++ b/tetrad-gui/src/main/resources/config/devConfig.xml
@@ -943,17 +943,17 @@
edu.cmu.tetradapp.editor.BayesUpdaterEditor
-
-
-
-
-
- edu.cmu.tetradapp.model.CptInvariantUpdaterWrapper
-
- edu.cmu.tetradapp.editor.BayesUpdaterEditor
-
-
+
+
+
+
+
+
+
+
+
+
+
edu.cmu.tetradapp.model.SemUpdaterWrapper
@@ -1190,6 +1190,14 @@
edu.cmu.tetradapp.model.RequiredGraphModel
edu.cmu.tetradapp.knowledge_editor.KnowledgeBoxEditor
+
+
+
+
+
+ edu.cmu.tetradapp.model.RemoveNonSkeletonEdgesModel
+ edu.cmu.tetradapp.knowledge_editor.KnowledgeBoxEditor
+
diff --git a/tetrad-gui/src/main/resources/config/prodConfig.xml b/tetrad-gui/src/main/resources/config/prodConfig.xml
index 6b96cf0b1c..f97d4c42e0 100644
--- a/tetrad-gui/src/main/resources/config/prodConfig.xml
+++ b/tetrad-gui/src/main/resources/config/prodConfig.xml
@@ -903,17 +903,17 @@
edu.cmu.tetradapp.editor.BayesUpdaterEditor
-
-
-
-
-
- edu.cmu.tetradapp.model.CptInvariantUpdaterWrapper
-
- edu.cmu.tetradapp.editor.BayesUpdaterEditor
-
-
+
+
+
+
+
+
+
+
+
+
+
edu.cmu.tetradapp.model.SemUpdaterWrapper
@@ -1160,6 +1160,14 @@
edu.cmu.tetradapp.model.RequiredGraphModel
edu.cmu.tetradapp.knowledge_editor.KnowledgeBoxEditor
+
+
+
+
+
+ edu.cmu.tetradapp.model.RemoveNonSkeletonEdgesModel
+ edu.cmu.tetradapp.knowledge_editor.KnowledgeBoxEditor
+
diff --git a/tetrad-gui/src/main/resources/resources/javahelp/Map.jhm b/tetrad-gui/src/main/resources/resources/javahelp/Map.jhm
index b5a8177d05..136ac97764 100644
--- a/tetrad-gui/src/main/resources/resources/javahelp/Map.jhm
+++ b/tetrad-gui/src/main/resources/resources/javahelp/Map.jhm
@@ -97,7 +97,7 @@
-
+
diff --git a/tetrad-gui/src/main/resources/resources/javahelp/TetradHelpTOC.xml b/tetrad-gui/src/main/resources/resources/javahelp/TetradHelpTOC.xml
index 808373ab07..97f00a59c8 100644
--- a/tetrad-gui/src/main/resources/resources/javahelp/TetradHelpTOC.xml
+++ b/tetrad-gui/src/main/resources/resources/javahelp/TetradHelpTOC.xml
@@ -61,7 +61,7 @@
-
+
diff --git a/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/mbfs.html b/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/mbfs.html
index 2fe3e59702..7ec4f081a6 100644
--- a/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/mbfs.html
+++ b/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/mbfs.html
@@ -9,11 +9,11 @@
- Search Algorithms: MBFS |
+ Search Algorithms: PC-MB |
-The MBFS search (Markov blanket fan Search) is designed to search for Markov blanket DAGs of
+The PC-MB search is designed to search for Markov blanket DAGs of
target variables in datasets, under the assumptions of the PC algorithm--i.e., that the true causal graph over the
variables in the dataset does not contain any cycles, that there are no hidden common causes between variables in
the dataset, and that no relationship between variables in the dataset is deterministic. The Markov blanket of a
diff --git a/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/types_of_algorithms.html b/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/types_of_algorithms.html
index 39c19bf020..326d3a2327 100644
--- a/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/types_of_algorithms.html
+++ b/tetrad-gui/src/main/resources/resources/javahelp/manual/boxes/search/types_of_algorithms.html
@@ -32,7 +32,7 @@ Types of Algorithms
or the algorithm uses only conditional independence information as data.
For CPDAG algorithms, it is assumed that there are no latent common causes
in the model--that is, there can be latents, but there cannot be structures of
- the following form: X<-L->Y, where X and Y are measured and L is not.
+ the following form: X<~~L~~>Y, where X and Y are measured and L is not.
PAG (Partial Ancestral Graph) algorithm. This is the class of equivalence
classes of graphs one obtains if one assumes latent common causes (as above)
diff --git a/tetrad-gui/src/main/resources/resources/javahelp/manual/graph_edge_types.html b/tetrad-gui/src/main/resources/resources/javahelp/manual/graph_edge_types.html
index 321f753c76..f797bf4995 100644
--- a/tetrad-gui/src/main/resources/resources/javahelp/manual/graph_edge_types.html
+++ b/tetrad-gui/src/main/resources/resources/javahelp/manual/graph_edge_types.html
@@ -68,12 +68,12 @@ Graph Edge Types
- If an edge is green that means there is no latent
- confounder. Otherwise, there is possibly latent confounder.
+ | If an edge is solid, that means there is no latent
+ confounder (i.e., is visible). If dashed, there is possibly latent confounder.
|
- If an edge is bold (thickened) that means it is
+ | If an edge is thickened that means it is
definitely direct. Otherwise, it is possibly direct.
|
diff --git a/tetrad-lib/pom.xml b/tetrad-lib/pom.xml
index 2b1f634b8a..8677159f35 100644
--- a/tetrad-lib/pom.xml
+++ b/tetrad-lib/pom.xml
@@ -6,7 +6,7 @@
io.github.cmu-phil
tetrad
- 7.1.2-2
+ 7.1.3-1
tetrad-lib
@@ -115,7 +115,7 @@
org.json
json
- 20220320
+ 20220924
@@ -130,7 +130,7 @@
org.jsoup
jsoup
- 1.14.3
+ 1.15.3
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 e068adc62a..173d899ade 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
@@ -41,7 +41,6 @@
import edu.cmu.tetrad.data.*;
import edu.cmu.tetrad.data.simulation.LoadDataAndGraphs;
import edu.cmu.tetrad.graph.*;
-import edu.cmu.tetrad.search.DagToPag;
import edu.cmu.tetrad.search.SearchGraphUtils;
import edu.cmu.tetrad.util.*;
import org.reflections.Reflections;
@@ -51,7 +50,11 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.*;
-import java.util.concurrent.RecursiveTask;
+import java.util.concurrent.Callable;
+import java.util.concurrent.Executors;
+import java.util.concurrent.ForkJoinPool;
+
+import static edu.cmu.tetrad.search.SearchGraphUtils.dagToPag;
/**
* Script to do a comparison of a list of algorithms using a list of statistics
@@ -62,6 +65,12 @@
*/
public class Comparison {
+ private boolean parallelized = false;
+
+ public void setParallelized(boolean parallelized) {
+ this.parallelized = parallelized;
+ }
+
public enum ComparisonGraph {
true_DAG, CPDAG_of_the_true_DAG, PAG_of_the_true_DAG
}
@@ -296,16 +305,6 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
double[][][][] allStats = calcStats(algorithmSimulationWrappers, algorithmWrappers, simulationWrappers,
statistics, numRuns, stdout);
- // Print out the preliminary information for statistics types, etc.
- this.out.println();
- this.out.println("Statistics:");
- this.out.println();
-
- for (Statistic stat : statistics.getStatistics()) {
- this.out.println(stat.getAbbreviation() + " = " + stat.getDescription());
- }
-
- this.out.println();
{
int numTables = allStats.length;
@@ -333,6 +332,7 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
}
}
+ this.out.println();
this.out.println("Simulations:");
this.out.println();
@@ -362,6 +362,18 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
}
}
+
+ // Print out the preliminary information for statistics types, etc.
+ this.out.println();
+ this.out.println("Statistics:");
+ this.out.println();
+
+ for (Statistic stat : statistics.getStatistics()) {
+ this.out.println(stat.getAbbreviation() + " = " + stat.getDescription());
+ }
+
+ this.out.println();
+
if (isSortByUtility()) {
this.out.println();
this.out.println("Sorting by utility, high to low.");
@@ -389,11 +401,14 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
this.out.println("interval [0, 1], with higher being better.");
}
- this.out.println();
this.out.println("Graphs are being compared to the " + this.comparisonGraph.toString().replace("_", " ") + ".");
+ this.out.println("All statistics are individually summarized over " + numRuns + " runs using the indicated statistic.");
this.out.println();
+ statTables = calcStatTables(allStats, Mode.Average, numTables,
+ algorithmSimulationWrappers, numStats, statistics);
+
// Add utilities to table as the last column.
for (int u = 0; u < numTables; u++) {
for (int t = 0; t < algorithmSimulationWrappers.size(); t++) {
@@ -401,10 +416,11 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
}
}
- // Print all of the tables.
+ // Print all the tables.
printStats(statTables, statistics, Mode.Average, newOrder, algorithmSimulationWrappers,
algorithmWrappers, simulationWrappers, utilities, parameters);
+
statTables = calcStatTables(allStats, Mode.StandardDeviation, numTables,
algorithmSimulationWrappers, numStats, statistics);
@@ -417,7 +433,7 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
printStats(statTables, statistics, Mode.StandardDeviation, newOrder, algorithmSimulationWrappers, algorithmWrappers,
simulationWrappers, utilities, parameters);
- statTables = calcStatTables(allStats, Mode.WorstCase, numTables, algorithmSimulationWrappers,
+ statTables = calcStatTables(allStats, Mode.MinValue, numTables, algorithmSimulationWrappers,
numStats, statistics);
for (int u = 0; u < numTables; u++) {
@@ -426,10 +442,10 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
}
}
- printStats(statTables, statistics, Mode.WorstCase, newOrder, algorithmSimulationWrappers, algorithmWrappers,
+ printStats(statTables, statistics, Mode.MinValue, newOrder, algorithmSimulationWrappers, algorithmWrappers,
simulationWrappers, utilities, parameters);
- statTables = calcStatTables(allStats, Mode.MedianCase, numTables, algorithmSimulationWrappers,
+ statTables = calcStatTables(allStats, Mode.MaxValue, numTables, algorithmSimulationWrappers,
numStats, statistics);
for (int u = 0; u < numTables; u++) {
@@ -438,15 +454,27 @@ public void compareFromSimulations(String resultsPath, Simulations simulations,
}
}
- printStats(statTables, statistics, Mode.MedianCase, newOrder, algorithmSimulationWrappers, algorithmWrappers,
+ printStats(statTables, statistics, Mode.MaxValue, newOrder, algorithmSimulationWrappers, algorithmWrappers,
simulationWrappers, utilities, parameters);
- // Add utilities to table as the last column.
+ statTables = calcStatTables(allStats, Mode.MedianValue, numTables, algorithmSimulationWrappers,
+ numStats, statistics);
+
for (int u = 0; u < numTables; u++) {
for (int t = 0; t < algorithmSimulationWrappers.size(); t++) {
statTables[u][t][numStats] = utilities[t];
}
}
+
+ printStats(statTables, statistics, Mode.MedianValue, newOrder, algorithmSimulationWrappers, algorithmWrappers,
+ simulationWrappers, utilities, parameters);
+
+// // Add utilities to table as the last column.
+// for (int u = 0; u < numTables; u++) {
+// for (int t = 0; t < algorithmSimulationWrappers.size(); t++) {
+// statTables[u][t][numStats] = utilities[t];
+// }
+// }
}
for (int i = 0; i < simulations.getSimulations().size(); i++) {
@@ -483,7 +511,9 @@ public void saveToFiles(String dataPath, Simulation simulation, Parameters param
parameters.set(param, simulationWrapper.getValue(param));
}
- simulationWrapper.createData(simulationWrapper.getSimulationSpecificParameters(), false);
+ if (simulation.getNumDataModels() == 0) {
+ simulationWrapper.createData(simulationWrapper.getSimulationSpecificParameters(), true);
+ }
File subdir = dir;
if (simulationWrappers.size() > 1) {
@@ -534,9 +564,8 @@ public void saveToFiles(String dataPath, Simulation simulation, Parameters param
if (isSavePags()) {
File file4 = new File(dir4, "pag." + (j + 1) + ".txt");
- GraphUtils.saveGraph(new DagToPag(graph).convert(), file4, false);
+ GraphUtils.saveGraph(dagToPag(graph), file4, false);
}
-
}
PrintStream out = new PrintStream(new FileOutputStream(new File(subdir, "parameters.txt")));
@@ -621,7 +650,7 @@ public void saveToFilesSingleSimulation(String dataPath, Simulation simulation,
if (isSavePags()) {
File file4 = new File(dir4, "pag." + (j + 1) + ".txt");
- GraphUtils.saveGraph(new DagToPag(graph).convert(), file4, false);
+ GraphUtils.saveGraph(dagToPag(graph), file4, false);
}
}
} catch (IOException e) {
@@ -888,8 +917,15 @@ private double[][][][] calcStats(List algorithmSimul
}
}
- for (AlgorithmTask task : tasks) {
- task.compute();
+ if (parallelized) {
+ int parallelism = ForkJoinPool.getCommonPoolParallelism() + 10;
+ ForkJoinPool pool = (ForkJoinPool) Executors.newWorkStealingPool(parallelism);
+ pool.invokeAll(tasks);
+ pool.shutdown();
+ } else {
+ for (AlgorithmTask task : tasks) {
+ task.call();
+ }
}
return allStats;
@@ -1024,7 +1060,7 @@ public void setComparisonGraph(ComparisonGraph comparisonGraph) {
this.comparisonGraph = comparisonGraph;
}
- private class AlgorithmTask extends RecursiveTask {
+ private class AlgorithmTask implements Callable {
private final List algorithmSimulationWrappers;
private final List algorithmWrappers;
@@ -1049,7 +1085,7 @@ public AlgorithmTask(List algorithmSimulationWrapper
}
@Override
- protected Boolean compute() {
+ public Boolean call() {
doRun(this.algorithmSimulationWrappers, this.algorithmWrappers,
this.simulationWrappers, this.statistics, this.numGraphTypes, this.allStats, this.run, this.stdout);
return true;
@@ -1198,7 +1234,7 @@ private void doRun(List algorithmSimulationWrappers,
} else if (this.comparisonGraph == ComparisonGraph.CPDAG_of_the_true_DAG) {
comparisonGraph = SearchGraphUtils.cpdagForDag(new EdgeListGraph(trueGraph));
} else if (this.comparisonGraph == ComparisonGraph.PAG_of_the_true_DAG) {
- comparisonGraph = new DagToPag(new EdgeListGraph(trueGraph)).convert();
+ comparisonGraph = dagToPag(new EdgeListGraph(trueGraph));
} else {
throw new IllegalArgumentException("Unrecognized graph type.");
}
@@ -1296,7 +1332,7 @@ private void saveGraph(String resultsPath, Graph graph, int i, int simIndex,
}
private enum Mode {
- Average, StandardDeviation, WorstCase, MedianCase
+ Average, StandardDeviation, MinValue, MaxValue, MedianValue
}
private String getHeader(int u) {
@@ -1375,11 +1411,13 @@ private double[][][] calcStatTables(double[][][][] allStats, Mode mode, int numT
} else if (mode == Mode.Average) {
double mean = StatUtils.mean(allStats[u][i][j]);
statTables[u][i][j] = mean;
- } else if (mode == Mode.WorstCase) {
+ } else if (mode == Mode.MinValue) {
statTables[u][i][j] = StatUtils.min(allStats[u][i][j]);
+ } else if (mode == Mode.MaxValue) {
+ statTables[u][i][j] = StatUtils.max(allStats[u][i][j]);
} else if (mode == Mode.StandardDeviation) {
statTables[u][i][j] = StatUtils.sd(allStats[u][i][j]);
- } else if (mode == Mode.MedianCase) {
+ } else if (mode == Mode.MedianValue) {
statTables[u][i][j] = StatUtils.median(allStats[u][i][j]);
} else {
throw new IllegalStateException();
@@ -1398,13 +1436,15 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod
Parameters parameters) {
if (mode == Mode.Average) {
- this.out.println("AVERAGE STATISTICS");
+ this.out.println("AVERAGE VALUE");
} else if (mode == Mode.StandardDeviation) {
- this.out.println("STANDARD DEVIATIONS");
- } else if (mode == Mode.WorstCase) {
- this.out.println("WORST CASE");
- } else if (mode == Mode.MedianCase) {
- this.out.println("MEDIAN CASE");
+ this.out.println("STANDARD DEVIATION");
+ } else if (mode == Mode.MinValue) {
+ this.out.println("MIN VALUE");
+ } else if (mode == Mode.MaxValue) {
+ this.out.println("MAX VALUE");
+ } else if (mode == Mode.MedianValue) {
+ this.out.println("MEDIAN VALUE");
} else {
throw new IllegalStateException();
}
@@ -1427,7 +1467,7 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod
+ (isShowUtilities() ? 1 : 0);
TextTable table = new TextTable(rows, cols);
- table.setTabDelimited(isTabDelimitedTables());
+ table.setDelimiter(isTabDelimitedTables() ? TextTable.Delimiter.TAB : TextTable.Delimiter.JUSTIFIED);
int initialColumn = 0;
@@ -1763,12 +1803,14 @@ public SimulationWrapper(Simulation simulation, Parameters parameters) {
@Override
public void createData(Parameters parameters, boolean newModel) {
- this.simulation.createData(parameters, newModel);
- this.graphs = new ArrayList<>();
- this.dataModels = new ArrayList<>();
- for (int i = 0; i < this.simulation.getNumDataModels(); i++) {
- this.graphs.add(this.simulation.getTrueGraph(i));
- this.dataModels.add(this.simulation.getDataModel(i));
+ if (newModel) {
+ this.simulation.createData(parameters, newModel);
+ this.graphs = new ArrayList<>();
+ this.dataModels = new ArrayList<>();
+ for (int i = 0; i < this.simulation.getNumDataModels(); i++) {
+ this.graphs.add(this.simulation.getTrueGraph(i));
+ this.dataModels.add(this.simulation.getDataModel(i));
+ }
}
}
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 009c7665ba..63704b1131 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
@@ -53,6 +53,8 @@
import java.util.*;
import java.util.concurrent.*;
+import static edu.cmu.tetrad.search.SearchGraphUtils.dagToPag;
+
/**
* Nov 14, 2017 12:00:31 PM
*
@@ -511,7 +513,7 @@ public void saveToFiles(String dataPath, Simulation simulation, Parameters param
if (isSavePags()) {
File file4 = new File(dir4, "pag." + (j + 1) + ".txt");
- GraphUtils.saveGraph(new DagToPag(graph).convert(), file4, false);
+ GraphUtils.saveGraph(dagToPag(graph), file4, false);
}
}
@@ -1147,7 +1149,7 @@ private void doRun(List algorithmSimulationWrappers,
} else if (this.comparisonGraph == ComparisonGraph.CPDAG_of_the_true_DAG) {
comparisonGraph = SearchGraphUtils.cpdagForDag(new EdgeListGraph(trueGraph));
} else if (this.comparisonGraph == ComparisonGraph.PAG_of_the_true_DAG) {
- comparisonGraph = new DagToPag(new EdgeListGraph(trueGraph)).convert();
+ comparisonGraph = dagToPag(new EdgeListGraph(trueGraph));
} else {
throw new IllegalArgumentException("Unrecognized graph type.");
}
@@ -1368,7 +1370,7 @@ private void printStats(double[][][] statTables, Statistics statistics, Mode mod
+ (isShowUtilities() ? 1 : 0);
TextTable table = new TextTable(rows, cols);
- table.setTabDelimited(isTabDelimitedTables());
+ table.setDelimiter(isTabDelimitedTables() ? TextTable.Delimiter.TAB : TextTable.Delimiter.JUSTIFIED);
int initialColumn = 0;
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/MultiDataSetAlgorithm.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/MultiDataSetAlgorithm.java
index ee058b01b9..0716945d70 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/MultiDataSetAlgorithm.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/MultiDataSetAlgorithm.java
@@ -1,5 +1,6 @@
package edu.cmu.tetrad.algcomparison.algorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.graph.Graph;
import edu.cmu.tetrad.util.Parameters;
@@ -16,9 +17,11 @@ public interface MultiDataSetAlgorithm extends Algorithm {
/**
* Runs the search.
*
- * @param dataSet The data set to run to the search on.
+ * @param dataSets The data set to run to the search on.
* @param parameters The paramters of the search.
* @return The result graph.
*/
- Graph search(List dataSet, Parameters parameters);
+ Graph search(List dataSets, Parameters parameters);
+
+ void setScoreWrapper(ScoreWrapper score);
}
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 92f73d482c..d4d1bdc84d 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
@@ -32,7 +32,7 @@
public class Bpc implements Algorithm, HasKnowledge, ClusterAlgorithm {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public Bpc() {
}
@@ -65,7 +65,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
Mimbuild mimbuild = new Mimbuild();
mimbuild.setPenaltyDiscount(parameters.getDouble(Params.PENALTY_DISCOUNT));
- mimbuild.setKnowledge((IKnowledge) parameters.get("knowledge", new Knowledge2()));
+ mimbuild.setKnowledge((Knowledge) parameters.get("knowledge", new Knowledge()));
if (parameters.getBoolean("includeThreeClusters", true)) {
mimbuild.setMinClusterSize(3);
@@ -136,12 +136,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
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 1d20751fd3..88abccf437 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
@@ -5,7 +5,6 @@
import edu.cmu.tetrad.annotation.AlgType;
import edu.cmu.tetrad.annotation.Bootstrapping;
import edu.cmu.tetrad.data.*;
-import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
import edu.cmu.tetrad.graph.GraphUtils;
import edu.cmu.tetrad.graph.Node;
@@ -33,7 +32,7 @@
public class Fofc implements Algorithm, HasKnowledge, ClusterAlgorithm {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public Fofc() {
}
@@ -76,7 +75,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
Mimbuild mimbuild = new Mimbuild();
mimbuild.setPenaltyDiscount(parameters.getDouble(Params.PENALTY_DISCOUNT));
- mimbuild.setKnowledge((IKnowledge) parameters.get("knowledge", new Knowledge2()));
+ mimbuild.setKnowledge((Knowledge) parameters.get("knowledge", new Knowledge()));
if (parameters.getBoolean("includeThreeClusters", true)) {
mimbuild.setMinClusterSize(3);
@@ -148,12 +147,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Ftfc.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Ftfc.java
index c556f72c8d..409bc4ede1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Ftfc.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/cluster/Ftfc.java
@@ -31,7 +31,7 @@
public class Ftfc implements Algorithm, HasKnowledge, ClusterAlgorithm {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public Ftfc() {
}
@@ -105,13 +105,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/CcdMaxConcatenated.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/CcdMaxConcatenated.java
index f7bf3dc59f..22bb2f6faa 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/CcdMaxConcatenated.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/CcdMaxConcatenated.java
@@ -2,6 +2,7 @@
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
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.annotation.Bootstrapping;
import edu.cmu.tetrad.data.*;
@@ -26,7 +27,7 @@
@Bootstrapping
public class CcdMaxConcatenated implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
private final IndependenceWrapper test;
public CcdMaxConcatenated(IndependenceWrapper test) {
@@ -69,6 +70,7 @@ public Graph search(List dataModels, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -76,6 +78,11 @@ public Graph search(List dataModels, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -90,6 +97,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -132,12 +140,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FASK.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FASK.java
index 638f63125e..190f786fd7 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FASK.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FASK.java
@@ -41,7 +41,7 @@ public class FASK implements Algorithm, HasKnowledge, UsesScoreWrapper, TakesInd
private IndependenceWrapper test;
private ScoreWrapper score;
private Graph externalGraph;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
private Algorithm algorithm;
// Don't delete.
@@ -178,13 +178,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofs.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofs.java
index dda72be1eb..4ce5ce8048 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofs.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofs.java
@@ -24,7 +24,7 @@
public class FasLofs implements Algorithm, HasKnowledge {
static final long serialVersionUID = 23L;
private final Lofs2.Rule rule;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public FasLofs(Lofs2.Rule rule) {
this.rule = rule;
@@ -83,12 +83,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofsConcatenated.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofsConcatenated.java
index 2c8a892e2c..38c17dd0d1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofsConcatenated.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FasLofsConcatenated.java
@@ -1,6 +1,7 @@
package edu.cmu.tetrad.algcomparison.algorithm.multi;
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.annotation.Bootstrapping;
import edu.cmu.tetrad.data.*;
@@ -29,7 +30,7 @@
public class FasLofsConcatenated implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
private final Lofs2.Rule rule;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public FasLofsConcatenated(Lofs2.Rule rule) {
this.rule = rule;
@@ -66,6 +67,7 @@ public Graph search(List dataModels, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -73,6 +75,11 @@ public Graph search(List dataModels, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
private Graph getGraph(FasLofs search) {
return search.search();
}
@@ -91,6 +98,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -128,12 +136,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskConcatenated.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskConcatenated.java
index 92a1962373..bb9b4ba034 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskConcatenated.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskConcatenated.java
@@ -39,7 +39,7 @@ public class FaskConcatenated implements MultiDataSetAlgorithm, HasKnowledge, Ta
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
private ScoreWrapper score;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public FaskConcatenated() {
@@ -86,6 +86,7 @@ public Graph search(List dataSets, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -93,6 +94,11 @@ public Graph search(List dataSets, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -107,6 +113,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -145,13 +152,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskVote.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskVote.java
index ca5c02e4a7..07331aa24c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskVote.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FaskVote.java
@@ -41,7 +41,7 @@
public class FaskVote implements MultiDataSetAlgorithm, HasKnowledge, UsesScoreWrapper, TakesExternalGraph, TakesIndependenceWrapper {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
private Graph externalGraph;
private ScoreWrapper score;
private IndependenceWrapper test;
@@ -87,6 +87,7 @@ public Graph search(List dataSets, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -109,6 +110,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
@@ -141,13 +143,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FgesConcatenated.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FgesConcatenated.java
index 4d78f2db6c..4b6e8ab932 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FgesConcatenated.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/FgesConcatenated.java
@@ -29,7 +29,7 @@
public class FgesConcatenated implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
private final ScoreWrapper score;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
private Algorithm externalGraph;
private boolean compareToTrue;
@@ -95,6 +95,7 @@ public Graph search(List dataModels, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -102,6 +103,11 @@ public Graph search(List dataModels, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -117,6 +123,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(score);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -158,13 +165,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
/**
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java
new file mode 100644
index 0000000000..102b4b4f78
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/Images.java
@@ -0,0 +1,232 @@
+package edu.cmu.tetrad.algcomparison.algorithm.multi;
+
+import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
+import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.score.SemBicScore;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
+import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
+import edu.cmu.tetrad.annotation.AlgType;
+import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.graph.EdgeListGraph;
+import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.search.*;
+import edu.cmu.tetrad.util.Parameters;
+import edu.cmu.tetrad.util.Params;
+import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.LinkedList;
+import java.util.List;
+
+/**
+ * Wraps the IMaGES algorithm for continuous variables.
+ *
+ * Requires that the parameter 'randomSelectionSize' be set to indicate how many
+ * datasets should be taken at a time (randomly). This cannot given multiple
+ * values.
+ *
+ * @author jdramsey
+ */
+@edu.cmu.tetrad.annotation.Algorithm(
+ name = "IMaGES",
+ command = "images",
+ algoType = AlgType.forbid_latent_common_causes,
+ dataType = DataType.All
+)
+@Bootstrapping
+public class Images implements MultiDataSetAlgorithm, HasKnowledge, UsesScoreWrapper {
+
+ static final long serialVersionUID = 23L;
+ private Knowledge knowledge = new Knowledge();
+
+ private ScoreWrapper score;
+
+ public Images() {
+ }
+
+ @Override
+ public Graph search(List dataSets, Parameters parameters) {
+ this.knowledge = dataSets.get(0).getKnowledge();
+ int meta = parameters.getInt(Params.IMAGES_META_ALG);
+
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ List _dataSets = new ArrayList<>();
+
+ if (parameters.getInt(Params.TIME_LAG) > 0) {
+ for (DataModel dataSet : dataSets) {
+ DataSet timeSeries = TimeSeriesUtils.createLagData((DataSet) dataSet, parameters.getInt(Params.TIME_LAG));
+ if (dataSet.getName() != null) {
+ timeSeries.setName(dataSet.getName());
+ }
+ _dataSets.add(timeSeries);
+ }
+
+ dataSets = _dataSets;
+ this.knowledge = _dataSets.get(0).getKnowledge();
+ }
+
+ List scores = new ArrayList<>();
+
+ for (DataModel dataModel : dataSets) {
+ Score s = score.getScore(dataModel, parameters);
+ scores.add(s);
+ }
+
+ ImagesScore score = new ImagesScore(scores);
+
+ if (meta == 1) {
+ edu.cmu.tetrad.search.Fges search = new edu.cmu.tetrad.search.Fges(score);
+ search.setKnowledge(new Knowledge((Knowledge) knowledge));
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+// else if (meta == 2) {
+// Grasp search = new edu.cmu.tetrad.search.Grasp(score);
+// search.setKnowledge(this.knowledge);
+// search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+// search.bestOrder(score.getVariables());
+// search.setDepth(6);
+// search.setSingularDepth(1);
+// search.setNonSingularDepth(1);
+// return search.getGraph(true);
+// }
+ else if (meta == 2) {
+ Boss search = new Boss(score);
+ search.setAlgType(Boss.AlgType.BOSS1);
+ search.setKnowledge(new Knowledge((Knowledge) knowledge));
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ search.bestOrder(score.getVariables());
+ return search.getGraph(true);
+ }
+// else if (meta == 4) {
+// Boss search = new edu.cmu.tetrad.search.Boss(score);
+// search.setKnowledge(this.knowledge);
+// search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+// search.bestOrder(score.getVariables());
+// return search.getGraph();
+// }
+ else if (meta == 3) {
+ BridgesOld search = new edu.cmu.tetrad.search.BridgesOld(score);
+ search.setKnowledge(this.knowledge);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+ else {
+ throw new IllegalArgumentException("Unrecognized meta option: " + meta);
+ }
+ } else {
+ Images imagesSemBic = new Images();
+
+ List dataSets2 = new ArrayList<>();
+
+ for (DataModel dataModel : dataSets) {
+ dataSets2.add((DataSet) dataModel);
+ }
+
+ List _dataSets = new ArrayList<>();
+
+ if (parameters.getInt(Params.TIME_LAG) > 0) {
+ for (DataSet dataSet : dataSets2) {
+ DataSet timeSeries = TimeSeriesUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG));
+ if (dataSet.getName() != null) {
+ timeSeries.setName(dataSet.getName());
+ }
+ _dataSets.add(timeSeries);
+ }
+
+ dataSets2 = _dataSets;
+ }
+
+ GeneralResamplingTest search = new GeneralResamplingTest(
+ dataSets2,
+ imagesSemBic,
+ parameters.getInt(Params.NUMBER_RESAMPLING),
+ parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
+ parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ search.setKnowledge(dataSets.get(0).getKnowledge());
+ search.setScoreWrapper(score);
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph search(DataModel dataSet, Parameters parameters) {
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ return search(Collections.singletonList(DataUtils.getMixedDataSet(dataSet)), parameters);
+ } else {
+ Images images = new Images();
+
+ List dataSets = Collections.singletonList(DataUtils.getMixedDataSet(dataSet));
+ GeneralResamplingTest search = new GeneralResamplingTest(dataSets,
+ images,
+ parameters.getInt(Params.NUMBER_RESAMPLING),
+ parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
+ parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+// search.setKnowledge(this.knowledge);
+
+ if (score == null) {
+ System.out.println();
+ }
+
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ search.setScoreWrapper(score);
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph getComparisonGraph(Graph graph) {
+ return new EdgeListGraph(graph);
+ }
+
+ @Override
+ public String getDescription() {
+ return "IMaGES";
+ }
+
+ @Override
+ public DataType getDataType() {
+ return DataType.All;
+ }
+
+ @Override
+ public List getParameters() {
+ List parameters = new LinkedList<>();
+ parameters.addAll(new SemBicScore().getParameters());
+
+ parameters.addAll((new Fges()).getParameters());
+ parameters.add(Params.RANDOM_SELECTION_SIZE);
+ parameters.add(Params.TIME_LAG);
+ parameters.add(Params.IMAGES_META_ALG);
+
+ parameters.add(Params.VERBOSE);
+
+ return parameters;
+ }
+
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+ @Override
+ public ScoreWrapper getScoreWrapper() {
+ return this.score;
+ }
+
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+ this.score = score;
+ }
+}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesBDeu.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesBDeu.java
index 83ef36efdc..c08e0c9b68 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesBDeu.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesBDeu.java
@@ -3,9 +3,10 @@
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges;
import edu.cmu.tetrad.algcomparison.score.BdeuScore;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
-import edu.cmu.tetrad.annotation.AlgType;
import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.annotation.Experimental;
import edu.cmu.tetrad.data.*;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
@@ -29,17 +30,18 @@
*
* @author jdramsey
*/
-@edu.cmu.tetrad.annotation.Algorithm(
- name = "IMaGES Discrete",
- command = "imgs_disc",
- algoType = AlgType.forbid_latent_common_causes,
- dataType = DataType.Discrete
-)
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "IMaGES Discrete",
+// command = "imgs_disc",
+// algoType = AlgType.forbid_latent_common_causes,
+// dataType = DataType.Discrete
+//)
@Bootstrapping
+@Experimental
public class ImagesBDeu implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public ImagesBDeu() {
}
@@ -71,6 +73,7 @@ public Graph search(List dataSets, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -78,6 +81,11 @@ public Graph search(List dataSets, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -92,6 +100,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -127,12 +136,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesPcStableMax.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesPcStableMax.java
index bd00d4ad8d..d9b0a32d4e 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesPcStableMax.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesPcStableMax.java
@@ -1,6 +1,7 @@
package edu.cmu.tetrad.algcomparison.algorithm.multi;
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.annotation.Bootstrapping;
import edu.cmu.tetrad.data.*;
@@ -29,7 +30,7 @@
@Bootstrapping
public class ImagesPcStableMax implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public ImagesPcStableMax() {
}
@@ -67,6 +68,7 @@ public Graph search(List dataModels, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -74,6 +76,11 @@ public Graph search(List dataModels, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -88,6 +95,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -131,12 +139,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesSemBic.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesSemBic.java
index 2eb1f3c1bf..80f5d5bb81 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesSemBic.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/ImagesSemBic.java
@@ -2,10 +2,11 @@
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.algcomparison.score.SemBicScore;
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
-import edu.cmu.tetrad.annotation.AlgType;
import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.annotation.Experimental;
import edu.cmu.tetrad.data.*;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
@@ -29,17 +30,18 @@
*
* @author jdramsey
*/
-@edu.cmu.tetrad.annotation.Algorithm(
- name = "IMaGES Continuous",
- command = "imgs_cont",
- algoType = AlgType.forbid_latent_common_causes,
- dataType = DataType.Continuous
-)
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "IMaGES Continuous",
+// command = "imgs_cont",
+// algoType = AlgType.forbid_latent_common_causes,
+// dataType = DataType.Continuous
+//)
@Bootstrapping
+@Experimental
public class ImagesSemBic implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public ImagesSemBic() {
}
@@ -51,7 +53,7 @@ public Graph search(List dataSets, Parameters parameters) {
if (parameters.getInt(Params.TIME_LAG) > 0) {
for (DataModel dataSet : dataSets) {
- DataSet timeSeries = TimeSeriesUtils.createLagData((DataSet) dataSet, parameters.getInt(Params.TIME_LAG));
+ DataSet timeSeries = TimeSeriesUtils.createLagData((DataSet) dataSet, parameters.getInt(Params.TIME_LAG));
if (dataSet.getName() != null) {
timeSeries.setName(dataSet.getName());
}
@@ -71,22 +73,35 @@ public Graph search(List dataSets, Parameters parameters) {
} else {
ImagesSemBic imagesSemBic = new ImagesSemBic();
- List datasets = new ArrayList<>();
+ List dataSets2 = new ArrayList<>();
+ for (DataModel dataModel : dataSets) {
+ dataSets2.add((DataSet) dataModel);
+ }
+ List _dataSets = new ArrayList<>();
- for (DataModel dataModel : dataSets) {
- dataModel.setKnowledge(knowledge);
- datasets.add((DataSet) dataModel);
+ if (parameters.getInt(Params.TIME_LAG) > 0) {
+ for (DataModel dataSet : dataSets2) {
+ DataSet timeSeries = TimeSeriesUtils.createLagData((DataSet) dataSet, parameters.getInt(Params.TIME_LAG));
+ if (dataSet.getName() != null) {
+ timeSeries.setName(dataSet.getName());
+ }
+ _dataSets.add(timeSeries);
+ }
+
+ dataSets2 = _dataSets;
+ this.knowledge = _dataSets.get(0).getKnowledge();
}
GeneralResamplingTest search = new GeneralResamplingTest(
- datasets,
+ dataSets2,
imagesSemBic,
parameters.getInt(Params.NUMBER_RESAMPLING),
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -95,6 +110,11 @@ public Graph search(List dataSets, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -109,6 +129,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -147,12 +168,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/MultiFaskV1.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/MultiFaskV1.java
index 4400e486b9..f4e541e1c7 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/MultiFaskV1.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/MultiFaskV1.java
@@ -2,6 +2,7 @@
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
import edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag.Fges;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
import edu.cmu.tetrad.algcomparison.score.SemBicScore;
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.annotation.Bootstrapping;
@@ -39,7 +40,7 @@
public class MultiFaskV1 implements MultiDataSetAlgorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public MultiFaskV1() {
@@ -84,6 +85,7 @@ public Graph search(List dataSets, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -91,6 +93,11 @@ public Graph search(List dataSets, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -105,6 +112,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -142,12 +150,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/PcStableMaxConcatenated.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/PcStableMaxConcatenated.java
index d17e17e19c..0b231bc764 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/PcStableMaxConcatenated.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/multi/PcStableMaxConcatenated.java
@@ -3,6 +3,7 @@
import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
import edu.cmu.tetrad.algcomparison.algorithm.MultiDataSetAlgorithm;
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.annotation.Bootstrapping;
import edu.cmu.tetrad.data.*;
@@ -33,7 +34,7 @@ public class PcStableMaxConcatenated implements MultiDataSetAlgorithm, HasKnowle
private boolean compareToTrue;
private final IndependenceWrapper test;
private final Algorithm externalGraph = null;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public PcStableMaxConcatenated(IndependenceWrapper test, boolean compareToTrue) {
this.test = test;
@@ -77,6 +78,7 @@ public Graph search(List dataModels, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -84,6 +86,11 @@ public Graph search(List dataModels, Parameters parameters) {
}
}
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+
+ }
+
@Override
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
@@ -98,6 +105,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
+ search.setScoreWrapper(null);
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
@@ -144,13 +152,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java
index aeedad2943..703bc275cb 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS.java
@@ -9,10 +9,18 @@
import edu.cmu.tetrad.annotation.AlgType;
import edu.cmu.tetrad.annotation.Bootstrapping;
import edu.cmu.tetrad.annotation.Experimental;
-import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.data.DataModel;
+import edu.cmu.tetrad.data.DataSet;
+import edu.cmu.tetrad.data.DataType;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
-import edu.cmu.tetrad.search.*;
+import edu.cmu.tetrad.graph.Node;
+import edu.cmu.tetrad.graph.NodeType;
+import edu.cmu.tetrad.search.Boss;
+import edu.cmu.tetrad.search.IndependenceTest;
+import edu.cmu.tetrad.search.Score;
+import edu.cmu.tetrad.search.TimeSeriesUtils;
import edu.cmu.tetrad.util.Parameters;
import edu.cmu.tetrad.util.Params;
import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
@@ -21,7 +29,7 @@
import java.util.List;
/**
- * GRaSP (Greedy Relaxations of Sparsest Permutation)
+ * BOSS (Best Order Score Search)
*
* @author bryanandrews
* @author josephramsey
@@ -37,15 +45,19 @@ public class BOSS implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapp
static final long serialVersionUID = 23L;
private ScoreWrapper score;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public BOSS() {
// Used in reflection; do not delete.
}
- public BOSS(ScoreWrapper score, IndependenceWrapper test) {
- this.score = score;
+// public BOSS(ScoreWrapper score) {
+// this.score = score;
+// }
+
+ public BOSS(IndependenceWrapper test, ScoreWrapper score) {
this.test = test;
+ this.score = score;
}
@Override
@@ -64,28 +76,44 @@ public Graph search(DataModel dataModel, Parameters parameters) {
Score score = this.score.getScore(dataModel, parameters);
IndependenceTest test = this.test.getTest(dataModel, parameters);
- test.setVerbose(parameters.getBoolean(Params.VERBOSE));
Boss boss = new Boss(test, score);
- boss.setDepth(parameters.getInt(Params.GRASP_DEPTH));
- boss.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
- boss.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_VERMA_PEARL));
+ if (parameters.getInt(Params.BOSS_ALG) == 1) {
+ boss.setAlgType(Boss.AlgType.BOSS1);
+ } else if (parameters.getInt(Params.BOSS_ALG) == 2) {
+ boss.setAlgType(Boss.AlgType.BOSS2);
+ } else if (parameters.getInt(Params.BOSS_ALG) == 3) {
+ boss.setAlgType(Boss.AlgType.BOSS3);
+ } else {
+ throw new IllegalArgumentException("Unrecognized boss algorithm type.");
+ }
+
+ boss.setDepth(parameters.getInt(Params.DEPTH));
boss.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
+ boss.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
+ boss.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER));
boss.setVerbose(parameters.getBoolean(Params.VERBOSE));
- boss.setCacheScores(parameters.getBoolean(Params.CACHE_SCORES));
-
boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
+ boss.setCaching(parameters.getBoolean(Params.CACHE_SCORES));
+
boss.setKnowledge(this.knowledge);
- boss.bestOrder(score.getVariables());
- return boss.getGraph(parameters.getBoolean(Params.OUTPUT_CPDAG));
+
+ boss.bestOrder(new ArrayList(score.getVariables()));
+ return boss.getGraph(true);
} else {
- BOSS algorithm = new BOSS(this.score, this.test);
+ BOSS algorithm = new BOSS(this.test, this.score);
DataSet data = (DataSet) dataModel;
- GeneralResamplingTest search = new GeneralResamplingTest(data, algorithm, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ GeneralResamplingTest search = new GeneralResamplingTest(
+ data,
+ algorithm,
+ parameters.getInt(Params.NUMBER_RESAMPLING),
+ parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
+ parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT),
+ parameters.getInt(Params.RESAMPLING_ENSEMBLE),
+ parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
search.setKnowledge(this.knowledge);
-
search.setParameters(parameters);
search.setVerbose(parameters.getBoolean(Params.VERBOSE));
return search.search();
@@ -99,8 +127,7 @@ public Graph getComparisonGraph(Graph graph) {
@Override
public String getDescription() {
- return "BOSS (Better Order Score Search) using " + this.test.getDescription()
- + " or " + this.score.getDescription();
+ return "BOSS (Best Order Score Search) using " + this.score.getDescription();
}
@Override
@@ -113,15 +140,19 @@ public List getParameters() {
ArrayList params = new ArrayList<>();
// Flags
- params.add(Params.GRASP_DEPTH);
+ params.add(Params.BOSS_ALG);
+ params.add(Params.DEPTH);
params.add(Params.GRASP_USE_SCORE);
- params.add(Params.GRASP_USE_VERMA_PEARL);
+ params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
+ params.add(Params.TIME_LAG);
+ params.add(Params.CACHE_SCORES);
params.add(Params.VERBOSE);
// Parameters
params.add(Params.NUM_STARTS);
+
return params;
}
@@ -136,22 +167,22 @@ public void setScoreWrapper(ScoreWrapper score) {
}
@Override
- public IndependenceWrapper getIndependenceWrapper() {
- return this.test;
+ public Knowledge getKnowledge() {
+ return this.knowledge.copy();
}
@Override
- public void setIndependenceWrapper(IndependenceWrapper independenceWrapper) {
- this.test = independenceWrapper;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
- public IKnowledge getKnowledge() {
- return this.knowledge.copy();
+ public void setIndependenceWrapper(IndependenceWrapper test) {
+ this.test = test;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge.copy();
+ public IndependenceWrapper getIndependenceWrapper() {
+ return this.test;
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB.java
new file mode 100644
index 0000000000..cb6a7eb93e
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB.java
@@ -0,0 +1,144 @@
+package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag;
+
+import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
+import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
+import edu.cmu.tetrad.annotation.AlgType;
+import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.annotation.Experimental;
+import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.graph.EdgeListGraph;
+import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.graph.GraphUtils;
+import edu.cmu.tetrad.graph.Node;
+import edu.cmu.tetrad.search.BossMB;
+import edu.cmu.tetrad.search.Score;
+import edu.cmu.tetrad.util.Parameters;
+import edu.cmu.tetrad.util.Params;
+import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * BOSS-MB.
+ *
+ * @author jdramsey
+ */
+@edu.cmu.tetrad.annotation.Algorithm(
+ name = "BOSS-MB",
+ command = "boss-mb",
+ algoType = AlgType.search_for_Markov_blankets
+)
+@Bootstrapping
+@Experimental
+public class BOSS_MB implements Algorithm, HasKnowledge, UsesScoreWrapper {
+
+ static final long serialVersionUID = 23L;
+ private ScoreWrapper score;
+ private Knowledge knowledge = new Knowledge();
+ private String targets;
+
+ public BOSS_MB() {
+ }
+
+ public BOSS_MB(ScoreWrapper score) {
+ this.score = score;
+ }
+
+ @Override
+ public Graph search(DataModel dataSet, Parameters parameters) {
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ this.targets = parameters.getString(Params.TARGETS);
+
+ String[] tokens = this.targets.split(",");
+ List targets = new ArrayList<>();
+
+ Score score = this.score.getScore(dataSet, parameters);
+
+ for (String t : tokens) {
+ String name = t.trim();
+ targets.add(score.getVariable(name));
+ }
+
+
+ BossMB boss = new BossMB(score);
+
+ boss.setDepth(parameters.getInt(Params.GRASP_DEPTH));
+ boss.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
+ boss.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ boss.setFindMb(parameters.getBoolean(Params.MB));
+
+ boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
+ boss.setKnowledge(this.knowledge);
+
+ boss.bestOrder(score.getVariables(), targets);
+ return boss.getGraph();
+ } else {
+ BOSS_MB fgesMb = new BOSS_MB(this.score);
+
+ DataSet data = (DataSet) dataSet;
+ GeneralResamplingTest search = new GeneralResamplingTest(data, fgesMb, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ search.setKnowledge(this.knowledge);
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph getComparisonGraph(Graph graph) {
+ Node target = graph.getNode(this.targets);
+ return GraphUtils.markovBlanketDag(target, new EdgeListGraph(graph));
+ }
+
+ @Override
+ public String getDescription() {
+ return "BOSS-MB using " + this.score.getDescription();
+ }
+
+ @Override
+ public DataType getDataType() {
+ return this.score.getDataType();
+ }
+
+ @Override
+ public List getParameters() {
+ List params = new ArrayList<>();
+ params.add(Params.TARGETS);
+ params.add(Params.MB);
+
+ // Flags
+ params.add(Params.GRASP_DEPTH);
+ params.add(Params.GRASP_USE_DATA_ORDER);
+ params.add(Params.CACHE_SCORES);
+ params.add(Params.VERBOSE);
+
+ // Parameters
+ params.add(Params.NUM_STARTS);
+
+ return params;
+ }
+
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+ @Override
+ public ScoreWrapper getScoreWrapper() {
+ return this.score;
+ }
+
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+ this.score = score;
+ }
+
+}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB2.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB2.java
new file mode 100644
index 0000000000..63a4595c03
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSS_MB2.java
@@ -0,0 +1,117 @@
+package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag;
+
+import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
+import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
+import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.graph.EdgeListGraph;
+import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.search.BossMB2;
+import edu.cmu.tetrad.search.Score;
+import edu.cmu.tetrad.util.Parameters;
+import edu.cmu.tetrad.util.Params;
+import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+
+import java.util.ArrayList;
+import java.util.List;
+
+///**
+// * BOSS-MB.
+// *
+// * @author jdramsey
+// */
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "BOSS-MB2",
+// command = "boss-mb2",
+// algoType = AlgType.search_for_Markov_blankets
+//)
+//@Bootstrapping
+//@Experimental
+public class BOSS_MB2 implements Algorithm, HasKnowledge, UsesScoreWrapper {
+
+ static final long serialVersionUID = 23L;
+ private ScoreWrapper score;
+ private Knowledge knowledge = new Knowledge();
+
+ public BOSS_MB2() {
+ }
+
+ public BOSS_MB2(ScoreWrapper score) {
+ this.score = score;
+ }
+
+ @Override
+ public Graph search(DataModel dataSet, Parameters parameters) {
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ Score score = this.score.getScore(dataSet, parameters);
+
+ BossMB2 boss = new BossMB2(score);
+
+ boss.setDepth(parameters.getInt(Params.DEPTH));
+ boss.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ boss.setFindMb(parameters.getBoolean(Params.MB));
+ boss.setKnowledge(this.knowledge);
+
+ return boss.search(score.getVariables());
+ } else {
+ BOSS_MB2 fgesMb = new BOSS_MB2(this.score);
+
+ DataSet data = (DataSet) dataSet;
+ GeneralResamplingTest search = new GeneralResamplingTest(data, fgesMb, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ search.setKnowledge(this.knowledge);
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph getComparisonGraph(Graph graph) {
+ return new EdgeListGraph(graph);
+ }
+
+ @Override
+ public String getDescription() {
+ return "BOSS-MB2 using " + this.score.getDescription();
+ }
+
+ @Override
+ public DataType getDataType() {
+ return this.score.getDataType();
+ }
+
+ @Override
+ public List getParameters() {
+ List params = new ArrayList<>();
+ params.add(Params.MB);
+
+ // Flags
+ params.add(Params.DEPTH);
+ params.add(Params.CACHE_SCORES);
+ params.add(Params.VERBOSE);
+
+ return params;
+ }
+
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+ @Override
+ public ScoreWrapper getScoreWrapper() {
+ return this.score;
+ }
+
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+ this.score = score;
+ }
+
+}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES.java
new file mode 100644
index 0000000000..aa32db3379
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES.java
@@ -0,0 +1,152 @@
+package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag;
+
+import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
+import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
+import edu.cmu.tetrad.annotation.AlgType;
+import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.annotation.Experimental;
+import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.graph.EdgeListGraph;
+import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.search.Bridges;
+import edu.cmu.tetrad.search.Score;
+import edu.cmu.tetrad.search.TimeSeriesUtils;
+import edu.cmu.tetrad.util.Parameters;
+import edu.cmu.tetrad.util.Params;
+import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FGES (the heuristic version).
+ *
+ * @author jdramsey
+ */
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "BRIDGES",
+// command = "bridges",
+// algoType = AlgType.forbid_latent_common_causes
+//)
+//@Bootstrapping
+//@Experimental
+public class BRIDGES implements Algorithm, HasKnowledge, UsesScoreWrapper {
+
+ static final long serialVersionUID = 23L;
+
+ private ScoreWrapper score;
+ private Knowledge knowledge = new Knowledge();
+
+ public BRIDGES() {
+
+ }
+
+ public BRIDGES(ScoreWrapper score) {
+ this.score = score;
+ }
+
+ @Override
+ public Graph search(DataModel dataModel, Parameters parameters) {
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ if (parameters.getInt(Params.TIME_LAG) > 0) {
+ DataSet dataSet = (DataSet) dataModel;
+ DataSet timeSeries = TimeSeriesUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG));
+ if (dataSet.getName() != null) {
+ timeSeries.setName(dataSet.getName());
+ }
+ dataModel = timeSeries;
+ knowledge = timeSeries.getKnowledge();
+ }
+
+ Score score = this.score.getScore(dataModel, parameters);
+ Graph graph;
+
+ Bridges search
+ = new Bridges(score);
+ search.setKnowledge(this.knowledge);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ search.setMeekVerbose(parameters.getBoolean(Params.MEEK_VERBOSE));
+ search.setMaxDegree(parameters.getInt(Params.MAX_DEGREE));
+ search.setSymmetricFirstStep(parameters.getBoolean(Params.SYMMETRIC_FIRST_STEP));
+ search.setFaithfulnessAssumed(parameters.getBoolean(Params.FAITHFULNESS_ASSUMED));
+ search.setParallelized(parameters.getBoolean(Params.PARALLELIZED));
+ search.setDepth(parameters.getInt(Params.DEPTH));
+
+ Object obj = parameters.get(Params.PRINT_STREAM);
+ if (obj instanceof PrintStream) {
+ search.setOut((PrintStream) obj);
+ }
+
+ graph = search.search();
+
+ return graph;
+ } else {
+ BRIDGES fges = new BRIDGES(this.score);
+
+ DataSet data = (DataSet) dataModel;
+ GeneralResamplingTest search = new GeneralResamplingTest(
+ data, fges, parameters.getInt(Params.NUMBER_RESAMPLING),
+ parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
+ parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ search.setKnowledge(this.knowledge);
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph getComparisonGraph(Graph graph) {
+ return new EdgeListGraph(graph);
+ }
+
+ @Override
+ public String getDescription() {
+ return "BRIDGES using " + this.score.getDescription();
+ }
+
+ @Override
+ public DataType getDataType() {
+ return this.score.getDataType();
+ }
+
+ @Override
+ public List getParameters() {
+ List parameters = new ArrayList<>();
+ parameters.add(Params.SYMMETRIC_FIRST_STEP);
+ parameters.add(Params.MAX_DEGREE);
+ parameters.add(Params.PARALLELIZED);
+ parameters.add(Params.FAITHFULNESS_ASSUMED);
+ parameters.add(Params.TIME_LAG);
+ parameters.add(Params.DEPTH);
+
+ parameters.add(Params.VERBOSE);
+ parameters.add(Params.MEEK_VERBOSE);
+
+ return parameters;
+ }
+
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+ @Override
+ public ScoreWrapper getScoreWrapper() {
+ return this.score;
+ }
+
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+ this.score = score;
+ }
+
+}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES2.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES2.java
new file mode 100644
index 0000000000..5ea5bb1e8c
--- /dev/null
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES2.java
@@ -0,0 +1,145 @@
+package edu.cmu.tetrad.algcomparison.algorithm.oracle.cpdag;
+
+import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
+import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
+import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
+import edu.cmu.tetrad.annotation.AlgType;
+import edu.cmu.tetrad.annotation.Bootstrapping;
+import edu.cmu.tetrad.annotation.Experimental;
+import edu.cmu.tetrad.data.*;
+import edu.cmu.tetrad.graph.EdgeListGraph;
+import edu.cmu.tetrad.graph.Graph;
+import edu.cmu.tetrad.search.Bridges2;
+import edu.cmu.tetrad.search.Score;
+import edu.cmu.tetrad.search.TimeSeriesUtils;
+import edu.cmu.tetrad.util.Parameters;
+import edu.cmu.tetrad.util.Params;
+import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * FGES (the heuristic version).
+ *
+ * @author jdramsey
+ */
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "BRIDGES2",
+// command = "bridges2",
+// algoType = AlgType.forbid_latent_common_causes
+//)
+//@Bootstrapping
+//@Experimental
+public class BRIDGES2 implements Algorithm, HasKnowledge, UsesScoreWrapper {
+
+ static final long serialVersionUID = 23L;
+
+ private ScoreWrapper score;
+ private Knowledge knowledge = new Knowledge();
+
+ public BRIDGES2() {
+
+ }
+
+ public BRIDGES2(ScoreWrapper score) {
+ this.score = score;
+ }
+
+ @Override
+ public Graph search(DataModel dataModel, Parameters parameters) {
+ if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
+ if (parameters.getInt(Params.TIME_LAG) > 0) {
+ DataSet dataSet = (DataSet) dataModel;
+ DataSet timeSeries = TimeSeriesUtils.createLagData(dataSet, parameters.getInt(Params.TIME_LAG));
+ if (dataSet.getName() != null) {
+ timeSeries.setName(dataSet.getName());
+ }
+ dataModel = timeSeries;
+ knowledge = timeSeries.getKnowledge();
+ }
+
+ Score score = this.score.getScore(dataModel, parameters);
+ Graph graph;
+
+ Bridges2 search = new Bridges2(score);
+ search.setKnowledge(this.knowledge);
+ search.setMaxDegree(parameters.getInt(Params.MAX_DEGREE));
+
+ Object obj = parameters.get(Params.PRINT_STREAM);
+ if (obj instanceof PrintStream) {
+ search.setOut((PrintStream) obj);
+ }
+
+ graph = search.search();
+
+ return graph;
+ } else {
+ BRIDGES2 fges = new BRIDGES2(this.score);
+
+ DataSet data = (DataSet) dataModel;
+ GeneralResamplingTest search = new GeneralResamplingTest(
+ data, fges, parameters.getInt(Params.NUMBER_RESAMPLING),
+ parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE),
+ parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
+ search.setKnowledge(this.knowledge);
+ search.setParameters(parameters);
+ search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ return search.search();
+ }
+ }
+
+ @Override
+ public Graph getComparisonGraph(Graph graph) {
+ return new EdgeListGraph(graph);
+ }
+
+ @Override
+ public String getDescription() {
+ return "BRIDGES using " + this.score.getDescription();
+ }
+
+ @Override
+ public DataType getDataType() {
+ return this.score.getDataType();
+ }
+
+ @Override
+ public List getParameters() {
+ List parameters = new ArrayList<>();
+ parameters.add(Params.SYMMETRIC_FIRST_STEP);
+ parameters.add(Params.MAX_DEGREE);
+ parameters.add(Params.PARALLELIZED);
+ parameters.add(Params.FAITHFULNESS_ASSUMED);
+ parameters.add(Params.TIME_LAG);
+ parameters.add(Params.DEPTH);
+
+ parameters.add(Params.VERBOSE);
+ parameters.add(Params.MEEK_VERBOSE);
+
+ return parameters;
+ }
+
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+ @Override
+ public ScoreWrapper getScoreWrapper() {
+ return this.score;
+ }
+
+ @Override
+ public void setScoreWrapper(ScoreWrapper score) {
+ this.score = score;
+ }
+
+}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/rGES.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES_OLD.java
similarity index 68%
rename from tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/rGES.java
rename to tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES_OLD.java
index cdca1f0503..d6e980b477 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/rGES.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BRIDGES_OLD.java
@@ -2,15 +2,17 @@
import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
import edu.cmu.tetrad.annotation.AlgType;
import edu.cmu.tetrad.annotation.Bootstrapping;
import edu.cmu.tetrad.annotation.Experimental;
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.data.DataType;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
-import edu.cmu.tetrad.search.Rges;
+import edu.cmu.tetrad.search.BridgesOld;
import edu.cmu.tetrad.search.Score;
import edu.cmu.tetrad.util.Parameters;
import edu.cmu.tetrad.util.Params;
@@ -20,26 +22,29 @@
import java.util.List;
/**
- * rGES (experimental algorithm).
+ * BRIDGES (experimental algorithm).
*
* @author bryanandrews
*/
-@edu.cmu.tetrad.annotation.Algorithm(
- name = "rGES",
- command = "rges",
- algoType = AlgType.forbid_latent_common_causes
-)
-@Bootstrapping
-@Experimental
-public class rGES implements Algorithm, UsesScoreWrapper {
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "BRIDGES_OLD",
+// command = "bridges-old",
+// algoType = AlgType.forbid_latent_common_causes
+//)
+//@Bootstrapping
+//@Experimental
+public class BRIDGES_OLD implements Algorithm, HasKnowledge, UsesScoreWrapper {
static final long serialVersionUID = 23L;
private ScoreWrapper score;
- public rGES() {}
+ private Knowledge knowledge = new Knowledge();
- public rGES(ScoreWrapper score) {
+
+ public BRIDGES_OLD() {}
+
+ public BRIDGES_OLD(ScoreWrapper score) {
this.score = score;
}
@@ -49,8 +54,10 @@ public Graph search(DataModel dataModel, Parameters parameters) {
Score score = this.score.getScore(dataModel, parameters);
Graph graph;
- Rges search = new Rges(score);
- search.setVerbose(parameters.getBoolean(Params.VERBOSE));
+ BridgesOld search = new BridgesOld(score);
+// search.setKnowledge(knowledge);
+ search.setVerbose(false);
+// search.setVerbose(parameters.getBoolean(Params.VERBOSE));
search.setMaxDegree(parameters.getInt(Params.MAX_DEGREE));
search.setSymmetricFirstStep(parameters.getBoolean(Params.SYMMETRIC_FIRST_STEP));
search.setFaithfulnessAssumed(parameters.getBoolean(Params.FAITHFULNESS_ASSUMED));
@@ -74,7 +81,7 @@ public Graph getComparisonGraph(Graph graph) {
@Override
public String getDescription() {
- return "rGES (r Greedy Equivalence Search) using " + this.score.getDescription();
+ return "BRIDGES_OLD (BRIDGES is not Restricted to Imaps During Greedy Equivalent Search) using " + this.score.getDescription();
}
@Override
@@ -104,4 +111,15 @@ public void setScoreWrapper(ScoreWrapper score) {
this.score = score;
}
+ @Override
+ public Knowledge getKnowledge() {
+ return this.knowledge;
+ }
+
+ @Override
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
+ }
+
+
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java
index a2cf005949..6fd3bfb93f 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CPC.java
@@ -34,7 +34,7 @@ public class CPC implements Algorithm, HasKnowledge, TakesIndependenceWrapper {
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public CPC() {
}
@@ -145,13 +145,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CpcStable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CpcStable.java
index 87b9f68414..af3a64c634 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CpcStable.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/CpcStable.java
@@ -28,7 +28,7 @@ public class CpcStable implements Algorithm, HasKnowledge, TakesIndependenceWrap
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
private Algorithm algorithm;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public CpcStable() {
}
@@ -93,13 +93,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FAS.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FAS.java
index bcedfd0d40..241beb50d1 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FAS.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FAS.java
@@ -34,7 +34,7 @@ public class FAS implements Algorithm, HasKnowledge, TakesIndependenceWrapper {
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public FAS() {
}
@@ -98,13 +98,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Fges.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Fges.java
index 9eac885510..bac789e847 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Fges.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Fges.java
@@ -35,7 +35,7 @@ public class Fges implements Algorithm, HasKnowledge, UsesScoreWrapper {
static final long serialVersionUID = 23L;
private ScoreWrapper score;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public Fges() {
@@ -125,13 +125,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
@@ -144,4 +144,4 @@ public void setScoreWrapper(ScoreWrapper score) {
this.score = score;
}
-}
+}
\ No newline at end of file
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMb.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMb.java
index 2994e8c1f7..1ea423191a 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMb.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMb.java
@@ -36,7 +36,7 @@ public class FgesMb implements Algorithm, HasKnowledge, UsesScoreWrapper {
static final long serialVersionUID = 23L;
private ScoreWrapper score;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
private String targetName;
public FgesMb() {
@@ -105,13 +105,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMeasurement.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMeasurement.java
index e199684593..7f3c5b0c96 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMeasurement.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/FgesMeasurement.java
@@ -28,7 +28,7 @@ public class FgesMeasurement implements Algorithm, HasKnowledge {
static final long serialVersionUID = 23L;
private final ScoreWrapper score;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public FgesMeasurement(ScoreWrapper score) {
this.score = score;
@@ -104,13 +104,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSP.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSP.java
index b68dac29d7..1fa2a94dfe 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSP.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSP.java
@@ -38,7 +38,7 @@ public class GRaSP implements Algorithm, UsesScoreWrapper, TakesIndependenceWrap
static final long serialVersionUID = 23L;
private ScoreWrapper score;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public GRaSP() {
// Used in reflection; do not delete.
@@ -73,7 +73,7 @@ public Graph search(DataModel dataModel, Parameters parameters) {
grasp.setNonSingularDepth(parameters.getInt(Params.GRASP_NONSINGULAR_DEPTH));
grasp.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG));
grasp.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
- grasp.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_VERMA_PEARL));
+ grasp.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER));
grasp.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
grasp.setVerbose(parameters.getBoolean(Params.VERBOSE));
grasp.setCacheScores(parameters.getBoolean(Params.CACHE_SCORES));
@@ -121,7 +121,7 @@ public List getParameters() {
params.add(Params.GRASP_SINGULAR_DEPTH);
params.add(Params.GRASP_NONSINGULAR_DEPTH);
params.add(Params.GRASP_ORDERED_ALG);
- params.add(Params.GRASP_USE_VERMA_PEARL);
+ params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
params.add(Params.CACHE_SCORES);
params.add(Params.TIME_LAG);
@@ -154,12 +154,12 @@ public void setIndependenceWrapper(IndependenceWrapper independenceWrapper) {
}
@Override
- public IKnowledge getKnowledge() {
- return this.knowledge.copy();
+ public Knowledge getKnowledge() {
+ return new Knowledge((Knowledge) knowledge);
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge.copy();
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSPTol.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSPTol.java
index 98e5a26ddd..76af4772a3 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSPTol.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GRaSPTol.java
@@ -37,7 +37,7 @@ public class GRaSPTol implements Algorithm, UsesScoreWrapper, TakesIndependenceW
static final long serialVersionUID = 23L;
private ScoreWrapper score;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public GRaSPTol() {
// Used in reflection; do not delete.
@@ -72,7 +72,7 @@ public Graph search(DataModel dataModel, Parameters parameters) {
grasp.setNonSingularDepth(parameters.getInt(Params.GRASP_NONSINGULAR_DEPTH));
grasp.setOrdered(parameters.getBoolean(Params.GRASP_ORDERED_ALG));
grasp.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
- grasp.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_VERMA_PEARL));
+ grasp.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_RASKUTTI_UHLER));
grasp.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
grasp.setToleranceDepth(parameters.getInt(Params.GRASP_TOLERANCE_DEPTH));
grasp.setAllowRandomnessInsideAlgorithm(parameters.getBoolean(Params.GRASP_ALLOW_RANDOMNESS_INSIDE_ALGORITHM));
@@ -104,7 +104,7 @@ public Graph getComparisonGraph(Graph graph) {
@Override
public String getDescription() {
- return "GRaSP (Greedy Relaxed Sparsest Permutation) using " + this.test.getDescription()
+ return "GRaSPTol (Greedy Relaxed Sparsest Permutation Tolerance) using " + this.test.getDescription()
+ " or " + this.score.getDescription();
}
@@ -124,7 +124,7 @@ public List getParameters() {
params.add(Params.GRASP_TOLERANCE_DEPTH);
params.add(Params.GRASP_ORDERED_ALG);
// params.add(Params.GRASP_USE_SCORE);
- params.add(Params.GRASP_USE_VERMA_PEARL);
+ params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
params.add(Params.GRASP_ALLOW_RANDOMNESS_INSIDE_ALGORITHM);
params.add(Params.CACHE_SCORES);
@@ -158,12 +158,12 @@ public void setIndependenceWrapper(IndependenceWrapper independenceWrapper) {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge.copy();
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge.copy();
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GesMe.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GesMe.java
index 396f879f5c..71ba828462 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GesMe.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/GesMe.java
@@ -117,7 +117,7 @@ public Graph search(DataModel dataSet, Parameters parameters) {
leaves.add(nodes.get(indices.get(i)));
}
- IKnowledge knowledge2 = new Knowledge2();
+ Knowledge knowledge2 = new Knowledge();
for (Node v : nodes) {
if (leaves.contains(v)) {
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC.java
index 5223d21f71..8785942255 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC.java
@@ -34,7 +34,7 @@ public class PC implements Algorithm, HasKnowledge, TakesIndependenceWrapper {
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public PC() {
}
@@ -146,13 +146,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PCMAX.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PCMAX.java
index a9025143e6..b22dae777c 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PCMAX.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PCMAX.java
@@ -34,7 +34,7 @@ public class PCMAX implements Algorithm, HasKnowledge, TakesIndependenceWrapper
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public PCMAX() {
}
@@ -147,13 +147,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/MBFS.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC_MB.java
similarity index 65%
rename from tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/MBFS.java
rename to tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC_MB.java
index ae246fb7e4..c10bffc161 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/MBFS.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PC_MB.java
@@ -12,9 +12,11 @@
import edu.cmu.tetrad.graph.GraphUtils;
import edu.cmu.tetrad.graph.Node;
import edu.cmu.tetrad.search.IndependenceTest;
+import edu.cmu.tetrad.search.PcMb;
import edu.cmu.tetrad.util.Parameters;
import edu.cmu.tetrad.util.Params;
import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
+import org.jetbrains.annotations.NotNull;
import java.util.ArrayList;
import java.util.List;
@@ -25,22 +27,22 @@
* @author jdramsey
*/
@edu.cmu.tetrad.annotation.Algorithm(
- name = "MBFS",
- command = "mbfs",
+ name = "PC-MB",
+ command = "pc-mb",
algoType = AlgType.search_for_Markov_blankets
)
@Bootstrapping
-public class MBFS implements Algorithm, HasKnowledge, TakesIndependenceWrapper {
+public class PC_MB implements Algorithm, HasKnowledge, TakesIndependenceWrapper {
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
- private String targetName;
+ private Knowledge knowledge = new Knowledge();
+ private List targets;
- public MBFS() {
+ public PC_MB() {
}
- public MBFS(IndependenceWrapper type) {
+ public PC_MB(IndependenceWrapper type) {
this.test = type;
}
@@ -48,24 +50,15 @@ public MBFS(IndependenceWrapper type) {
public Graph search(DataModel dataSet, Parameters parameters) {
if (parameters.getInt(Params.NUMBER_RESAMPLING) < 1) {
IndependenceTest test = this.test.getTest(dataSet, parameters);
- edu.cmu.tetrad.search.Mbfs search = new edu.cmu.tetrad.search.Mbfs(test, parameters.getInt(Params.DEPTH));
-
+ PcMb search = new PcMb(test, parameters.getInt(Params.DEPTH));
+ List targets = targets(test, parameters.getString(Params.TARGETS));
+ this.targets = targets;
search.setDepth(parameters.getInt(Params.DEPTH));
search.setKnowledge(this.knowledge);
-
- this.targetName = parameters.getString(Params.TARGET_NAME);
- if (this.targetName.isEmpty()) {
- throw new IllegalArgumentException("Target variable name needs to be provided.");
- }
-
- if (test.getVariable(this.targetName) == null) {
- throw new IllegalArgumentException("Target variable name '" + this.targetName + "' not found in dataset.");
- }
-
- Node target = test.getVariable(this.targetName);
- return search.search(target.getName());
+ search.setFindMb(parameters.getBoolean(Params.MB));
+ return search.search(targets);
} else {
- MBFS algorithm = new MBFS(this.test);
+ PC_MB algorithm = new PC_MB(this.test);
DataSet data = (DataSet) dataSet;
GeneralResamplingTest search = new GeneralResamplingTest(data, algorithm, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
@@ -77,15 +70,26 @@ public Graph search(DataModel dataSet, Parameters parameters) {
}
}
+ @NotNull
+ private List targets(IndependenceTest test, String targetString) {
+ String[] tokens = targetString.split(",");
+ List targets = new ArrayList<>();
+
+ for (String t : tokens) {
+ String name = t.trim();
+ targets.add(test.getVariable(name));
+ }
+ return targets;
+ }
+
@Override
public Graph getComparisonGraph(Graph graph) {
- Node target = graph.getNode(this.targetName);
- return GraphUtils.markovBlanketDag(target, new EdgeListGraph(graph));
+ return GraphUtils.markovBlanketDag(targets.get(0), new EdgeListGraph(graph));
}
@Override
public String getDescription() {
- return "MBFS (Markov Blanket Fan Search) using " + this.test.getDescription();
+ return "PC-MB (Markov blanket search using PC) using " + this.test.getDescription();
}
@Override
@@ -96,21 +100,22 @@ public DataType getDataType() {
@Override
public List getParameters() {
List parameters = new ArrayList<>();
+ parameters.add(Params.TARGETS);
+ parameters.add(Params.MB);
parameters.add(Params.DEPTH);
- parameters.add(Params.TARGET_NAME);
parameters.add(Params.VERBOSE);
return parameters;
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcAll.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcAll.java
index 67e77955fe..122593ac79 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcAll.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcAll.java
@@ -34,7 +34,7 @@ public class PcAll implements Algorithm, HasKnowledge, TakesIndependenceWrapper
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public PcAll() {
}
@@ -147,13 +147,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcStable.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcStable.java
index 0e779cc049..be8c1ec2f9 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcStable.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/PcStable.java
@@ -27,7 +27,7 @@ public class PcStable implements Algorithm, HasKnowledge, TakesIndependenceWrapp
static final long serialVersionUID = 23L;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public PcStable() {
}
@@ -87,13 +87,13 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
@Override
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pcd.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pcd.java
index 6ac4bbf536..8abc4cd458 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pcd.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/Pcd.java
@@ -23,7 +23,7 @@
@Bootstrapping
public class Pcd implements Algorithm, HasKnowledge {
static final long serialVersionUID = 23L;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
public Pcd() {
}
@@ -93,12 +93,12 @@ public List getParameters() {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge;
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge;
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSTuck.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SIMPLE_DEMO_GA.java
similarity index 69%
rename from tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSTuck.java
rename to tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SIMPLE_DEMO_GA.java
index 79763214bc..d6a1cda905 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/BOSSTuck.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SIMPLE_DEMO_GA.java
@@ -6,9 +6,6 @@
import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper;
import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
-import edu.cmu.tetrad.annotation.AlgType;
-import edu.cmu.tetrad.annotation.Bootstrapping;
-import edu.cmu.tetrad.annotation.Experimental;
import edu.cmu.tetrad.data.*;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
@@ -26,24 +23,24 @@
* @author bryanandrews
* @author josephramsey
*/
-@edu.cmu.tetrad.annotation.Algorithm(
- name = "BOSSTuck",
- command = "boss-tuck",
- algoType = AlgType.forbid_latent_common_causes
-)
-@Bootstrapping
-@Experimental
-public class BOSSTuck implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, HasKnowledge {
+//@edu.cmu.tetrad.annotation.Algorithm(
+// name = "SIMPLE_DEMO_GA",
+// command = "simple-demo-ga",
+// algoType = AlgType.forbid_latent_common_causes
+//)
+//@Bootstrapping
+//@Experimental
+public class SIMPLE_DEMO_GA implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, HasKnowledge {
static final long serialVersionUID = 23L;
private ScoreWrapper score;
private IndependenceWrapper test;
- private IKnowledge knowledge = new Knowledge2();
+ private Knowledge knowledge = new Knowledge();
- public BOSSTuck() {
+ public SIMPLE_DEMO_GA() {
// Used in reflection; do not delete.
}
- public BOSSTuck(ScoreWrapper score, IndependenceWrapper test) {
+ public SIMPLE_DEMO_GA(ScoreWrapper score, IndependenceWrapper test) {
this.score = score;
this.test = test;
}
@@ -65,21 +62,10 @@ public Graph search(DataModel dataModel, Parameters parameters) {
IndependenceTest test = this.test.getTest(dataModel, parameters);
test.setVerbose(parameters.getBoolean(Params.VERBOSE));
- BossTuck boss = new BossTuck(test, score);
-
- boss.setDepth(parameters.getInt(Params.GRASP_DEPTH));
- boss.setUseScore(parameters.getBoolean(Params.GRASP_USE_SCORE));
- boss.setUseRaskuttiUhler(parameters.getBoolean(Params.GRASP_USE_VERMA_PEARL));
- boss.setUseDataOrder(parameters.getBoolean(Params.GRASP_USE_DATA_ORDER));
- boss.setVerbose(parameters.getBoolean(Params.VERBOSE));
- boss.setCacheScores(parameters.getBoolean(Params.CACHE_SCORES));
-
- boss.setNumStarts(parameters.getInt(Params.NUM_STARTS));
- boss.setKnowledge(this.knowledge);
- boss.bestOrder(score.getVariables());
- return boss.getGraph(parameters.getBoolean(Params.OUTPUT_CPDAG));
+ SimpleDemoGA boss = new SimpleDemoGA(score, 10);
+ return boss.search();
} else {
- BOSSTuck algorithm = new BOSSTuck(this.score, this.test);
+ SIMPLE_DEMO_GA algorithm = new SIMPLE_DEMO_GA(this.score, this.test);
DataSet data = (DataSet) dataModel;
GeneralResamplingTest search = new GeneralResamplingTest(data, algorithm, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
@@ -99,7 +85,7 @@ public Graph getComparisonGraph(Graph graph) {
@Override
public String getDescription() {
- return "BOSS-tuck (Better Order Score Search) using " + this.test.getDescription()
+ return "SIMPLE_DEMO_GA using " + this.test.getDescription()
+ " or " + this.score.getDescription();
}
@@ -115,8 +101,9 @@ public List getParameters() {
// Flags
params.add(Params.GRASP_DEPTH);
params.add(Params.GRASP_USE_SCORE);
- params.add(Params.GRASP_USE_VERMA_PEARL);
+ params.add(Params.GRASP_USE_RASKUTTI_UHLER);
params.add(Params.GRASP_USE_DATA_ORDER);
+ params.add(Params.CACHE_SCORES);
params.add(Params.VERBOSE);
// Parameters
@@ -146,12 +133,12 @@ public void setIndependenceWrapper(IndependenceWrapper independenceWrapper) {
}
@Override
- public IKnowledge getKnowledge() {
+ public Knowledge getKnowledge() {
return this.knowledge.copy();
}
@Override
- public void setKnowledge(IKnowledge knowledge) {
- this.knowledge = knowledge.copy();
+ public void setKnowledge(Knowledge knowledge) {
+ this.knowledge = new Knowledge((Knowledge) knowledge);
}
}
diff --git a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SP.java b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SP.java
index 39c9997343..9d9ec7dd70 100644
--- a/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SP.java
+++ b/tetrad-lib/src/main/java/edu/cmu/tetrad/algcomparison/algorithm/oracle/cpdag/SP.java
@@ -3,6 +3,7 @@
import edu.cmu.tetrad.algcomparison.algorithm.Algorithm;
import edu.cmu.tetrad.algcomparison.independence.IndependenceWrapper;
import edu.cmu.tetrad.algcomparison.score.ScoreWrapper;
+import edu.cmu.tetrad.algcomparison.utils.HasKnowledge;
import edu.cmu.tetrad.algcomparison.utils.TakesIndependenceWrapper;
import edu.cmu.tetrad.algcomparison.utils.UsesScoreWrapper;
import edu.cmu.tetrad.annotation.AlgType;
@@ -10,12 +11,12 @@
import edu.cmu.tetrad.data.DataModel;
import edu.cmu.tetrad.data.DataSet;
import edu.cmu.tetrad.data.DataType;
+import edu.cmu.tetrad.data.Knowledge;
import edu.cmu.tetrad.graph.EdgeListGraph;
import edu.cmu.tetrad.graph.Graph;
import edu.cmu.tetrad.search.IndependenceTest;
import edu.cmu.tetrad.search.OtherPermAlgs;
import edu.cmu.tetrad.search.Score;
-import edu.cmu.tetrad.sem.Parameter;
import edu.cmu.tetrad.util.Parameters;
import edu.cmu.tetrad.util.Params;
import edu.pitt.dbmi.algo.resampling.GeneralResamplingTest;
@@ -34,18 +35,20 @@
algoType = AlgType.forbid_latent_common_causes
)
@Bootstrapping
-public class SP implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper {
+public class SP implements Algorithm, UsesScoreWrapper, TakesIndependenceWrapper, HasKnowledge {
static final long serialVersionUID = 23L;
private ScoreWrapper score = null;
private IndependenceWrapper test;
+ private Knowledge knowledge = new Knowledge();
+
public SP() {
// Used in reflection; do not delete.
}
- public SP(ScoreWrapper score, IndependenceWrapper test) {
- this.score = score;
+ public SP(IndependenceWrapper test, ScoreWrapper score) {
this.test = test;
+ this.score = score;
}
@Override
@@ -57,20 +60,12 @@ public Graph search(DataModel dataModel, Parameters parameters) {
test.setVerbose(parameters.getBoolean(Params.VERBOSE));
- OtherPermAlgs otherPermAlgs;
-
- otherPermAlgs = new OtherPermAlgs(test, score);
-
- OtherPermAlgs.Method method = OtherPermAlgs.Method.SP;
-
- otherPermAlgs.setMethod(method);
- otherPermAlgs.setUsePearl(parameters.getBoolean(Params.GRASP_USE_VERMA_PEARL));
- otherPermAlgs.setVerbose(parameters.getBoolean(Params.VERBOSE));
-
- otherPermAlgs.bestOrder(score.getVariables());
- return otherPermAlgs.getGraph(true);
+ edu.cmu.tetrad.search.SP sp = new edu.cmu.tetrad.search.SP(test, score);
+ sp.setKnowledge(knowledge);
+ sp.bestOrder(score.getVariables());
+ return sp.getGraph(true);
} else {
- GRaSP algorithm = new GRaSP(this.score, this.test);
+ SP algorithm = new SP(this.test, this.score);
DataSet data = (DataSet) dataModel;
GeneralResamplingTest search = new GeneralResamplingTest(data, algorithm, parameters.getInt(Params.NUMBER_RESAMPLING), parameters.getDouble(Params.PERCENT_RESAMPLE_SIZE), parameters.getBoolean(Params.RESAMPLING_WITH_REPLACEMENT), parameters.getInt(Params.RESAMPLING_ENSEMBLE), parameters.getBoolean(Params.ADD_ORIGINAL_DATASET));
@@ -99,7 +94,7 @@ public DataType getDataType() {
@Override
public List getParameters() {
ArrayList