Basic Image AlgorithmS Library  2.8.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
Public Member Functions | Protected Member Functions | List of all members
BIAS::LevenbergMarquardtBase Class Referenceabstract

Base interface for classes using non-linear optimization of a target function using the Levenberg-Marquardt algorithm. More...

#include <MathAlgo/LevenbergMarquardtBase.hh>

+ Inheritance diagram for BIAS::LevenbergMarquardtBase:

Public Member Functions

 LevenbergMarquardtBase ()
 
int LM_Compute (const int numResiduals, const int numParameters, BIAS::Vector< double > &startX, BIAS::Vector< double > &resultX, BIAS::Vector< double > &residuals)
 Compute Levenberg-Marquardt algorithm using the user defined target function f(x) implemented in LM_TargetFunction_, and the analytic Jacobian J(x) implemented in LM_Jacobian_. More...
 
int LM_ComputeWithoutJacobian (const int numResiduals, const int numParameters, BIAS::Vector< double > &startX, BIAS::Vector< double > &resultX, BIAS::Vector< double > &residuals, const double epsilon=LM_DEF_EPSILON)
 Compute Levenberg-Marquardt algorithm using the user defined target function f(x) implemented in LM_TargetFunction_. More...
 
BIAS::Matrix< double > LM_GetJacobianResult () const
 Return the resulting Jacobian J(x) from the last computation. More...
 
int LM_GetMaxIterations () const
 Return the maximal number of iterations to perform. More...
 
int LM_GetNumOfIterations () const
 Return the number of iterations performed in last computation. More...
 
BIAS::Vector< double > LM_GetParameterResult () const
 Return the resulting parameter vector x from last computation. More...
 
BIAS::Vector< double > LM_GetResidualsResult () const
 Return the resulting residual vector f(x) from last computation. More...
 
double LM_GetSumOfSquaredErrors () const
 Return the sum of squared errors from the last computation. More...
 
double LM_GetTolerance () const
 Return tolerance used to evaluate convergence. More...
 
void LM_SetMaxIterations (const int iters)
 Set the maximal number of iterations to perform. More...
 
void LM_SetTolerance (const double tol)
 Set tolerance used to evaluate convergence. More...
 
virtual ~LevenbergMarquardtBase ()
 

Protected Member Functions

virtual int LM_JacobianFunction_ (const BIAS::Vector< double > &x, BIAS::Matrix< double > &J)
 Compute Jacobian J(x) of target function f evaluated at vector x. More...
 
virtual int LM_TargetFunction_ (const BIAS::Vector< double > &x, BIAS::Vector< double > &residuals)=0
 Compute residuals of target function f for input vector x. More...
 

Detailed Description

Base interface for classes using non-linear optimization of a target function using the Levenberg-Marquardt algorithm.

Note
Since this class used virtual function calls to evaluate the target function of the Levenber-Marquardt instance, and data is copied between BIAS data structure and arrays in every iteration, it is not well suited for high-performance demands! Use the direct Minpack interface from Minpack.hh instead when you are targeting at performance!

Provides a class interface to Minpack with convenient definition of target function f(x) and Jacobian J(x).

See Also
Minpack.hh
Author
esquivel
Date
05/2010
Examples:
ExampleLevenbergMarquardt.cpp.

Definition at line 56 of file LevenbergMarquardtBase.hh.

Constructor & Destructor Documentation

BIAS::LevenbergMarquardtBase::LevenbergMarquardtBase ( )
inline

Definition at line 76 of file LevenbergMarquardtBase.hh.

virtual BIAS::LevenbergMarquardtBase::~LevenbergMarquardtBase ( )
inlinevirtual

Definition at line 84 of file LevenbergMarquardtBase.hh.

Member Function Documentation

int LevenbergMarquardtBase::LM_Compute ( const int  numResiduals,
const int  numParameters,
BIAS::Vector< double > &  startX,
BIAS::Vector< double > &  resultX,
BIAS::Vector< double > &  residuals 
)

Compute Levenberg-Marquardt algorithm using the user defined target function f(x) implemented in LM_TargetFunction_, and the analytic Jacobian J(x) implemented in LM_Jacobian_.

Returns
Returns value < 0 if computation failed, 0 for convergence, and > 0 otherwise (see LevenbergMarquardt in #Minpack.hh).

Definition at line 30 of file LevenbergMarquardtBase.cpp.

References BIAS::LevenbergMarquardtExtended(), TNT::Vector< T >::newsize(), and TNT::Matrix< T >::newsize().

int LevenbergMarquardtBase::LM_ComputeWithoutJacobian ( const int  numResiduals,
const int  numParameters,
BIAS::Vector< double > &  startX,
BIAS::Vector< double > &  resultX,
BIAS::Vector< double > &  residuals,
const double  epsilon = LM_DEF_EPSILON 
)

Compute Levenberg-Marquardt algorithm using the user defined target function f(x) implemented in LM_TargetFunction_.

   The Jacobian of f is approximated numerically using the given
   value epsilon.
Parameters
epsilonis "an input variable used in determining a suitable step length for the forward-difference approximation" of the Jacobian of f (see documentation of minpack/fdjac2.c)
Returns
Returns value < 0 if computation failed, 0 for convergence, and > 0 otherwise (see LevenbergMarquardt in #Minpack.hh).

Definition at line 57 of file LevenbergMarquardtBase.cpp.

References BIAS::ComputeJacobian(), BIAS::LevenbergMarquardtExtended(), TNT::Vector< T >::newsize(), TNT::Matrix< T >::newsize(), and BIAS::Matrix< T >::SetZero().

BIAS::Matrix<double> BIAS::LevenbergMarquardtBase::LM_GetJacobianResult ( ) const
inline

Return the resulting Jacobian J(x) from the last computation.

Definition at line 139 of file LevenbergMarquardtBase.hh.

int BIAS::LevenbergMarquardtBase::LM_GetMaxIterations ( ) const
inline

Return the maximal number of iterations to perform.

Definition at line 119 of file LevenbergMarquardtBase.hh.

int BIAS::LevenbergMarquardtBase::LM_GetNumOfIterations ( ) const
inline

Return the number of iterations performed in last computation.

Definition at line 127 of file LevenbergMarquardtBase.hh.

BIAS::Vector<double> BIAS::LevenbergMarquardtBase::LM_GetParameterResult ( ) const
inline

Return the resulting parameter vector x from last computation.

Definition at line 131 of file LevenbergMarquardtBase.hh.

BIAS::Vector<double> BIAS::LevenbergMarquardtBase::LM_GetResidualsResult ( ) const
inline

Return the resulting residual vector f(x) from last computation.

Definition at line 135 of file LevenbergMarquardtBase.hh.

double BIAS::LevenbergMarquardtBase::LM_GetSumOfSquaredErrors ( ) const
inline

Return the sum of squared errors from the last computation.

Definition at line 123 of file LevenbergMarquardtBase.hh.

double BIAS::LevenbergMarquardtBase::LM_GetTolerance ( ) const
inline

Return tolerance used to evaluate convergence.

Definition at line 111 of file LevenbergMarquardtBase.hh.

virtual int BIAS::LevenbergMarquardtBase::LM_JacobianFunction_ ( const BIAS::Vector< double > &  x,
BIAS::Matrix< double > &  J 
)
inlineprotectedvirtual

Compute Jacobian J(x) of target function f evaluated at vector x.

Note
Override this with the user specified Jacobian function. Otherwise, only a numerical approximation of J(x) will be used.

Definition at line 96 of file LevenbergMarquardtBase.hh.

void BIAS::LevenbergMarquardtBase::LM_SetMaxIterations ( const int  iters)
inline

Set the maximal number of iterations to perform.

Definition at line 115 of file LevenbergMarquardtBase.hh.

void BIAS::LevenbergMarquardtBase::LM_SetTolerance ( const double  tol)
inline

Set tolerance used to evaluate convergence.

Definition at line 107 of file LevenbergMarquardtBase.hh.

virtual int BIAS::LevenbergMarquardtBase::LM_TargetFunction_ ( const BIAS::Vector< double > &  x,
BIAS::Vector< double > &  residuals 
)
protectedpure virtual

Compute residuals of target function f for input vector x.

Note
Override this with the user specified target function.

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