When I run BIOMD0000001040 with gillespie SSA, the mean trajectory doesn't match the ODE solution
even though it probably should. It looks like an assignment rule that depends on time is not being re-evaluated
as the simulation advances, so the propensity it feeds is stale by one output interval.
The model has an assignment rule Mpl = Aexp(ct) - Bexp(dt), which is an explicit function of time,
and Mpl appears in the rate of the synthesis reaction that produces Mrbc. With CVODE this behaves
correctly. With gillespie, Mrbc stays frozen at zero for the first output interval and then trails the
ODE for the rest of the run. I am on roadrunner 2.9.2.
import numpy as np, roadrunner
rr = roadrunner.RoadRunner("BIOMD0000001040.xml")
ODE
rr.timeCourseSelections = ["time", "[Mrbc]"]
print("ODE:", np.array(rr.simulate(0, 10, 6))[:, 1])
gillespie, mean over 40 replicates
means = []
for s in range(40):
rr.reset()
rr.setIntegrator("gillespie")
rr.integrator.seed = s + 1
rr.timeCourseSelections = ["time", "[Mrbc]"]
means.append(np.array(rr.simulate(0, 10, 6))[:, 1])
print("SSA:", np.mean(means, 0))
This is what I get:
ODE: [0, 36.53, 83.08, 113.69, 129.62, 135.46]
SSA: [0, 0, 49.67, 83.12, 101.67, 109.90]
For this model Mrbc is effectively an immigration–death process with a time-varying immigration rate,
so the SSA mean has to converge to the ODE solution exactly, and CVODE confirms that the ODE values
above are the correct answer. The gillespie mean is shifted down by roughly one output interval, which
is consistent with the propensity being computed from Mpl evaluated at the previous sample time rather
than the current time.
When I run BIOMD0000001040 with gillespie SSA, the mean trajectory doesn't match the ODE solution
even though it probably should. It looks like an assignment rule that depends on time is not being re-evaluated
as the simulation advances, so the propensity it feeds is stale by one output interval.
The model has an assignment rule Mpl = Aexp(ct) - Bexp(dt), which is an explicit function of time,
and Mpl appears in the rate of the synthesis reaction that produces Mrbc. With CVODE this behaves
correctly. With gillespie, Mrbc stays frozen at zero for the first output interval and then trails the
ODE for the rest of the run. I am on roadrunner 2.9.2.
import numpy as np, roadrunner
rr = roadrunner.RoadRunner("BIOMD0000001040.xml")
ODE
rr.timeCourseSelections = ["time", "[Mrbc]"]
print("ODE:", np.array(rr.simulate(0, 10, 6))[:, 1])
gillespie, mean over 40 replicates
means = []
for s in range(40):
rr.reset()
rr.setIntegrator("gillespie")
rr.integrator.seed = s + 1
rr.timeCourseSelections = ["time", "[Mrbc]"]
means.append(np.array(rr.simulate(0, 10, 6))[:, 1])
print("SSA:", np.mean(means, 0))
This is what I get:
ODE: [0, 36.53, 83.08, 113.69, 129.62, 135.46]
SSA: [0, 0, 49.67, 83.12, 101.67, 109.90]
For this model Mrbc is effectively an immigration–death process with a time-varying immigration rate,
so the SSA mean has to converge to the ODE solution exactly, and CVODE confirms that the ODE values
above are the correct answer. The gillespie mean is shifted down by roughly one output interval, which
is consistent with the propensity being computed from Mpl evaluated at the previous sample time rather
than the current time.