Class CG

Implementation of the Conjugate Gradient algorithm

An implementation of the conjugate gradient optimization algorithm. This class implements 4 different variations of CG defined by the so-called beta-parameter:

  1. Polak-Ribiere
  2. Fletcher-Reeves
  3. Hestenes-Stiefel
  4. Dai-Yuan

Additionally this CG implementation defaults to a beta-damping factor to achieve a smooth restart method, instead of abrupt CG restarts when beta < 0, for instance.

Methods

CG:new ([beta="PR"][, beta_damping=0.8][, restart="Powell"][, optimizer], ...) Instantiating a new CG object

The parameters must be specified with a table of named arguments

The CG optimizer implements several variations of the algorithms: The beta-parameter calculation may be performed using either (beta field in argument table):

  • Polak-Ribiere (default)
  • Fletcher-Reeves
  • Hestenes-Stiefel
  • Dai-Yuan

CG algorithms also implements a restart method based on different criteria in this algorithm there is a default smooth restart by damping the beta parameter (default to 0.8).

CG:reset () Reset the CG algorithm for restart purposes All history will be cleared and the algorithm will restart the CG optimization from scratch.
CG:add_history (F, G) Add the current parameters and the gradient for those to the history
CG:optimize (F, G) Returns the optimized parameters which should minimize the function with respect to the current conjugate gradient
CG:conjugate () Return the new conjugate direction This will take into account how the beta-value is calculated.
CG:SIESTA (siesta) SIESTA function for performing a complete SIESTA CG optimization.
CG:info () Print some information regarding the CG object


Methods

CG:new ([beta="PR"][, beta_damping=0.8][, restart="Powell"][, optimizer], ...)

Instantiating a new CG object

The parameters must be specified with a table of named arguments

The CG optimizer implements several variations of the algorithms: The beta-parameter calculation may be performed using either (beta field in argument table):

  • Polak-Ribiere (default)
  • Fletcher-Reeves
  • Hestenes-Stiefel
  • Dai-Yuan

CG algorithms also implements a restart method based on different criteria in this algorithm there is a default smooth restart by damping the beta parameter (default to 0.8). In addition to this there are schemes for explicit restart (restart field in argument table):

  • negative, when beta < 0 CG restarts the conjugate gradient
  • Powel, when the scalar-projection of the two previous gradients is above 0.2

Parameters:

  • beta string determine the method used for beta-parameter calculation (default "PR")
  • beta_damping number a factor for the beta variable such that a smooth restart is obtained (default 0.8)
  • restart string method of restart (default "Powell")
  • optimizer Optimizer the optimization method used to minimize along the direction (defaults to the LBFGS optimizer) (optional)
  • ... any arguments Optimizer:new accepts

Usage:

    cg = CG{<field1 = value>, <field2 = value>}
    while not cg:optimized() do
       F = cg:optimize(F, G)
    end
CG:reset ()
Reset the CG algorithm for restart purposes All history will be cleared and the algorithm will restart the CG optimization from scratch.
CG:add_history (F, G)
Add the current parameters and the gradient for those to the history

Parameters:

  • F Array the parameters
  • G Array the gradient for the function with the parameters F
CG:optimize (F, G)
Returns the optimized parameters which should minimize the function with respect to the current conjugate gradient

Parameters:

  • F Array the parameters for the function
  • G Array the gradient for the parameters

Returns:

    a new set of parameters to be used for the function
CG:conjugate ()
Return the new conjugate direction This will take into account how the beta-value is calculated.

Returns:

    the new conjugate direction
CG:SIESTA (siesta)
SIESTA function for performing a complete SIESTA CG optimization.

This function will query these fdf-flags from SIESTA:

  • MD.MaxForceTol
  • MD.MaxCGDispl

and use those as the tolerance for convergence as well as the maximum displacement for each optimization step.

Everything else is controlled by the CG object.

Note that all internal operations in this function relies on units being in - Ang - eV - eV/Ang

Parameters:

  • siesta table the SIESTA global table.
CG:info ()
Print some information regarding the CG object
generated by LDoc 1.4.6 Last updated 2019-05-23 08:36:38