TRF Language Model
wb::LBFGS Class Reference

#include <wb-solve.h>

Inheritance diagram for wb::LBFGS:
wb::Solve

Public Member Functions

 LBFGS (Func *pfunc=NULL, double dtol=1e-5)
 constructor More...
 
 ~LBFGS ()
 destructor More...
 
virtual void IterInit ()
 iter init More...
 
virtual void ComputeDir (int k, const double *pdParam, const double *pdGradient, double *pdDir)
 Calculate the update direction p_k, referring to "Numerical Optimization"��P178��Algorithm 7.4. More...
 
void CirQueueBuf_Init ()
 Init the circular queue. More...
 
void CirQueueBuf_Release ()
 release the circular queue More...
 
void CirQueueBuf_Prev (int i, double *&pd_s, double *&pd_y)
 find the previoud ith datas, i<=m_nLimitiedNum More...
 
void CirQueueBuf_In (double *&pd_s, double *&pd_y)
 in queue. return the pointer. More...
 
- Public Member Functions inherited from wb::Solve
 Solve (Func *pfunc=NULL, double dtol=1e-5)
 
virtual bool Run (const double *pInitParams=NULL)
 Run iteration. input the init-parameters. More...
 
virtual double LineSearch (double *pdDir, double dValue, const double *pdParam, const double *pdGradient)
 linear search. More...
 
virtual void Update (double *pdParam, const double *pdDir, double dStep)
 Update. More...
 
virtual bool StopDecision (int k, double dValue, const double *pdGradient)
 Stop decision. More...
 

Protected Attributes

int m_nLimitiedNum
 limited number, i.e. m More...
 
sy * m_pCirQueueBuf
 the buffer of circular queue to store s_k = x_k - x_(k-1) and y_k = g_k - g_{k-1} More...
 
int m_nCirQueueBufTail
 queue tail More...
 
double * m_pd_s
 
double * m_pd_y
 current s_k = x_k - x_{k-1} and y_k More...
 
double * m_pdPrevGradient
 gradient on previous iteration More...
 
double * m_pdPrevParam
 parameter on previous iteration More...
 
double * m_pdAlpha
 auxillary factor in ComputeDir More...
 
- Protected Attributes inherited from wb::Solve
const char * m_pAlgorithmName
 the algorithm name. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from wb::Solve
static double VecProduct (const double *pdVec1, const double *pdVec2, int nSize)
 calculate the dot of two vectors More...
 
static double VecNorm (const double *pdVec, int nSize)
 calculate the norm of a vector More...
 
static double VecDist (const double *pdVec1, const double *pdVec2, int nSize)
 calculate the distance of two vectors More...
 
- Public Attributes inherited from wb::Solve
Funcm_pfunc
 pointer to the function More...
 
double * m_pdRoot
 save the root of the function More...
 
int m_nIterNum
 current iteration number, iter form m_nIterMin to m_nIterMax More...
 
int m_nIterMin
 minium iteration number More...
 
int m_nIterMax
 maximum iteration number More...
 
double m_dSpendMinute
 record the iteration spend time��minute�� More...
 
double m_dStop
 stop threshold More...
 
double m_dGain
 itera step. ==0 means using the line search . More...
 

Detailed Description

Definition at line 150 of file wb-solve.h.

Constructor & Destructor Documentation

§ LBFGS()

wb::LBFGS::LBFGS ( Func pfunc = NULL,
double  dtol = 1e-5 
)
inline

constructor

Definition at line 169 of file wb-solve.h.

§ ~LBFGS()

wb::LBFGS::~LBFGS ( )
inline

destructor

Definition at line 182 of file wb-solve.h.

Member Function Documentation

§ CirQueueBuf_In()

void wb::LBFGS::CirQueueBuf_In ( double *&  pd_s,
double *&  pd_y 
)

in queue. return the pointer.

Definition at line 360 of file wb-solve.cpp.

§ CirQueueBuf_Init()

void wb::LBFGS::CirQueueBuf_Init ( )

Init the circular queue.

Definition at line 334 of file wb-solve.cpp.

§ CirQueueBuf_Prev()

void wb::LBFGS::CirQueueBuf_Prev ( int  i,
double *&  pd_s,
double *&  pd_y 
)

find the previoud ith datas, i<=m_nLimitiedNum

Definition at line 354 of file wb-solve.cpp.

§ CirQueueBuf_Release()

void wb::LBFGS::CirQueueBuf_Release ( )

release the circular queue

Definition at line 343 of file wb-solve.cpp.

§ ComputeDir()

void wb::LBFGS::ComputeDir ( int  k,
const double *  pdParam,
const double *  pdGradient,
double *  pdDir 
)
virtual

Calculate the update direction p_k, referring to "Numerical Optimization"��P178��Algorithm 7.4.

Reimplemented from wb::Solve.

Definition at line 254 of file wb-solve.cpp.

§ IterInit()

void wb::LBFGS::IterInit ( )
virtual

iter init

Reimplemented from wb::Solve.

Definition at line 241 of file wb-solve.cpp.

Member Data Documentation

§ m_nCirQueueBufTail

int wb::LBFGS::m_nCirQueueBufTail
protected

queue tail

Definition at line 160 of file wb-solve.h.

§ m_nLimitiedNum

int wb::LBFGS::m_nLimitiedNum
protected

limited number, i.e. m

Definition at line 158 of file wb-solve.h.

§ m_pCirQueueBuf

sy* wb::LBFGS::m_pCirQueueBuf
protected

the buffer of circular queue to store s_k = x_k - x_(k-1) and y_k = g_k - g_{k-1}

Definition at line 159 of file wb-solve.h.

§ m_pd_s

double* wb::LBFGS::m_pd_s
protected

Definition at line 161 of file wb-solve.h.

§ m_pd_y

double * wb::LBFGS::m_pd_y
protected

current s_k = x_k - x_{k-1} and y_k

Definition at line 161 of file wb-solve.h.

§ m_pdAlpha

double* wb::LBFGS::m_pdAlpha
protected

auxillary factor in ComputeDir

Definition at line 165 of file wb-solve.h.

§ m_pdPrevGradient

double* wb::LBFGS::m_pdPrevGradient
protected

gradient on previous iteration

Definition at line 163 of file wb-solve.h.

§ m_pdPrevParam

double* wb::LBFGS::m_pdPrevParam
protected

parameter on previous iteration

Definition at line 164 of file wb-solve.h.


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