18 #ifndef QMCPLUSPLUS_QMCFSLINEAROPTIMIZATION_BATCHED_H 19 #define QMCPLUSPLUS_QMCFSLINEAROPTIMIZATION_BATCHED_H 25 #include "Optimize/NRCOptimization.h" 26 #include "Optimize/NRCOptimizationFunctionWrapper.h" 27 #ifdef HAVE_LMY_ENGINE 28 #include "formic/utils/matrix.h" 29 #include "formic/utils/lmyengine/engine.h" 47 class QMCCostFunctionBase;
58 const std::optional<EstimatorManagerInput>& global_emi,
75 void process(xmlNodePtr cur)
override;
77 bool processOptXML(xmlNodePtr cur,
const std::string& vmcMove,
bool reportH5,
bool useGPU);
84 #ifdef HAVE_LMY_ENGINE 86 void engine_start(cqmc::engine::LMYEngine<ValueType>* EngineObj,
99 NRCOptimizationFunctionWrapper<QMCFixedSampleLinearOptimizeBatched>
objFuncWrapper_;
104 app_log() <<
" Cost Function is Invalid. If this frequently, try reducing the step size of the line minimization " 105 "or reduce the number of cycles. " 112 const std::vector<RealType>& cv,
113 const std::vector<double>& sh,
129 #ifdef HAVE_LMY_ENGINE 141 const std::vector<double>& shiffts_s,
142 std::vector<std::vector<RealType>>& parameterDirections);
144 #ifdef HAVE_LMY_ENGINE 145 formic::VarDeps vdeps;
146 cqmc::engine::LMYEngine<ValueType>* EngineObj;
156 std::vector<double>
prepare_shifts(
const double central_shift)
const;
159 #ifdef HAVE_LMY_ENGINE 160 std::vector<formic::ColVec<double>> previous_update;
OptimizerType previous_optimizer_type
type of the previous optimization method, updated by processOptXML before run
int num_shifts
number of shifts we will try
int nkept
number of directions kept
RealType bestShift_i
the previous best identity shift
int nolds
number of old updates kept
RealType costFunc(RealType dl)
OutputMatrix output_hamiltonian_
void start()
common operation to start optimization
xmlNodePtr wfNode
xml node to be dumped
helper functions for EinsplineSetBuilder
NewTimer & invert_olvmat_timer_
Input representation for VMC driver class runtime parameters.
OutputMatrix output_overlap_
bool adaptive_three_shift_run()
NewTimer & cost_function_timer_
std::vector< double > prepare_shifts(const double central_shift) const
returns a vector of three shift values centered around the provided shift.
OptimizerType current_optimizer_type
type of the current optimization method, updated by processOptXML before run
QMCDriverNew Base class for Unified Drivers.
bool block_lm
whether we are doing block algorithm
Declaration of QMCDriverNew.
LMYOptions options_LMY_
LMY engine related options.
LinearMethod related functions.
A set of light weight walkers that are carried between driver sections and restart.
void print_cost_summary_header()
prints a header for the summary of each shift's result
bool filter_info
whether to filter parameters for the lm
RealType shift_s_base
Shift_s adjustment base.
NewTimer & initialize_timer_
bool doHybrid
whether to use hybrid method
std::unique_ptr< GradientTest > testEngineObj
Timer accumulates time and call counts.
NewTimer & line_min_timer_
std::vector< RealType > optdir
std::unique_ptr< QMCCostFunctionBase > optTarget
target cost function to optimize
bool ValidCostFunction(bool valid)
RealType bestShift_s
the previous best overlap shift
Wrapping information on parallelism.
NewTimer & eigenvalue_timer_
RealType shift_i_input
current shift_i, shift_s input values
NewTimer & generate_samples_timer_
bool one_shift_run()
Performs one iteration of the linear method using an adaptive scheme that tries three different shift...
RealType max_param_change
max amount a parameter may change relative to current wave function weight
~QMCFixedSampleLinearOptimizeBatched() override
Destructor.
bool block_first
whether to do the first part of block lm
std::string eigensolver_
Choice of eigenvalue solver.
std::unique_ptr< HybridEngine > hybridEngineObj
class to handle a set of parameters
bool is_best_cost(const int ii, const std::vector< RealType > &cv, const std::vector< double > &sh, const RealType ic) const
Returns whether the proposed new cost is the best compared to the others.
QMCFixedSampleLinearOptimizeBatched(const ProjectData &project_data, QMCDriverInput &&qmcdriver_input, const std::optional< EstimatorManagerInput > &global_emi, VMCDriverInput &&vmcdriver_input, WalkerConfigurations &wc, MCPopulation &&population, SampleStack &samples, Communicate *comm)
Constructor.
QTBase::ValueType ValueType
RealType omega_shift
the shift to use when targeting an excited state
void print_cost_summary(const double si, const double ss, const RealType mc, const RealType cv, const int ind, const int bi, const bool gu)
prints a summary of the computed cost for the given shift
RealType cost_increase_tol
the tolerance to cost function increases when choosing the best shift in the adaptive shift method ...
QMCRunType getRunType() override
int nsamp_comp
number of samples to do in correlated sampling part
NRCOptimizationFunctionWrapper< QMCFixedSampleLinearOptimizeBatched > objFuncWrapper_
RealType target_shift_i
the shift_i value that the adaptive shift method should aim for
bool block_second
whether to do the second part of block lm
std::string MinMethod
name of the current optimization method, updated by processOptXML before run
bool previous_linear_methods_run()
std::vector< RealType > optparam
void solveShiftsWithoutLMYEngine(const std::vector< double > &shifts_i, const std::vector< double > &shiffts_s, std::vector< std::vector< RealType >> ¶meterDirections)
For each set of shifts, solves the linear method eigenproblem by building and diagonalizing the matri...
bool block_third
whether to do the third part of block lm
bool targetExcited
whether we are targeting an excited state
std::unique_ptr< DescentEngine > descentEngineObj
NewTimer & build_olv_ham_timer_
bool processOptXML(xmlNodePtr cur, const std::string &vmcMove, bool reportH5, bool useGPU)
process xml node value (parameters for both VMC and OPT) for the actual optimization ...
bool store_samples
whether to store samples for the lm
RealType max_relative_cost_change
the maximum relative change in the cost function for the adaptive three-shift scheme ...
LatticeGaussianProduct::ValueType ValueType
int nblocks
number of blocks used in block algorithm
QMCTraits::RealType RealType
void finish()
common operation to finish optimization, used by the derived classes
bool filter_param
whether to filter parameters for the lm
int nstabilizers
Number of iterations maximum before generating new configurations.
std::bitset< 2 > accept_history
accept history, remember the last 2 iterations, value 00, 01, 10, 11
int Max_iterations
Number of iterations maximum before generating new configurations.
bool run() override
Run the Optimization algorithm.
double ratio_threshold
threshold for filtering parameters for the lm
Output the Hamiltonian and overlap matrices from linear method.
void setWaveFunctionNode(xmlNodePtr cur)
const std::optional< EstimatorManagerInput > global_emi_
This is retained in order to construct and reconstruct the vmcEngine.
bool do_output_matrices_hdf_
bool output_matrices_initialized_
void process(xmlNodePtr cur) override
preprocess xml node
bool do_output_matrices_csv_
Input representation for Driver base class runtime parameters.
std::unique_ptr< VMCBatched > vmcEngine
vmc engine
VMCDriverInput vmcdriver_input_