Changeset 322d58 for src


Ignore:
Timestamp:
Apr 4, 2018, 4:59:48 PM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
AutomationFragmentation_failures, Candidate_v1.6.1, ChemicalSpaceEvaluator, Enhanced_StructuralOptimization, Enhanced_StructuralOptimization_continued, Exclude_Hydrogens_annealWithBondGraph, ForceAnnealing_with_BondGraph, ForceAnnealing_with_BondGraph_contraction-expansion, Gui_displays_atomic_force_velocity, JobMarket_RobustOnKillsSegFaults, JobMarket_StableWorkerPool, PythonUI_with_named_parameters, StoppableMakroAction, TremoloParser_IncreasedPrecision
Children:
bca6b6
Parents:
1e49e6
git-author:
Frederik Heber <heber@…> (04/06/17 05:09:37)
git-committer:
Frederik Heber <frederik.heber@…> (04/04/18 16:59:48)
Message:

ForceAnnealing now uses step width according to Barzilai-Borwein method.

  • this is not as good as what MPQC does but as long as Actions don't have an internal state, we cannot do anything better, e.g. a real line-search.
  • removed paramater delta from optimize-structure.
  • DOCU: Updated entry in user guide and noted Barzilai-Borwein method.
  • TESTS: removed deltat from force annealing regression tests.
  • TESTS: switched off StructureOptimization integration tests as poolworkers crash at the moment, making the tests hang indefinitely.
Location:
src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/MoleculeAction/ForceAnnealingAction.cpp

    r1e49e6 r322d58  
    9292  ForceAnnealing<std::vector<atom *> > optimizer(
    9393      set,
    94       params.Deltat.get(),
    9594      true,
    9695      params.steps.get());
  • src/Actions/MoleculeAction/ForceAnnealingAction.def

    r1e49e6 r322d58  
    1616// ValueStorage by the token "Z" -> first column: int, Z, "Z"
    1717// "undefine" if no parameters are required, use (NOPARAM_DEFAULT) for each (undefined) default value
    18 #define paramtypes (boost::filesystem::path)(double)(unsigned int)(bool)
    19 #define paramtokens ("forces-file")("deltat")("steps")("output-every-step")
    20 #define paramdescriptions ("file containing")("time step width")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang")
    21 #define paramdefaults (PARAM_DEFAULT(""))(PARAM_DEFAULT(0.1))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))
    22 #define paramreferences (forcesfile)(Deltat)(steps)(DoOutput)
     18#define paramtypes (boost::filesystem::path)(unsigned int)(bool)
     19#define paramtokens ("forces-file")("steps")("output-every-step")
     20#define paramdescriptions ("file containing")("fixed number of optimization steps to be performed")("whether WorldTime should be increased and output written after every step, useful if optimization might hang")
     21#define paramdefaults (PARAM_DEFAULT(""))(NOPARAM_DEFAULT)(PARAM_DEFAULT("0"))
     22#define paramreferences (forcesfile)(steps)(DoOutput)
    2323#define paramvalids \
    2424(DummyValidator< boost::filesystem::path >()) \
    25 (PositiveValidator< double >()) \
    2625(NotZeroValidator< unsigned int >()) \
    2726(DummyValidator<bool>())
  • src/Dynamics/ForceAnnealing.hpp

    r1e49e6 r322d58  
    3232 *
    3333 * Sadly, we have to use some static instances as so far values cannot be passed
    34  * between actions. Hence, we need to store the current step and the adaptive
     34 * between actions. Hence, we need to store the current step and the adaptive-
    3535 * step width (we cannot perform a linesearch, as we have no control over the
    3636 * calculation of the forces).
     
    4242  /** Constructor of class ForceAnnealing.
    4343   *
     44   * \note We use a fixed delta t of 1.
     45   *
    4446   * \param _atoms set of atoms to integrate
    4547   * \param _Deltat time step width in atomic units
     
    4951  ForceAnnealing(
    5052      AtomSetMixin<T> &_atoms,
    51       double _Deltat,
    5253      bool _IsAngstroem,
    5354      const size_t _maxSteps) :
    54     AtomicForceManipulator<T>(_atoms, _Deltat, _IsAngstroem),
     55    AtomicForceManipulator<T>(_atoms, 1., _IsAngstroem),
    5556    maxSteps(_maxSteps)
    5657  {}
     
    8990        iter != AtomicForceManipulator<T>::atoms.end(); ++iter) {
    9091      // atom's force vector gives steepest descent direction
     92      const Vector oldPosition = (*iter)->getPositionAtStep(NextStep-2 >= 0 ? NextStep - 2 : 0);
    9193      const Vector currentPosition = (*iter)->getPosition();
     94      const Vector oldGradient = (*iter)->getAtomicForceAtStep(NextStep-2 >= 0 ? NextStep - 2 : 0);
    9295      const Vector currentGradient = (*iter)->getAtomicForce();
    9396      LOG(4, "DEBUG: Force for atom " << **iter << " is " << currentGradient);
    9497
    95       // artificial update: deltat may be considered as 1/2 s^2 units, mass
    96       // is neglected deliberately as this makes all atoms equally fast or
    97       // hydrogens slower (and they need to wait for other atoms to arrive at
    98       // final position).
    99       Vector PositionUpdate = currentDeltat * currentGradient;
     98      // we use Barzilai-Borwein update with position reversed to get descent
     99      const Vector GradientDifference = (currentGradient - oldGradient);
     100      const double stepwidth =
     101          fabs((currentPosition - oldPosition).ScalarProduct(GradientDifference))/
     102          GradientDifference.NormSquared();
     103      Vector PositionUpdate = stepwidth * currentGradient;
     104      if (fabs(stepwidth) < 1e-10) {
     105        // dont' warn in first step, deltat usage normal
     106        if (currentStep != 1)
     107          ELOG(1, "INFO: Barzilai-Borwein stepwidth is zero, using deltat " << currentDeltat << " instead.");
     108        PositionUpdate = currentDeltat * currentGradient;
     109      }
    100110      LOG(3, "DEBUG: Update would be " << PositionUpdate);
    101111
Note: See TracChangeset for help on using the changeset viewer.