Occasionally I see requests to solve very many nonlinear least squares problems, all of which have the same model, but different sets of data. The simple answer is a loop, or you might use a parallel computing solution. However, you can also use a capability that is built into the optimization toolbox solvers - to allow you to solve many small problems in parallel with a block diagonal Jacobian matrix.
For example, suppose you are asked to estimate the coefficients for the model
y = a1 + a2*exp(a3*x)
This is a simple problem to solve using any nonlinear regression tool. (I recommend my own fminspleas, also on the File Exchange.) But suppose you have 10000 sets of data, so you need to solve for 10000 sets of parameters? You could just use a loop, but loops are not always the most efficient way to solve a problem.
batchpleas is the tool for this problem. It will typically allow for an order of magnitude enhancement in throughput, without the need for any parallel processing toolbox. For example the example I provide in the included demo showed a 13-1 speedup when fitting a set of 10000 curves to data, each with 3 parameters to estimate.
The latest revision now offers bound constraints to be placed on all parameters.
John D'Errico (2022). Batched partitioned nonlinear least squares (https://www.mathworks.com/matlabcentral/fileexchange/49950-batched-partitioned-nonlinear-least-squares), MATLAB Central File Exchange. Retrieved .
MATLAB Release Compatibility
Platform CompatibilityWindows macOS Linux
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!