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.hpp>
|
| 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)) |
|
int | get_iter () |
|
template<class T > |
void | next_direct (double *px, double *pgradient, int &flag, double *rdirect, T *t, void(T::*p_calGradient)(double *px, double *rgradient)) |
| Get the next direction d with TN method.
|
|
|
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.
|
|
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
◆ Opt_TN()
ModuleBase::Opt_TN::Opt_TN |
( |
| ) |
|
|
inline |
◆ ~Opt_TN()
ModuleBase::Opt_TN::~Opt_TN |
( |
| ) |
|
|
inline |
◆ allocate()
void ModuleBase::Opt_TN::allocate |
( |
int |
nx | ) |
|
|
inline |
Allocate the space for the arrays in cg_.
- Parameters
-
nx | length of the solution array x |
◆ get_epsilon()
double ModuleBase::Opt_TN::get_epsilon |
( |
double * |
px, |
|
|
double * |
pcg_direction |
|
) |
| |
|
inlineprivate |
Get epsilon used in interpolation. epsilon = 2*sqrt(mach_prec_) * (1+|x|) / |d|. || means modulu.
- Parameters
-
px | x |
pcg_direction | the direction of cg_ |
- Returns
- epsilon
◆ get_iter()
int ModuleBase::Opt_TN::get_iter |
( |
| ) |
|
|
inline |
◆ inner_product()
double ModuleBase::Opt_TN::inner_product |
( |
double * |
pa, |
|
|
double * |
pb, |
|
|
int |
length |
|
) |
| |
|
inlineprivate |
◆ next_direct() [1/2]
void ModuleBase::Opt_TN::next_direct |
( |
double * |
px, |
|
|
double * |
pgradient, |
|
|
int & |
flag, |
|
|
double * |
rdirect, |
|
|
T * |
t, |
|
|
void(T::*)(double *ptemp_x, double *rtemp_gradient) |
p_calGradient |
|
) |
| |
◆ next_direct() [2/2]
void ModuleBase::Opt_TN::next_direct |
( |
double * |
px, |
|
|
double * |
pgradient, |
|
|
int & |
flag, |
|
|
double * |
rdirect, |
|
|
T * |
t, |
|
|
void(T::*)(double *px, double *rgradient) |
p_calGradient |
|
) |
| |
Get the next direction d with TN method.
- Template Parameters
-
- Parameters
-
[in] | px | current x. |
[in] | pgradient | df(x)/dx. |
[out] | flag | record which truncated condition was triggered, 0 for cond.1, 1 for cond.2, and 2 for cond.3. |
[out] | rdirect | next optimization direction. |
[in] | t | pointer of class T, which contains the gradient function. |
[in] | p_calGradient | a function pointer, which calculates gradient at provided x. |
◆ refresh()
void ModuleBase::Opt_TN::refresh |
( |
int |
nx_new = 0 | ) |
|
|
inline |
Refresh the class. If nx changes, reallocate space in cg_.
- Parameters
-
nx_new | length of new x, default 0 means the length doesn't change |
◆ set_para()
void ModuleBase::Opt_TN::set_para |
( |
double |
dV | ) |
|
|
inline |
◆ 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 file:
- /home/runner/work/abacus-develop/abacus-develop/source/source_base/opt_TN.hpp