[R-sig-dyn-mod] Problem with simecol and ode - crash from R

Thomas Petzoldt Thomas.Petzoldt at tu-dresden.de
Wed Oct 21 14:02:31 CEST 2009


Rainer M Krug wrote:
> Hi
> 
> I have a problem with simecol, particularly with the logistic growth model
> with harvesting: with the parameters as given below, it crashes R.
> 
> When I change h to values below 100, it works, changing the solver to
> "euler" or "rk4", it works
> 
> Any idea what is happening, or am I doing something wrong?

Hi Rainer,

as you see yourself, this is not a problem of package simecol, it is a
problem of lsoda from the deSolve package. The reason is, that with the
parameters given, your simulation runs to minus infinity.

As a result, former versions of deSolve/lsoda produced a buffer overflow
and this resulted in a "stack smashing" error.

The "stack smashing" bug was solved in version 1.5 of deSolve, available
from CRAN since last weekend. Instead of breaking R lsoda now issues an
error message. I admit that this error message is not very helpful, but
there are several possibilities to diagnose the problem:

One option is to use a fixed step solver (rk4, euler) as you did, or a
different variable time step solver (rk alias ode45, vode, lsode or
daspk). Given your model and parameters, try:

solver(lgH) <- "vode"
plot(sim(lgH))

lsoda seems the only one that fails completely, but even that case can
be solved (in the diagnostic sense, i.e. by potentially loosing
accuracy) if you limit hmin, e.g.:

solver(lgH) <- "lsoda"
plot(sim(lgH, hmin = 1e-12))


Hope it helps and please update deSolve.

Thomas Petzoldt



More information about the R-sig-dynamic-models mailing list