RDKit
Open-source cheminformatics and machine learning.
BFGSOpt Namespace Reference

Functions

template<typename EnergyFunctor >
void linearSearch (unsigned int dim, double *oldPt, double oldVal, double *grad, double *dir, double *newPt, double &newVal, EnergyFunctor func, double maxStep, int &resCode)
 Do a Quasi-Newton minimization along a line. More...
 
template<typename EnergyFunctor , typename GradientFunctor >
int minimize (unsigned int dim, double *pos, double gradTol, unsigned int &numIters, double &funcVal, EnergyFunctor func, GradientFunctor gradFunc, unsigned int snapshotFreq, RDKit::SnapshotVect *snapshotVect, double funcTol=TOLX, unsigned int maxIts=MAXITS)
 Do a BFGS minimization of a function. More...
 
template<typename EnergyFunctor , typename GradientFunctor >
int minimize (unsigned int dim, double *pos, double gradTol, unsigned int &numIters, double &funcVal, EnergyFunctor func, GradientFunctor gradFunc, double funcTol=TOLX, unsigned int maxIts=MAXITS)
 Do a BFGS minimization of a function. More...
 

Variables

const double FUNCTOL
 Default tolerance for function convergence in the minimizer. More...
 
const double MOVETOL
 Default tolerance for x changes in the minimizer. More...
 
const int MAXITS = 200
 Default maximum number of iterations. More...
 
const double EPS = 3e-8
 Default gradient tolerance in the minimizer. More...
 
const double TOLX
 Default direction vector tolerance in the minimizer. More...
 
const double MAXSTEP = 100.0
 Default maximim step size in the minimizer. More...
 

Function Documentation

template<typename EnergyFunctor >
void BFGSOpt::linearSearch ( unsigned int  dim,
double *  oldPt,
double  oldVal,
double *  grad,
double *  dir,
double *  newPt,
double &  newVal,
EnergyFunctor  func,
double  maxStep,
int &  resCode 
)

Do a Quasi-Newton minimization along a line.

See Numerical Recipes in C, Section 9.7 for a description of the algorithm.

Parameters
dimthe dimensionality of the space.
oldPtthe current position, as an array.
oldValthe current function value.
gradthe value of the function gradient at oldPt
dirthe minimization direction
newPtused to return the final position
newValused to return the final function value
functhe function to minimize
maxStepthe maximum allowable step size
resCodeused to return the results of the search.

Possible values for resCode are on return are:

  • 0: success
  • 1: the stepsize got too small. This probably indicates success.
  • -1: the direction is bad (orthogonal to the gradient)

Definition at line 49 of file BFGSOpt.h.

References ForceFields::UFF::Params::lambda, and PRECONDITION.

Referenced by minimize().

template<typename EnergyFunctor , typename GradientFunctor >
int BFGSOpt::minimize ( unsigned int  dim,
double *  pos,
double  gradTol,
unsigned int &  numIters,
double &  funcVal,
EnergyFunctor  func,
GradientFunctor  gradFunc,
unsigned int  snapshotFreq,
RDKit::SnapshotVect snapshotVect,
double  funcTol = TOLX,
unsigned int  maxIts = MAXITS 
)

Do a BFGS minimization of a function.

See Numerical Recipes in C, Section 10.7 for a description of the algorithm.

Parameters
dimthe dimensionality of the space.
posthe starting position, as an array.
gradToltolerance for gradient convergence
numItersused to return the number of iterations required
funcValused to return the final function value
functhe function to minimize
gradFunccalculates the gradient of func
funcToltolerance for changes in the function value for convergence.
maxItsmaximum number of iterations allowed
snapshotFreqa snapshot of the minimization trajectory will be stored after as many steps as indicated through this parameter; defaults to 0 (no snapshots stored)
snapshotVectpointer to a std::vector<Snapshot> object that will receive the coordinates and energies every snapshotFreq steps; defaults to NULL (no snapshots stored)
Returns
a flag indicating success (or type of failure). Possible values are:
  • 0: success
  • 1: too many iterations were required

Definition at line 184 of file BFGSOpt.h.

References CHECK_INVARIANT, CLEANUP, linearSearch(), PRECONDITION, and RDUNUSED_PARAM.

Referenced by minimize().

template<typename EnergyFunctor , typename GradientFunctor >
int BFGSOpt::minimize ( unsigned int  dim,
double *  pos,
double  gradTol,
unsigned int &  numIters,
double &  funcVal,
EnergyFunctor  func,
GradientFunctor  gradFunc,
double  funcTol = TOLX,
unsigned int  maxIts = MAXITS 
)

Do a BFGS minimization of a function.

Parameters
dimthe dimensionality of the space.
posthe starting position, as an array.
gradToltolerance for gradient convergence
numItersused to return the number of iterations required
funcValused to return the final function value
functhe function to minimize
gradFunccalculates the gradient of func
funcToltolerance for changes in the function value for convergence.
maxItsmaximum number of iterations allowed
Returns
a flag indicating success (or type of failure). Possible values are:
  • 0: success
  • 1: too many iterations were required

Definition at line 378 of file BFGSOpt.h.

References minimize().

Variable Documentation

const double BFGSOpt::EPS = 3e-8

Default gradient tolerance in the minimizer.

Definition at line 23 of file BFGSOpt.h.

const double BFGSOpt::FUNCTOL
Initial value:
=
1e-4

Default tolerance for function convergence in the minimizer.

Definition at line 18 of file BFGSOpt.h.

const int BFGSOpt::MAXITS = 200

Default maximum number of iterations.

Definition at line 22 of file BFGSOpt.h.

const double BFGSOpt::MAXSTEP = 100.0

Default maximim step size in the minimizer.

Definition at line 26 of file BFGSOpt.h.

const double BFGSOpt::MOVETOL
Initial value:
=
1e-7

Default tolerance for x changes in the minimizer.

Definition at line 20 of file BFGSOpt.h.

const double BFGSOpt::TOLX
Initial value:
=
4. * EPS
const double EPS
Default gradient tolerance in the minimizer.
Definition: BFGSOpt.h:23

Default direction vector tolerance in the minimizer.

Definition at line 24 of file BFGSOpt.h.