use of cbit.vcell.solver.ode.IDASolverStandalone in project vcell by virtualcell.
the class ParameterEstimationTaskSimulatorIDA method getRowColumnRestultSetByBestEstimations.
public RowColumnResultSet getRowColumnRestultSetByBestEstimations(ParameterEstimationTask parameterEstimationTask, String[] paramNames, double[] paramValues) throws Exception {
// create a temp simulation based on math description
KeyValue key = new KeyValue("" + Math.abs(new Random().nextLong()));
SimulationVersion dummyVersion = new SimulationVersion(key, "name", new User("temp", new KeyValue("1")), null, null, null, null, null, null, null);
Simulation simulation = new Simulation(dummyVersion, parameterEstimationTask.getSimulationContext().getMathDescription());
ReferenceData refData = parameterEstimationTask.getModelOptimizationSpec().getReferenceData();
double[] times = refData.getDataByColumn(0);
double endTime = times[times.length - 1];
ExplicitOutputTimeSpec exTimeSpec = new ExplicitOutputTimeSpec(times);
// set simulation ending time and output interval
simulation.getSolverTaskDescription().setTimeBounds(new TimeBounds(0, endTime));
simulation.getSolverTaskDescription().setOutputTimeSpec(exTimeSpec);
// set parameters as math overrides
MathOverrides mathOverrides = simulation.getMathOverrides();
for (int i = 0; i < paramNames.length; i++) {
mathOverrides.putConstant(new Constant(paramNames[i], new Expression(paramValues[i])));
}
SimulationTask simTask = new SimulationTask(new SimulationJob(simulation, 0, null), 0);
IDASolverStandalone idaSolver = new IDASolverStandalone(simTask, ResourceUtil.getLocalSimDir("temp"), false);
// startSolver();
idaSolver.runSolver();
Thread.sleep(1000);
long startTimeMS = System.currentTimeMillis();
while (idaSolver.getSolverStatus().isRunning() && System.currentTimeMillis() < (startTimeMS + 10000L)) {
Thread.sleep(500);
}
ODESolverResultSet resultset = idaSolver.getODESolverResultSet();
return resultset;
}
Aggregations