diff --git a/licenses/AUTHORS.txt b/licenses/AUTHORS.txt
index 47bbd0af..b93036ab 100644
--- a/licenses/AUTHORS.txt
+++ b/licenses/AUTHORS.txt
@@ -41,6 +41,8 @@
rodrigue@ebi.ac.uk
Hannes Planatscher, NMI Reutlingen, Germany,
Hannes.Planatscher@nmi.de
+ Shalin Shah, Duke University USA,
+ shalin.shah@duke.edu
-- Thanks to --
diff --git a/pom.xml b/pom.xml
index f1d7b78b..b951c371 100644
--- a/pom.xml
+++ b/pom.xml
@@ -260,7 +260,6 @@
junit
junit
${junit.version}
-
org.sbml.jsbml
@@ -304,25 +303,21 @@
scpsolver
SCPSolver
1.0v2
-
scpsolver
GLPKSolverPack
4.35v2
-
scpsolver
LPSOLVESolverPack
5.5.2.5
-
kisao
libkisao
1.0.3.1-rc
-
diff --git a/src/lib/UmlGraph.jar b/src/lib/UmlGraph.jar
deleted file mode 100644
index 19d27ae7..00000000
Binary files a/src/lib/UmlGraph.jar and /dev/null differ
diff --git a/src/lib/commons-math-2.2-src.zip b/src/lib/commons-math-2.2-src.zip
deleted file mode 100644
index 78108f6c..00000000
Binary files a/src/lib/commons-math-2.2-src.zip and /dev/null differ
diff --git a/src/lib/commons-math-2.2.jar b/src/lib/commons-math-2.2.jar
deleted file mode 100644
index b29a39c5..00000000
Binary files a/src/lib/commons-math-2.2.jar and /dev/null differ
diff --git a/src/lib/de/uni-rostock/sbi/CombineArchive/1.3.6/CombineArchive-1.3.6.jar b/src/lib/de/uni-rostock/sbi/CombineArchive/1.3.6/CombineArchive-1.3.6.jar
deleted file mode 100644
index 6903a1f4..00000000
Binary files a/src/lib/de/uni-rostock/sbi/CombineArchive/1.3.6/CombineArchive-1.3.6.jar and /dev/null differ
diff --git a/src/lib/ext-lib/commons-io-1.4.jar b/src/lib/ext-lib/commons-io-1.4.jar
deleted file mode 100644
index 133dc6cb..00000000
Binary files a/src/lib/ext-lib/commons-io-1.4.jar and /dev/null differ
diff --git a/src/lib/ext-lib/jaxen-1.1.1.jar b/src/lib/ext-lib/jaxen-1.1.1.jar
deleted file mode 100644
index b6336311..00000000
Binary files a/src/lib/ext-lib/jaxen-1.1.1.jar and /dev/null differ
diff --git a/src/lib/ext-lib/jdom-contrib.jar b/src/lib/ext-lib/jdom-contrib.jar
deleted file mode 100644
index 503f2317..00000000
Binary files a/src/lib/ext-lib/jdom-contrib.jar and /dev/null differ
diff --git a/src/lib/ext-lib/jdom.jar b/src/lib/ext-lib/jdom.jar
deleted file mode 100644
index a2877278..00000000
Binary files a/src/lib/ext-lib/jdom.jar and /dev/null differ
diff --git a/src/lib/ext-lib/jmathml.jar b/src/lib/ext-lib/jmathml.jar
deleted file mode 100644
index f67fd3f5..00000000
Binary files a/src/lib/ext-lib/jmathml.jar and /dev/null differ
diff --git a/src/lib/ext-lib/xom-1.2.1.jar b/src/lib/ext-lib/xom-1.2.1.jar
deleted file mode 100644
index af14578c..00000000
Binary files a/src/lib/ext-lib/xom-1.2.1.jar and /dev/null differ
diff --git a/src/lib/jfree/jfreechart/1.0.19/jcommon-1.0.23.jar b/src/lib/jfree/jfreechart/1.0.19/jcommon-1.0.23.jar
deleted file mode 100644
index 4dbb094a..00000000
Binary files a/src/lib/jfree/jfreechart/1.0.19/jcommon-1.0.23.jar and /dev/null differ
diff --git a/src/lib/jfree/jfreechart/1.0.19/jfreechart-1.0.19.jar b/src/lib/jfree/jfreechart/1.0.19/jfreechart-1.0.19.jar
deleted file mode 100644
index 10f276c6..00000000
Binary files a/src/lib/jfree/jfreechart/1.0.19/jfreechart-1.0.19.jar and /dev/null differ
diff --git a/src/lib/kisao/LibKiSAO/1.0.3.1/libkisao-1.0.3.1-rc.jar b/src/lib/kisao/LibKiSAO/1.0.3.1/libkisao-1.0.3.1-rc.jar
deleted file mode 100644
index 276dca1a..00000000
Binary files a/src/lib/kisao/LibKiSAO/1.0.3.1/libkisao-1.0.3.1-rc.jar and /dev/null differ
diff --git a/src/lib/lp-lib/GLPKSolverPack.jar b/src/lib/lp-lib/GLPKSolverPack.jar
deleted file mode 100644
index 26f10386..00000000
Binary files a/src/lib/lp-lib/GLPKSolverPack.jar and /dev/null differ
diff --git a/src/lib/lp-lib/LPSOLVESolverPack.jar b/src/lib/lp-lib/LPSOLVESolverPack.jar
deleted file mode 100644
index 6481c137..00000000
Binary files a/src/lib/lp-lib/LPSOLVESolverPack.jar and /dev/null differ
diff --git a/src/lib/nmi/scpsolver/1.0/GLPKSolverPack-4.35v2.jar b/src/lib/nmi/scpsolver/1.0/GLPKSolverPack-4.35v2.jar
deleted file mode 100644
index 2c10271e..00000000
Binary files a/src/lib/nmi/scpsolver/1.0/GLPKSolverPack-4.35v2.jar and /dev/null differ
diff --git a/src/lib/nmi/scpsolver/1.0/LPSOLVESolverPack-5.5.2.5.jar b/src/lib/nmi/scpsolver/1.0/LPSOLVESolverPack-5.5.2.5.jar
deleted file mode 100644
index 6481c137..00000000
Binary files a/src/lib/nmi/scpsolver/1.0/LPSOLVESolverPack-5.5.2.5.jar and /dev/null differ
diff --git a/src/lib/nmi/scpsolver/1.0/SCPSolver-1.0v2.jar b/src/lib/nmi/scpsolver/1.0/SCPSolver-1.0v2.jar
deleted file mode 100644
index f96ecba5..00000000
Binary files a/src/lib/nmi/scpsolver/1.0/SCPSolver-1.0v2.jar and /dev/null differ
diff --git a/src/lib/org/jlibsedml/jlibsedml/2.2.3/jlibsedml-2.2.3.jar b/src/lib/org/jlibsedml/jlibsedml/2.2.3/jlibsedml-2.2.3.jar
deleted file mode 100644
index c137335e..00000000
Binary files a/src/lib/org/jlibsedml/jlibsedml/2.2.3/jlibsedml-2.2.3.jar and /dev/null differ
diff --git a/src/lib/org/sbml/JSBML/1.3.1/jsbml-1.3.1.jar b/src/lib/org/sbml/JSBML/1.3.1/jsbml-1.3.1.jar
deleted file mode 100644
index 5e51d988..00000000
Binary files a/src/lib/org/sbml/JSBML/1.3.1/jsbml-1.3.1.jar and /dev/null differ
diff --git a/src/main/java/org/simulator/examples/SEDMLExample.java b/src/main/java/org/simulator/examples/SEDMLExample.java
index c0796a60..67223188 100644
--- a/src/main/java/org/simulator/examples/SEDMLExample.java
+++ b/src/main/java/org/simulator/examples/SEDMLExample.java
@@ -1,20 +1,26 @@
package org.simulator.examples;
-import de.binfalse.bflog.LOGGER;
+import static org.junit.Assert.fail;
+
+import java.io.File;
+import java.util.List;
+import java.util.Map;
+
import org.jfree.ui.RefineryUtilities;
-import org.jlibsedml.*;
+import org.jlibsedml.AbstractTask;
+import org.jlibsedml.Curve;
+import org.jlibsedml.Libsedml;
+import org.jlibsedml.Output;
+import org.jlibsedml.Plot2D;
+import org.jlibsedml.SedML;
+import org.jlibsedml.XMLException;
import org.jlibsedml.execution.IProcessedSedMLSimulationResults;
import org.jlibsedml.execution.IRawSedmlSimulationResults;
import org.semanticweb.owlapi.model.OWLOntologyCreationException;
-import org.simulator.math.odes.MultiTable;
-import org.simulator.plot.PlotMultiTable;
+import org.simulator.plot.PlotProcessedSedmlResults;
import org.simulator.sedml.SedMLSBMLSimulatorExecutor;
-import java.io.File;
-import java.util.List;
-import java.util.Map;
-
-import static org.junit.Assert.fail;
+import de.binfalse.bflog.LOGGER;
/**
* This test class shows how a SED-ML file can be interpreted and executed using
@@ -43,7 +49,7 @@ public static void main(String[] args) throws XMLException, OWLOntologyCreationE
// in this SED-ML file there's just one output. If there were several,
// we could either iterate or get user to decide what they want to run.
- Output wanted = sedml.getOutputs().get(0);
+ Output wanted = sedml.getOutputs().get(2);
SedMLSBMLSimulatorExecutor exe = new SedMLSBMLSimulatorExecutor(sedml, wanted, sedmlDir);
// This gets the raw simulation results - one for each Task that was run.
LOGGER.warn("Collecting tasks...");
@@ -52,10 +58,22 @@ public static void main(String[] args) throws XMLException, OWLOntologyCreationE
fail ("Simulatation failed: " + exe.getFailureMessages().get(0));
return;
}
+
// now process.In this case, there's no processing performed - we're displaying the
// raw results.
- LOGGER.warn("Outputs wanted: " + wanted.getAllDataGeneratorReferences());
- IProcessedSedMLSimulationResults mt = exe.processSimulationResults(wanted, res);
+ LOGGER.warn("Outputs wanted: " + wanted.getId());
+ IProcessedSedMLSimulationResults prRes = exe.processSimulationResults(wanted, res);
+
+ if(wanted.isPlot2d()) {
+ Plot2D plots = (Plot2D) wanted;
+ List curves = plots.getListOfCurves();
+
+ // plot all processed results as per curve descriptions
+ PlotProcessedSedmlResults p = new PlotProcessedSedmlResults(prRes, curves, plots.getElementName());
+ p.pack();
+ RefineryUtilities.centerFrameOnScreen(p);
+ p.setVisible( true );
+ }
}
}
diff --git a/src/main/java/org/simulator/plot/PlotProcessedSedmlResults.java b/src/main/java/org/simulator/plot/PlotProcessedSedmlResults.java
new file mode 100644
index 00000000..107843c0
--- /dev/null
+++ b/src/main/java/org/simulator/plot/PlotProcessedSedmlResults.java
@@ -0,0 +1,153 @@
+/*
+ * ---------------------------------------------------------------------
+ * This file is part of Simulation Core Library, a Java-based library
+ * for efficient numerical simulation of biological models.
+ *
+ * Copyright (C) 2007-2016 jointly by the following organizations:
+ * 1. University of Tuebingen, Germany
+ * 2. Keio University, Japan
+ * 3. Harvard University, USA
+ * 4. The University of Edinburgh, UK
+ * 5. EMBL European Bioinformatics Institute (EBML-EBI), Hinxton, UK
+ * 6. The University of California, San Diego, La Jolla, CA, USA
+ * 7. The Babraham Institute, Cambridge, UK
+ * 8. Duke University, USA
+ *
+ * This library is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation. A copy of the license
+ * agreement is provided in the file named "LICENSE.txt" included with
+ * this software distribution and also available online as
+ * .
+ * ---------------------------------------------------------------------
+ */
+package org.simulator.plot;
+
+import org.jfree.chart.ChartPanel;
+import org.jfree.chart.ChartUtilities;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.apache.commons.io.FileUtils;
+import org.jfree.chart.ChartFactory;
+import org.jfree.chart.JFreeChart;
+import org.jfree.ui.ApplicationFrame;
+import org.jlibsedml.Curve;
+import org.jlibsedml.execution.IProcessedSedMLSimulationResults;
+
+import org.jfree.chart.plot.PlotOrientation;
+import org.jfree.data.xy.XYSeries;
+import org.jfree.data.xy.XYSeriesCollection;
+
+/**
+ * This class adds output data-plot support to SBSCL
+ *
+ * @author Shalin Shah
+ * @since 1.5
+ */
+@SuppressWarnings("serial")
+public class PlotProcessedSedmlResults extends ApplicationFrame {
+ private IProcessedSedMLSimulationResults species;
+ private XYSeriesCollection graphData;
+ private String title;
+ private List curves;
+ private JFreeChart lineChart;
+ private static final int CHART_WIDTH = 1366;
+ private static final int CHART_HEIGHT = 768;
+
+ /**
+ * Initializes the JFreeChart and dataSet for the chart using IProcessedSedMLSimulationResults
+ *
+ * @param IProcessedSedMLSimulationResults
+ * The input data type to the plot API is 2D data wrapped with jsedmllib data structure
+ * which gets converted internally to XY line plot
+ */
+ public PlotProcessedSedmlResults(IProcessedSedMLSimulationResults data, String title) {
+ super(title);
+
+ this.title = title;
+ this.species = data;
+ this.lineChart = ChartFactory.createXYLineChart(this.title,
+ ".", ".", createDataset(),
+ PlotOrientation.VERTICAL, true, true, false);
+
+ ChartPanel chartPanel = new ChartPanel( this.lineChart );
+ chartPanel.setPreferredSize( new java.awt.Dimension(CHART_WIDTH, CHART_HEIGHT));
+ setContentPane(chartPanel);
+
+ }
+
+ public PlotProcessedSedmlResults(IProcessedSedMLSimulationResults data, List curves, String title) {
+ super(title);
+
+ this.title = title;
+ this.species = data;
+ this.curves = curves;
+
+ this.lineChart = ChartFactory.createXYLineChart(this.title,
+ ".", ".", createDataset(),
+ PlotOrientation.VERTICAL, true, true, false);
+
+
+ ChartPanel chartPanel = new ChartPanel( this.lineChart );
+ chartPanel.setPreferredSize( new java.awt.Dimension(CHART_WIDTH, CHART_HEIGHT));
+ setContentPane(chartPanel);
+ }
+
+ /**
+ * Helper function that converts IProcessedSedMLSimulationResults to DataSet for LineChart
+ */
+ private XYSeriesCollection createDataset() {
+ graphData = new XYSeriesCollection();
+
+ // For each curve in the current output element of sedml file
+ // simple extract data generators and plot them
+ for(Curve cur: this.curves) {
+ Double[] xData = species.getDataByColumnId(cur.getXDataReference());
+ Double[] yData = species.getDataByColumnId(cur.getYDataReference());
+ XYSeries series = new XYSeries(cur.getId(), false);
+
+ for(int row = 0; row < Math.min(xData.length, yData.length); row++) {
+ series.add(xData[row], yData[row]);
+ }
+ graphData.addSeries(series);
+ }
+
+ return graphData;
+ }
+
+ /**
+ * Helper function that can save the generated plot (simulationPath sedml file) as a PNG image
+ * with fileName in the results folder
+ */
+ public void savePlot(String simulationPath, String fileName) throws IOException {
+ // Get full folder for sedml xml file
+ String outputPath = getFolderPathForTestResource(simulationPath);
+ // Store the plots in the results folder in the same directory
+ outputPath = outputPath + "/results/simulation_core/" + fileName + ".png";
+ OutputStream out = FileUtils.openOutputStream(new File(outputPath));
+ // Use default width and height for chart size and save as png
+ ChartUtilities.writeChartAsPNG(out, this.lineChart, CHART_WIDTH, CHART_HEIGHT);
+ }
+
+ /**
+ * Get absolute parent path for given test resource.
+ * Due to the relative paths of SBML and SED-ML files the resource loading is not working
+ * in maven.
+ *
+ * Example:
+ * resourcePath="/fba/e_coli_core.xml"
+ */
+ private static String getFolderPathForTestResource(String resourcePath) {
+
+ String path = null;
+ File currentDir = new File(System.getProperty("user.dir"));
+ path = currentDir.getAbsolutePath() + "/src/test/resources" + resourcePath;
+ File pwd = new File(path);
+
+ return pwd.getParentFile().getAbsolutePath();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/org/simulator/sedml/ProcessSedMLResults.java b/src/main/java/org/simulator/sedml/ProcessSedMLResults.java
index 8ea8c2bb..d90d0507 100644
--- a/src/main/java/org/simulator/sedml/ProcessSedMLResults.java
+++ b/src/main/java/org/simulator/sedml/ProcessSedMLResults.java
@@ -351,7 +351,7 @@ private IRawSedmlSimulationResults flattenResultsList(List row + timeBegin).toArray();
diff --git a/src/main/java/org/simulator/sedml/SedMLSBMLSimulatorExecutor.java b/src/main/java/org/simulator/sedml/SedMLSBMLSimulatorExecutor.java
index 01275578..cf56500a 100644
--- a/src/main/java/org/simulator/sedml/SedMLSBMLSimulatorExecutor.java
+++ b/src/main/java/org/simulator/sedml/SedMLSBMLSimulatorExecutor.java
@@ -34,6 +34,7 @@
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+
import org.apache.commons.io.FileUtils;
import org.apache.log4j.Logger;
import org.jlibsedml.AbstractTask;
@@ -55,7 +56,6 @@
import org.jlibsedml.execution.IProcessedSedMLSimulationResults;
import org.jlibsedml.execution.IRawSedmlSimulationResults;
import org.jlibsedml.execution.ModelResolver;
-
import org.jlibsedml.modelsupport.BioModelsModelsRetriever;
import org.jlibsedml.modelsupport.KisaoOntology;
import org.jlibsedml.modelsupport.KisaoTerm;
@@ -70,7 +70,6 @@
import org.simulator.math.odes.MultiTable;
import org.simulator.math.odes.RosenbrockSolver;
import org.simulator.sbml.SBMLinterpreter;
-
import de.binfalse.bflog.LOGGER;
import net.biomodels.kisao.IKiSAOQueryMaker;
import net.biomodels.kisao.impl.KiSAOQueryMaker;
@@ -251,7 +250,7 @@ protected IRawSedmlSimulationResults executeSimulation(String modelStr, UniformT
}
return null;
}
-
+
protected IRawSedmlSimulationResults executeSimulation(String modelStr, OneStep sim) {
AbstractDESSolver solver = getSolverForKisaoID(sim.getAlgorithm().getKisaoID());
@@ -314,12 +313,76 @@ protected IRawSedmlSimulationResults executeSimulation(String modelStr, SteadySt
}
return null;
}
+
+ protected IRawSedmlSimulationResults executeSimulation(String modelStr,
+ Simulation sim, Map mapChangesToList, int element) {
+
+ AbstractDESSolver solver = getSolverForKisaoID(sim.getAlgorithm().getKisaoID());
+ File tmp = null;
+ try {
+ // get a JSBML object from the model string.
+ tmp = File.createTempFile("Sim", "sbml");
+ FileUtils.writeStringToFile(tmp, modelStr, "UTF-8");
+ Model model = (new SBMLReader()).readSBML(tmp).getModel();
+
+ // If there are any changes make them before execution
+ if (mapChangesToList != null) {
+ // Find all the setValues and set them to current element in range
+ for(String change: mapChangesToList.keySet()) {
+ model.getParameter(change).setValue(mapChangesToList.get(change)[element]);;
+ }
+ }
+
+ // now run simulation
+ SBMLinterpreter interpreter = null;
+ if (amountHash != null) {
+ interpreter = new SBMLinterpreter(model, 0, 0, 1, amountHash);
+ } else {
+ interpreter = new SBMLinterpreter(model);
+ }
+ solver.setIncludeIntermediates(false);
+
+ if(sim instanceof OneStep) {
+ OneStep finalSim = (OneStep) sim;
+ // A step-size randomly taken since SED-ML L1V2 says simulator decides this
+ // A better way to decide step size is essential
+ solver.setStepSize(finalSim.getStep() / ONE_STEP_SIM_STEPS);
+ MultiTable mts = solver.solve(interpreter, interpreter.getInitialValues(), 0.0, finalSim.getStep());
+
+ // adapt the MultiTable to jlibsedml interface.
+ // return only 1 point for OneStep simulation: start and end
+ return new MultTableSEDMLWrapper(mts.filter(new double[] { finalSim.getStep() }));
+ }
+ else if(sim instanceof UniformTimeCourse) {
+ UniformTimeCourse finalSim = (UniformTimeCourse) sim;
+ solver.setStepSize((finalSim.getOutputEndTime() - finalSim.getOutputStartTime()) / (finalSim.getNumberOfPoints()));
+ MultiTable mts = solver.solve(interpreter, interpreter.getInitialValues(), finalSim.getOutputStartTime(),
+ finalSim.getOutputEndTime());
+
+ // adapt the MultiTable to jlibsedml interface.
+ return new MultTableSEDMLWrapper(mts);
+ }
+ else if(sim instanceof SteadyState) {
+ // set default stepSize and call solver. Solver will automatically find
+ // steadyState and terminate when steadyState is reached.
+ MultiTable mts = solver.steadystate(interpreter, interpreter.getInitialValues(), STEADY_STATE_STEPS);
+
+ // adapt the MultiTable to jlibsedml interface.
+ return new MultTableSEDMLWrapper(mts);
+ }
+
+
+ } catch (Exception e) {
+ LOGGER.warn(e.getMessage());
+ }
+ return null;
+ }
/**
* This method is a wrapper to the runSimulations method from
* {@link AbstractSedmlExecutor} to add additional support for repeatedTasks. It
* identifies the type of task, before running the simulations.
- * @throws OWLOntologyCreationException
+ * @throws OWLOntologyCreationException
*/
public Map> run() throws OWLOntologyCreationException {
@@ -342,50 +405,60 @@ public Map> run() throws OWLOntol
Map range = repTask.getRanges();
List repTaskResults = new ArrayList();
- // Store state of all the existing changes by subTasks
- List modelState = new ArrayList();
-
// Find all the variable from listOfChanges and create tasks
if (range.size() > 0 && subTasks.size() > 0) {
+ // Load original model from one of the subtasks and update its state
+ org.jlibsedml.Model curModel = sedml.getModelWithId(sedml.getTaskWithId(repTask.getSubTasks().
+ values().iterator().next().getTaskId()).getModelReference());
+
+ // 2. Get the Xpath parameter in setValue and a double[] before simulations
+ Map mapChangesToList = new HashMap();
+ if (repTask.getChanges().size() > 0) {
+
+ for (SetValue change : repTask.getChanges()) {
+ String xPath = change.getTargetXPath().getTargetAsString();
+ xPath = xPath.substring(xPath.indexOf("'") + 1);
+ xPath = xPath.substring(0, xPath.indexOf("'"));
+
+ if(change.getRangeReference() != null) {
+ double[] setValueRange = getRangeListRange(range.get(change.getRangeReference()));
+ mapChangesToList.put(xPath, setValueRange);
+ }else {
+ LOGGER.warn("No range specified for SetValue element" + change.getId() + " of repeated task " + repTask.getId());
+ return null;
+ }
+ }
+ }
+
// Iterate over master range
Range masterRange = range.get(repTask.getRange());
for (int element = 0; element < masterRange.getNumElements(); element++) {
-
List stResults = new ArrayList();
+
+ // 1. Check for resetModel, original SBML model file is re-read
+ if (repTask.getResetModel()) {
+ curModel = sedml.getModelWithId(sedml.getTaskWithId(repTask.getSubTasks().
+ values().iterator().next().getTaskId()).getModelReference());
+ }
+
+ // 3. Execute subTasks in sorted order with the current state of model
for (Entry st : subTasks.entrySet()) {
SubTask subTask = st.getValue();
AbstractTask relatedTask = sedml.getTaskWithId(subTask.getTaskId());
+
+ // subtasks refer to same model but can refer to different simulations
+ Simulation sim = sedml.getSimulation(relatedTask.getSimulationReference());
+ String changedModel = modelResolver.getModelString(curModel);
// A subTask can also be a repeatedTask in which case
// recurse all repeatedTasks subTasks to add all of them
if (relatedTask instanceof RepeatedTask) {
// TODO: Handle nested repeatedTask
LOGGER.warn("Warning! Nested repeatedTask found and ignored.");
+
} else {
- // Load original model and update its state
- org.jlibsedml.Model curModel = sedml.getModelWithId(relatedTask.getModelReference());
-
- // 1. Check for resetModel, if so clear all the SetValues
- if (repTask.getResetModel()) {
- modelState.clear();
- }
-
- // 2. (optional) Check if any new changes are added
- modelState.addAll(repTask.getChanges());
-
- // Set model to previously stored state by applying all the current
- // changes. If resetModel=true then this will be empty and we get fresh
- // model with no modification
- if (modelState.size() > 0) {
- for (SetValue change : modelState) {
- curModel.addChange(change);
- }
- }
-
- // 3. Execute subTasks in sorted order with the current state of model
- Simulation sim = sedml.getSimulation(relatedTask.getSimulationReference());
- String changedModel = modelResolver.getModelString(curModel);
+
IRawSedmlSimulationResults output = null;
// Quickly run error checks before final execution
if (!supportsLanguage(curModel.getLanguage())) {
@@ -404,13 +477,11 @@ public Map> run() throws OWLOntol
if(!canExecuteSimulation(sim))
sim = tryAlternateAlgo(sim);
- if (sim instanceof OneStep) {
- output = executeSimulation(changedModel, (OneStep) sim);
- } else if (sim instanceof SteadyState) {
- output = executeSimulation(changedModel, (SteadyState) sim);
- } else if (sim instanceof UniformTimeCourse) {
- output = executeSimulation(changedModel, (UniformTimeCourse) sim);
- }
+ // Execute simulations with changes, simulation type
+ if(mapChangesToList.size() > 0)
+ output = executeSimulation(changedModel, sim, mapChangesToList, element);
+ else
+ output = executeSimulation(changedModel, sim, null, -1);
if (output == null) {
LOGGER.warn("Simulation failed during execution: "
@@ -428,7 +499,7 @@ public Map> run() throws OWLOntol
.reduce((a, b) -> new MultTableSEDMLWrapper(new MultiTable(mergeTimeCols(a, b),
mergeDataCols(a.getData(), b.getData()), stResults.get(0).getColumnHeaders())))
.get();
-
+
// Add big subTask result to list of repTask results
repTaskResults.add(reducedStResults);
}
@@ -463,13 +534,13 @@ public Map> run() throws OWLOntol
if(!canExecuteSimulation(sim))
sim = tryAlternateAlgo(sim);
- // Identify simulation type and run it. Store the results in a Map
- if (sim instanceof OneStep) {
+ // Identify simulation type and run it
+ if(sim instanceof OneStep) {
results = executeSimulation(changedModel, (OneStep) sim);
- } else if (sim instanceof SteadyState) {
- results = executeSimulation(changedModel, (SteadyState) sim);
- } else if (sim instanceof UniformTimeCourse) {
+ }else if(sim instanceof UniformTimeCourse) {
results = executeSimulation(changedModel, (UniformTimeCourse) sim);
+ }else if(sim instanceof SteadyState) {
+ results = executeSimulation(changedModel, (SteadyState) sim);
}
if (results == null) {
@@ -479,10 +550,19 @@ public Map> run() throws OWLOntol
res.put(stdTask, new ArrayList(Arrays.asList(results)));
}
}
-
return res;
}
+ private double[] getRangeListRange(Range range) {
+ // TODO Auto-generated method stub
+ double[] rangeList = new double[range.getNumElements()];
+ for(int index = 0; index < range.getNumElements(); index++) {
+ rangeList[index] = range.getElementAt(index);
+ }
+
+ return rangeList;
+ }
+
/**
* Merge two 2D arrays into one 2D array in X-direction
*
@@ -510,7 +590,7 @@ private double[] mergeTimeCols(MultTableSEDMLWrapper a, MultTableSEDMLWrapper b)
// Get end time point for taskA
double[] timeA = a.getMultiTable().getTimePoints();
double timeBegin = timeA[timeA.length - 1];
-
+
// Add end time point to taskB
double[] timeB = Arrays.stream(b.getMultiTable().getTimePoints()).map(row -> row + timeBegin).toArray();
diff --git a/src/test/java/org/simulator/TestUtils.java b/src/test/java/org/simulator/TestUtils.java
index 4e258bf3..bb64979b 100644
--- a/src/test/java/org/simulator/TestUtils.java
+++ b/src/test/java/org/simulator/TestUtils.java
@@ -1,19 +1,15 @@
package org.simulator;
import org.apache.commons.lang.StringUtils;
-import org.apache.commons.lang3.ObjectUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import javax.xml.stream.XMLStreamException;
import org.apache.commons.lang3.ArrayUtils;
import java.io.*;
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import static org.junit.Assert.*;
-
/**
* Helper functions for tests.
*/
@@ -33,7 +29,7 @@ public static Iterable