cancel
Showing results for 
Search instead for 
Did you mean: 

OpenCL

luker
Journeyman III

OpenCL library including solver for nonlinear least squares problems

For a project im in need of a nonlinear least squares solver for the purpose of curve fitting with custom functions. Thus I have a set of observed points, a set of target points and a (user specific) function whose parameters I seek to optimise in order to minimize the square error.

As far as I can tell algorithms to solve this sort of problem are nonlinear conjugate gradient (NLCG) or the Levenberg-Marquardt algorithm (LMA). Unfortunately I could not find any OpenCL (or even CUDA) library solving this particularly problem.

Does someone know about an existing implementation?

Thanks

Tags (2)
0 Likes
Reply
2 Replies
ajhill
Journeyman III

Re: OpenCL library including solver for nonlinear least squares problems

Consider using Nelder Mead instead of NLCG or LMA. I'm not sure if it is in any existing library,

but it would be simple to implement in OpenCL. NM is flexible and sounds like a good "fit" to your

project problem statement - I've used a C++ implementation I wrote for similar work for many years.

I think there's a partial implementation of NM in Rob Farber's CUDA book, but it's probably quicker to

write a new routine from scratch than try to translate his code from CUDA to OpenCL.

0 Likes
Reply
luker
Journeyman III

Re: OpenCL library including solver for nonlinear least squares problems

Thank you for your feedback ajhill​. I went down the road implementing LMA myself (currently in progress). For anyone running into the same problem: Following post describes the math and the various methods for the iterative step calculation: Linear And Nonlinear Least-Squares With Math.NET | Imaging Shop

Most of the operations can be straightforward done by the routines implemented in Math libraries (I used ViennaCL - Linear Algebra Library using CUDA, OpenCL, and OpenMP​ since they provide an SVD implementation). Whats left to do is to calculate the Jacobian using forward (or centered) differences and to figure out a way to let users easily supply model functions which will be used to calculate the residuals in an OpenCL kernel with arbitrary kernel arguments.

0 Likes
Reply