Version: 6.5, 7, 8
import javax.swing.JOptionPane;
import se.facilia.ecolego.domain.OutputReference;
import se.facilia.ecolego.domain.model.EcolegoProject;
import se.facilia.ecolego.scripts.AbstractEcolegoScript;
import se.facilia.ecolego.simulation.model.ResultModel;
/**
* This script demonstrates how to read results from the currently selected project.
*/
public class ManageResultsScript extends AbstractEcolegoScript {
@Override
public void launch() throws Exception {
// Retrieve the current project
EcolegoProject project = getSelectedProject();
// The ResultsModel is a facade used to access simulation results
ResultModel resultModel = project.getSimulationModel()
.getResultModel();
// An OutputReference represents a simulation result for one output and one set of dependencies (indices)
OutputReference ref = OutputReference.create("Concentrations.Soil[Cs-137]");
// See if there are results for this output
if (!resultModel.contains(ref)) {
JOptionPane.showMessageDialog(null, "There are no results for " + ref);
return;
}
// Read the time vector for the latest simulation
double[] timeVector = resultModel.getTime();
// Read a single value for a single time point and a single iteration. The time point is given as an index of
// the time vector
int t = 0;
int iteration = 0;
double d = resultModel.get(ref, t, iteration);
// Read all values for a time dependent output for a single iteration
double[] values = resultModel.getForAllTimePoints(ref, iteration);
// Find the number of iterations of a probabilistic simulation
int noIterations = resultModel.getNumberOfSimulations(ref.getContextId());
// Read the mean values of a time dependent output
double[] mean = resultModel.getMean(ref, timeVector);
// Read the std deviation of a time dependent output
double[] stdDev = resultModel.getStdDev(ref, timeVector);
// Read a percentile for a time dependent output
double[] perc95 = resultModel.getPercentile(ref, timeVector, 95.0);
}
}