No project description provided
Project description
rodeo: Probabilistic ODE Solver
Mohan Wu, Martin Lysy
Description
rodeo is a fast and flexible Python front-end library with a Fortran/C++ back-end that uses probabilistic numerics to solve ordinary differential equations (ODEs). That is, most ODE solvers (such as Euler's method) produce a deterministic approximation to the ODE on a grid of size delta
. As delta
goes to zero, the approximation converges to the true ODE solution. Probabilistic solvers such as rodeo also output a solution an a grid of size delta
; however, the solution is random. Still, as delta
goes to zero, the probabilistic numerical approximation converges to the true solution.
rodeo implements the probabilistic solver of Chkrebtii et al (2016). This begins by putting a Gaussian process prior on the ODE solution, and updating it sequentially as the solver steps through the grid. The user-facing interface is written in Python to allow for a wide appeal. The back-end is a time-varying Kalman filter implemented in C++ and Fortran using state-of-the-art linear algrebra routines found here. rodeo is 10-40x faster than a pure Python implementation, achieving comparable speeds to the widely-used deterministic solver odein in the Scipy library. Various low-level backends are provided in the following modules:
-
rodeo.cython
: This module performs the underlying linear algebra using the BLAS/LAPACK routines provided by NumPy through a Cython interface. To maximize speed, no input checks are provided. All inputs must befloat64
NumPy arrays in Fortran order. -
rodeo.eigen
: This module uses the C++ Eigen library for linear algebra. The interface is also through Cython.
Here again we have the same input requirements and lack of checks. Eigen is known to be faster than most BLAS/LAPACK implementations, but it needs to be compiled properly to achieve maximum performance. In particular this involves linking against an installed version of Eigen (not provided) and setting the right compiler flags for SIMD and OpenMP support. Some defaults are provided insetup.py
, but tweaks may be required depending on the user's system. -
rodeo.numba
: This module once again uses BLAS/LAPACK but the interface is through Numba. Here input checks are performed and the inputs can be in either C or Fortran order, and single or double precision (float32
andfloat64
). However, C ordered arrays are first converted to Fortran order, so the latter is preferable for performance considerations.
Installation
Download the repo from GitHub and then install with the setup.py
script:
git clone https://github.com/mlysy/rodeo.git
cd rodeo
pip install .
Unit Testing
The unit tests are done against the deterministic ode solver odeint to ensure that the solutions are approximately equal. They can be ran through the following commands:
cd tests
python -m unittest discover -v
Examples
We provide four separate ODE problems as examples to demonstrate the capabilities of rodeo. These examples are best viewed in the examples/tutorial.ipynb
jupyter notebook, hence extra installations are required.
pip install .[examples]
Documentation
The HTML documentation can be compiled from the kalmantv root folder:
pip install .[docs]
cd docs
make html
This will create the documentation in docs/build
.
Usage
Please see the detailed example in the tutorial here. Running the tutorial compares the deterministic Euler solver to the probabilistic solver for the ODE initial value problem
x(t)^{(2)} = sin(2t) - x_t^{(0)}
x(0)^{(1)} = 0
x(0)^{(0)} = -1
The results for N = 50, 100, and 200 grid points for both solvers is shown below.
rodeo is also capable of performing parameter inference using the mode-quadrature approximation method. For example the two variate FitzHugh-Nagumo model can be stated as
V(t)^{(1)} = cV(t)^{(0)} - (V(t)^{(0)})^3/3 + R(t)^({0})
R(t)^{(1)} = -(V(t)^{(0)} - a + bR(t)^{(0)})/c
V^{(0)} = -1, R^{(0)} = 1
where the parameter of interest is theta = (a,b,c)
. A comparison of the deterministic Euler solver to the probabilistic solver is shown below.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file rodeo-0.4.tar.gz
.
File metadata
- Download URL: rodeo-0.4.tar.gz
- Upload date:
- Size: 25.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3dcc0eeb414127bd56b32297b2e0594c6b5837510ba0c26af59c00abbbda11bd |
|
MD5 | 412e7b29ab432387f86858f1c58dea24 |
|
BLAKE2b-256 | a386466d93b5442203e96789458abea3cb35afe825afacddcf0caf2203db10a9 |
File details
Details for the file rodeo-0.4-cp37-cp37m-win_amd64.whl
.
File metadata
- Download URL: rodeo-0.4-cp37-cp37m-win_amd64.whl
- Upload date:
- Size: 386.6 kB
- Tags: CPython 3.7m, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.5.0 importlib_metadata/4.8.1 pkginfo/1.5.0.1 requests/2.21.0 requests-toolbelt/0.9.1 tqdm/4.31.1 CPython/3.7.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cc217008f15fc49e6efeb05e53738cf01e372a4b1917dd13a2631dc1f93db66d |
|
MD5 | 352c46a06e62b4fb39750f0c02ee5d9b |
|
BLAKE2b-256 | 8074cbf67fd5beef3984d4506ade2125b4cf44ee54936938f85975a8aaf833ab |