From 700c892b4485d0e7ee7e19583e5d7372161980ce Mon Sep 17 00:00:00 2001 From: seanebum Date: Tue, 16 Nov 2021 13:09:28 -0500 Subject: [PATCH 1/2] changed resume behavior to treat previous end time as time "0" when resuming. Previously, simulation was setting t+increment as time 0, duplicating the state from previous run end time --- gillespy2/solvers/cpp/c_solver.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gillespy2/solvers/cpp/c_solver.py b/gillespy2/solvers/cpp/c_solver.py index 7966c9035..aef5d0d39 100644 --- a/gillespy2/solvers/cpp/c_solver.py +++ b/gillespy2/solvers/cpp/c_solver.py @@ -324,14 +324,14 @@ def _update_resume_data(self, resume: Results, simulation_data: "list[dict[str, resume_time = float(resume["time"][-1]) increment = resume_time - float(resume["time"][-2]) # Replace the simulation's timespan to continue where the Results object left off. - simulation_data[-1]["time"] = numpy.arange(start=(resume_time + increment), - stop=(resume_time + time_stopped + increment), + simulation_data[-1]["time"] = numpy.arange(start=(resume_time), + stop=(resume_time + time_stopped), step=increment) for entry_name, entry_data in simulation_data[-1].items(): # The results of the current simulation is treated as an "extension" of the resume data. # As such, the new simulation output is formed by joining the two end to end. - new_data = numpy.concatenate((resume[entry_name], entry_data), axis=None) + new_data = numpy.concatenate((resume[entry_name], entry_data[1:]), axis=None) simulation_data[-1][entry_name] = new_data return simulation_data From a076f194a7acd10ecc1c348bc50743a448c00cf6 Mon Sep 17 00:00:00 2001 From: seanebum Date: Wed, 17 Nov 2021 12:58:20 -0500 Subject: [PATCH 2/2] fix time being cut off by 1 --- gillespy2/solvers/cpp/c_solver.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gillespy2/solvers/cpp/c_solver.py b/gillespy2/solvers/cpp/c_solver.py index aef5d0d39..05b7fd16c 100644 --- a/gillespy2/solvers/cpp/c_solver.py +++ b/gillespy2/solvers/cpp/c_solver.py @@ -325,7 +325,7 @@ def _update_resume_data(self, resume: Results, simulation_data: "list[dict[str, increment = resume_time - float(resume["time"][-2]) # Replace the simulation's timespan to continue where the Results object left off. simulation_data[-1]["time"] = numpy.arange(start=(resume_time), - stop=(resume_time + time_stopped), + stop=(resume_time + time_stopped + increment), step=increment) for entry_name, entry_data in simulation_data[-1].items():