ODE stress test
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 839
- Forks
- 220
- Avg merge
- 2d 4h
- Merged PRs (30d)
- 14
Description
Moved here from stan-dev/math wiki page "ODE stress test", which has since been deleted.
(DL: 3/15/2018. There wasn't a good place to put this, so I'm stashing it as a wiki page for now.)
@wds15 provided a good test that shows difference in speed without differences in behavior. We should include this in performance monitoring at some point in the future. It was also used to find a bug in the implementation.
test/unit/math/rev/mat/functor/integrate_ode_bdf_stress_test.cpp
#include <stan/math/rev/mat.hpp>
#include <boost/random.hpp>
#include <stan/math/prim/scal/prob/lognormal_rng.hpp>
#include <gtest/gtest.h>
// very small michaelis menten example
#include <test/unit/math/rev/arr/functor/coupled_mm.hpp>
#include <test/unit/util.hpp>
#include <vector>
// test which triggers the too much work exception from odeint
TEST(StanOde_tooMuchWork_test, cvodes_coupled_mm) {
coupled_mm_ode_fun f_;
boost::ecuyer1988 rng;
// initial value and parameters from model definition
double t0 = 0;
std::vector<double> ts_long;
ts_long.push_back(1E10);
std::vector<double> ts_short;
ts_short.push_back(1);
std::vector<double> data;
std::vector<int> data_int;
typedef stan::math::var scalar_type;
for (std::size_t i = 0; i < 1000; i++) {
stan::math::start_nested();
std::vector<scalar_type> theta_v(4);
theta_v[0] = stan::math::lognormal_rng(1, 2, rng);
theta_v[1] = stan::math::lognormal_rng(-1, 2, rng);
theta_v[2] = stan::math::lognormal_rng(-1, 2, rng);
theta_v[3] = stan::math::lognormal_rng(-2, 2, rng);
std::vector<scalar_type> y0_v(2);
y0_v[0] = stan::math::lognormal_rng(5, 2, rng);
y0_v[1] = stan::math::lognormal_rng(-1, 2, rng);
std::vector<std::vector<scalar_type> > res = stan::math::integrate_ode_bdf(
f_, y0_v, t0, ts_long, theta_v, data, data_int, 0, 1E-10, 1E-10, 10000);
stan::math::grad(res[0][0].vi_);
stan::math::recover_memory_nested();
}
stan::math::print_stack(std::cout);
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with test/unit/math/rev/mat/functor/integrate_ode_bdf_stress_test.cpp and inspect the coupled_mm_ode_fun test and its performance-monitoring context. Add this ODE stress case to the project's performance monitoring so speed differences are visible without changes in behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- performance, testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100