22 std::vector<Return_t> numeric_grad(num_params);
23 std::vector<Return_t> params(num_params);
24 std::vector<Return_t> analytic_grad(num_params);
26 for (
int i = 0; i < num_params; i++)
34 int namelen = root_name.length();
37 std::string fname = root_name.substr(0, namelen - 5) +
".param.s000.scalar.dat";
41 for (
int i = 0; i < num_params; i++)
53 costFunc.
GradCost(analytic_grad, params);
62 std::string_view param_name_header(
"Param_Name");
63 size_t max_name_len = param_name_header.size();
64 for (
int k = 0; k < num_params; k++)
67 max_name_len = std::max(vname.size(), max_name_len);
72 app_log() << std::setw(max_name_len) << std::left << param_name_header
73 << std::setw(14) << std::right <<
" Value " 74 << std::setw(20) << std::right <<
" Numeric " 75 << std::setw(20) << std::right <<
" Analytic " 76 << std::setw(14) <<
" Percent" << std::endl;
79 for (
int k = 0; k < num_params; k++)
82 std::ostringstream rel_diff_str;
83 std::string over_threshold;
84 if (numeric_grad[k] != 0)
86 double rel_diff_percent = 100 * (numeric_grad[k] - analytic_grad[k]) / numeric_grad[k];
87 rel_diff_str << std::scientific << std::setprecision(2) << rel_diff_percent;
91 over_threshold =
" !";
93 over_threshold =
" !!";
95 over_threshold =
" !!!";
99 rel_diff_str <<
"inf";
100 over_threshold =
" !!!";
105 app_log() << std::setw(max_name_len) << std::left << vname
106 << std::setprecision(6) << std::setw(14) << std::right << params[k]
107 << std::setprecision(10) << std::setw(20) << std::right << numeric_grad[k]
108 << std::setw(20) << std::right << analytic_grad[k]
109 << std::setw(14) << std::right << rel_diff_str.str() << over_threshold << std::endl;
117 app_log() << std::setprecision(6);
void run(QMCCostFunctionBase &costFunc, const std::string &root_name)
helper functions for EinsplineSetBuilder
std::string getParamName(int i) const override
void GradCost(std::vector< Return_rt > &PGradient, const std::vector< Return_rt > &PM, Return_rt FiniteDiff=0) override
return the gradient of cost value for CGMinimization
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
Tests for variational parameter derivatives.
bool do_param_output() const
double get_finite_diff_delta() const
Implements wave-function optimization.
Return_rt & Params(int i) override
assign optimization parameter i
int getNumParams() const override
return the number of optimizable parameters
std::ofstream param_deriv_file_