use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.
the class IonSearchEditor method layoutByKnowledge.
public void layoutByKnowledge() {
GraphWorkbench resultWorkbench = getWorkbench();
Graph graph = resultWorkbench.getGraph();
IKnowledge knowledge = (IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2());
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
// resultWorkbench.setGraph(graph);
}
use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.
the class IonSearchEditor method execute.
/**
* Executes the algorithm. The execution takes place inside a thread, so one
* cannot count on a result graph having been found when the method
*/
public void execute() {
Window owner = (Window) getTopLevelAncestor();
final WatchedProcess process = new WatchedProcess(owner) {
public void watch() {
getExecuteButton().setEnabled(false);
setErrorMessage(null);
if (!knowledgeMessageShown) {
Parameters searchParams = getAlgorithmRunner().getParams();
if (searchParams != null) {
IKnowledge knowledge = (IKnowledge) searchParams.get("knowledge", new Knowledge2());
if (!knowledge.isEmpty()) {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Using previously set knowledge. (To edit, use " + "the Knowledge menu.)");
knowledgeMessageShown = true;
}
}
}
try {
storeLatestWorkbenchGraph();
getAlgorithmRunner().execute();
IonRunner runner = (IonRunner) getAlgorithmRunner();
arrangeGraphs();
ionDisplay.resetGraphs(runner.getStoredGraphs());
} catch (Exception e) {
CharArrayWriter writer1 = new CharArrayWriter();
PrintWriter writer2 = new PrintWriter(writer1);
e.printStackTrace(writer2);
String message = writer1.toString();
writer2.close();
e.printStackTrace(System.out);
TetradLogger.getInstance().error(message);
String messageString = e.getMessage();
if (e.getCause() != null) {
messageString = e.getCause().getMessage();
}
if (messageString == null) {
messageString = message;
}
setErrorMessage(messageString);
TetradLogger.getInstance().error("************Algorithm stopped!");
getExecuteButton().setEnabled(true);
throw new RuntimeException(e);
}
getWorkbenchScroll().setBorder(new TitledBorder(getResultLabel()));
Graph resultGraph = resultGraph();
doDefaultArrangement(resultGraph);
getWorkbench().setBackground(Color.WHITE);
getWorkbench().setGraph(resultGraph);
getGraphHistory().clear();
getGraphHistory().add(resultGraph);
getWorkbench().repaint();
// For Mimbuild, e.g., that need to do a second stage.
firePropertyChange("algorithmFinished", null, null);
getExecuteButton().setEnabled(true);
firePropertyChange("modelChanged", null, null);
}
};
Thread watcher = new Thread() {
public void run() {
while (true) {
try {
sleep(300);
if (!process.isAlive()) {
getExecuteButton().setEnabled(true);
return;
}
} catch (InterruptedException e) {
getExecuteButton().setEnabled(true);
return;
}
}
}
};
watcher.start();
}
use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.
the class LingamSearchEditor method layoutByKnowledge.
public void layoutByKnowledge() {
GraphWorkbench resultWorkbench = getWorkbench();
Graph graph = resultWorkbench.getGraph();
IKnowledge knowledge = (IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2());
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
// resultWorkbench.setGraph(graph);
}
use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.
the class MarkovBlanketSearchEditor method execute.
// ===========================PRIVATE METHODS==========================//
/**
* Executes the algorithm. The execution takes place inside a thread, so one
* cannot count on a result graph having been found when the method
*/
private void execute() {
Window owner = (Window) getTopLevelAncestor();
final WatchedProcess process = new WatchedProcess(owner) {
public void watch() {
getExecuteButton().setEnabled(false);
setErrorMessage(null);
if (!knowledgeMessageShown) {
IKnowledge knowledge = (IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2());
if (!knowledge.isEmpty()) {
JOptionPane.showMessageDialog(JOptionUtils.centeringComp(), "Using previously set knowledge. (To edit, use " + "the Knowledge menu.)");
knowledgeMessageShown = true;
}
}
try {
getAlgorithmRunner().execute();
} catch (Exception e) {
CharArrayWriter writer1 = new CharArrayWriter();
PrintWriter writer2 = new PrintWriter(writer1);
e.printStackTrace(writer2);
String message = writer1.toString();
writer2.close();
e.printStackTrace(System.out);
TetradLogger.getInstance().error(message);
String messageString = e.getMessage();
if (e.getCause() != null) {
messageString = e.getCause().getMessage();
}
if (messageString == null) {
messageString = message;
}
setErrorMessage(messageString);
getExecuteButton().setEnabled(true);
throw new RuntimeException(e);
}
setLabel();
DataSet modelForMarkovBlanket = algorithmRunner.getDataModelForMarkovBlanket();
if (modelForMarkovBlanket != null) {
table.setDataSet(modelForMarkovBlanket);
}
table.repaint();
getExecuteButton().setEnabled(true);
}
};
// getWorkbenchScroll().setBorder(
// new TitledBorder(getResultLabel()));
// Graph resultGraph = resultGraph();
//
// doDefaultArrangement(resultGraph);
// getWorkbench().setBackground(Color.WHITE);
// getWorkbench().setGraph(resultGraph);
// getGraphHistory().clear();
// getGraphHistory().add(resultGraph);
// getWorkbench().repaint();
Thread watcher = new Thread() {
public void run() {
while (true) {
try {
sleep(300);
if (!process.isAlive()) {
getExecuteButton().setEnabled(true);
return;
}
} catch (InterruptedException e) {
getExecuteButton().setEnabled(true);
return;
}
}
}
};
watcher.start();
}
use of edu.cmu.tetrad.data.Knowledge2 in project tetrad by cmu-phil.
the class MbSearchEditor method layoutByKnowledge.
public void layoutByKnowledge() {
GraphWorkbench resultWorkbench = getWorkbench();
Graph graph = resultWorkbench.getGraph();
IKnowledge knowledge = (IKnowledge) getAlgorithmRunner().getParams().get("knowledge", new Knowledge2());
SearchGraphUtils.arrangeByKnowledgeTiers(graph, knowledge);
// resultWorkbench.setGraph(graph);
}
Aggregations