pele.optimize#

Module source

Optimizers (pele.optimize)#

This module contains all of the local optimizers available in pele. There are so many available for testing purposes and because sometimes different optimizers are more appropriate in different circumstances. These optimizers are all local. That is they stop at a local minimum. For global optimization see global optimization.

In our experience, we have found that the best minimizers are lbfgs and fire. lbfgs seems to be by far the fastest, however there are some circumstances where the better stability of fire might be useful. CVODE exists if you want guarantees that the endpoint is the one connected by the steepest descent equation (see https://arxiv.org/abs/2409.12113). Mixed Descent is also designed to increase the probability that the path is connected by steepest descent, (but is currently WIP because it only improves performance over CVODE for LJ clusters) LBFGS can also fail in non-Hamiltonian situations where you have forces, but no potential function. This is the case in the Nudged elastic band, where the NEB force doesn’t correspond to any NEB energy.

Note

we use the words “optimize”, “quench”, and “minimize” interchangeably

All of the optimizers that are functions in this package have the same form:

res = optimizer(coords, potential, **kwargs)

where coords is the starting structure, potential supplies the energy and gradient, and kwargs contains optional parameters. The return value is a Result object, which is simply a dictionary where __getattr__ is a wrapper for __getitem__. So the coords can be accessed as res.coords or as res[“coords”].

We have tried to make the minimizers as consistent as possible, but it is not always possible. Some of the common parameters most of them accept are:

  1. nsteps : number of iterations

  2. tol : tolerance criterion for the rms gradient

  3. iprint : how often to print status information

LBFGS routines#

limited-memory BFGS (Broyden-Fletcher-Goldfarb-Shanno) routine

http://en.wikipedia.org/wiki/Limited-memory_BFGS

These routines (excluding the scipy version) are slightly different from most lbfgs routines in that the don’t use a line search. Instead, both the step size and direction returned by the lbfgs routine are accepted subject to a constraint on the energy change. If the energy rises more than a given amount then the step size is reduce until the condition is satisfied. Note: this is what makes lbfgs potentially fail with non-Hamiltonian systems.

C++ LBFGS#

lbfgs_cpp() constructs LBFGS_CPP and returns its result. The system class uses this implementation for its default local minimizer.

Python and Fortran LBFGS#

LBFGS is the Python implementation; MYLBFGS uses a Fortran step update. Their function wrappers return the optimization result.

FIRE#

Python FIRE#

fire() runs the Python Fire implementation.

Native modified FIRE#

modifiedfire_cpp() runs ModifiedFireCPP, the Python interface to the C++ pele::MODIFIED_FIRE implementation:

from pele.optimize import modifiedfire_cpp
result = modifiedfire_cpp(coords, potential)

To retain the optimizer object between calls, construct ModifiedFireCPP(coords, potential, **kwargs) and call its run() method.

Native gradient descent#

These C++ optimizer classes take the potential before the initial coordinates. Call run() on the optimizer to obtain its result.

CVODE and mixed descent#

These native optimizers require a build with SUNDIALS and the cvode feature enabled. Their constructors take the potential before the initial coordinates. GenericMixedDescent also takes the non-convex and convex optimizer objects, a tolerance, and a translation offset.

Native optimizer options#

StopCriterionType selects the stopping criterion for native LBFGS, modified FIRE, and extended mixed descent. HessianType selects the Hessian implementation used by CVODEBDFOptimizer.

SciPy optimizers#

These functions wrap the corresponding optimizers in SciPy.

Python steepest descent#

This implementation is intended for testing and is slow.