16 #ifndef QMCPLUSPLUS_OPTIMIZE_VARIABLESET_H 17 #define QMCPLUSPLUS_OPTIMIZE_VARIABLESET_H 53 using pair_type = std::pair<std::string, real_type>;
55 using iterator = std::vector<pair_type>::iterator;
57 using size_type = std::vector<pair_type>::size_type;
101 [&vname](
const auto& value) {
return value.first == vname; });
109 int getIndex(
const std::string& vname)
const;
121 inline int getLoc(
const std::string& vname)
const 139 Index.push_back(ind_loc);
152 while (PTit != PTend)
154 (*PTit).second = type;
162 types.resize(ptend - ptit);
163 auto tit(types.begin());
164 while (ptit != ptend)
165 (*tit++) = (*ptit++).second;
182 return (*loc).second;
212 for (
int i = 0; i <
Recompute.size(); i++)
225 for (
int i = 0; i <
Recompute.size(); i++)
263 template<
typename ForwardIterator>
264 void activate(ForwardIterator first, ForwardIterator last,
bool reindex)
266 while (first != last)
288 template<
typename ForwardIterator>
289 void disable(ForwardIterator first, ForwardIterator last,
bool reindex)
291 while (first != last)
322 void print(std::ostream& os,
int leftPadSpaces = 0,
bool printHeader =
false)
const;
iterator find(const std::string &vname)
return the iterator of a named parameter
bool recompute(int i) const
void writeToHDF(const std::string &filename, qmcplusplus::hdf_archive &hout) const
real_type & operator[](int i)
assign the i-th value
helper functions for EinsplineSetBuilder
void setIndexDefault()
set default Indices, namely all the variables are active
bool is_optimizable() const
if any of Index value is not zero, return true
QTBase::RealType RealType
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
virtual ~VariableSet()=default
viturval destructor for safety
void disable(ForwardIterator first, ForwardIterator last, bool reindex)
deactivate variables for optimization
int getLoc(const std::string &vname) const
void resetIndex()
reset Index
void activate(ForwardIterator first, ForwardIterator last, bool reindex)
activate variables for optimization
void setParameterType(int type)
real_type operator[](int i) const
return the i-th value
std::pair< std::string, int > index_pair_type
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::vector< pair_type >::const_iterator const_iterator
iterator begin()
return the first iterator
void insert(const std::string &vname, real_type v, bool enable=true, int type=OTHER_P)
std::pair< std::string, real_type > pair_type
VariableSet()
default constructor
const_iterator begin() const
return the first const_iterator
class to handle a set of variables that can be modified during optimizations
int where(int i) const
return the locator of the i-th Index
int getType(int i) const
get the i-th parameter's type
int size_of_active() const
return the number of active variables
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 getParameterTypeList(std::vector< int > &types) const
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 insertFrom(const VariableSet &input)
insert a VariableSet to the list
testing::ValidSpinDensityInput input
real_type & operator[](const std::string &vname)
equivalent to std::map<std::string,T>[string] operator
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
std::vector< pair_type >::size_type size_type
iterator end()
return the last iterator
int num_active_vars
number of active variables