Algorith sandbox
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
algo::qn::BroydenFletcherGoldfarbShanno< T > Class Template Reference
Inheritance diagram for algo::qn::BroydenFletcherGoldfarbShanno< T >:
util::MixIn< IQuasiNewton< T >, BroydenFletcherGoldfarbShanno< T > > algo::qn::IQuasiNewton< T > util::Object< IQuasiNewton< T > >

Public Types

typedef std::function< T(const ublas::vector< T > &x)> function_type
 
- Public Types inherited from algo::qn::IQuasiNewton< T >
typedef std::function< T(const ublas::vector< T > &x)> function_type
 

Public Member Functions

 BroydenFletcherGoldfarbShanno (const double epsilon, const std::size_t maxIteration)
 
- Public Member Functions inherited from algo::qn::IQuasiNewton< T >
ublas::vector< double > operator() (const ublas::vector< double > &x0, const function_type &f, const std::shared_ptr< ILineSearcher > searcher)
 solve $\mathrm{argmin}_{x}f(x) More...
 
- Public Member Functions inherited from util::Object< IQuasiNewton< T > >
const IQuasiNewton< T > & cast ()
 
bool operator== (const IQuasiNewton< T > &o) const
 
std::shared_ptr< IQuasiNewton< T > > clone () const
 

Private Member Functions

ublas::vector< double > doOperatorParenthesis (const ublas::vector< double > &x0, const function_type &f, const std::shared_ptr< ILineSearcher > searcher)
 
ublas::matrix< double > calculateInverseHessian (const ublas::vector< double > &x1, const ublas::vector< double > &x2, const ublas::vector< double > &df1, const ublas::vector< double > &df2, const ublas::matrix< double > &H)
 calculates inverse hessian by follwoing formula: $$ B_{k+1}^{-1} := \left(I - \frac{dx_{k} y_{k}^{T}}{y_{k}^{T}dx_{k}} \right) B_{k}^{-1} \left( I - \frac{y_{k}dx_{k}^{T}}{y_{k}^{T}dx_{k}}\right) + \frac{dx_{k}dx^{T}}{y_{k}^{T}s_{k}}. $$ Here $B_{k}$ is $k$-th hessian, $dx_{k} := x_{k+1} - x_{k}$, $I$ is identity matrix, $y_{k} := df_{k+1} - df_{k}.$ Following formula is derived from above equation. $$ B_{k+1}^{-1} = \frac{B_{k}^{-1} + (dx_{k}^{T}y_{k} + y_{k}^{T}B_{k}^{-1}y_{k})(dx_{k}dx_{k}^{T})}{(dx_{k}^{T}y_{k})^{2}} - \frac{B_{k}^{-1}y_{k}dx_{k}^{T} + dx_{k}y_{k}^{T}B_{k}^{-1}}{dx_{k}^{T}y_{k}}. $$ More...
 
bool isConverge (const ublas::vector< double > &x1, const ublas::vector< double > &x2)
 Check whether algorithm is converged or not. More...
 

Private Attributes

const double _epsilon
 
const std::size_t _maxIteration
 

Constructor & Destructor Documentation

template<typename T >
template algo::qn::BroydenFletcherGoldfarbShanno< T >::BroydenFletcherGoldfarbShanno ( const double  epsilon,
const std::size_t  maxIteration 
)
Parameters
epsilonalgorithm is converged if error is less than epsilon.
maxIterationalgorithm is iterated until converged or number of maxInteration.

Member Function Documentation

template<typename T >
template ublas::matrix< double > algo::qn::BroydenFletcherGoldfarbShanno< T >::calculateInverseHessian ( const ublas::vector< double > &  x1,
const ublas::vector< double > &  x2,
const ublas::vector< double > &  df1,
const ublas::vector< double > &  df2,
const ublas::matrix< double > &  H 
)
private

calculates inverse hessian by follwoing formula: $$ B_{k+1}^{-1} := \left(I - \frac{dx_{k} y_{k}^{T}}{y_{k}^{T}dx_{k}} \right) B_{k}^{-1} \left( I - \frac{y_{k}dx_{k}^{T}}{y_{k}^{T}dx_{k}}\right) + \frac{dx_{k}dx^{T}}{y_{k}^{T}s_{k}}. $$ Here $B_{k}$ is $k$-th hessian, $dx_{k} := x_{k+1} - x_{k}$, $I$ is identity matrix, $y_{k} := df_{k+1} - df_{k}.$ Following formula is derived from above equation. $$ B_{k+1}^{-1} = \frac{B_{k}^{-1} + (dx_{k}^{T}y_{k} + y_{k}^{T}B_{k}^{-1}y_{k})(dx_{k}dx_{k}^{T})}{(dx_{k}^{T}y_{k})^{2}} - \frac{B_{k}^{-1}y_{k}dx_{k}^{T} + dx_{k}y_{k}^{T}B_{k}^{-1}}{dx_{k}^{T}y_{k}}. $$

Todo:
check the first equation is correct or not.
Parameters
x1previous value.
x2current value.
df1
df2
Hprevious inverse hessian.
Returns
inverse hessian.
template<typename T >
template bool algo::qn::BroydenFletcherGoldfarbShanno< T >::isConverge ( const ublas::vector< double > &  x1,
const ublas::vector< double > &  x2 
)
private

Check whether algorithm is converged or not.

Parameters
x1previous value.
x2current value.
Returns
true if algorithm is converged.

The documentation for this class was generated from the following files: