Package ffx.algorithms.optimize
Class Minimize
java.lang.Object
ffx.algorithms.optimize.Minimize
- All Implemented Interfaces:
Terminatable
,OptimizationListener
- Direct Known Subclasses:
CrystalMinimize
,MinimizeOpenMM
Minimize the potential energy of a system to an RMS gradient per atom convergence criteria.
- Since:
- 1.0
- Author:
- Michael J. Schnieders
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Enumerates available molecular minimization engines; presently limited to the FFX reference engine and the OpenMM engine. -
Field Summary
Modifier and TypeFieldDescriptionprotected final AlgorithmListener
The AlgorithmListener to update the UI.static final int
The default number of correction vectors used by the limited-memory L-BFGS optimization routine.protected boolean
A flag to indicate the algorithm is done.protected double
The final potential energy.protected final double[]
The gradient.protected final MolecularAssembly
The MolecularAssembly being operated on.protected final int
Number of variables.protected int
The number of optimization steps taken.protected final Potential
The potential energy to optimize.protected final double[]
Scaling applied to each variable.protected int
The return status of the optimization.protected boolean
A flag to indicate the algorithm should be terminated.protected long
Minimization time in nanoseconds.protected final double[]
Current value of each variable. -
Constructor Summary
ConstructorDescriptionMinimize
(MolecularAssembly molecularAssembly, AlgorithmListener algorithmListener) Constructor for Minimize.Minimize
(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) Constructor for Minimize. -
Method Summary
Modifier and TypeMethodDescriptionstatic Minimize.MinimizationEngine
defaultEngine
(MolecularAssembly molecularAssembly, Potential potentialEnergy) double
Getter for the fieldenergy
.int
Getter for the number of iterations completed this minimization.double
getRMSGradient.int
Getter for the fieldstatus
.minimize()
minimizeminimize
(double eps) minimizeminimize
(double eps, int maxIterations) minimizeminimize
(int m, double eps, int maxIterations) minimizestatic Minimize
minimizeFactory
(MolecularAssembly assembly, Potential potentialEnergy, AlgorithmListener listener, Minimize.MinimizationEngine engine) dynamicsFactory.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.void
This should be implemented as a blocking interrupt; when the method returns theTerminatable
algorithm has reached a clean termination point.
-
Field Details
-
molecularAssembly
The MolecularAssembly being operated on. -
potential
The potential energy to optimize. -
algorithmListener
The AlgorithmListener to update the UI. -
n
protected final int nNumber of variables. -
x
protected final double[] xCurrent value of each variable. -
grad
protected final double[] gradThe gradient. -
scaling
protected final double[] scalingScaling applied to each variable. -
done
protected boolean doneA flag to indicate the algorithm is done. -
terminate
protected boolean terminateA flag to indicate the algorithm should be terminated. -
time
protected long timeMinimization time in nanoseconds. -
energy
protected double energyThe final potential energy. -
status
protected int statusThe return status of the optimization. -
nSteps
protected int nStepsThe number of optimization steps taken. -
DEFAULT_LBFGS_VECTORS
public static final int DEFAULT_LBFGS_VECTORSThe 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
-
Minimize
public Minimize(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) Constructor for Minimize.- Parameters:
molecularAssembly
- aMolecularAssembly
object.potential
- aPotential
object.algorithmListener
- aAlgorithmListener
object.
-
Minimize
Constructor for Minimize.- Parameters:
molecularAssembly
- aMolecularAssembly
object.algorithmListener
- aAlgorithmListener
object.
-
-
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
- aMolecularAssembly
object.potentialEnergy
- aPotential
object.listener
- aAlgorithmListener
object.engine
- aMDEngine
object.- Returns:
- a
MolecularDynamics
object.
-
getEnergy
public double getEnergy()Getter for the fieldenergy
.- Returns:
- a double.
-
getRMSGradient
public double getRMSGradient()getRMSGradient.- Returns:
- a double.
-
getStatus
public int getStatus()Getter for the fieldstatus
.- 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
minimize- Returns:
- a
Potential
object.
-
minimize
minimize- Parameters:
eps
- The convergence criteria.- Returns:
- a
Potential
object.
-
minimize
minimize- Parameters:
eps
- The convergence criteria.maxIterations
- The maximum number of iterations.- Returns:
- a
Potential
object.
-
minimize
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 interfaceOptimizationListener
- 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 theTerminatable
algorithm has reached a clean termination point. For example, between minimize or molecular dynamics steps.- Specified by:
terminate
in interfaceTerminatable
-