Search in sources :

Example 1 with Scorer

use of edu.cmu.tetrad.sem.Scorer in project tetrad by cmu-phil.

the class PValueImproverEditor method setGraphWorkbench.

private void setGraphWorkbench(final GraphWorkbench graphWorkbench) {
    JTabbedPane tabbedPane = new JTabbedPane();
    this.graphWorkbench = graphWorkbench;
    if (getOriginalSemIm() != null) {
        setOriginalSemIm(new SemIm(getWrapper().getOriginalSemIm()));
    }
    this.newSemIm = getWrapper().getNewSemIm();
    if (getNewSemIm() != null) {
        SemImEditor newEditor = new SemImEditor(new SemImWrapper(getNewSemIm()));
        final GraphWorkbench workbench = newEditor.getWorkbench();
        workbench.addPropertyChangeListener(new PropertyChangeListener() {

            public void propertyChange(PropertyChangeEvent propertyChangeEvent) {
                if ("modelChanged".equals(propertyChangeEvent.getPropertyName())) {
                    System.out.println(propertyChangeEvent);
                    Graph graph = workbench.getGraph();
                    System.out.println(graph);
                    try {
                        new Dag(graph);
                    } catch (IllegalArgumentException e) {
                        return;
                    }
                    Scorer scorer = new DagScorer((DataSet) getWrapper().getDataModel());
                    scorer.score(graph);
                    getWrapper().setNewSemIm(scorer.getEstSem());
                    setGraphWorkbench(graphWorkbench);
                }
            }
        });
        tabbedPane.addTab("New Model", newEditor);
    }
    if (getOriginalSemIm() != null) {
        SemImEditor originalEditor = new SemImEditor(new SemImWrapper(getOriginalSemIm()));
        tabbedPane.addTab("Original Model", originalEditor);
    }
    if (graphWorkbench != null) {
        tabbedPane.addTab("forbid_latent_common_causes", graphWorkbench);
    }
    panel.removeAll();
    panel.add(tabbedPane, BorderLayout.CENTER);
    panel.revalidate();
    panel.repaint();
    firePropertyChange("modelChanged", null, null);
}
Also used : DagScorer(edu.cmu.tetrad.sem.DagScorer) PropertyChangeEvent(java.beans.PropertyChangeEvent) PropertyChangeListener(java.beans.PropertyChangeListener) DataSet(edu.cmu.tetrad.data.DataSet) Scorer(edu.cmu.tetrad.sem.Scorer) DagScorer(edu.cmu.tetrad.sem.DagScorer) Dag(edu.cmu.tetrad.graph.Dag) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) Graph(edu.cmu.tetrad.graph.Graph) GraphWorkbench(edu.cmu.tetradapp.workbench.GraphWorkbench) SemImWrapper(edu.cmu.tetradapp.model.SemImWrapper) SemIm(edu.cmu.tetrad.sem.SemIm)

Aggregations

DataSet (edu.cmu.tetrad.data.DataSet)1 Dag (edu.cmu.tetrad.graph.Dag)1 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)1 Graph (edu.cmu.tetrad.graph.Graph)1 DagScorer (edu.cmu.tetrad.sem.DagScorer)1 Scorer (edu.cmu.tetrad.sem.Scorer)1 SemIm (edu.cmu.tetrad.sem.SemIm)1 SemImWrapper (edu.cmu.tetradapp.model.SemImWrapper)1 GraphWorkbench (edu.cmu.tetradapp.workbench.GraphWorkbench)1 PropertyChangeEvent (java.beans.PropertyChangeEvent)1 PropertyChangeListener (java.beans.PropertyChangeListener)1