Is it possible to improve speed in Matlab ODE solvers? (ode45 ode15s etc.)

I wrote code to solve the system using ode45 and ode15s in matlab. I am wondering if I can improve the speed of the code using several core (or parallel code) in my script.

Has anyone tried this?

thanks

+4
source share
2 answers

No, you can’t.

All numerical integrators, ode45 and friends included, use some form of iterative scheme to solve custom (related) non-linear (partial) differential equations.

Each new step in the iterative schemes ode45/15s/.. (to calculate the new state of the system) depends on the previous step (old state of the system), therefore these numerical integrators cannot be parallelized efficiently.

The only acceleration you can do that can have a big impact is to optimize your implementation of the differential equation.

+5
source

In my experience, the only way to use several cores for solutions for ODE solutions in MATLAB is to use the “loop loop” to run several calculations at the same time, one calculation will not be faster, but you can start a lot with different parameters and after this long wait has several solutions . Therefore, if you need to run ODE many times, that can speed up your work.

To speed up one ODE function, it’s also good to play with the RelTol and AbsTol settings (changing the shape of the time from several hours to several hours), using the Jpattern option can also be very useful (my almost three-diagonal drawing made it work twice as fast), If your differential the equation is simple, try to compile it first or at least vectorize it (I used to write some part of the code in Java, and then pointed MATLAB to use the compiled .class file). Obviously, the length of your solution vector plays an important role, so don't make it more than a few pursued.

+2
source

Source: https://habr.com/ru/post/1480541/


All Articles