Closed kaizu closed 5 years ago
The code below already works. It looks simple enough.
w = f.create_world()
w.bind_to(first_model)
f.create_simulator(first_model, w).run(duration1)
f.create_simulator(second_model, w).run(duration2)
print(w.t()) #=> duration1 + duration2
The member function of factories could be simplified more.
w = f.create_world()
w.bind_to(first_model)
f.simulator(first_model, w).run(duration1)
f.simulator(second_model, w).run(duration2)
By the way, switch
is unavailable because it's a reserved word in C++.
Finally, the following is an example to change rates.
from ecell4 import *
def create_model(kf, kr):
with reaction_rules():
~A == A | (kf, kr)
return get_model()
m1 = create_model(1.0, 1.0)
m2 = create_model(0.0, 1.0)
f = gillespie.GillespieFactory()
w = f.create_world(ones() * cbrt(100))
w.bind_to(m1)
obs = FixedIntervalNumberObserver(0.1, ["A"])
f.create_simulator(m1, w).run(10.0, obs)
f.create_simulator(m2, w).run(10.0, obs)
show(obs)
Provide the better way to switch models.
The current way is as follows:
What I expect is something like: