Thursday, June 26, 2008

announcement: minpack package

I have been using a simple solver (based on Broyden's method) to finds roots of systems of nonlinear equation, but I encountered an ill-behaving class of problems that required heavier artillery. Numerical methods have made a lot of progress in the last 50 years. Methods presented in introductory textbooks are quite straightforward and very simple to code, but do not cut the mustard when it comes to more difficult situations (eg when you don't have a good initial guess, your function looks like the fjords of Norway, etc). State of the art methods are powerful, but they are tricky to program: the main idea is easy to grasp, but one has to cover a lot of special cases (eg line-search, niceties of trust-region methods) so implementing them from scratch takes a lot of time (and debugging). This is why most researchers rely on Fortran (or most recently, C) packages of these methods. Common Lisp users generally have two alternatives if they don't want to implement these methods from scratch. They can use the foreign code directly via the FFI, or translate the code using f2cl, which is available as part of CLOCC. I found the second option more appealing, for the following reasons:
  • fewer dependencies (no need to install/compile foreign libraries)
  • no need to have callbacks (which are a pain in the neck)
  • better integration into Lisp (eg you can use the condition system)
This is the first time I used f2cl, but it was quite easy to do, especially as CLOCC already has things set up for MINPACK. I think that translating from Fortran is the way to go for some libraries, even though I recognize that for libraries like LAPACK where pure performance matters, FFI is the better option, especially as the functions there have simpler interfaces and don't need callbacks and complex condition handling. MINPACK has already been available as part of CLOCC, but I had a hard time getting the whole thing work in SBCL, and it doesn't use ASDF, so I decided to package it to make it self-contained and ASDF-installable. The extended version of the project I am working on will probably need homotopy methods, and I am looking forward to packaging that too.

No comments:

Post a Comment