[R-sig-dyn-mod] Modify times parameter in lsoda at runtime
Faelens Ruben
ruben.faelens at altran.com
Fri Dec 2 15:38:23 CET 2011
Thank you for your help. I have succeeded into creating this "event
simulator" by using the root finding functionality of LSODA. Thank you
for your help!
For future reference, here is the code:
rootfunc <- function(t,y,p) {
if( length(EventQueue) == 0)
stop()
else
return min(t-EventQueue$t)
}
eventfunc <- function(t,y,p) {
# Execute event
[...]
# Remove event from event queue
[...]
return(y)
}
lsoda(
y=y,
times=c(0, 1e8),
func=Model,
parms=parms,
events=list(func=eventfunc, root=TRUE),
rootfunc=rootfunc
)
More information about the R-sig-dynamic-models
mailing list