Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions src/QMCDrivers/WFOpt/QMCCostFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,16 @@ void QMCCostFunction::checkConfigurations(EngineHandle& handle)
*In future, both the LM and descent engines should be children of some parent engine base class.
* */
void QMCCostFunction::engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
const std::string& MinMethod)
{
const auto num_opt_vars = opt_vars.size();
if (MinMethod == "descent")
{
if (!descentEngineObj)
throw std::runtime_error("Descent optimization requires a DescentEngine");
//Reset vectors and scalars from any previous iteration
descentEngineObj.prepareStorage(omp_get_max_threads(), num_opt_vars);
descentEngineObj->prepareStorage(omp_get_max_threads(), num_opt_vars);
}
RealType et_tot = 0.0;
RealType e2_tot = 0.0;
Expand Down Expand Up @@ -438,7 +440,8 @@ void QMCCostFunction::engine_checkConfigurations(cqmc::engine::LMYEngine<Return_
std::vector<FullPrecValueType> der_rat_samp_comp(der_rat_samp.begin(), der_rat_samp.end());
std::vector<FullPrecValueType> le_der_samp_comp(le_der_samp.begin(), le_der_samp.end());

descentEngineObj.takeSample(ip, der_rat_samp_comp, le_der_samp_comp, le_der_samp_comp, 1.0, saved[REWEIGHT]);
descentEngineObj->takeSample(ip, der_rat_samp_comp, le_der_samp_comp, le_der_samp_comp, 1.0,
saved[REWEIGHT]);
}
#endif
}
Expand Down Expand Up @@ -480,7 +483,7 @@ void QMCCostFunction::engine_checkConfigurations(cqmc::engine::LMYEngine<Return_
if (MinMethod == "adaptive")
EngineObj.sample_finish();
else if (MinMethod == "descent")
descentEngineObj.sample_finish();
descentEngineObj->sample_finish();
#endif

app_log().flush();
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WFOpt/QMCCostFunction.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class QMCCostFunction : public QMCCostFunctionBase, public CloneManager
void checkConfigurations(EngineHandle& handle) override;
#ifdef HAVE_LMY_ENGINE
void engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
const std::string& MinMethod) override;
#endif

Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WFOpt/QMCCostFunctionBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class QMCCostFunctionBase : public MPIObjectBase
virtual void checkConfigurationsSR(EngineHandle& handle);
#ifdef HAVE_LMY_ENGINE
virtual void engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
const std::string& MinMethod) = 0;

#endif
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WFOpt/QMCCostFunctionBatched.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -627,7 +627,7 @@ void QMCCostFunctionBatched::checkConfigurationsSR(EngineHandle& handle)

#ifdef HAVE_LMY_ENGINE
void QMCCostFunctionBatched::engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
const std::string& MinMethod)
{ APP_ABORT("LMYEngine not implemented with batch optimization"); }
#endif
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WFOpt/QMCCostFunctionBatched.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class QMCCostFunctionBatched : public QMCCostFunctionBase, public QMCTraits
void checkConfigurationsSR(EngineHandle& handle) override;
#ifdef HAVE_LMY_ENGINE
void engine_checkConfigurations(cqmc::engine::LMYEngine<Return_t>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
const std::string& MinMethod) override;
#endif

Expand Down
8 changes: 4 additions & 4 deletions src/QMCDrivers/WFOpt/QMCFixedSampleLinearOptimize.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,7 @@ bool QMCFixedSampleLinearOptimize::adaptive_three_shift_run()
EngineObj->reset();

// generate samples and compute weights, local energies, and derivative vectors
engine_start(*EngineObj, *descentEngineObj, MinMethod);
engine_start(*EngineObj, descentEngineObj.get(), MinMethod);

// get dimension of the linear method matrices
size_t N = numParams + 1;
Expand Down Expand Up @@ -1018,7 +1018,7 @@ bool QMCFixedSampleLinearOptimize::adaptive_three_shift_run()
finish();

// take sample
engine_start(*EngineObj, *descentEngineObj, MinMethod);
engine_start(*EngineObj, descentEngineObj.get(), MinMethod);
}

// say what we are doing
Expand Down Expand Up @@ -1396,7 +1396,7 @@ bool QMCFixedSampleLinearOptimize::descent_run()
optTarget->setneedGrads(true);

//Compute Lagrangian derivatives needed for parameter updates with engine_checkConfigurations, which is called inside engine_start
engine_start(*EngineObj, *descentEngineObj, MinMethod);
engine_start(*EngineObj, descentEngineObj.get(), MinMethod);

int descent_num = descentEngineObj->getDescentNum();

Expand Down Expand Up @@ -1519,7 +1519,7 @@ void QMCFixedSampleLinearOptimize::start()

#ifdef HAVE_LMY_ENGINE
void QMCFixedSampleLinearOptimize::engine_start(cqmc::engine::LMYEngine<ValueType>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
std::string MinMethod)
{
app_log() << "entering engine_start function" << std::endl;
Expand Down
2 changes: 1 addition & 1 deletion src/QMCDrivers/WFOpt/QMCFixedSampleLinearOptimize.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ class QMCFixedSampleLinearOptimize : public QMCDriver, public LinearMethod, priv
void start();
#ifdef HAVE_LMY_ENGINE
void engine_start(cqmc::engine::LMYEngine<ValueType>& EngineObj,
DescentEngine& descentEngineObj,
DescentEngine* descentEngineObj,
std::string MinMethod);
#endif
///common operation to finish optimization, used by the derived classes
Expand Down
3 changes: 3 additions & 0 deletions src/formic/utils/lmyengine/engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ cqmc::engine::LMYEngine<S>::LMYEngine(const formic::VarDeps* dep_ptr,
_lm_ham_shift_i(lm_ham_shift_i),
_lm_ham_shift_s(lm_ham_shift_s),
_lm_max_update_abs(lm_max_update_abs),
_le_list(1),
_vg(1),
_weight(1),
_shift_scale(shift_scale),
_dep_ptr(dep_ptr),
_mbuilder(_der_rat,
Expand Down
Loading