File Lbfgs.h

Copyright

This code is licensed under the 3-clause BSD license.

Copyright ETH Zurich, Laboratory for Physical Chemistry, Reiher Group.

See LICENSE.txt for details.

namespace Scine

This header file contains functions that allow for common notation for common things that can be done at a different degree of derivatives.

This header contains alias definitions defining which classes to use for the different degrees of derivatives.

namespace Utils
class Lbfgs : public Scine::Utils::Optimizer
#include <Lbfgs.h>

An implementation of a limited memory BFGS optimization algorithm.

The implementation includes an optional linesearch using both Wolfe conditions.

Public Functions

Lbfgs()

Default constructor.

template<class UpdateFunction>
int optimize(Eigen::VectorXd &parameters, UpdateFunction &&function, GradientBasedCheck &check)

The main routine of the optimizer that carries out the actual optimization.

Return

int Returns the number of optimization cycles carried out until the conclusion of the optimization function.

Template Parameters
  • UpdateFunction: A lambda function with a void return value, and the arguments:

    1. const Eigen::VectorXd& parameters

    2. double& value

    3. Eigen::VectorXd& gradients

Parameters
  • parameters: The parameters to be optimized.

  • function: The function to be evaluated in order to get values and gradients for a given set of parameters.

  • check: The ConvergenceCheck to be used in order to determine when the optimization is finished or should stop for other reasons.

virtual void addSettingsDescriptors(UniversalSettings::DescriptorCollection &collection) const

Adds all relevant options to the given UniversalSettings::DescriptorCollection thus expanding it to include the L-BFGS’s options.

Parameters
  • collection: The DescriptorCollection to which new fields shall be added.

virtual void applySettings(const Settings &settings)

Updates the L-BFGS’s options with those values given in the Settings.

Parameters
  • settings: The settings to update the option of the L-BFGS with.

Public Members

unsigned int maxm = 10

The maximum number of old steps stored.

After hitting this maximum number of stored data, the oldest parameters and gradients will be replaced

bool linesearch = true

Switch to turn on and off the use of a linesearch.

double c1 = 0.0001

1st parameter for the Wolfe conditions.

This parameter is only relevant if the linesearch is turned on.

double c2 = 0.9

2nd parameter for the Wolfe conditions.

This parameter is only relevant if the linesearch is turned on. Also a value as low as 0.1 can be used.

double stepLength = 1.0

The initial step length used in the L-BFGS.

Note: the first step is a gradient descent with 0.1 times the steplength.

bool useTrustRadius = false

Enable the use of a trust radius for all steps.

double trustRadius = 0.1

The maximum size (RMS) of a taken step.

int maxBacktracking = 5

The maximum number of consecutive backtracking steps allowed.

Public Static Attributes

constexpr const char *lbfgsMaxm = "lbfgs_maxm"
constexpr const char *lbfgsLinesearch = "lbfgs_linesearch"
constexpr const char *lbfgsC1 = "lbfgs_c1"
constexpr const char *lbfgsC2 = "lbfgs_c2"
constexpr const char *lbfgsStepLength = "lbfgs_step_length"
constexpr const char *lbfgsUseTrustRadius = "lbfgs_use_trust_radius"
constexpr const char *lbfgsTrustRadius = "lbfgs_trust_radius"
constexpr const char *lbfgsMaxBacktracking = "lbfgs_max_backtracking"