tinyopt 700
Tinyopt, a lightweight, header only optimization library
Loading...
Searching...
No Matches
tinyopt::solvers::SolverLBFGS< Gradient_t, HistoryCapacity > Class Template Reference
Inheritance diagram for tinyopt::solvers::SolverLBFGS< Gradient_t, HistoryCapacity >:
tinyopt::solvers::SolverGD< VecX > tinyopt::solvers::SolverBase< VecX::Scalar, traits::params_trait< VecX >::Dims >

Public Types

using Base = SolverGD<Gradient_t>
using Scalar = typename Base::Scalar
using Grad_t = typename Base::Grad_t
Public Types inherited from tinyopt::solvers::SolverGD< VecX >
using Base
using Scalar
using Grad_t
using H_t
Public Types inherited from tinyopt::solvers::SolverBase< VecX::Scalar, traits::params_trait< VecX >::Dims >
using Scalar

Public Member Functions

 SolverLBFGS (const Options &options={})
void reset ()
template<typename X_t, typename AccFunc>
bool Build (const X_t &x, const AccFunc &acc, bool resize_and_clear=true)
std::optional< Vector< Scalar, Dims > > Solve () const override
 Solve the linear system dx = -lr * grad, returns nullopt on failure.
void GoodStep (Scalar=0) override
void BadStep (Scalar=0) override
Public Member Functions inherited from tinyopt::solvers::SolverGD< VecX >
 SolverGD (const Options &options={})
void InitWith (const Grad_t &g)
 Initialize solver with specific gradient and hessian.
void reset ()
 Reset the solver state and clear gradient & 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.
auto GetAccFunc (const AccFunc &acc) const
 Ugly function to make sure the returned type is always a pair<scalar, scalar>...
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, bool resize_and_clear=true)
Index dims () const override
const Grad_t & Gradient () const
Scalar GradientNorm () const
Scalar GradientSquaredNorm () const
Public Member Functions inherited from tinyopt::solvers::SolverBase< VecX::Scalar, traits::params_trait< VecX >::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

Static Public Attributes

static constexpr Index Dims = Base::Dims
static constexpr bool IsNLLS = false
static constexpr bool FirstOrder = true
Static Public Attributes inherited from tinyopt::solvers::SolverGD< VecX >
static constexpr bool IsNLLS
static constexpr bool FirstOrder
static constexpr Index Dims
Static Public Attributes inherited from tinyopt::solvers::SolverBase< VecX::Scalar, traits::params_trait< VecX >::Dims >
static constexpr Index Dims

Additional Inherited Members

Public Attributes inherited from tinyopt::solvers::SolverGD< VecX >
const Options options_
Protected Attributes inherited from tinyopt::solvers::SolverGD< VecX >
Grad_t grad_
Protected Attributes inherited from tinyopt::solvers::SolverBase< VecX::Scalar, traits::params_trait< VecX >::Dims >
const Options options_
Cost cost_

Member Function Documentation

◆ Solve()

template<typename Gradient_t = VecX, std::size_t HistoryCapacity = 8>
std::optional< Vector< Scalar, Dims > > tinyopt::solvers::SolverLBFGS< Gradient_t, HistoryCapacity >::Solve ( ) const
inlineoverridevirtual

Solve the linear system dx = -lr * grad, returns nullopt on failure.

Reimplemented from tinyopt::solvers::SolverGD< VecX >.


The documentation for this class was generated from the following file:
  • include/tinyopt/solvers/bfgs.h