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
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumerates available molecular minimization engines; presently limited to the FFX reference engine and the OpenMM engine. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AlgorithmListenerThe AlgorithmListener to update the UI.static final intThe default number of correction vectors used by the limited-memory L-BFGS optimization routine.protected booleanA flag to indicate the algorithm is done.protected doubleThe final potential energy.The energy of each step in the minimization.protected final double[]The gradient.protected final MolecularAssemblyThe MolecularAssembly being operated on.protected final intNumber of variables.protected intThe number of optimization steps taken.protected final PotentialThe potential energy to optimize.protected final double[]Scaling applied to each variable.protected intThe return status of the optimization.protected booleanA flag to indicate the algorithm should be terminated.protected longMinimization time in nanoseconds.protected final double[]Current value of each variable. -
Constructor Summary
ConstructorsConstructorDescriptionMinimize(MolecularAssembly molecularAssembly, AlgorithmListener algorithmListener) Constructor for Minimize.Minimize(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) Constructor for Minimize. -
Method Summary
Modifier and TypeMethodDescriptionstatic Minimize.MinimizationEnginedefaultEngine(MolecularAssembly molecularAssembly, Potential potentialEnergy) doubleGetter for the fieldenergy.Get the energy for each step in the minimization.intGetter for the number of iterations completed this minimization.doublegetRMSGradient.intGetter for the fieldstatus.minimize()minimizeminimize(double eps) minimizeminimize(double eps, int maxIterations) minimizeminimize(int m, double eps, int maxIterations) minimizestatic MinimizeminimizeFactory(MolecularAssembly assembly, Potential potentialEnergy, AlgorithmListener listener, Minimize.MinimizationEngine engine) dynamicsFactory.booleanoptimizationUpdate(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.voidThis should be implemented as a blocking interrupt; when the method returns theTerminatablealgorithm has reached a clean termination point.toString()
-
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. -
energyList
The energy of each step in the minimization. -
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 <= 7is recommended.- See Also:
-
-
Constructor Details
-
Minimize
public Minimize(MolecularAssembly molecularAssembly, Potential potential, AlgorithmListener algorithmListener) Constructor for Minimize.- Parameters:
molecularAssembly- aMolecularAssemblyobject.potential- aPotentialobject.algorithmListener- aAlgorithmListenerobject.
-
Minimize
Constructor for Minimize.- Parameters:
molecularAssembly- aMolecularAssemblyobject.algorithmListener- aAlgorithmListenerobject.
-
-
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- aMolecularAssemblyobject.potentialEnergy- aPotentialobject.listener- aAlgorithmListenerobject.engine- aMDEngineobject.- Returns:
- a
MolecularDynamicsobject.
-
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
-
getEnergyList
Get the energy for each step in the minimization.- Returns:
- The energy for each step in the minimization.
-
minimize
minimize- Returns:
- a
Potentialobject.
-
minimize
minimize- Parameters:
eps- The convergence criteria.- Returns:
- a
Potentialobject.
-
minimize
minimize- Parameters:
eps- The convergence criteria.maxIterations- The maximum number of iterations.- Returns:
- a
Potentialobject.
-
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
Potentialobject.
-
toString
-
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:
optimizationUpdatein 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 theTerminatablealgorithm has reached a clean termination point. For example, between minimize or molecular dynamics steps.- Specified by:
terminatein interfaceTerminatable
-