Search in sources :

Example 1 with BayesNetSimulation

use of edu.cmu.tetrad.algcomparison.simulation.BayesNetSimulation in project tetrad by cmu-phil.

the class SimulationEditor method resetPanel.

private void resetPanel(Simulation simulation, String[] graphItems, String[] simulationItems, JTabbedPane tabbedPane) {
    RandomGraph randomGraph = (simulation.getSourceGraph() == null) ? new SingleGraph(new EdgeListGraph()) : new SingleGraph(simulation.getSourceGraph());
    if (!simulation.isFixedGraph()) {
        String graphItem = (String) graphsDropdown.getSelectedItem();
        simulation.getParams().set("graphsDropdownPreference", graphItem);
        if (graphItem.equals(graphItems[0])) {
            randomGraph = new RandomForward();
        } else if (graphItem.equals(graphItems[1])) {
            randomGraph = new ScaleFree();
        } else if (graphItem.equals(graphItems[2])) {
            randomGraph = new Cyclic();
        } else if (graphItem.equals(graphItems[3])) {
            randomGraph = new RandomSingleFactorMim();
        } else if (graphItem.equals(graphItems[4])) {
            randomGraph = new RandomTwoFactorMim();
        } else {
            throw new IllegalArgumentException("Unrecognized simulation type: " + graphItem);
        }
    }
    if (!simulation.isFixedSimulation()) {
        if (simulation.getSourceGraph() == null) {
            String simulationItem = (String) simulationsDropdown.getSelectedItem();
            simulation.getParams().set("simulationsDropdownPreference", simulationItem);
            simulation.setFixedGraph(false);
            if (randomGraph instanceof SingleGraph) {
                simulation.setFixedGraph(true);
            }
            if (simulationItem.equals(simulationItems[0])) {
                simulation.setSimulation(new BayesNetSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[1])) {
                simulation.setSimulation(new SemSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[2])) {
                simulation.setSimulation(new LinearFisherModel(randomGraph, simulation.getInputDataModelList()), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[3])) {
                simulation.setSimulation(new LeeHastieSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[4])) {
                simulation.setSimulation(new ConditionalGaussianSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[5])) {
                simulation.setSimulation(new TimeSeriesSemSimulation(randomGraph), simulation.getParams());
            } else {
                throw new IllegalArgumentException("Unrecognized simulation type: " + simulationItem);
            }
        } else {
            String simulationItem = (String) simulationsDropdown.getSelectedItem();
            simulation.getParams().set("simulationsDropdownPreference", simulationItem);
            simulation.setFixedGraph(false);
            if (randomGraph instanceof SingleGraph) {
                simulation.setFixedGraph(true);
            }
            if (simulationItem.equals(simulationItems[0])) {
                simulation.setSimulation(new BayesNetSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[1])) {
                simulation.setSimulation(new SemSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[2])) {
                simulation.setSimulation(new LinearFisherModel(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[3])) {
                simulation.setSimulation(new LeeHastieSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[4])) {
                simulation.setSimulation(new ConditionalGaussianSimulation(randomGraph), simulation.getParams());
            } else if (simulationItem.equals(simulationItems[5])) {
                simulation.setSimulation(new TimeSeriesSemSimulation(randomGraph), simulation.getParams());
            } else {
                throw new IllegalArgumentException("Unrecognized simulation type: " + simulationItem);
            }
        }
    }
    tabbedPane.setComponentAt(0, new PaddingPanel(getParameterPanel(simulation, simulation.getSimulation(), simulation.getParams())));
}
Also used : LinearFisherModel(edu.cmu.tetrad.algcomparison.simulation.LinearFisherModel) RandomSingleFactorMim(edu.cmu.tetrad.algcomparison.graph.RandomSingleFactorMim) TimeSeriesSemSimulation(edu.cmu.tetrad.algcomparison.simulation.TimeSeriesSemSimulation) GeneralSemSimulation(edu.cmu.tetrad.algcomparison.simulation.GeneralSemSimulation) SemSimulation(edu.cmu.tetrad.algcomparison.simulation.SemSimulation) StandardizedSemSimulation(edu.cmu.tetrad.algcomparison.simulation.StandardizedSemSimulation) RandomForward(edu.cmu.tetrad.algcomparison.graph.RandomForward) EdgeListGraph(edu.cmu.tetrad.graph.EdgeListGraph) BayesNetSimulation(edu.cmu.tetrad.algcomparison.simulation.BayesNetSimulation) ScaleFree(edu.cmu.tetrad.algcomparison.graph.ScaleFree) TimeSeriesSemSimulation(edu.cmu.tetrad.algcomparison.simulation.TimeSeriesSemSimulation) PaddingPanel(edu.cmu.tetradapp.ui.PaddingPanel) RandomTwoFactorMim(edu.cmu.tetrad.algcomparison.graph.RandomTwoFactorMim) RandomGraph(edu.cmu.tetrad.algcomparison.graph.RandomGraph) Cyclic(edu.cmu.tetrad.algcomparison.graph.Cyclic) LeeHastieSimulation(edu.cmu.tetrad.algcomparison.simulation.LeeHastieSimulation) ConditionalGaussianSimulation(edu.cmu.tetrad.algcomparison.simulation.ConditionalGaussianSimulation) SingleGraph(edu.cmu.tetrad.algcomparison.graph.SingleGraph)

Aggregations

Cyclic (edu.cmu.tetrad.algcomparison.graph.Cyclic)1 RandomForward (edu.cmu.tetrad.algcomparison.graph.RandomForward)1 RandomGraph (edu.cmu.tetrad.algcomparison.graph.RandomGraph)1 RandomSingleFactorMim (edu.cmu.tetrad.algcomparison.graph.RandomSingleFactorMim)1 RandomTwoFactorMim (edu.cmu.tetrad.algcomparison.graph.RandomTwoFactorMim)1 ScaleFree (edu.cmu.tetrad.algcomparison.graph.ScaleFree)1 SingleGraph (edu.cmu.tetrad.algcomparison.graph.SingleGraph)1 BayesNetSimulation (edu.cmu.tetrad.algcomparison.simulation.BayesNetSimulation)1 ConditionalGaussianSimulation (edu.cmu.tetrad.algcomparison.simulation.ConditionalGaussianSimulation)1 GeneralSemSimulation (edu.cmu.tetrad.algcomparison.simulation.GeneralSemSimulation)1 LeeHastieSimulation (edu.cmu.tetrad.algcomparison.simulation.LeeHastieSimulation)1 LinearFisherModel (edu.cmu.tetrad.algcomparison.simulation.LinearFisherModel)1 SemSimulation (edu.cmu.tetrad.algcomparison.simulation.SemSimulation)1 StandardizedSemSimulation (edu.cmu.tetrad.algcomparison.simulation.StandardizedSemSimulation)1 TimeSeriesSemSimulation (edu.cmu.tetrad.algcomparison.simulation.TimeSeriesSemSimulation)1 EdgeListGraph (edu.cmu.tetrad.graph.EdgeListGraph)1 PaddingPanel (edu.cmu.tetradapp.ui.PaddingPanel)1