TRF Language Model
wb::Solve Class Reference

the base class of all the solve classes, and provide a gradient descent algorithm. More...

#include <wb-solve.h>

Inheritance diagram for wb::Solve:
hrf::SAtrain trf::SAtrain wb::LBFGS

Public Member Functions

 Solve (Func *pfunc=NULL, double dtol=1e-5)
 
virtual bool Run (const double *pInitParams=NULL)
 Run iteration. input the init-parameters. More...
 
virtual void IterInit ()
 initial the iteration, for derivation. More...
 
virtual void ComputeDir (int k, const double *pdParam, const double *pdGradient, double *pdDir)
 Calculate the update direction p_k. 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...
 

Static Public Member Functions

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

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...
 

Protected Attributes

const char * m_pAlgorithmName
 the algorithm name. More...
 

Detailed Description

the base class of all the solve classes, and provide a gradient descent algorithm.

Author
wangbin
Date
2016-03-04

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

Constructor & Destructor Documentation

§ Solve()

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

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

Member Function Documentation

§ ComputeDir()

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

Calculate the update direction p_k.

Parameters
[in]kiteration number, from 1 to ...
[in]pdParamparameter x_k
[in]pdGradientthe gradient at x_k
[out]pdDirreturn the direction

Reimplemented in wb::LBFGS.

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

§ IterInit()

virtual void wb::Solve::IterInit ( )
inlinevirtual

initial the iteration, for derivation.

Reimplemented in wb::LBFGS.

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

§ LineSearch()

double wb::Solve::LineSearch ( double *  pdDir,
double  dValue,
const double *  pdParam,
const double *  pdGradient 
)
virtual

linear search.

Parameters
[in]pdDirupdate direction p_k
[in]dValuethe function value at x_k
[in]pdGradientthe gradient at x_k
[in]pdCurParamparameter x_k
Returns
the learning step.

Ëã·¨²Î¼ÓNumerical Optimization£¬P57£¬½éÉܵÄinterpolationËã·¨

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

§ Run()

bool wb::Solve::Run ( const double *  pInitParams = NULL)
virtual

Run iteration. input the init-parameters.

< ±£´æµü´ú²½³¤

init

Reimplemented in hrf::SAtrain, and trf::SAtrain.

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

§ StopDecision()

bool wb::Solve::StopDecision ( int  k,
double  dValue,
const double *  pdGradient 
)
virtual

Stop decision.

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

§ Update()

void wb::Solve::Update ( double *  pdParam,
const double *  pdDir,
double  dStep 
)
virtual

Update.

Reimplemented in hrf::SAtrain, and trf::SAtrain.

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

§ VecDist()

double wb::Solve::VecDist ( const double *  pdVec1,
const double *  pdVec2,
int  nSize 
)
static

calculate the distance of two vectors

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

§ VecNorm()

double wb::Solve::VecNorm ( const double *  pdVec,
int  nSize 
)
static

calculate the norm of a vector

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

§ VecProduct()

double wb::Solve::VecProduct ( const double *  pdVec1,
const double *  pdVec2,
int  nSize 
)
static

calculate the dot of two vectors

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

Member Data Documentation

§ m_dGain

double wb::Solve::m_dGain

itera step. ==0 means using the line search .

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

§ m_dSpendMinute

double wb::Solve::m_dSpendMinute

record the iteration spend time��minute��

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

§ m_dStop

double wb::Solve::m_dStop

stop threshold

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

§ m_nIterMax

int wb::Solve::m_nIterMax

maximum iteration number

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

§ m_nIterMin

int wb::Solve::m_nIterMin

minium iteration number

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

§ m_nIterNum

int wb::Solve::m_nIterNum

current iteration number, iter form m_nIterMin to m_nIterMax

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

§ m_pAlgorithmName

const char* wb::Solve::m_pAlgorithmName
protected

the algorithm name.

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

§ m_pdRoot

double* wb::Solve::m_pdRoot

save the root of the function

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

§ m_pfunc

Func* wb::Solve::m_pfunc

pointer to the function

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


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