Open TorkelE opened 3 years ago
I thought I mentioned that it's not odd or without a reason, just random. I show in https://arxiv.org/abs/1804.04344 that the stability of a method can be heavily dependent on the noise terms that you get. This is showing all of the signs of instability though, hence it's definitely what I termed pathwise stiffness and the standard drift-implicit methods do nothing here (since it's "stiffness in the noise"). This will be a good test for some of the new methods we're cooking up though, like a TruncatedFullyImplicitEM and the like, but that will take some time to develop.
Note that looking at a single seed doesn't make much sense, because with adaptivity two methods on the same seed will still get a different Brownian path. So it's really just, for a given method on a given seed, the Brownian path that it sees is an unstable path.
Though @YingboMa if you could look at the nonlinear solvers in this case to have fresh eyes and maybe see if I missed anything there, that would be great.
Seems that (yet again) when I start to believe that I'm getting a vague grip on how to solve things numerically, something will pop up to rudely prove me the difference!
SDEs are hard. Stiffness is SDEs is even weirder than ODEs 🤷
On a general level, it is kinda cool that there's this kind of strange behaviours in numerical systems, makes the field seem quite cool. On a local level, it kind of sucks.
Practically, would it be appropriate to use Stratonovich type methods to solve this kind of chemical Langevin problems?
Actually, I think I have found similar errors, but for other parameter sets, for the Stratonovich methods as well.
Originally posted as https://discourse.julialang.org/t/strange-maxiters-numeric-instability-occured-when-solving-certain-sde/49392 however, after looking closer at it I think it might be a bug in the package, so it probably fits better here.
Short Summary
SDEProblem
which when I try to solve it sometimes, strangely, hits maxiters.dt
suddenly becoming very small.seed
it becomes consistent.Full Story
Basically, I am investigating a simple SDE system, performing a large number of simulation over a large number of parameters. However, I have recently started getting strange
This is rather rare (been when solving 10s of thousands of times it comes up quite a lot). It does not come up every time I solve a certain
SDEProblem
(but I can make it reproducible by specifying aseed
). There seem to be some patterns though, where for some parameter selections the solver is much more likely to hit the maxiters.This is a basic reproducible example:
Solving without this seed, things are mostly fine:
yields maybe only 1 such error per run.
Even increasing maxiters a bit, I receive no benefit:
still errors.
To try ad figure out what is happening I plot the solution, and the time step length, for an attempt where I ran into the problem (and one where I didn't).
Here's the solutions using something like
I can get the dt:
In these, I only plot the successful solution to the same length as the time point where the failed one failed. Here's a comparison where I plot the full length of the successful simulation.
Looking at the (failed) solution directly, the last 20 values of
sol.t
becomeswhile the last 20 values of
dts
areThe problem does not seem to depend on the amount of noise in the system. I can check the outputs of
sys_f
andsys_g
at the final value (where it hits maxiters):gives
and
gives
Further proving this point, I look at another parameter set. Here we note that the last parameter scales the noise, by making this very small, the noise become negligible. This error happens even when this parameter is 0.001 (very small).
Finally, I have tried investigating this over several solvers. Looking at the initial problem I try:
Of these,
sol_ImplicitEM
,sol_STrapezoid
,sol_SImplicitMidpoint
all fails, whileImplicitEulerHeun
,ISSEM
,ISSEulerHeun
succeeds. See plots (know it is not super helpful, but best I got to show how they fail. Solutions: dts:Finally, I try scanning for other seeds which causes failure in the remaining three. Did not find any for
ImplicitEulerHeun
orISSEulerHeun
, however,ISSEM
fails for seed=15088718199444158177Looking at this seed specifically,
ImplicitEM
andSImplicitMidpoint
also fails, while the remaining three succeeds.Trying to find a pattern, it seems like I can find errors for the Ito methods, but not for the Stratonovich methods.
This is the output of Pkg.status()