Add fitting functionality using Ceres-Solver #189
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This branch is an attempt at adding fitting functionality to
so3g
using theCeres-Solver
library to support both non-linear least squares and general optimization problems. It is used to duplicate the existing noise-fitting function insotodlib
. The idea of this function is to:The cost function classes and fitting functions have been written in a model-independent manner, so they should be easy to adapt for other data and model types.
Ceres
includes options for bounds/constraints and supports auto differentiation so derivatives and gradients don't need be calculated manually. The general minimization routine forCeres
doesn't seem to have uncertainty calculations (its least-squares routines do) so I have manually calculated the inverted Hessian matrix to get the parameter uncertainties.I put most of the code into new
fitting_ops.cxx
andfitting_ops.h
files instead of putting it all inarray_ops.cxx
. I added anarray_ops.h
file to hold shared functions declarations.I've added a cmake directory with cmake files for
Ceres,
Eigen
,Gflag
, andGlog
with the last 3 being dependencies ofCeres-Solver
. We could move these intospt3g
at some point, but this also seems to work in my tests.Eigen
is a nice optimized vector, matrix, and linear algebra library that might be useful on its own, but it is not required to useEigen
when working withCeres
.Building the Docker image for tests will take a few minutes longer now as I found that Ceres needed to be built from source as the necessary version doesn't appear to be available through
apt-get libceres-dev
.