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

Base class for conjugate gradient optimization algorithms. More...

#include <cg_base.h>

Inheritance diagram for CG_Base:
Collaboration diagram for CG_Base:

Public Member Functions

void setup_cg_grad (const int dim, double *grad, const double *grad0, double *cg_grad, const double *cg_grad0, const int &ncggrad, int &flag)
 Setup conjugate gradient direction.
void Brent (double &fa, double &fb, double &fc, double &xa, double &xb, double &xc, double &best_x, double &xpt)
 Brent's method for one-dimensional minimization.
void third_order (const double &e0, const double &e1, const double &fa, const double &fb, const double x, double &best_x)
 Third-order polynomial interpolation for line search.
void f_cal (const int dim, const double *g0, const double *g1, double &f_value)
 Calculate projection of gradient onto search direction.
void setup_move (const int dim, double *move, double *cg_gradn, const double &trust_radius)
 Calculate movement vector from CG direction.

Protected Member Functions

void normalize (const int dim, double *cg_gradn, const double *cg_grad)
 Normalize vector.

Detailed Description

Base class for conjugate gradient optimization algorithms.

This class provides common CG utility functions that can be shared between different optimization implementations (ions movement and lattice change). The functions are designed to be independent of specific data sources.

Member Function Documentation

◆ Brent()

void CG_Base::Brent ( double & fa,
double & fb,
double & fc,
double & xa,
double & xb,
double & xc,
double & best_x,
double & xpt )

Brent's method for one-dimensional minimization.

Parameters
faFunction value at xa
fbFunction value at xb
fcFunction value at xc
xaLeft bound
xbMiddle point
xcRight bound
best_xOutput best step length
xptPrevious best point
Here is the call graph for this function:
Here is the caller graph for this function:

◆ f_cal()

void CG_Base::f_cal ( const int dim,
const double * g0,
const double * g1,
double & f_value )

Calculate projection of gradient onto search direction.

Parameters
dimDimension of vectors
g0First vector (usually search direction)
g1Second vector (usually gradient)
f_valueOutput projection value
Here is the call graph for this function:
Here is the caller graph for this function:

◆ normalize()

void CG_Base::normalize ( const int dim,
double * cg_gradn,
const double * cg_grad )
protected

Normalize vector.

Parameters
dimDimension of vector
cg_gradnOutput normalized vector
cg_gradInput vector
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_cg_grad()

void CG_Base::setup_cg_grad ( const int dim,
double * grad,
const double * grad0,
double * cg_grad,
const double * cg_grad0,
const int & ncggrad,
int & flag )

Setup conjugate gradient direction.

Parameters
dimDimension of the optimization problem
gradCurrent gradient
grad0Previous gradient
cg_gradOutput CG direction
cg_grad0Previous CG direction
ncggradCG iteration counter
flagRestart flag
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setup_move()

void CG_Base::setup_move ( const int dim,
double * move,
double * cg_gradn,
const double & trust_radius )

Calculate movement vector from CG direction.

Parameters
dimDimension of the optimization problem
moveOutput movement vector
cg_gradnNormalized CG direction
trust_radiusStep size limit
Here is the call graph for this function:
Here is the caller graph for this function:

◆ third_order()

void CG_Base::third_order ( const double & e0,
const double & e1,
const double & fa,
const double & fb,
const double x,
double & best_x )

Third-order polynomial interpolation for line search.

Parameters
e0Energy at previous step
e1Energy at current step
faGradient projection at previous step
fbGradient projection at current step
xCurrent step length
best_xOutput optimal step length
Here is the call graph for this function:
Here is the caller graph for this function:

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