39 for (
int i = 0; i <
input.size(); ++i)
50 (*loc).second =
input.NameAndValue[i].second;
63 throw std::runtime_error(
"Inconsistent number of parameters in two provided " 66 for (
int i = 0; i < input_1.
size(); ++i)
71 throw std::runtime_error(
"Inconsistent parameters exist in the two provided " 90 (*loc).second = sum_val;
103 throw std::runtime_error(
"Inconsistent number of parameters in two provided " 106 for (
int i = 0; i < input_1.
size(); ++i)
111 throw std::runtime_error(
"Inconsistent parameters exist in the two provided " 130 (*loc).second = diff_val;
137 std::vector<int> valid(
Index);
145 for (
int i = 0; i < valid.size(); ++i)
160 for (
int i = 0; i <
Index.size(); ++i)
191 for (
int i = 0; i <
Index.size(); ++i)
197 std::string pad_str = std::string(leftPadSpaces,
' ');
198 int max_name_len = 0;
202 return e1.first.length() < e2.first.length();
205 int max_value_len = 28;
206 int max_type_len = 1;
207 int max_recompute_len = 1;
209 int max_index_len = 1;
212 max_name_len = std::max(max_name_len, 4);
214 max_recompute_len = 9;
216 os << pad_str << setw(max_name_len) <<
"Name" 217 <<
" " << setw(max_value_len) <<
"Value" 218 <<
" " << setw(max_type_len) <<
"Type" 219 <<
" " << setw(max_recompute_len) <<
"Recompute" 220 <<
" " << setw(max_use_len) <<
"Use" 221 <<
" " << setw(max_index_len) <<
"Index" << std::endl;
222 os << pad_str << std::setfill(
'-') << setw(max_name_len) <<
"" 223 <<
" " << setw(max_value_len) <<
"" 224 <<
" " << setw(max_type_len) <<
"" 225 <<
" " << setw(max_recompute_len) <<
"" 226 <<
" " << setw(max_use_len) <<
"" 227 <<
" " << setw(max_index_len) <<
"" << std::endl;
228 os << std::setfill(
' ');
233 os << pad_str << setw(max_name_len) <<
NameAndValue[i].first <<
" " << std::setprecision(6) << std::scientific
235 << setw(max_recompute_len) <<
Recompute[i].second <<
" ";
237 os << std::defaultfloat;
240 os << setw(max_use_len) <<
"OFF" << std::endl;
242 os << setw(max_use_len) <<
"ON" 243 <<
" " << setw(max_index_len) <<
Index[i] << std::endl;
254 std::vector<int> vp_file_version{1, 1, 0};
255 hout.
write(vp_file_version,
"version");
258 hout.
write(timestamp,
"timestamp");
260 hout.
push(
"name_value_lists");
262 std::vector<qmcplusplus::QMCTraits::RealType> param_values;
263 std::vector<std::string> param_names;
266 param_names.push_back(pair_it.first);
267 param_values.push_back(pair_it.second);
270 hout.
write(param_names,
"parameter_names");
271 hout.
write(param_values,
"parameter_values");
277 if (!hin.
open(filename, H5F_ACC_RDONLY))
279 std::ostringstream err_msg;
280 err_msg <<
"Unable to open VP file: " << filename;
281 throw std::runtime_error(err_msg.str());
286 hin.
push(
"name_value_lists",
false);
288 catch (std::runtime_error&)
290 std::ostringstream err_msg;
291 err_msg <<
"The group name_value_lists in not present in file: " << filename;
292 throw std::runtime_error(err_msg.str());
295 std::vector<qmcplusplus::QMCTraits::RealType> param_values;
296 hin.
read(param_values,
"parameter_values");
298 std::vector<std::string> param_names;
299 hin.
read(param_names,
"parameter_names");
301 for (
int i = 0; i < param_names.size(); i++)
303 std::string& vp_name = param_names[i];
307 (*
this)[vp_name] = param_values[i];
iterator find(const std::string &vname)
return the iterator of a named parameter
void writeToHDF(const std::string &filename, qmcplusplus::hdf_archive &hout) const
void write(T &data, const std::string &aname)
write the data to the group aname and check status runtime error is issued on I/O error ...
bool open(const std::filesystem::path &fname, unsigned flags=H5F_ACC_RDWR)
open a file
void setIndexDefault()
set default Indices, namely all the variables are active
const_iterator end() const
return the last const_iterator
std::vector< pair_type >::iterator iterator
void readFromHDF(const std::string &filename, qmcplusplus::hdf_archive &hin)
Read variational parameters from an HDF file.
std::vector< int > Index
store locator of the named variable
void resetIndex()
reset Index
void insertFromDiff(const VariableSet &input_1, const VariableSet &input_2)
take the difference (input_1-input_2) of values of the optimizable parameter values in two VariableSe...
std::pair< std::string, real_type > pair_type
class to handle a set of variables that can be modified during optimizations
void clear()
clear the variable set
size_type size() const
return the size
void insertFromSum(const VariableSet &input_1, const VariableSet &input_2)
sum together the values of the optimizable parameter values in two VariableSet objects, and set this object's values to equal them.
void push(const std::string &gname, bool createit=true)
push a group to the group stack
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
std::vector< pair_type > NameAndValue
qmcplusplus::QMCTraits::RealType real_type
const std::string & name(int i) const
return the name of i-th variable
std::vector< index_pair_type > ParameterType
void read(T &data, const std::string &aname)
read the data from the group aname and check status runtime error is issued on I/O error ...
void insertFrom(const VariableSet &input)
insert a VariableSet to the list
testing::ValidSpinDensityInput input
void removeInactive()
remove inactive variables and trim the internal data
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
std::vector< index_pair_type > Recompute
int num_active_vars
number of active variables