Monday, April 25, 2011

GNU Science Library

In our quest to get better and running simulations of networks of neurons, we've been trying to replicate a number of papers covering a variety of techniques. For example, we looked at the integrate-and-fire model of Hansel 1998 and the modified Hodgkin & Huxley approach of Rubin and Terman 2004.

Part of the problem in running these simulations is developing and properly understanding the numerical methodology responsible for cranking through the differential equations. There are a number of available techniques, and up until now we'd been basically hand coding them (we're developing our simulations in GNU C/C++ since we want these sims to run quickly over tens of thousands of neurons, which basically rules out Matlab). Forward Euler is pretty easy to code but is numerically very limited and requires small step sizes (meaning large numbers of calculations). More advanced methods such as Runge-Kutta and the adaptive step-size method of Runge-Kutta-Fehlberg can get away with far fewer calculations but require more coding and are therefore more prone to coding mistakes. All that extra code has to be tested and validated, a time consuming process.

We were pleased then to discover that the GNU Science Library (or GSL for short) has built in support for Ordinary Differential Equations. Although I'd used GSL before because of its matrix library (which its cumbersome to use - I now prefer to use openCV's matrix library instead), I hadn't been aware of its ODE capabilities. The solver supports a range of algorithms including the embedded Runge-Kutta Prince-Dormand method and the august Bulirsch-Stoer method that actually required a Jacobian in addition to the actual differential equations themselves.

If I have some time later this week I'll post some benchmarks to give an idea on the savings of computation time.

No comments:

Post a Comment