File Bfgs.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 Bfgs : public Scine::Utils::Optimizer
#include <Bfgs.h>

An implementation of the BFGS optimization algorithm.

The implementation includes an optional GDIIS.

Public Functions

Bfgs()

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 BFGS’s options.

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

virtual void applySettings(const Settings &settings)

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

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

Public Members

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.

bool useGdiis = true

Switch to enable the use of a GDIIS possibly accelerating convergence.

int gdiisMaxStore = 5

The maximum number of old steps used in the GDIIS.

Eigen::MatrixXd invH

The inverse Hessian.

std::unique_ptr<std::function<void(Eigen::MatrixXd&)>> projection = nullptr

A possible Hessian projection.

Public Static Attributes

constexpr const char *bfgsUseTrustRadius = "bfgs_use_trust_radius"
constexpr const char *bfgsTrustRadius = "bfgs_trust_radius"
constexpr const char *bfgsUseGdiis = "bfgs_use_gdiis"
constexpr const char *bfgsGdiisMaxStore = "bfgs_gdiis_max_store"