Clear Filters
Clear Filters

ode15s get stuck randomly

4 views (last 30 days)
Flavien
Flavien on 14 Mar 2013
Hi,
I'm running into a weird problem with the ode15s solver. At the beginning my code was running perfectly well, but since a little while sometimes the ode15s solver get stuck either at a timestep in the middle of the run or even at the first iteration.
What I mean by stuck is that it takes a really really long time to finally end the time step. My wonder comes from the fact that I happened a few time that running the code with the exact same parameters as when stuck, but in a new folder and recopying the files one by one there, the code would run at a much more "reasonable" speed...
Have anyone run into that kind of issue or know where it could be coming from?
Thanks a lot,
Flavien

Accepted Answer

Jan
Jan on 14 Mar 2013
This sounds like a magic behaviour. But without any doubt Matlab acts deterministically. Different guesses:
  1. You think that you have started the integration with the same parameters, but accidently you didn't. Bugs happen.
  2. The function to be integrated contains discontinuities. This is outside the specifications of Matlab's integrators and must be caught by an event function. See http://www.mathworks.com/matlabcentral/answers/59582#answer_72047 . Then tiny variations of the input can cause a completely different output and runtime.
  3. The function contains calls to a subfunction, when it is stored in a specific folder. So a function in either the same folder or a private subfolder shadows a builtin oder user-defined function.
  4. It is not the integrator, which needs more time, but another task on the computer: E.g. when the input data are read from the disk and a sector is damaged, the reading will take much longer. Or the computer started the virus detection or hard disk defragmentation.
The solution is always the same: Use the debugger to find the differences between the versions running with different speeds. Check if the effect is reproducible.
  1 Comment
Flavien
Flavien on 14 Mar 2013
Hi Jan,
Thanks for the answer. It does looks like a "magic" behaviour to me. My code is divided in two parts, the part where the bug happens being the base of the code. With that part only I never really had any problem, it usually comes when everything is integrated. I also found that sometimes removing the function both where the ode solver is called and where my initialization is made, then re-copying theses function from the first part of the code, it ends up running much faster... So I'm pretty sure the parameters are the same.
It is, however, a pretty unstable code. And the fork of working parameter is fairly narrow, the tiny variations in the input you mention can definitely have large consequences.
In the end I would believe that your 2nd guess describe the best what happens although I don't think the function is discontinuous. I will try to run the debugger to see what happens further.
Thanks, Flavien

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!