Class GradientOptimizer#
Defined in File optimizer.hpp
Inheritance Relationships#
Base Type#
public pele::Optimizer(Class Optimizer)
Derived Types#
public pele::ExtendedMixedOptimizer(Class ExtendedMixedOptimizer)public pele::GenericMixedDescent(Class GenericMixedDescent)public pele::LBFGS(Class LBFGS)public pele::MixedDescentEndOnly(Class MixedDescentEndOnly)public pele::Newton(Class Newton)public pele::NewtonWithExtendedPotential(Class NewtonWithExtendedPotential)public pele::ODEBasedOptimizer(Class ODEBasedOptimizer)public pele::Steepest_Descent(Class Steepest_Descent)
Class Documentation#
-
class GradientOptimizer : public pele::Optimizer#
This defines the basic interface for optimizers.
All pele optimizers should derive from this class.
Subclassed by pele::ExtendedMixedOptimizer, pele::GenericMixedDescent, pele::LBFGS, pele::MixedDescentEndOnly, pele::Newton, pele::NewtonWithExtendedPotential, pele::ODEBasedOptimizer, pele::Steepest_Descent
Public Functions
- std::shared_ptr<pele::BasePotential> potential,
- const pele::Array<double> x0,
- double tol = 1e-4,
- bool save_trajectory = false,
- int iterations_before_save = 1,
- StopCriterionType stop = GRADIENT
-
inline virtual ~GradientOptimizer()#
-
inline GradientOptimizer(const GradientOptimizer&)#
-
inline GradientOptimizer()#
-
virtual void one_iteration() = 0#
Do one iteration iteration of the optimization algorithm.
-
inline virtual void run(int const niter)#
Run the optimization algorithm until the stop criterion is satisfied or until the maximum number of iterations is reached.
-
inline void print_stats()#
-
inline virtual void run()#
Run the optimzation algorithm for niter iterations or until the stop criterion is satisfied.
-
inline virtual void set_func_gradient(double f, Array<double> grad)#
Set the initial func and gradient.
This can be used to avoid one potential call
-
inline void set_tol(double tol)#
-
inline void set_maxstep(double maxstep)#
-
inline void set_max_iter(int max_iter)#
-
inline void set_iprint(int iprint)#
-
inline void set_verbosity(int verbosity)#
-
inline void set_f(double f_in)#
-
inline void set_rms(double rms_in)#
-
inline void set_tolerance(double tol)#
-
inline virtual double get_f() const#
-
inline virtual double get_rms() const#
-
inline virtual int get_nfev() const#
-
inline virtual int get_nhev() const#
-
inline virtual int get_niter() const#
-
inline int get_maxiter() const#
-
inline double get_maxstep()#
-
inline double get_gradient_norm_()#
-
inline double get_step_norm_()#
-
inline double get_tol() const#
-
inline virtual bool success()#
-
inline int get_verbosity_()#
-
inline bool get_last_step_failed()#
-
inline std::shared_ptr<pele::BasePotential> get_potential()#
-
inline virtual bool stop_criterion_satisfied()#
Return true if the termination condition is satisfied, false otherwise.
- inline virtual void compute_func_gradient( )#
functions for LineSearch
Protected Functions
- inline virtual void compute_func_gradient(
- Array<double> x,
- double &func,
- std::vector<xsum_small_accumulator> &gradient
Compute the objective value and fill the supplied gradient accumulators.
-
inline virtual void initialize_func_gradient()#
compute the initial func and gradient
-
inline virtual void update_costly_trajectory_info()#
-
inline virtual void update_cheap_trajectory_info()#
Protected Attributes
-
std::shared_ptr<pele::BasePotential> potential_#
A pointer to the object that computes the function and gradient.
-
double tol_#
The tolerance for the rms gradient.
-
double maxstep_#
The maximum step size.
-
int maxiter_#
The maximum number of iterations.
-
int iprint_#
how often to print status information
-
int verbosity_#
How much information to print.
-
int iter_number_#
The current iteration number.
-
int nfev_#
number of get_energy_gradient evaluations.
-
int nhev_#
number of get_energy_gradient_hessian evaluations
-
double f_#
The current function value.
-
double gradient_norm_#
The root mean square of the gradient.
-
double step_norm_#
The norm of the step taken.
-
std::unique_ptr<AbstractStopCriterion> stop_criterion#
-
bool func_initialized_#
This flag keeps track of whether the function and gradient have been initialized.This allows the initial function and gradient to be computed outside of the constructor and also allows the function and gradient to be passed rather than computed.
The downside is that it complicates the logic because this flag must be checked at all places where the gradient, function value, or rms can be first accessed.
-
bool last_step_failed_#
Whether the last step failed helpful for newton, when combining in mixed descent.
-
bool succeeded_#
Whether the optimization succeeded.
-
bool save_trajectory_#
Whether to save the trajectory.
-
int iterations_before_save_#
How often to save the trajectory.