ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
ModuleBase::Opt_TN Class Reference

A class designed to deal with optimization problems with Truncated-Newton (TN) method. At each step, the optimization direction d is determined by roughly solving linear equation Hd=-g, where H is Hessian matrix of f(x), and g is the gradient df(x)/dx. In this section, we get Hd by interpolation, and solve Hd=-g with CG method. We set three truncated conditions: 1) the residual of CG method has decreased more than 90%; 2) the number of CG iteration is more than 50; 3) the residual of CG method doesn't decrease and the CG iteration is larger than 9. More...

#include <opt_tn.h>

Collaboration diagram for ModuleBase::Opt_TN:

Public Member Functions

 Opt_TN ()
 ~Opt_TN ()
void allocate (int nx)
 Allocate the space for the arrays in cg_.
void set_para (double dV)
void refresh (int nx_new=0)
 Refresh the class. If nx changes, reallocate space in cg_.
template<class T>
void next_direct (double *px, double *pgradient, int &flag, double *rdirect, T *t, void(T::*p_calGradient)(double *ptemp_x, double *rtemp_gradient))
 Get the next direction d with TN method.
int get_iter ()

Private Member Functions

double inner_product (double *pa, double *pb, int length)
double get_epsilon (double *px, double *pcg_direction)
 Get epsilon used in interpolation. epsilon = 2*sqrt(mach_prec_) * (1+|x|) / |d|. || means modulu.

Private Attributes

Opt_CG cg_
double dV_ = 1.
int nx_ = 0
int iter_ = 0
double mach_prec_ = 0.

Detailed Description

A class designed to deal with optimization problems with Truncated-Newton (TN) method. At each step, the optimization direction d is determined by roughly solving linear equation Hd=-g, where H is Hessian matrix of f(x), and g is the gradient df(x)/dx. In this section, we get Hd by interpolation, and solve Hd=-g with CG method. We set three truncated conditions: 1) the residual of CG method has decreased more than 90%; 2) the number of CG iteration is more than 50; 3) the residual of CG method doesn't decrease and the CG iteration is larger than 9.

Author
sunliang

Constructor & Destructor Documentation

◆ Opt_TN()

ModuleBase::Opt_TN::Opt_TN ( )

◆ ~Opt_TN()

ModuleBase::Opt_TN::~Opt_TN ( )
inline

Member Function Documentation

◆ allocate()

void ModuleBase::Opt_TN::allocate ( int nx)

Allocate the space for the arrays in cg_.

Parameters
nxlength of the solution array x

◆ get_epsilon()

double ModuleBase::Opt_TN::get_epsilon ( double * px,
double * pcg_direction )
private

Get epsilon used in interpolation. epsilon = 2*sqrt(mach_prec_) * (1+|x|) / |d|. || means modulu.

Parameters
pxx
pcg_directionthe direction of cg_
Returns
epsilon
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_iter()

int ModuleBase::Opt_TN::get_iter ( )
inline

◆ inner_product()

double ModuleBase::Opt_TN::inner_product ( double * pa,
double * pb,
int length )
private
Here is the call graph for this function:
Here is the caller graph for this function:

◆ next_direct()

template<class T>
void ModuleBase::Opt_TN::next_direct ( double * px,
double * pgradient,
int & flag,
double * rdirect,
T * t,
void(T::* p_calGradient )(double *ptemp_x, double *rtemp_gradient) )

Get the next direction d with TN method.

Template Parameters
Tfor example, ESolver_OF
Parameters
[in]pxcurrent x.
[in]pgradientdf(x)/dx.
[out]flagrecord which truncated condition was triggered, 0 for cond.1, 1 for cond.2, and 2 for cond.3.
[out]rdirectnext optimization direction.
[in]tpointer of class T, which contains the gradient function.
[in]p_calGradienta function pointer, which calculates gradient at provided x.
Here is the call graph for this function:

◆ refresh()

void ModuleBase::Opt_TN::refresh ( int nx_new = 0)

Refresh the class. If nx changes, reallocate space in cg_.

Parameters
nx_newlength of new x, default 0 means the length doesn't change

◆ set_para()

void ModuleBase::Opt_TN::set_para ( double dV)

Member Data Documentation

◆ cg_

Opt_CG ModuleBase::Opt_TN::cg_
private

◆ dV_

double ModuleBase::Opt_TN::dV_ = 1.
private

◆ iter_

int ModuleBase::Opt_TN::iter_ = 0
private

◆ mach_prec_

double ModuleBase::Opt_TN::mach_prec_ = 0.
private

◆ nx_

int ModuleBase::Opt_TN::nx_ = 0
private

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