void storeLatestWorkbenchGraph() { Graph latestWorkbenchGraph = workbench.getGraph(); if (latestWorkbenchGraph.getNumNodes() == 0) { return; } SearchParams searchParams = algorithmRunner.getParams(); try { Graph graph = new MarshalledObject<Graph>(latestWorkbenchGraph).get(); if (graph == null) { throw new NullPointerException("Null graph"); } if (searchParams != null) { searchParams.setSourceGraph(graph); } } catch (IOException e) { e.printStackTrace(); if (searchParams != null) { searchParams.setSourceGraph(null); } } catch (ClassNotFoundException e) { if (searchParams != null) { searchParams.setSourceGraph(null); } e.printStackTrace(); } }
/** * Provides methods for estimating a Bayes IM from an existing BayesIM and a discrete dataset * using EM (Expectation Maximization). The data columns in the given data must be equal to a * variable in the given Bayes IM but the latter may contain variables which don't occur in the * dataset (latent variables). The first argument of the constructoris the BayesPm whose graph * contains latent and observed variables. The second is the dataset of observed variables; * missing value codes may be present. */ public EmBayesEstimator(BayesPm bayesPm, DataSet dataSet) { if (bayesPm == null) { throw new NullPointerException(); } if (dataSet == null) { throw new NullPointerException(); } List<Node> observedVars = new ArrayList<Node>(); this.bayesPm = bayesPm; this.dataSet = dataSet; // this.variables = Collections.unmodifiableList(vars); graph = bayesPm.getDag(); this.nodes = new Node[graph.getNumNodes()]; Iterator<Node> it = graph.getNodes().iterator(); for (int i = 0; i < this.nodes.length; i++) { this.nodes[i] = it.next(); // System.out.println("node " + i + " " + nodes[i]); } for (int i = 0; i < this.nodes.length; i++) { if (nodes[i].getNodeType() == NodeType.MEASURED) { observedVars.add(bayesPm.getVariable(nodes[i])); } } // Make sure variables in dataset are measured variables in the BayesPM // for (Node dataSetVariable : this.dataSet.getVariables()) { // if (!observedVars.contains(dataSetVariable)) { // throw new IllegalArgumentException( // "Some var in the dataset is not a " + // "measured variable in the Bayes net"); // } // } // Make sure all measured variables in the BayesPm are in the discrete dataset for (Node observedVar : observedVars) { try { this.dataSet.getVariable(observedVar.getName()); } catch (Exception e) { throw new IllegalArgumentException( "Some observed var in the Bayes net " + "is not in the dataset: " + observedVar); } } findBayesNetObserved(); // Sets bayesPmObs initialize(); }
public void closeEmptySessions() { JInternalFrame[] frames = desktopPane.getAllFramesInLayer(0); for (JInternalFrame frame : frames) { Object o = frame.getContentPane().getComponents()[0]; if (o instanceof SessionEditor) { SessionEditor sessionEditor = (SessionEditor) o; SessionEditorWorkbench workbench = sessionEditor.getSessionWorkbench(); Graph graph = workbench.getGraph(); if (graph.getNumNodes() == 0) { frame.dispose(); } } } }