|
tinyopt 700
Tinyopt, a lightweight, header only optimization library
|
Public Types | |
| using | Base = tinyopt::solvers::SolverGN<Hessian_t> |
| using | Scalar = typename Hessian_t::Scalar |
| using | H_t = Hessian_t |
| using | Grad_t = Vector<Scalar, Dims> |
| using | Options = tinyopt::Options |
| Public Types inherited from tinyopt::solvers::SolverGN< MatX > | |
| using | Base |
| using | Scalar |
| using | H_t |
| using | Grad_t |
| Public Types inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| using | Scalar |
Public Member Functions | |
| SolverLM (const Options &options={}) | |
| void | reset () override |
| Reset the solver state and clear gradient & hessian. | |
| void | Rebuild (bool b) override |
| Force the solver to rebuild or skip it. | |
| template<typename X_t, typename AccFunc> | |
| bool | Build (const X_t &x, const AccFunc &acc_func, bool resize_and_clear=true) |
| void | GoodStep (Scalar quality) override |
| Damping stategy for a good step: increase the damping factor \lambda. | |
| void | BadStep (Scalar=0.0f) override |
| Damping stategy for a bad step: decrease the damping factor \lambda. | |
| void | FailedStep () override |
| Damping stategy for a failure to solve the linear system, decrease the damping factor \lambda. | |
| std::optional< Grad_t > | Solve () const override |
| Solve the linear system dx = -H^-1 * grad, returns nullopt on failure. | |
| std::string | stateAsString () const override |
| H_t | Hessian () const |
| Latest Hessian approximation (JtJ), un-damped. | |
| std::optional< H_t > | Covariance () const override |
| Latest Covariance estimate. | |
| Scalar | MaxStdDev (bool use_damped=true) const |
| Public Member Functions inherited from tinyopt::solvers::SolverGN< MatX > | |
| SolverGN (const Options &options={}) | |
| void | InitWith (const Grad_t &g, const H_t &h) |
| Initialize solver with specific gradient and hessian. | |
| bool | resize (int dims) |
| Resize H and grad if needed, return true if they were resized. | |
| void | clear () |
| Set gradient and hessian to 0s. | |
| bool | ResizeIfNeeded (const X_t &x) |
| Check whether we need to resize the system (gradient), return true if it did. | |
| Scalar | Evaluate (const X_t &x, const AccFunc &acc, bool save) |
| Accumulate residuals and return the final error. | |
| bool | Accumulate (const X_t &x, const AccFunc &acc) |
| Accumulate residuals and update the gradient, returns true on success. | |
| bool | Build (const X_t &x, const AccFunc &acc_func, bool resize_and_clear=true) |
| virtual Index | dims () const override |
| Scalar | MaxStdDev (bool use_damped=true) const |
| const H_t & | Hessian () const |
| Latest, eventually damped Hessian approximation (JtJ). | |
| const H_t & | H () const |
| const Grad_t & | Gradient () const |
| Scalar | GradientNorm () const |
| Scalar | GradientSquaredNorm () const |
| Public Member Functions inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| SolverBase (const Options &options={}) | |
| bool | Clamp (Grad_t &g, Scalar minmax) const |
| Clamp the gradient 'g' to within [-minmax, minmax], if minmax is not 0. Returns true if 'g' was clamped. | |
| void | NormalizeCost (Cost &cost) |
| Eventually normalize the cost. | |
| virtual void | GoodStep (Scalar=0.0f) |
| virtual void | BadStep (Scalar=0.0f) |
| const Cost & | cost () const |
Static Public Attributes | |
| static constexpr bool | IsNLLS = true |
| static constexpr bool | FirstOrder = false |
| static constexpr Index | Dims = Base::Dims |
| Static Public Attributes inherited from tinyopt::solvers::SolverGN< MatX > | |
| static constexpr bool | IsNLLS |
| static constexpr bool | FirstOrder |
| static constexpr Index | Dims |
| Static Public Attributes inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| static constexpr Index | Dims |
Protected Member Functions | |
| void | ApplyJacobiScaling () |
| void | ApplyJacobiScaling (H_t &hessian, bool inverse) const |
Protected Attributes | |
| const Options | options_ |
| Grad_t | scaling_ |
| Scalar | lambda_ = 1e-4f |
| Initial damping factor (\lambda). | |
| Scalar | prev_lambda_ = 0.0f |
| Previous damping factor (0 at start). | |
| Scalar | bad_factor_ = 2.0f |
| Current damping scaling factor for bad steps. | |
| bool | rebuild_linear_system_ = true |
| Protected Attributes inherited from tinyopt::solvers::SolverGN< MatX > | |
| H_t | H_ |
| Grad_t | grad_ |
| Protected Attributes inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| const Options | options_ |
| Cost | cost_ |
Additional Inherited Members | |
| Public Attributes inherited from tinyopt::solvers::SolverGN< MatX > | |
| const Options | options_ |
|
inline |
Build the gradient and hessian by accumulating residuals and their jacobians Returns true on success
|
inlineoverridevirtual |
Latest Covariance estimate.
Reimplemented from tinyopt::solvers::SolverGN< MatX >.
|
inlineoverridevirtual |
Damping stategy for a failure to solve the linear system, decrease the damping factor \lambda.
Reimplemented from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)>.
|
inline |
Return the square root of the maximum (co)variance of the H.inv() H being the damped Hessian H_ if use_damped == true (faster) or un-damped Hessian() (accurate)
|
inlineoverridevirtual |
Force the solver to rebuild or skip it.
Reimplemented from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)>.
|
inlineoverridevirtual |
Reset the solver state and clear gradient & hessian.
Reimplemented from tinyopt::solvers::SolverGN< MatX >.
|
inlineoverridevirtual |
Solve the linear system dx = -H^-1 * grad, returns nullopt on failure.
Reimplemented from tinyopt::solvers::SolverGN< MatX >.
|
inlineoverridevirtual |
|
protected |
Whether the linear system (H and gradient) have to be rebuilt or a simple evaluation can do it.