QMCPACK
optimize Namespace Reference

Classes

struct  VariableSet
 class to handle a set of variables that can be modified during optimizations More...
 

Enumerations

enum  {
  OTHER_P = 0, LOGLINEAR_P, LOGLINEAR_K, LINEAR_P,
  SPO_P, BACKFLOW_P
}
 An enum useful for determining the type of parameter is being optimized. More...
 

Functions

 TEST_CASE ("VariableSet empty", "[optimize]")
 
 TEST_CASE ("VariableSet one", "[optimize]")
 
 TEST_CASE ("VariableSet output", "[optimize]")
 
 TEST_CASE ("VariableSet HDF output and input", "[optimize]")
 

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

An enum useful for determining the type of parameter is being optimized.

knowing this in the opt routine can reduce the computational load.

Enumerator
OTHER_P 
LOGLINEAR_P 
LOGLINEAR_K 
LINEAR_P 
SPO_P 
BACKFLOW_P 

Definition at line 35 of file VariableSet.h.

36 {
37  OTHER_P = 0,
38  LOGLINEAR_P, //B-spline Jastrows
39  LOGLINEAR_K, //K space Jastrows
40  LINEAR_P, //Multi-determinant coefficients
41  SPO_P, //SPO set Parameters
42  BACKFLOW_P //Backflow parameters
43 };

Function Documentation

◆ TEST_CASE() [1/4]

optimize::TEST_CASE ( "VariableSet empty"  ,
""  [optimize] 
)

Definition at line 25 of file test_variable_set.cpp.

References VariableSet::find(), VariableSet::getIndex(), VariableSet::is_optimizable(), VariableSet::NameAndValue, qmcplusplus::REQUIRE(), and VariableSet::size_of_active().

26 {
27  VariableSet vs;
28 
29  REQUIRE(vs.is_optimizable() == false);
30  REQUIRE(vs.size_of_active() == 0);
31  REQUIRE(vs.find("something") == vs.NameAndValue.end());
32  REQUIRE(vs.getIndex("something") == -1);
33 }
REQUIRE(std::filesystem::exists(filename))

◆ TEST_CASE() [2/4]

optimize::TEST_CASE ( "VariableSet one"  ,
""  [optimize] 
)

Definition at line 35 of file test_variable_set.cpp.

References VariableSet::activate(), qmcplusplus::CHECK(), VariableSet::getIndex(), VariableSet::insert(), VariableSet::is_optimizable(), VariableSet::name(), VariableSet::print(), qmcplusplus::REQUIRE(), and VariableSet::size_of_active().

36 {
37  VariableSet vs;
38  VariableSet::real_type first_val(1.123456789);
39  vs.insert("first", first_val);
40  std::vector<std::string> names{"first"};
41  vs.activate(names.begin(), names.end(), true);
42 
43  REQUIRE(vs.is_optimizable() == true);
44  REQUIRE(vs.size_of_active() == 1);
45  REQUIRE(vs.getIndex("first") == 0);
46  REQUIRE(vs.name(0) == "first");
47  double first_val_real = 1.123456789;
48  CHECK(vs[0] == Approx(first_val_real));
49 
50  std::ostringstream o;
51  vs.print(o, 0, false);
52  //std::cout << o.str() << std::endl;
53  REQUIRE(o.str() == "first 1.123457e+00 0 1 ON 0\n");
54 
55  std::ostringstream o2;
56  vs.print(o2, 1, true);
57  //std::cout << o2.str() << std::endl;
58 
59  char formatted_output[] = " Name Value Type Recompute Use Index\n"
60  " ----- ---------------------------- ---- --------- --- -----\n"
61  " first 1.123457e+00 0 1 ON 0\n";
62 
63 
64  REQUIRE(o2.str() == formatted_output);
65 }
REQUIRE(std::filesystem::exists(filename))
OHMMS_PRECISION real_type
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))

◆ TEST_CASE() [3/4]

optimize::TEST_CASE ( "VariableSet output"  ,
""  [optimize] 
)

Definition at line 67 of file test_variable_set.cpp.

References VariableSet::activate(), VariableSet::insert(), VariableSet::print(), and qmcplusplus::REQUIRE().

68 {
69  VariableSet vs;
70  VariableSet::real_type first_val(11234.56789);
71  VariableSet::real_type second_val(0.000256789);
72  VariableSet::real_type third_val(-1.2);
73  vs.insert("s", first_val);
74  vs.insert("second", second_val);
75  vs.insert("really_long_name", third_val);
76  std::vector<std::string> names{"s", "second", "really_long_name"};
77  vs.activate(names.begin(), names.end(), true);
78 
79  std::ostringstream o;
80  vs.print(o, 0, true);
81  //std::cout << o.str() << std::endl;
82 
83  char formatted_output[] = " Name Value Type Recompute Use Index\n"
84  "---------------- ---------------------------- ---- --------- --- -----\n"
85  " s 1.123457e+04 0 1 ON 0\n"
86  " second 2.567890e-04 0 1 ON 1\n"
87  "really_long_name -1.200000e+00 0 1 ON 2\n";
88 
89  REQUIRE(o.str() == formatted_output);
90 }
REQUIRE(std::filesystem::exists(filename))
OHMMS_PRECISION real_type

◆ TEST_CASE() [4/4]

optimize::TEST_CASE ( "VariableSet HDF output and input"  ,
""  [optimize] 
)

Definition at line 92 of file test_variable_set.cpp.

References qmcplusplus::CHECK(), VariableSet::end(), VariableSet::find(), VariableSet::insert(), VariableSet::readFromHDF(), and VariableSet::writeToHDF().

93 {
94  VariableSet vs;
95  VariableSet::real_type first_val(11234.56789);
96  VariableSet::real_type second_val(0.000256789);
97  VariableSet::real_type third_val(-1.2);
98  vs.insert("s", first_val);
99  vs.insert("second", second_val);
100  vs.insert("really_really_really_long_name", third_val);
102  vs.writeToHDF("vp.h5", hout);
103 
104  VariableSet vs2;
105  vs2.insert("s", 0.0);
106  vs2.insert("second", 0.0);
108  vs2.readFromHDF("vp.h5", hin);
109  CHECK(vs2.find("s")->second == Approx(first_val));
110  CHECK(vs2.find("second")->second == Approx(second_val));
111  // This value as in the file, but not in the VariableSet that loaded the file,
112  // so the value does not get added.
113  CHECK(vs2.find("really_really_really_long_name") == vs2.end());
114 }
class to handle hdf file
Definition: hdf_archive.h:51
OHMMS_PRECISION real_type
CHECK(log_values[0]==ComplexApprox(std::complex< double >{ 5.603777579195571, -6.1586603331188225 }))