ABACUS develop
Atomic-orbital Based Ab-initio Computation at UStc
Loading...
Searching...
No Matches
line_search.h
Go to the documentation of this file.
1#ifndef LINE_SEARCH_H
2#define LINE_SEARCH_H
3
4#include <fstream>
5
7{
8 public:
11
12 bool line_search(
13 const bool restart, // whether to restart line search (when cg direction has changed)
14 const double x, // position for function at x
15 const double y, // value of function at x
16 const double f, // gradient of function at x
17 double &xnew, // postion where function has to be evaluated
18 const double conv_thr, // predicted change of function value of function at xnew
19 std::ofstream &ofs_running);
20
21 bool first_order(
22 const double x,
23 const double y,
24 const double f,
25 double &xnew);
26
27 bool third_order(
28 const double x,
29 const double y,
30 const double f,
31 double &xnew,
32 const double conv_thr);
33
34 void init_brent(const double x, const double y, const double f);
35
36 void update_brent(const double x, const double y, const double f);
37
38 bool brent(
39 const double x,
40 const double y,
41 const double f,
42 double &xnew,
43 const double conv_thr,
44 std::ofstream &ofs_running);
45
46 private:
47 int ls_step = 0; // step of line search
48 bool bracked = false; // whether the minima is bracked by [a,c]
50 double xa = 0.0;
51 double xb = 0.0;
52 double xc = 0.0;
53 double fa = 0.0;
54 double fb = 0.0;
55 double fc = 0.0;
56 double ya = 0.0;
57 double yb = 0.0;
59 double fstart = 0.0; // keep record of initial gradient for brent method
60 const double e8 = 1.0e-8;
61};
62
63#endif
double xb
Definition line_search.h:51
int ls_step
Definition line_search.h:47
~Line_Search()
Definition line_search.h:10
double fb
Definition line_search.h:54
const double e8
Definition line_search.h:60
bool brent(const double x, const double y, const double f, double &xnew, const double conv_thr, std::ofstream &ofs_running)
Definition line_search.cpp:209
void update_brent(const double x, const double y, const double f)
Definition line_search.cpp:196
double fstart
Definition line_search.h:59
double xa
these variables used to keep record of some points
Definition line_search.h:50
double yb
Definition line_search.h:57
double ya
Definition line_search.h:56
bool third_order(const double x, const double y, const double f, double &xnew, const double conv_thr)
Definition line_search.cpp:65
bool first_order(const double x, const double y, const double f, double &xnew)
Definition line_search.cpp:51
void init_brent(const double x, const double y, const double f)
Definition line_search.cpp:145
Line_Search()
Definition line_search.h:9
bool line_search(const bool restart, const double x, const double y, const double f, double &xnew, const double conv_thr, std::ofstream &ofs_running)
Definition line_search.cpp:10
double fc
Definition line_search.h:55
double fa
Definition line_search.h:53
bool bracked
Definition line_search.h:48
double xc
Definition line_search.h:52