stan-dev / math

The Stan Math Library is a C++ template library for automatic differentiation of any order using forward, reverse, and mixed modes. It includes a range of built-in functions for probabilistic modeling, linear algebra, and equation solving.
https://mc-stan.org
BSD 3-Clause "New" or "Revised" License
737 stars 185 forks source link

Add boost::odeint's Cash-Karp integrator #2334

Closed yizhang-yiz closed 3 years ago

yizhang-yiz commented 3 years ago

Description

This issue is spawned out of the benchmark in #2326 , where additional integrators from odeint & arkode was evaluated. In particular, boost::odeint's Cash-Karp method(ckrk) that has better stability shows to be an potential addition to our integrators.

Example

WIP branch: cash_karp_ckrk.

Expected Output

Same integrator output but potentially more efficient when parameter sampled causes the system to be stability-constrained.

Current Version:

v3.4.0

@bbbales2 @wds15

bbbales2 commented 3 years ago

That seems better. What is different between the two? Is this a choice that someone could make or is it always guess and check?

yizhang-yiz commented 3 years ago

@bbbales2 ckrk has a greater stability region than rk45 so it's more stable, and it's designed for problems with large derivatives and/or rapid oscillations. So it suits better for ODEs that could be sampled into mild stiffness(the SIR & Van del Pol example above). For non-stiff problem it could cause slow down by trying too hard on parameters that could be right-out rejected(the Lotka-Volterra example).