-
-
Notifications
You must be signed in to change notification settings - Fork 234
Open
Labels
Description
A very common event is one which updates a parameter (often at some time point of a simulation). Currently, these also updates the parameter of the original problem.:
@variables t X(t)
@parameters p d
D = Differential(t)
eqs = [
D(X) ~ p - d*X
]
discrete_events = [
[5.0] => [p ~ 0.1]
]
@mtkbuild osys = ODESystem(eqs, t; discrete_events)
u0 = [X => 0.0]
tspan = (0.0, 10.)
ps = [p => 5.0, d => 1.0]
oprob = ODEProblem(osys, u0, tspan, ps)
sol = solve(oprob, Tsit5())
plot(sol)sol = solve(oprob, Tsit5())
plot(sol)This means that if you want to re-simulate the problem, you have to create a new one. In practice when I make ensemble simulations with events I just run a deepcopy whenever a problem is passed into solve.
There are probably perks of this approach, but doesn't it feel more natural to not have events (the same hold for callbacks) mutate the original problem?

