52 targetExcitedStr(
"no"),
58 do_override_output(true)
64 #if defined(QMCCOSTFUNCTION_DEBUG) 65 std::array<char, 16> fname;
68 throw std::runtime_error(
"Error generating filename");
69 debug_stream = std::make_unique<std::ofstream>(fname.data());
70 debug_stream->setf(std::ios::scientific, std::ios::floatfield);
92 for (
int ip = 0; ip < r.size(); ++ip)
94 for (
int ip = 0; ip < r.size(); ++ip)
95 RngSaved[ip] = r[ip].
get().makeClone();
147 Return_rt wgtinv = 1.0 /
static_cast<Return_rt
>(
NumSamples);
160 const Return_rt small = 1.0e-10;
180 std::array<char, 128> newxml;
183 length = std::snprintf(newxml.data(), newxml.size(),
"%s.opt.xml",
RootName.c_str());
185 length = std::snprintf(newxml.data(), newxml.size(),
"%s.opt.%d.xml",
RootName.c_str(),
ReportCounter);
187 throw std::runtime_error(
"Error generating fileroot");
188 xmlSaveFormatFile(newxml.data(),
m_doc_out, 1);
203 #if defined(QMCCOSTFUNCTION_DEBUG) 218 std::ostringstream vp_filename;
219 vp_filename <<
RootName <<
".vp.h5";
224 for (
auto opt_obj : opt_obj_refs)
225 opt_obj.get().writeVariationalParameters(hout);
227 std::string newxml =
RootName +
".opt.xml";
228 *
msg_stream <<
" <optVariables href=\"" << newxml <<
"\">" << std::endl;
230 *
msg_stream <<
" </optVariables>" << std::endl;
232 xmlSaveFormatFile(newxml.c_str(),
m_doc_out, 1);
253 std::vector<opt_variables_type::real_type> CIcoeff;
256 std::array<char, 128> Coeff;
257 if (std::snprintf(Coeff.data(), Coeff.size(),
"CIcoeff_%d", ci_size + 1) < 0)
258 throw std::runtime_error(
"Error generating fileroot");
274 *
msg_stream <<
" <Ci Coeffs saved in opt_coeffs=\"" <<
newh5 <<
"\">" << std::endl;
277 hout.
push(
"MultiDet",
true);
278 hout.
write(ci_size,
"NbDet");
279 hout.
write(CIcoeff,
"Coeff");
290 bool samesign =
true;
317 std::string includeNonlocalH;
318 std::string writeXmlPerStep(
"no");
319 std::string computeNLPPderiv;
321 astring variational_subset_str;
323 m_param.
add(writeXmlPerStep,
"dumpXML");
333 m_param.
add(variational_subset_str,
"variational_subset");
336 if (!includeNonlocalH.empty())
337 app_warning() <<
"'nonlocalpp' no more affects any part of the execution. Please remove it from your input file." 339 if (!computeNLPPderiv.empty())
341 <<
"'use_nonlocalpp_deriv' no more affects any part of the execution. Please remove it from your input file." 352 xmlNodePtr qsave = q;
354 std::vector<xmlNodePtr> cset;
355 std::vector<std::string> excluded;
356 std::map<std::string, std::vector<std::string>*> equalConstraints;
357 std::map<std::string, std::vector<std::string>*> negateConstraints;
358 std::vector<std::string> idtag;
359 xmlNodePtr cur = qsave->children;
363 std::string cname((
const char*)(cur->name));
364 if (cname ==
"optimize")
366 std::vector<std::string> tmpid;
368 idtag.insert(idtag.end(), tmpid.begin(), tmpid.end());
370 else if (cname ==
"exclude")
372 std::vector<std::string> tmpid;
374 excluded.insert(excluded.end(), tmpid.begin(), tmpid.end());
376 else if (cname ==
"cost")
380 else if (cname ==
"set")
382 std::string ctype(
"equal");
385 pAttrib.
add(ctype,
"type");
386 pAttrib.
add(
s,
"name");
388 if (ctype ==
"equal" || ctype ==
"=")
390 std::map<std::string, std::vector<std::string>*>::iterator eit(equalConstraints.find(
s));
391 std::vector<std::string>* eqSet = 0;
392 if (eit == equalConstraints.end())
394 eqSet =
new std::vector<std::string>;
395 equalConstraints[
s] = eqSet;
398 eqSet = (*eit).second;
399 std::vector<std::string> econt;
401 eqSet->insert(eqSet->end(), econt.begin(), econt.end());
408 app_log() <<
" TrialWaveFunction \"" <<
Psi.
getName() <<
"\" has " << opt_obj_refs.size()
409 <<
" optimizable objects:" << std::endl;
411 app_log() <<
" '" << obj.getName() <<
"'" << (obj.isOptimized() ?
" optimized" :
" fixed") << std::endl;
416 if (obj.isOptimized())
429 if (equalConstraints.size())
431 std::map<std::string, std::vector<std::string>*>::iterator eit(equalConstraints.begin());
432 while (eit != equalConstraints.end())
434 nc += (*eit).second->size();
437 excluded.insert(excluded.end(), (*eit).second->begin(), (*eit).second->end());
460 std::map<std::string, std::vector<std::string>*>::iterator eit(equalConstraints.begin());
461 while (eit != equalConstraints.end())
466 const std::vector<std::string>& elist(*((*eit).second));
467 for (
int i = 0; i < elist.size(); ++i)
476 delete (*eit).second;
485 APP_ABORT(
"QMCCostFunctionBase::put No valid optimizable variables are found.");
494 msg_stream->setf(std::ios::scientific, std::ios::floatfield);
501 *
msg_stream <<
" Using Default Cost Function: Cost = <|E-E_ff|^2>" << std::endl;
512 for (
int i = 0; i < cset.size(); i++)
516 pAttrib.
add(pname,
"name");
517 pAttrib.
put(cset[i]);
518 if (pname ==
"energy")
520 else if ((pname ==
"variance") || (pname ==
"unreweightedvariance"))
522 else if (pname ==
"difference")
524 else if ((pname ==
"reweightedVariance") || (pname ==
"reweightedvariance"))
534 m_doc_out = xmlNewDoc((
const xmlChar*)
"1.0");
535 xmlNodePtr qm_root = xmlNewNode(NULL, BAD_CAST
"qmcsystem");
536 xmlNodePtr wf_root = xmlAddChild(qm_root, xmlCopyNode(
m_wfPtr, 1));
537 xmlDocSetRootElement(
m_doc_out, qm_root);
538 xmlXPathContextPtr acontext = xmlXPathNewContext(
m_doc_out);
542 std::ostringstream vp_filename;
543 vp_filename <<
RootName <<
".vp.h5";
545 OhmmsXPathObject vp_file_nodes(
"//override_variational_parameters", acontext);
546 if (vp_file_nodes.
empty())
549 xmlNodePtr vp_file_node = xmlNewNode(NULL, BAD_CAST
"override_variational_parameters");
550 xmlSetProp(vp_file_node, BAD_CAST
"href", BAD_CAST vp_filename.str().c_str());
551 xmlAddChild(wf_root, vp_file_node);
556 for (
int iparam = 0; iparam < vp_file_nodes.
size(); iparam++)
558 xmlSetProp(vp_file_nodes[iparam], BAD_CAST
"href", BAD_CAST vp_filename.str().c_str());
564 xmlXPathObjectPtr result = xmlXPathEvalExpression((
const xmlChar*)
"//var", acontext);
565 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
567 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
574 xmlXPathFreeObject(result);
576 result = xmlXPathEvalExpression((
const xmlChar*)
"//radfunc", acontext);
577 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
579 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
583 if (xmlAttrPtr aptr = xmlHasProp(cur, (
const xmlChar*)
"exponent"); aptr !=
nullptr)
585 std::string expID = aname +
"_E";
587 attribNodes[expID] = std::pair<xmlNodePtr, std::string>(cur,
"exponent");
589 std::string cID = aname +
"_C";
590 if (xmlAttrPtr aptr = xmlHasProp(cur, (
const xmlChar*)
"contraction"); aptr !=
nullptr)
592 attribNodes[cID] = std::pair<xmlNodePtr, std::string>(cur,
"contraction");
594 xmlXPathFreeObject(result);
596 result = xmlXPathEvalExpression((
const xmlChar*)
"//ci", acontext);
597 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
599 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
603 xmlAttrPtr aptr = xmlHasProp(cur, (
const xmlChar*)
"coeff");
605 if (xmlAttrPtr aptr = xmlHasProp(cur, (
const xmlChar*)
"coeff"); aptr != NULL)
607 attribNodes[aname] = std::pair<xmlNodePtr, std::string>(cur,
"coeff");
609 xmlXPathFreeObject(result);
611 result = xmlXPathEvalExpression((
const xmlChar*)
"//csf", acontext);
612 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
614 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
618 if (xmlAttrPtr aptr = xmlHasProp(cur, (
const xmlChar*)
"coeff"); aptr !=
nullptr)
620 attribNodes[aname] = std::pair<xmlNodePtr, std::string>(cur,
"coeff");
622 xmlXPathFreeObject(result);
626 result = xmlXPathEvalExpression((
const xmlChar*)
"//detlist", acontext);
627 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
629 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
630 xmlSetProp(cur, (
const xmlChar*)
"opt_coeffs", (
const xmlChar*)
newh5.c_str());
632 xmlXPathFreeObject(result);
638 xmlXPathFreeContext(acontext);
648 std::ostringstream vout;
649 vout.setf(std::ios::scientific, std::ios::floatfield);
652 xmlSetProp(attrib.first, (
const xmlChar*)attrib.second.c_str(), (
const xmlChar*)vout.str().c_str());
656 std::string rname(cname);
658 std::string datatype(
"none");
659 std::string aname(
"0");
660 cAttrib.
add(datatype,
"type");
661 cAttrib.
add(aname,
"id");
663 if (datatype ==
"Array")
667 std::vector<Return_rt> c;
670 if (name.find(aname) == 0)
676 xmlNodePtr contentPtr = cptr;
677 if (xmlNodeIsText(contentPtr->children))
678 contentPtr = contentPtr->children;
682 else if (rname.find(
"cj_") == 0)
688 xmlNodePtr cur = cptr->children;
691 std::string childName((
const char*)(cur->name));
692 if (childName ==
"lambda")
700 std::array<char, 32> lambda_id;
703 length = std::snprintf(lambda_id.data(), lambda_id.size(),
"%s_%d", rname.c_str(), i);
705 length = std::snprintf(lambda_id.data(), lambda_id.size(),
"%s_%d_%d", rname.c_str(), i, j);
707 throw std::runtime_error(
"Error generating lambda_id");
711 std::ostringstream vout;
712 vout.setf(std::ios::scientific, std::ios::floatfield);
714 vout << (*vTarget).second;
715 xmlSetProp(cur, (
const xmlChar*)
"c", (
const xmlChar*)vout.str().c_str());
730 xmlXPathObjectPtr result = xmlXPathEvalExpression((
const xmlChar*)cname, acontext);
731 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
733 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
735 std::string aname(
"0");
737 std::string datatype(
"none");
738 cAttrib.
add(aname,
"id");
739 cAttrib.
add(aname,
"name");
740 cAttrib.
add(datatype,
"type");
745 if (datatype ==
"Array")
753 bool notlisted =
true;
755 while (notlisted && oit != oit_end)
757 const std::string& oname((*oit).first);
758 notlisted = (oname.find(aname) >= oname.size());
767 xmlXPathFreeObject(result);
772 xmlXPathObjectPtr result = xmlXPathEvalExpression((
const xmlChar*)cname, acontext);
773 for (
int iparam = 0; iparam < result->nodesetval->nodeNr; iparam++)
776 xmlNodePtr cur = result->nodesetval->nodeTab[iparam];
778 std::string aname(
"none");
779 std::string atype(
"none");
780 cAttrib.
add(aname,
"name");
781 cAttrib.
add(atype,
"type");
783 if (atype ==
"Counting")
786 xmlNodePtr cur2 = cur->xmlChildrenNode;
788 bool Ftag_found =
false;
792 std::string tname2((
const char*)cur2->name);
794 std::string aname2(
"none");
795 std::string aopt2(
"yes");
796 std::string ref_id(
"g0");
797 cAttrib2.
add(aname2,
"name");
798 cAttrib2.
add(aopt2,
"opt");
799 cAttrib2.
add(ref_id,
"reference_id");
802 if (tname2 ==
"var" && aname2 ==
"F" && (aopt2 ==
"yes" || aopt2 ==
"true"))
812 for (; oit != oit_end; ++oit)
814 const std::string& oname((*oit).first);
815 if (oname.find(
"F_") == 0)
823 xmlNodeAddContent(cur, (
const xmlChar*)
"\n ");
824 xmlNodePtr F_tag = xmlNewChild(cur, NULL, (
const xmlChar*)
"var", NULL);
825 xmlSetProp(F_tag, (
const xmlChar*)
"name", (
const xmlChar*)
"F");
826 xmlSetProp(F_tag, (
const xmlChar*)
"opt", (
const xmlChar*)
"true");
827 xmlNodeSetContent(F_tag, (
const xmlChar*)
" ");
829 xmlNodeAddContent(cur, (
const xmlChar*)
"\n ");
832 cur2 = cur->xmlChildrenNode;
835 std::string tname2((
const char*)cur2->name);
837 std::string aname2(
"none");
838 std::string atype2(
"normalized_gaussian");
839 std::string aopt2(
"yes");
840 std::string ref_id(
"g0");
841 cAttrib2.
add(aname2,
"name");
842 cAttrib2.
add(atype2,
"type");
843 cAttrib2.
add(aopt2,
"opt");
844 cAttrib2.
add(ref_id,
"reference_id");
847 if (tname2 ==
"region" && (aopt2 ==
"true" || aopt2 ==
"yes") && Fnum != 0)
850 if (atype2 ==
"voronoi")
853 xmlUnsetProp(cur, (
const xmlChar*)
"source");
854 xmlSetProp(cur2, (
const xmlChar*)
"type", (
const xmlChar*)
"normalized_gaussian");
855 xmlSetProp(cur2, (
const xmlChar*)
"reference_id", (
const xmlChar*)ref_id.c_str());
857 xmlNodePtr child = cur2->xmlChildrenNode;
858 while (child != NULL)
860 xmlUnlinkNode(child);
861 child = cur2->xmlChildrenNode;
864 int Fdim = (
std::sqrt(1 + 8 * Fnum) - 1) / 2;
865 for (
int i = 0; i < Fdim; ++i)
867 std::ostringstream os;
869 std::string gid = os.str();
870 std::string opt = (gid != ref_id) ?
"true" :
"false";
873 xmlNodeAddContent(cur2, (
const xmlChar*)
"\n ");
874 xmlNodePtr function_tag = xmlNewChild(cur2, NULL, (
const xmlChar*)
"function", NULL);
875 xmlNewProp(function_tag, (
const xmlChar*)
"id", (
const xmlChar*)gid.c_str());
876 xmlNodeAddContent(function_tag, (
const xmlChar*)
"\n ");
878 xmlNodePtr A_tag = xmlNewChild(function_tag, NULL, (
const xmlChar*)
"var", NULL);
879 xmlNodeAddContent(function_tag, (
const xmlChar*)
"\n ");
880 xmlNewProp(A_tag, (
const xmlChar*)
"name", (
const xmlChar*)
"A");
881 xmlNewProp(A_tag, (
const xmlChar*)
"opt", (
const xmlChar*)opt.c_str());
885 os << std::setprecision(6) << std::scientific;
893 xmlNodeSetContent(A_tag, (
const xmlChar*)(os.str().c_str()));
896 xmlNodePtr B_tag = xmlNewChild(function_tag, NULL, (
const xmlChar*)
"var", NULL);
897 xmlNodeAddContent(function_tag, (
const xmlChar*)
"\n ");
898 xmlNewProp(B_tag, (
const xmlChar*)
"name", (
const xmlChar*)
"B");
899 xmlNewProp(B_tag, (
const xmlChar*)
"opt", (
const xmlChar*)opt.c_str());
903 os << std::setprecision(6) << std::scientific;
909 xmlNodeSetContent(B_tag, (
const xmlChar*)(os.str().c_str()));
912 xmlNodePtr C_tag = xmlNewChild(function_tag, NULL, (
const xmlChar*)
"var", NULL);
913 xmlNodeAddContent(function_tag, (
const xmlChar*)
"\n ");
914 xmlNewProp(C_tag, (
const xmlChar*)
"name", (
const xmlChar*)
"C");
915 xmlNewProp(C_tag, (
const xmlChar*)
"opt", (
const xmlChar*)opt.c_str());
919 os << std::setprecision(6) << std::scientific;
924 xmlNodeSetContent(C_tag, (
const xmlChar*)(os.str().c_str()));
926 xmlNodeAddContent(cur2, (
const xmlChar*)
"\n ");
931 xmlNodePtr cur3 = cur2->xmlChildrenNode;
934 std::string tname3((
const char*)cur3->name);
936 std::string fid(
"none");
937 cAttrib3.
add(fid,
"id");
940 if (tname3 ==
"function")
943 xmlNodePtr cur4 = cur3->xmlChildrenNode;
946 std::string tname4((
const char*)cur4->name);
948 std::string aname4(
"none");
949 std::string aopt4(
"false");
950 cAttrib4.
add(aname4,
"name");
951 cAttrib4.
add(aopt4,
"opt");
953 if (tname4 ==
"var" && (aopt4 ==
"true" || aopt4 ==
"yes"))
955 std::string varname =
"cj_" + fid +
"_" + aname4;
956 bool notlisted =
true;
958 while (notlisted && oit != oit_end)
960 const std::string& oname((*oit).first);
961 notlisted = (oname.find(varname.substr(3)) >= oname.size());
979 xmlXPathFreeObject(result);
987 if (rname.find(
"cj_F") < rname.size())
990 std::vector<Return_rt> f_vals;
993 if ((*vit).first.find(
"F_") == 0)
996 f_vals.push_back(fval);
1000 f_vals.push_back(0);
1002 int Fdim = (
std::sqrt(1 + 8 * f_vals.size()) - 1) / 2;
1003 std::ostringstream os;
1004 std::string pad_str = std::string(14,
' ');
1006 os << std::setprecision(6) << std::scientific;
1008 auto fit = f_vals.begin();
1009 for (
int i = 0; i < Fdim; ++i)
1012 for (
int j = 0; j < Fdim; ++j)
1018 os <<
" " << (*fit);
1027 xmlNodePtr cur2 = cur->children;
1028 xmlNodeSetContent(cur2, (
const xmlChar*)(os.str().c_str()));
1029 xmlNodeAddContent(cur2, (
const xmlChar*)
"\n ");
1034 std::string var_prefix = rname.substr(3);
1035 std::vector<Return_rt> vals;
1039 if (vit->first.find(var_prefix) == 0)
1042 vals.push_back(val);
1045 std::ostringstream os;
1046 os << std::setprecision(6) << std::scientific;
1047 for (
int i = 0; i < vals.size(); ++i)
1050 if (i < vals.size() - 1)
1053 xmlNodePtr cur2 = cur->children;
1054 xmlNodeSetContent(cur2, (
const xmlChar*)(os.str().c_str()));
1060 app_log() <<
"Effective weight of all the samples measured by correlated sampling is " << effective_weight
1064 WARNMSG(
" Smaller than the user specified threshold \"minwalkers\" = " 1066 <<
" If this message appears frequently. You might have to be cautious. " << std::endl
1067 <<
" Find info about parameter \"minwalkers\" in the user manual!");
1080 for (
auto& name : names)
1081 if (std::find_if(opt_obj_refs.begin(), opt_obj_refs.end(),
1082 [&name](
const OptimizableObject& obj) {
return name == obj.getName(); }) == opt_obj_refs.end())
1084 std::ostringstream msg;
1085 msg <<
"Variational subset entry '" << name <<
"' doesn't exist in the trial wavefunction which contains";
1087 msg <<
" '" << obj.getName() <<
"'";
1088 msg <<
"." << std::endl;
1093 obj.setOptimization(names.empty() || std::find_if(names.begin(), names.end(), [&obj](
const std::string& name) {
1094 return name == obj.getName();
1096 return opt_obj_refs;
1103 if (obj.isOptimized())
1104 obj.resetParametersExclusive(opt_variables);
1114 #ifdef HAVE_LMY_ENGINE 1115 QMCCostFunctionBase::Return_rt QMCCostFunctionBase::LMYEngineCost(
const bool needDeriv,
1116 cqmc::engine::LMYEngine<Return_t>* EngineObj)
1119 const Return_rt standardCost = this->
Cost(needDeriv);
1122 return this->LMYEngineCost_detail(EngineObj);
bool targetExcited
whether we are targeting an excited state
iterator find(const std::string &vname)
return the iterator of a named parameter
bool Write2OneXml
if true, do not write the *.opt.#.xml
Return_rt CostValue
value of the cost function
Return_rt Cost(bool needGrad=true) override
return the cost value for CGMinimization
Return_rt Etarget
target energy
std::vector< ParticleLaplacian * > d2LogPsi
Fixed Laplacian , , components.
void writeToHDF(const std::string &filename, qmcplusplus::hdf_archive &hout) const
std::ostream & app_warning()
Base class for any object which needs to know about a MPI communicator.
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 ...
std::vector< std::string > variational_subset_names
optimized parameter names
void delete_iter(IT first, IT last)
delete the pointers in [first,last)
helper functions for EinsplineSetBuilder
Return_rt computedCost()
return the cost value for CGMinimization
int NumSamples
global number of samples to use in correlated sampling
int rank() const
return the rank
std::ostream * msg_stream
stream to which progress is sent
const_iterator end() const
return the last const_iterator
std::string RootName
string for the file root
MakeReturn< UnaryNode< FnFabs, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t abs(const Vector< T1, C1 > &l)
std::vector< pair_type >::iterator iterator
std::vector< TinyVector< int, 2 > > equalVarMap
index mapping for <equal> constraints
bool put(xmlNodePtr cur)
assign attributes to the set
void addCJParams(xmlXPathContextPtr acontext, const char *cname)
Return_rt MinNumWalkers
fraction of the number of walkers below which the costfunction becomes invalid
void close()
close all the open groups and file
int NumOptimizables
total number of optimizable variables
Collection of Local Energy Operators.
QMCTraits::QTFull::RealType EffectiveWeight
Return_rt curAvg_w
current weighted average (correlated sampling)
xmlNodePtr m_wfPtr
xml node to be dumped
opt_variables_type OptVariables
list of optimizables
void disable(ForwardIterator first, ForwardIterator last, bool reindex)
deactivate variables for optimization
const std::string & getName() const
std::map< std::string, std::pair< xmlNodePtr, std::string > > attribNodes
attributes to be updated
UPtrVector< RandomBase< FullPrecRealType > > RngSaved
Random number generators.
void resetIndex()
reset Index
void activate(ForwardIterator first, ForwardIterator last, bool reindex)
activate variables for optimization
Communicate * Controller
Global Communicator for a process.
bool do_override_output
Flag on whether the variational parameter override is output to the new wavefunction.
int NumCostCalls
number of times cost function evaluated
bool put(std::istream &is) override
read from std::istream
class to handle xmlXPathObject
UniqueOptObjRefs extractOptimizableObjectRefs()
extract underlying OptimizableObject references
Wrapping information on parallelism.
std::string newh5
Path and name of the HDF5 prefix where CI coeffs are saved.
bool put(xmlNodePtr cur)
process xml node
Specialized paritlce class for atomistic simulations.
std::vector< ParticleGradient * > dLogPsi
Fixed Gradients , , components.
class to handle a set of parameters
Communicate * myComm
pointer to Communicate
class to handle a set of attributes of an xmlNode
This a subclass for runtime errors that will occur on all ranks.
std::map< std::string, xmlNodePtr > paramNodes
parameters to be updated`
Return_rt curAvg
current Average
std::string lowerCase(const std::string_view s)
++17
opt_variables_type OptVariablesForPsi
full list of optimizables
const_iterator begin() const
return the first const_iterator
XMLNodeString convert xmlNode contents into a std::string XMLAttrString convert one xmlNode attribute...
class to handle a set of variables that can be modified during optimizations
void setRng(RefVector< RandomBase< FullPrecRealType >> r)
Return_rt w_en
weights for energy and variance in the cost function
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
void checkOutVariables(const opt_variables_type &o)
Check out optimizable variables Assign index mappings from global list (o) to local values in each co...
bool isEffectiveWeightValid(EffectiveWeight effective_weight) const
check the validity of the effective weight calculated by correlatedSampling
std::string getXMLAttributeValue(const xmlNodePtr cur, const std::string_view name)
get the value string for attribute name if name is unfound in cur you get an empty string back this i...
void clear()
clear the variable set
size_type size() const
return the size
std::unique_ptr< std::ostream > debug_stream
stream for debug
void push(const std::string &gname, bool createit=true)
push a group to the group stack
bool putContent(T &a, xmlNodePtr cur)
replaces a's value with the first "element" in the "string" returned by XMLNodeString{cur}.
int ReportCounter
counter for output
void add(PDT &aparam, const std::string &aname_in, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new parameter corresponding to an xmlNode <parameter>
void printCJParams(xmlNodePtr cur, std::string &rname)
std::vector< std::reference_wrapper< T > > RefVector
MakeReturn< UnaryNode< FnSqrt, typename CreateLeaf< Vector< T1, C1 > >::Leaf_t > >::Expression_t sqrt(const Vector< T1, C1 > &l)
bool getContent(const T &a, xmlNodePtr cur)
write a value to a node.
bool create(const std::filesystem::path &fname, unsigned flags=H5F_ACC_TRUNC)
create a file
xmlDocPtr m_doc_out
document node to be dumped
Class to represent a many-body trial wave function.
UniqueOptObjRefs extractOptimizableObjects(TrialWaveFunction &psi) const
survey all the optimizable objects
virtual EffectiveWeight correlatedSampling(bool needGrad=true)=0
run correlated sampling return effective walkers ( w_i)^2/(Nw * w^2_i)
std::string targetExcitedStr
whether we are targeting an excited state
std::vector< Return_rt > SumValue
Sum of energies and weights for averages.
const std::string & name(int i) const
return the name of i-th variable
void resetOptimizableObjects(TrialWaveFunction &psi, const opt_variables_type &opt_variables) const
TrialWaveFunction & Psi
Trial function.
Return_rt curVar_abs
current variance of SUM_ABSE_WGT/SUM_WGT
Return_rt MaxWeight
maximum weight beyond which the weight is set to 1
void addCoefficients(xmlXPathContextPtr acontext, const char *cname)
add coefficient or coefficients
bool checkParameters()
Apply constraints on the optimizables.
void reportParametersH5()
report parameters in HDF5 at the end
QMCCostFunctionBase(ParticleSet &w, TrialWaveFunction &psi, QMCHamiltonian &h, Communicate *comm)
Constructor.
void Report() override
dump the current parameters and other report
void add(PDT &aparam, const std::string &aname, std::vector< PDT > candidate_values={}, TagStatus status=TagStatus::OPTIONAL)
add a new attribute
void print(std::ostream &os, int leftPadSpaces=0, bool printHeader=false) const
Return_rt curVar
current Variance
int getIndex(const std::string &vname) const
return the Index vaule for the named parameter
Return_rt curVar_w
current weighted variance (correlated sampling)
opt_variables_type InitVariables
Declaration of a MCWalkerConfiguration.
void resetCostFunction(std::vector< xmlNodePtr > &cset)
double omega_shift
the shift to use when targeting an excited state
void setTargetEnergy(Return_rt et)
void reportParameters()
report parameters at the end
std::map< std::string, xmlNodePtr > coeffNodes
coefficients to be updated
Return_rt EtargetEff
real target energy with the Correlation Factor
~QMCCostFunctionBase() override
Destructor.
virtual void resetPsi(bool final_reset=false)=0
reset the wavefunction
std::vector< RandomBase< FullPrecRealType > * > MoverRng