17 #ifndef QMCPLUSPLUS_COSTFUNCTIONBASE_H 18 #define QMCPLUSPLUS_COSTFUNCTIONBASE_H 21 #include "Optimize/OptimizeBase.h" 26 #ifdef HAVE_LMY_ENGINE 27 #include "formic/utils/matrix.h" 28 #include "formic/utils/lmyengine/engine.h" 80 bool put(xmlNodePtr cur);
93 Return_rt
Cost(
bool needGrad =
true)
override;
99 void GradCost(std::vector<Return_rt>& PGradient,
100 const std::vector<Return_rt>& PM,
101 Return_rt FiniteDiff = 0)
override{};
108 virtual void resetPsi(
bool final_reset =
false) = 0;
137 void addCJParams(xmlXPathContextPtr acontext,
const char* cname);
141 #ifdef HAVE_LMY_ENGINE 142 Return_rt LMYEngineCost(
const bool needDeriv, cqmc::engine::LMYEngine<Return_t>* EngineObj);
150 #ifdef HAVE_LMY_ENGINE 151 virtual void engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>* EngineObj,
153 const std::string& MinMethod) = 0;
269 std::map<std::string, std::pair<xmlNodePtr, std::string>>
attribNodes;
275 std::vector<RandomBase<FullPrecRealType>*>
MoverRng;
324 #ifdef HAVE_LMY_ENGINE 325 virtual Return_rt LMYEngineCost_detail(cqmc::engine::LMYEngine<Return_t>* EngineObj)
bool targetExcited
whether we are targeting an excited state
std::vector< TinyVector< int, 2 > > negateVarMap
index mapping for <negate> constraints
bool Write2OneXml
if true, do not write the *.opt.#.xml
Return_rt CostValue
value of the cost function
void setStream(std::ostream *os)
Return_rt Cost(bool needGrad=true) override
return the cost value for CGMinimization
bool reportH5
Save opt parameters to HDF5.
Return_rt Etarget
target energy
std::vector< ParticleLaplacian * > d2LogPsi
Fixed Laplacian , , components.
Base class for any object which needs to know about a MPI communicator.
std::vector< std::string > variational_subset_names
optimized parameter names
helper functions for EinsplineSetBuilder
Return_rt computedCost()
return the cost value for CGMinimization
int NumSamples
global number of samples to use in correlated sampling
std::string getParamName(int i) const override
std::ostream * msg_stream
stream to which progress is sent
Matrix< Return_rt > Records
Saved properties of all the walkers.
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
std::string RootName
string for the file root
void setneedGrads(bool tf)
void setRootName(const std::string &aroot)
virtual void checkConfigurations(EngineHandle &handle)=0
std::vector< TinyVector< int, 2 > > equalVarMap
index mapping for <equal> constraints
Return_t Params(int i) const override
return optimization parameter i
void addCJParams(xmlXPathContextPtr acontext, const char *cname)
Return_rt MinNumWalkers
fraction of the number of walkers below which the costfunction becomes invalid
int NumOptimizables
total number of optimizable variables
void setNumSamples(int newNumSamples)
Collection of Local Energy Operators.
ParticleAttrib< QTFull::ValueType > ParticleLaplacian
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
std::vector< std::unique_ptr< T > > UPtrVector
std::map< std::string, std::pair< xmlNodePtr, std::string > > attribNodes
attributes to be updated
declaration of MPIObjectBase
UPtrVector< RandomBase< FullPrecRealType > > RngSaved
Random number generators.
ParticleSet::ParticleLaplacian ParticleLaplacian
ParticleSet::ParticleGradient ParticleGradient
Saved derivative properties and Hderivative properties of all the walkers.
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
virtual void getConfigurations(const std::string &aroot)=0
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.
const opt_variables_type & getOptVariables() const
void getParameterTypes(std::vector< int > &types) const
int getReportCounter() const
return the counter which keeps track of optimization steps
std::map< std::string, xmlNodePtr > paramNodes
parameters to be updated`
Return_rt curAvg
current Average
opt_variables_type OptVariablesForPsi
full list of optimizables
class to handle a set of variables that can be modified during optimizations
void setRng(RefVector< RandomBase< FullPrecRealType >> r)
QMCTraits::FullPrecRealType FullPrecRealType
QMCHamiltonian & H
Hamiltonian.
Return_rt w_en
weights for energy and variance in the cost function
int getType(int i) const
get the i-th parameter's type
#define APP_ABORT(msg)
Widely used but deprecated fatal error macros from legacy code.
Implements wave-function optimization.
ParticleSet & W
Particle set.
bool isEffectiveWeightValid(EffectiveWeight effective_weight) const
check the validity of the effective weight calculated by correlatedSampling
Return_rt & Params(int i) override
assign optimization parameter i
size_type size() const
return the size
virtual Return_rt fillOverlapHamiltonianMatrices(Matrix< Return_rt > &Left, Matrix< Return_rt > &Right)=0
std::unique_ptr< std::ostream > debug_stream
stream for debug
void getParameterTypeList(std::vector< int > &types) const
Declaration of a TrialWaveFunction.
int ReportCounter
counter for output
void printCJParams(xmlNodePtr cur, std::string &rname)
std::vector< std::reference_wrapper< T > > RefVector
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
int getNumSamples() const
return the global number of samples
std::vector< Return_rt > SumValue
Sum of energies and weights for averages.
Return_rt getVariance() const
return variance after checkConfigurations
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.
bool getneedGrads() const
int getNumParams() const override
return the number of optimizable parameters
Return_rt curVar_abs
current variance of SUM_ABSE_WGT/SUM_WGT
ParticleAttrib< QTFull::GradType > ParticleGradient
Return_rt MaxWeight
maximum weight beyond which the weight is set to 1
void addCoefficients(xmlXPathContextPtr acontext, const char *cname)
add coefficient or coefficients
QTFull::RealType FullPrecRealType
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.
int PowerE
|E-E_T|^PowerE is used for the cost function
void setWaveFunctionNode(xmlNodePtr cur)
void Report() override
dump the current parameters and other report
Return_rt curVar
current Variance
Return_rt curVar_w
current weighted variance (correlated sampling)
opt_variables_type InitVariables
void resetCostFunction(std::vector< xmlNodePtr > &cset)
BareKineticEnergy::Return_t Return_t
double omega_shift
the shift to use when targeting an excited state
void setTargetEnergy(Return_rt et)
void reportParameters()
report parameters at the end
Declaration of QMCHamiltonian.
std::map< std::string, xmlNodePtr > coeffNodes
coefficients to be updated
Return_rt EtargetEff
real target energy with the Correlation Factor
~QMCCostFunctionBase() override
Destructor.
std::vector< RandomBase< FullPrecRealType > * > MoverRng
virtual void resetPsi(bool final_reset=false)=0
reset the wavefunction