Class Minimize

java.lang.Object
ffx.algorithms.optimize.Minimize
All Implemented Interfaces:
Terminatable, OptimizationListener
Direct Known Subclasses:
CrystalMinimize, MinimizeOpenMM

public class Minimize extends Object implements OptimizationListener, Terminatable
Minimize the potential energy of a system to an RMS gradient per atom convergence criteria.
Since:
1.0
Author:
Michael J. Schnieders
  • Field Details

    • molecularAssembly

      protected final MolecularAssembly molecularAssembly
      The MolecularAssembly being operated on.
    • potential

      protected final Potential potential
      The potential energy to optimize.
    • algorithmListener

      protected final AlgorithmListener algorithmListener
      The AlgorithmListener to update the UI.
    • n

      protected final int n
      Number of variables.
    • x

      protected final double[] x
      Current value of each variable.
    • grad

      protected final double[] grad
      The gradient.
    • scaling

      protected final double[] scaling
      Scaling applied to each variable.
    • done

      protected boolean done
      A flag to indicate the algorithm is done.
    • terminate

      protected boolean terminate
      A flag to indicate the algorithm should be terminated.
    • time

      protected long time
      Minimization time in nanoseconds.
    • energy

      protected double energy
      The final potential energy.
    • status

      protected int status
      The return status of the optimization.
    • nSteps

      protected int nSteps
      The number of optimization steps taken.
    • DEFAULT_LBFGS_VECTORS

      public static final int DEFAULT_LBFGS_VECTORS
      The default number of correction vectors used by the limited-memory L-BFGS optimization routine.

      Values of less than 3 are not recommended and large values will result in excessive computing time. The range from 3 <= mSave <= 7 is recommended.

      See Also:
  • Constructor Details

  • Method Details

    • defaultEngine

      public static Minimize.MinimizationEngine defaultEngine(MolecularAssembly molecularAssembly, Potential potentialEnergy)
    • minimizeFactory

      public static Minimize minimizeFactory(MolecularAssembly assembly, Potential potentialEnergy, AlgorithmListener listener, Minimize.MinimizationEngine engine)
      dynamicsFactory.
      Parameters:
      assembly - a MolecularAssembly object.
      potentialEnergy - a Potential object.
      listener - a AlgorithmListener object.
      engine - a MDEngine object.
      Returns:
      a MolecularDynamics object.
    • getEnergy

      public double getEnergy()
      Getter for the field energy.
      Returns:
      a double.
    • getRMSGradient

      public double getRMSGradient()
      getRMSGradient.
      Returns:
      a double.
    • getStatus

      public int getStatus()
      Getter for the field status.
      Returns:
      The status of the optimization.
    • getIterations

      public int getIterations()
      Getter for the number of iterations completed this minimization.
      Returns:
      The number of iterations
    • minimize

      public Potential minimize()
      minimize
      Returns:
      a Potential object.
    • minimize

      public Potential minimize(double eps)
      minimize
      Parameters:
      eps - The convergence criteria.
      Returns:
      a Potential object.
    • minimize

      public Potential minimize(double eps, int maxIterations)
      minimize
      Parameters:
      eps - The convergence criteria.
      maxIterations - The maximum number of iterations.
      Returns:
      a Potential object.
    • minimize

      public Potential minimize(int m, double eps, int maxIterations)
      minimize
      Parameters:
      m - The number of previous steps used to estimate the Hessian.
      eps - The convergence criteria.
      maxIterations - The maximum number of iterations.
      Returns:
      a Potential object.
    • optimizationUpdate

      public boolean optimizationUpdate(int iteration, int nBFGS, int functionEvaluations, double rmsGradient, double rmsCoordinateChange, double energy, double energyChange, double angle, LineSearch.LineSearchResult lineSearchResult)
      This method is called by the optimizer after each step.

      It can be used to log status messages, update the user interface, or gracefully terminate the optimizer.

      Implement the OptimizationListener interface.

      Specified by:
      optimizationUpdate in interface OptimizationListener
      Parameters:
      iteration - Number of iterations.
      nBFGS - Number of L-BFGS correction vectors.
      functionEvaluations - Number of function evaluations.
      rmsGradient - RMS gradient at current solution.
      rmsCoordinateChange - RMS coordinate change at current solution.
      energy - Function value at current solution.
      energyChange - Change in the function value compared to the previous solution.
      angle - Current angle between gradient and search direction.
      lineSearchResult - Result of the line search (null at iteration == 0).
      Returns:
      A return value of false will terminate the optimization.
      Since:
      1.0
    • terminate

      public void terminate()
      This should be implemented as a blocking interrupt; when the method returns the Terminatable algorithm has reached a clean termination point. For example, between minimize or molecular dynamics steps.
      Specified by:
      terminate in interface Terminatable