use of edu.cmu.tetrad.algcomparison.simulation.ConditionalGaussianSimulation in project tetrad by cmu-phil.
the class TestConditionalGaussianSimulation method testBryan.
public void testBryan(String... args) {
Parameters parameters = new Parameters();
parameters.set("numCategoriesToDiscretize", 5);
parameters.set("numRuns", 10);
parameters.set("numMeasures", 100);
parameters.set("avgDegree", 2);
parameters.set("sampleSize", 10000);
parameters.set("minCategories", 2);
parameters.set("maxCategories", 5);
parameters.set("percentDiscrete", 50);
parameters.set("differentGraphs", true);
parameters.set("maxDegree", 5);
parameters.set("maxIndegree", 5);
parameters.set("maxOutdegree", 5);
parameters.set("structurePrior", 1);
parameters.set("fDegree", -1);
parameters.set("discretize", true);
// parameters.set("discretize", true, false);
Statistics statistics = new Statistics();
statistics.add(new AdjacencyPrecision());
statistics.add(new AdjacencyRecall());
statistics.add(new ArrowheadPrecision());
statistics.add(new ArrowheadRecall());
statistics.add(new ElapsedTime());
statistics.setWeight("AHP", 1.0);
statistics.setWeight("AHR", 1.0);
Algorithms algorithms = new Algorithms();
algorithms.add(new Fges(new ConditionalGaussianBicScore()));
Simulations simulations = new Simulations();
simulations.add(new ConditionalGaussianSimulation(new RandomForward()));
Comparison comparison = new Comparison();
comparison.setShowAlgorithmIndices(true);
comparison.setShowSimulationIndices(true);
comparison.setSortByUtility(true);
comparison.setShowUtilities(true);
comparison.setParallelized(false);
comparison.compareFromSimulations("comparison", simulations, algorithms, statistics, parameters);
}
use of edu.cmu.tetrad.algcomparison.simulation.ConditionalGaussianSimulation 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())));
}
Aggregations