Rust bindings for Ceres Solver
cargo add ceres-solver --features=sourceCeres Solver is a C++ library for large optimization problems. It can be used to solve Non-linear Least Squares problems with constraints and general optimization problems. Here we provide a Rust binding for this library.
The bindings require Ceres Solver version 2.2, but the bindings may work with older or new versions. Please submit an issue if you need a support of other versions.
This project consists of three crates:
ceres-solveris a safe Rust bindingsceres-solver-sysis an unsafe Rust bindings written with the usage ofcxxceres-solver-srcis an optional no-code crate to build and distribute a minimal static Ceres Solver library
To build Ceres Solver statically and link it to your project, use source Cargo feature, which would add ceres-solver-src dependency into your project.
Current implementation of the binding is not complete. The following list shows the status of the binding support:
- Non-linear Least squares
-
Problem- basic class for NLLS, supports adding residual blocks, setting boundary conditions, marking parameter blocks to be constant/variable, and solving the problem -
CostFunction- user provides both residual and Jacobian -
SizedCostFunction- same but with the residual vector shape is known at compile time -
AutoDiffCostFunction- user provides residual and Jacobian is computed by automatic differentiation -
DynamicAutoDiffCostFunction- same but with the residual vector shape is unknown at compile time -
NumericDiffCostFunction- user provides residual and Jacobian is computed by numerical differentiation -
CostFunctionToFunctorandDynamicCostFunctionToFunctor- adapter to useCostFunctionas a mix of all other cost functions -
ConditionedCostFunction- adapter to useCostFunctionwith different conditioning -
GradientChecker- helper class to check the correctness of the Jacobian -
NormalPrior- changes a cost function to use a covariance matrix instead of a simple scalar product -
LossFunction- a function applied to the squared norm of the residual vector, both custom and Ceres stack loss functions are supported -
Manifold,AutoDiffManifold -
EvaluationCallback
-
- Solver -
Solverclass itself is not implemented, but the following nested classes are supported:Solver::Options- Minimizer options
- Line search options
- Trust region options
- Linear solver options
- Preconditioner options
- Sparse and dense linear algebra library selection
- Setting of the number of threads
- Bundle adjustment options
- Logging options
- Validation of the options
- Callbacks
Solver::Summary- Brief and full reports
- Cost function evaluation statistics
- Time statistics
- Jets
- Covariance estimation
- General unconstrained minimization
Please don't hesitate to create an issue to request prioritization of any functionality you need.