|
tinyopt 700
Tinyopt, a lightweight, header only optimization library
|
Public Types | |
| using | Base = SolverBase<typename Hessian_t::Scalar, SQRT(traits::params_trait<Hessian_t>::Dims)> |
| using | Scalar = typename Hessian_t::Scalar |
| using | H_t = Hessian_t |
| using | Grad_t = Vector<Scalar, Dims> |
| Public Types inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| using | Scalar |
Public Member Functions | |
| SolverGN (const Options &options={}) | |
| void | InitWith (const Grad_t &g, const H_t &h) |
| Initialize solver with specific gradient and hessian. | |
| virtual void | reset () |
| Reset the solver state and clear gradient & hessian. | |
| template<int D = Dims, std::enable_if_t< D==Dynamic, int > = 0> | |
| bool | resize (int dims) |
| Resize H and grad if needed, return true if they were resized. | |
| template<int D = Dims, std::enable_if_t< D !=Dynamic, int > = 0> | |
| bool | resize (int dims=Dims) |
| Resize H and grad if needed, return true if they were resized. | |
| void | clear () |
| Set gradient and hessian to 0s. | |
| template<typename X_t> | |
| bool | ResizeIfNeeded (const X_t &x) |
| Check whether we need to resize the system (gradient), return true if it did. | |
| template<typename X_t, typename AccFunc> | |
| Scalar | Evaluate (const X_t &x, const AccFunc &acc, bool save) |
| Accumulate residuals and return the final error. | |
| template<typename X_t, typename AccFunc> | |
| bool | Accumulate (const X_t &x, const AccFunc &acc) |
| Accumulate residuals and update the gradient, returns true on success. | |
| template<typename X_t, typename AccFunc> | |
| bool | Build (const X_t &x, const AccFunc &acc_func, bool resize_and_clear=true) |
| std::optional< Vector< Scalar, Dims > > | Solve () const override |
| Solve the linear system dx = -H^-1 * grad, returns nullopt on failure. | |
| virtual Index | dims () const override |
| Scalar | MaxStdDev (bool use_damped=true) const |
| virtual std::optional< H_t > | Covariance () const |
| Latest Covariance estimate. | |
| const H_t & | Hessian () const |
| Latest, eventually damped Hessian approximation (JtJ). | |
| const H_t & | H () const |
| H_t & | H () |
| const Grad_t & | Gradient () const |
| Grad_t & | Gradient () |
| 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) |
| virtual void | FailedStep () |
| virtual void | Rebuild (bool) |
| virtual std::string | stateAsString () const |
| const Cost & | cost () const |
Public Attributes | |
| const Options | options_ |
Static Public Attributes | |
| static constexpr bool | IsNLLS = true |
| static constexpr bool | FirstOrder = false |
| static constexpr Index | Dims = SQRT(traits::params_trait<Hessian_t>::Dims) |
| Static Public Attributes inherited from tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)> | |
| static constexpr Index | Dims |
Protected Attributes | |
| 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_ |
|
inline |
Build the gradient and hessian by accumulating residuals and their jacobians Returns true on success
|
inlinevirtual |
Latest Covariance estimate.
Reimplemented in tinyopt::solvers::SolverLM< Hessian_t >, and tinyopt::solvers::SolverLM< Hessian_t >.
|
inlineoverridevirtual |
|
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)
|
inlinevirtual |
Reset the solver state and clear gradient & hessian.
Reimplemented in tinyopt::solvers::SolverDogLeg< Hessian_t >, tinyopt::solvers::SolverDogLeg< Hessian_t >, tinyopt::solvers::SolverLM< Hessian_t >, and tinyopt::solvers::SolverLM< Hessian_t >.
|
inlineoverridevirtual |
Solve the linear system dx = -H^-1 * grad, returns nullopt on failure.
Implements tinyopt::solvers::SolverBase< MatX::Scalar, SQRT(traits::params_trait< MatX >::Dims)>.
Reimplemented in tinyopt::solvers::SolverLM< Hessian_t >, and tinyopt::solvers::SolverLM< Hessian_t >.