Open Qmin
0.8.0
GPU-accelerated Q-tensor-based liquid crystal simulations
|
Implement energy minimization via a laughable version of LBFGS. More...
#include <energyMinimizerLoLBFGS.h>
Public Member Functions | |
energyMinimizerLoLBFGS () | |
The basic constructor. More... | |
energyMinimizerLoLBFGS (shared_ptr< simpleModel > system) | |
The basic constructor that feeds in a target system to minimize. More... | |
virtual void | initializeParameters () |
Sets a bunch of default parameters that do not depend on the number of degrees of freedom. More... | |
virtual void | initializeFromModel () |
by default, set Ndof More... | |
void | minimize () |
Minimize to either the force tolerance or the maximum number of iterations. More... | |
virtual void | performUpdate () |
The "intergate equatios of motion just calls minimize. More... | |
void | setLoLBFGSParameters (int _m=5, scalar _dt=0.0001, scalar _c=1.00, scalar fc=1e-12, scalar _tau=10) |
scalar | getMaxForce () |
Return the maximum force. More... | |
void | setForceCutoff (scalar fc) |
Set the force cutoff. More... | |
virtual scalar | getClassSize () |
virtual void | integrateEquationOfMotion () |
virtual void | integrateEOMGPU () |
virtual void | integrateEOMCPU () |
virtual void | Update (int timestep) |
The fundamental function that a controlling Simulation can call. More... | |
void | setSimulation (shared_ptr< basicSimulation > _sim) |
set the simulation More... | |
virtual void | setModel (shared_ptr< simpleModel > _model) |
virtual function to allow the model to be a derived class More... | |
void | setPeriod (int _p) |
set the period More... | |
void | setPhase (int _p) |
set the phase More... | |
virtual void | spatialSorting () |
allow for spatial sorting to be called if necessary... More... | |
virtual void | setReproducible (bool rep) |
Allow for a reproducibility call to be made. More... | |
virtual void | setGPU (bool _useGPU=true) |
Enforce GPU operation. More... | |
int | getNdof () |
Get the number of degrees of freedom of the equation of motion. More... | |
void | setNdof (int _n) |
Set the number of degrees of freedom of the equation of motion. More... | |
virtual void | setDeltaT (scalar dt) |
allow all updaters to potentially implement an internal time scale More... | |
virtual void | setNThreads (int n) |
allow for setting multiple threads More... | |
void | setMaximumIterations (int maxIt) |
Set the maximum number of iterations before terminating (or set to -1 to ignore) More... | |
int | getCurrentIterations () |
int | getMaxIterations () |
void | setCurrentIterations (int newIterations) |
int | getNTotal () |
communicate the number of non-object sites across ranks More... | |
Public Attributes | |
bool | scheduledMomentum = false |
GPUArray< dVec > | displacement |
an array of displacements More... | |
shared_ptr< basicSimulation > | sim |
A pointer to the governing simulation. More... | |
shared_ptr< simpleModel > | model |
A pointer to a simpleModel that the updater acts on. More... | |
vector< scalar > | updaterData |
int | iterations |
The number of iterations performed. More... | |
Protected Member Functions | |
void | LoLBFGSStepCPU () |
void | LoLBFGSStepGPU () |
void | lineSearchCPU (GPUArray< dVec > &descentDirection) |
void | lineSearchGPU (GPUArray< dVec > &descentDirection) |
Protected Attributes | |
int | m =0 |
the number of past gradients, etc., to save More... | |
scalar | c |
a scalaing factor More... | |
scalar | forceMax |
the maximum value of the force More... | |
scalar | forceCutoff |
The cutoff value of the maximum force. More... | |
scalar | eta |
gain parameter More... | |
scalar | tau |
int | currentIterationInMLoop |
hmm... More... | |
GPUArray< scalar > | alpha |
vector of alpha values More... | |
GPUArray< scalar > | sDotY |
vector of s\cdot y terms More... | |
GPUArray< dVec > | unscaledStep |
the unscaled version of the step size More... | |
vector< GPUArray< dVec > > | gradientDifference |
vector of GPUArray of gradient differences More... | |
vector< GPUArray< dVec > > | secantEquation |
vector of GPUArray of steps in trajectory space More... | |
GPUArray< scalar > | sumReductionIntermediate |
Utility array for simple reductions. More... | |
GPUArray< scalar > | sumReductionIntermediate2 |
GPUArray< scalar > | reductions |
Utility array for simple (sum or dot product) reductions. More... | |
shared_ptr< kernelTuner > | dotProductTuner |
kernel tuner for performance More... | |
shared_ptr< kernelTuner > | minimizationTuner |
int | nThreads =1 |
number of threads to use More... | |
int | Period |
The period of the updater... the updater will work every Period timesteps. More... | |
int | Phase |
The phase of the updater... the updater will work every Period timesteps offset by a phase. More... | |
bool | useGPU |
whether the updater does its work on the GPU or not More... | |
bool | neverGPU |
whether the updater never does work on the GPU More... | |
int | Ndof |
some measure of the number of degrees of freedom the equations of motion might need to know about locally More... | |
int | nTotal |
the total number of non-object sites across all ranks More... | |
bool | reproducible |
whether the RNGs give reproducible results More... | |
scalar | deltaT |
The internal time step size. More... | |
int | maxIterations |
The maximum number of iterations allowed. More... | |
Implement energy minimization via a laughable version of LBFGS.
the "online" formalism of LBFGS ("A Stochastic Quasi-Newton Method for Online Convex Optimization", Nicol N. Schraudolph, Jin Yu, Simon Gunter, 2007) so that there is no line search, but without the "online" part related to stochastic gradient estimates
|
inline |
The basic constructor.
References initializeParameters().
energyMinimizerLoLBFGS::energyMinimizerLoLBFGS | ( | shared_ptr< simpleModel > | system | ) |
The basic constructor that feeds in a target system to minimize.
References initializeFromModel(), initializeParameters(), and updater::setModel().
|
virtual |
Sets a bunch of default parameters that do not depend on the number of degrees of freedom.
Initialize the minimizer with some default parameters. that do not depend on Ndof
References currentIterationInMLoop, forceMax, updater::iterations, reductions, GPUArray< T >::resize(), scheduledMomentum, setForceCutoff(), updater::setGPU(), setLoLBFGSParameters(), and updater::setMaximumIterations().
Referenced by energyMinimizerLoLBFGS().
|
virtual |
by default, set Ndof
Reimplemented from equationOfMotion.
References ArrayHandle< T >::data, gradientDifference, m, updater::model, updater::Ndof, GPUArray< T >::resize(), secantEquation, sumReductionIntermediate, sumReductionIntermediate2, and unscaledStep.
Referenced by energyMinimizerLoLBFGS(), minimize(), and setLoLBFGSParameters().
void energyMinimizerLoLBFGS::minimize | ( | ) |
Minimize to either the force tolerance or the maximum number of iterations.
References currentIterationInMLoop, updater::deltaT, eta, forceCutoff, forceMax, initializeFromModel(), updater::iterations, LoLBFGSStepCPU(), LoLBFGSStepGPU(), m, updater::maxIterations, updater::model, updater::Ndof, scheduledMomentum, tau, and updater::useGPU.
Referenced by performUpdate().
|
inlinevirtual |
The "intergate equatios of motion just calls minimize.
Reimplemented from equationOfMotion.
References minimize().
|
inline |
References alpha, c, updater::deltaT, eta, gradientDifference, initializeFromModel(), m, GPUArray< T >::resize(), sDotY, secantEquation, setForceCutoff(), and tau.
Referenced by initializeParameters().
|
inlinevirtual |
|
inline |
Set the force cutoff.
References forceCutoff.
Referenced by initializeParameters(), and setLoLBFGSParameters().
|
inlinevirtual |
Reimplemented from equationOfMotion.
References alpha, equationOfMotion::getClassSize(), GPUArray< T >::getNumElements(), gradientDifference, reductions, scalar, sDotY, secantEquation, sumReductionIntermediate, sumReductionIntermediate2, and unscaledStep.
|
protected |
References alpha, currentIterationInMLoop, ArrayHandle< T >::data, eta, forceMax, gradientDifference, access_location::host, host_dVec_dot_products(), host_dVec_plusEqual_dVec(), host_dVec_times_scalar(), updater::iterations, m, updater::model, updater::Ndof, access_mode::read, access_mode::readwrite, scalar, sDotY, secantEquation, updater::sim, and unscaledStep.
Referenced by minimize().
|
protected |
References alpha, currentIterationInMLoop, ArrayHandle< T >::data, access_location::device, eta, forceMax, gpu_copy_gpuarray(), gpu_dVec_plusEqual_dVec(), gpu_dVec_times_scalar(), gpu_gpuarray_dVec_dot_products(), gradientDifference, updater::iterations, m, updater::model, updater::Ndof, access_mode::read, access_mode::readwrite, scalar, sDotY, secantEquation, updater::sim, sumReductionIntermediate, sumReductionIntermediate2, and unscaledStep.
Referenced by minimize().
|
protected |
|
protected |
|
inlinevirtualinherited |
|
inlinevirtualinherited |
Reimplemented in velocityVerlet.
Referenced by equationOfMotion::integrateEquationOfMotion().
|
inlinevirtualinherited |
Reimplemented in velocityVerlet.
Referenced by equationOfMotion::integrateEquationOfMotion().
|
inlinevirtualinherited |
The fundamental function that a controlling Simulation can call.
References updater::performUpdate(), updater::Period, and updater::Phase.
|
inlineinherited |
set the simulation
References updater::sim.
|
inlinevirtualinherited |
virtual function to allow the model to be a derived class
References updater::initializeFromModel(), and updater::model.
Referenced by energyMinimizerFIRE::energyMinimizerFIRE(), energyMinimizerGradientDescent::energyMinimizerGradientDescent(), energyMinimizerLoLBFGS(), and energyMinimizerNesterovAG::energyMinimizerNesterovAG().
|
inlineinherited |
set the period
References updater::Period.
|
inlineinherited |
set the phase
References updater::Phase.
|
inlinevirtualinherited |
allow for spatial sorting to be called if necessary...
|
inlinevirtualinherited |
Allow for a reproducibility call to be made.
References updater::reproducible.
|
inlinevirtualinherited |
Enforce GPU operation.
References updater::useGPU.
Referenced by energyMinimizerNesterovAG::initializeParameters(), initializeParameters(), energyMinimizerGradientDescent::initializeParameters(), and energyMinimizerFIRE::initializeParameters().
|
inlineinherited |
Get the number of degrees of freedom of the equation of motion.
References updater::Ndof.
|
inlineinherited |
Set the number of degrees of freedom of the equation of motion.
References updater::Ndof.
|
inlinevirtualinherited |
allow all updaters to potentially implement an internal time scale
Reimplemented in energyMinimizerFIRE.
References updater::deltaT.
Referenced by energyMinimizerGradientDescent::initializeParameters(), and energyMinimizerGradientDescent::setGradientDescentParameters().
|
inlinevirtualinherited |
allow for setting multiple threads
References n, and updater::nThreads.
|
inlineinherited |
Set the maximum number of iterations before terminating (or set to -1 to ignore)
References updater::maxIterations.
Referenced by energyMinimizerNesterovAG::initializeParameters(), initializeParameters(), energyMinimizerGradientDescent::initializeParameters(), and energyMinimizerFIRE::initializeParameters().
|
inlineinherited |
References updater::iterations.
|
inlineinherited |
References updater::maxIterations.
|
inlineinherited |
References updater::iterations.
|
inherited |
communicate the number of non-object sites across ranks
References access_location::host, updater::model, updater::Ndof, updater::nTotal, access_mode::read, updater::sim, and updater::updaterData.
bool energyMinimizerLoLBFGS::scheduledMomentum = false |
Referenced by initializeParameters(), and minimize().
|
protected |
the number of past gradients, etc., to save
Referenced by initializeFromModel(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), minimize(), and setLoLBFGSParameters().
|
protected |
a scalaing factor
Referenced by lineSearchCPU(), and setLoLBFGSParameters().
|
protected |
the maximum value of the force
Referenced by getMaxForce(), initializeParameters(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and minimize().
|
protected |
The cutoff value of the maximum force.
Referenced by minimize(), and setForceCutoff().
|
protected |
gain parameter
Referenced by LoLBFGSStepCPU(), LoLBFGSStepGPU(), minimize(), and setLoLBFGSParameters().
|
protected |
Referenced by minimize(), and setLoLBFGSParameters().
|
protected |
hmm...
Referenced by initializeParameters(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and minimize().
vector of alpha values
Referenced by getClassSize(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and setLoLBFGSParameters().
vector of s\cdot y terms
Referenced by getClassSize(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and setLoLBFGSParameters().
|
protected |
the unscaled version of the step size
Referenced by getClassSize(), initializeFromModel(), LoLBFGSStepCPU(), and LoLBFGSStepGPU().
|
protected |
vector of GPUArray of gradient differences
Referenced by getClassSize(), initializeFromModel(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and setLoLBFGSParameters().
|
protected |
vector of GPUArray of steps in trajectory space
Referenced by getClassSize(), initializeFromModel(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), and setLoLBFGSParameters().
Utility array for simple reductions.
Referenced by getClassSize(), initializeFromModel(), and LoLBFGSStepGPU().
Referenced by getClassSize(), initializeFromModel(), and LoLBFGSStepGPU().
Utility array for simple (sum or dot product) reductions.
Referenced by getClassSize(), and initializeParameters().
|
protected |
kernel tuner for performance
|
protected |
|
inherited |
an array of displacements
Referenced by energyMinimizerAdam::adamStepCPU(), energyMinimizerAdam::adamStepGPU(), equationOfMotion::getClassSize(), energyMinimizerAdam::initializeFromModel(), equationOfMotion::initializeFromModel(), energyMinimizerGradientDescent::initializeFromModel(), energyMinimizerFIRE::initializeFromModel(), velocityVerlet::integrateEOMCPU(), and velocityVerlet::integrateEOMGPU().
|
inherited |
A pointer to the governing simulation.
Referenced by energyMinimizerAdam::adamStepCPU(), energyMinimizerAdam::adamStepGPU(), energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getNTotal(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), velocityVerlet::integrateEOMCPU(), velocityVerlet::integrateEOMGPU(), lineSearchCPU(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), energyMinimizerGradientDescent::minimize(), energyMinimizerFIRE::minimize(), energyMinimizerNesterovAG::nesterovStepCPU(), energyMinimizerNesterovAG::nesterovStepGPU(), updater::performUpdate(), and updater::setSimulation().
|
inherited |
A pointer to a simpleModel that the updater acts on.
Referenced by energyMinimizerAdam::adamStepCPU(), energyMinimizerAdam::adamStepGPU(), energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getNTotal(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), energyMinimizerAdam::initializeFromModel(), energyMinimizerNesterovAG::initializeFromModel(), initializeFromModel(), equationOfMotion::initializeFromModel(), energyMinimizerGradientDescent::initializeFromModel(), energyMinimizerFIRE::initializeFromModel(), updater::initializeFromModel(), velocityVerlet::integrateEOMCPU(), velocityVerlet::integrateEOMGPU(), equationOfMotion::integrateEquationOfMotion(), lineSearchCPU(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), minimize(), energyMinimizerGradientDescent::minimize(), energyMinimizerFIRE::minimize(), energyMinimizerNesterovAG::nesterovStepCPU(), energyMinimizerNesterovAG::nesterovStepGPU(), and updater::setModel().
|
inherited |
Referenced by energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getNTotal(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), energyMinimizerGradientDescent::initializeParameters(), and energyMinimizerFIRE::initializeParameters().
|
inherited |
The number of iterations performed.
Referenced by energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getCurrentIterations(), energyMinimizerAdam::initializeFromModel(), energyMinimizerNesterovAG::initializeParameters(), initializeParameters(), energyMinimizerGradientDescent::initializeParameters(), energyMinimizerFIRE::initializeParameters(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), minimize(), energyMinimizerGradientDescent::minimize(), energyMinimizerFIRE::minimize(), and updater::setCurrentIterations().
|
protectedinherited |
number of threads to use
Referenced by updater::setNThreads().
|
protectedinherited |
The period of the updater... the updater will work every Period timesteps.
Referenced by updater::setPeriod(), updater::Update(), and updater::updater().
|
protectedinherited |
The phase of the updater... the updater will work every Period timesteps offset by a phase.
Referenced by updater::setPhase(), updater::Update(), and updater::updater().
|
protectedinherited |
whether the updater does its work on the GPU or not
Referenced by energyMinimizerFIRE::fireStep(), energyMinimizerGradientDescent::gradientDescentStep(), equationOfMotion::integrateEquationOfMotion(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), minimize(), updater::setGPU(), and updater::updater().
|
protectedinherited |
whether the updater never does work on the GPU
Referenced by equationOfMotion::initializeFromModel(), energyMinimizerGradientDescent::initializeFromModel(), and energyMinimizerFIRE::initializeFromModel().
|
protectedinherited |
some measure of the number of degrees of freedom the equations of motion might need to know about locally
Referenced by energyMinimizerAdam::adamStepCPU(), energyMinimizerAdam::adamStepGPU(), energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getNdof(), updater::getNTotal(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), energyMinimizerAdam::initializeFromModel(), energyMinimizerNesterovAG::initializeFromModel(), initializeFromModel(), equationOfMotion::initializeFromModel(), energyMinimizerGradientDescent::initializeFromModel(), energyMinimizerFIRE::initializeFromModel(), updater::initializeFromModel(), energyMinimizerFIRE::initializeParameters(), velocityVerlet::integrateEOMCPU(), velocityVerlet::integrateEOMGPU(), equationOfMotion::integrateEquationOfMotion(), lineSearchCPU(), LoLBFGSStepCPU(), LoLBFGSStepGPU(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), minimize(), energyMinimizerGradientDescent::minimize(), energyMinimizerFIRE::minimize(), energyMinimizerNesterovAG::nesterovStepCPU(), energyMinimizerNesterovAG::nesterovStepGPU(), and updater::setNdof().
|
protectedinherited |
the total number of non-object sites across all ranks
Referenced by energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), updater::getNTotal(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), and energyMinimizerFIRE::initializeParameters().
|
protectedinherited |
whether the RNGs give reproducible results
Referenced by updater::setReproducible(), and updater::updater().
|
protectedinherited |
The internal time step size.
Referenced by energyMinimizerAdam::adamStepCPU(), energyMinimizerAdam::adamStepGPU(), energyMinimizerFIRE::fireStepCPU(), energyMinimizerFIRE::fireStepGPU(), energyMinimizerGradientDescent::gradientDescentCPU(), energyMinimizerGradientDescent::gradientDescentGPU(), velocityVerlet::integrateEOMCPU(), velocityVerlet::integrateEOMGPU(), minimize(), energyMinimizerFIRE::minimize(), energyMinimizerNesterovAG::nesterovStepCPU(), energyMinimizerNesterovAG::nesterovStepGPU(), energyMinimizerAdam::setAdamParameters(), energyMinimizerFIRE::setDeltaT(), updater::setDeltaT(), energyMinimizerFIRE::setFIREParameters(), energyMinimizerGradientDescent::setGradientDescentParameters(), setLoLBFGSParameters(), and energyMinimizerNesterovAG::setNesterovAGParameters().
|
protectedinherited |
The maximum number of iterations allowed.
Referenced by updater::getMaxIterations(), energyMinimizerAdam::minimize(), energyMinimizerNesterovAG::minimize(), minimize(), and updater::setMaximumIterations().