Changeset 10b1ef


Ignore:
Timestamp:
Nov 7, 2017, 7:34:56 AM (7 years ago)
Author:
Frederik Heber <frederik.heber@…>
Branches:
ForceAnnealing_with_BondGraph_continued_betteresults
Children:
03d40df
Parents:
38ac25
git-author:
Frederik Heber <frederik.heber@…> (11/04/17 10:00:15)
git-committer:
Frederik Heber <frederik.heber@…> (11/07/17 07:34:56)
Message:

ForceAnnealingAction's Undo removes trajectory item if it was added.

  • before Undo would not truly undo the change to the trajectory. Now, we additionally store the trajectory size and may recogniye thereby whether we added a step or not. Note that stepping the world time does not add to the trajectory, as it uses the last present map element closest to the current time step.
  • TESTFIX: XFAIL removed from Undo as it is now working. Extended Undo test to cover both cases (ForceAnnealing added new step and did not add new step).
Files:
2 added
4 edited

Legend:

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

    r38ac25 r10b1ef  
    9090          iter != World::getInstance().endAtomSelection();
    9191          ++iter)
    92         UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i));
     92          UndoInfo[i].push_back(AtomicInfo(*(iter->second), CurrentStep-i));
    9393    }
    9494  }
     95  std::vector<int> UndoTrajectorySize;
     96  UndoTrajectorySize.reserve(set.size());
     97  for (World::AtomSelectionConstIterator iter = World::getInstance().beginAtomSelection();
     98      iter != World::getInstance().endAtomSelection();
     99      ++iter)
     100    UndoTrajectorySize.push_back(iter->second->getTrajectorySize());
    95101
    96102  // instantiate optimizer
     
    129135
    130136  MoleculeForceAnnealingState *UndoState =
    131     new MoleculeForceAnnealingState(UndoInfo, RedoInfo, params);
     137    new MoleculeForceAnnealingState(UndoInfo, UndoTrajectorySize, RedoInfo, params);
    132138
    133139  return ActionState::ptr(UndoState);
     
    139145  const size_t CurrentStep = WorldTime::getInstance().getTime();
    140146
    141   // set stored old state
    142   for (int i=0;i<2;++i)
    143     SetAtomsFromAtomicInfo(state->UndoInfo[i], CurrentStep-i);
     147  // set stored old state and remove current one from trajectory if we set it
     148  for (int i=0;i<2;++i) {
     149    for(size_t j=0;j<state->UndoInfo[i].size();++j) {
     150      const AtomicInfo &_atominfo = state->UndoInfo[i][j];
     151      const atomId_t id = _atominfo.getId();
     152      atom * const _atom = World::getInstance().getAtom(AtomById(id));
     153      ASSERT( _atom != NULL,
     154          "MoleCuilder::SetAtomsFromAtomicInfo() - cannot find atom with id "
     155          +toString(id)+" in the world.");
     156      if (state->UndoTrajectorySize[j] > CurrentStep-i)
     157        _atominfo.setAtom( *_atom, CurrentStep-i );
     158      else
     159        _atom->removeSteps(state->UndoTrajectorySize[j], CurrentStep-i);
     160    }
     161  }
    144162
    145163  return ActionState::ptr(_state);
  • src/Actions/MoleculeAction/ForceAnnealingAction.def

    r38ac25 r10b1ef  
    3232(DummyValidator<bool>())
    3333
    34 #define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector< std::vector<AtomicInfo> >)
    35 #define statereferences (UndoInfo)(RedoInfo)
     34#define statetypes (std::vector< std::vector<AtomicInfo> >)(std::vector<int>)(std::vector< std::vector<AtomicInfo> >)
     35#define statereferences (UndoInfo)(UndoTrajectorySize)(RedoInfo)
    3636
    3737// some defines for all the names, you may use ACTION, STATE and PARAMS
  • tests/regression/Molecules/ForceAnnealing/post/test-undo.conf

    r38ac25 r10b1ef  
    8282Ion_Type2_2     8.532785963     4.158586027     3.535886037     0       1.000000e-01    0.000000e+00    0.000000e+00     # molecule nr 9
    8383Ion_Type2_3     7.283585982     3.275186040     3.535886037     0       1.000000e-01    0.000000e+00    0.000000e+00     # molecule nr 10
    84 
    85 Ion_Type1_1     9.782085945     2.645886050     2.645886050     0 # molecule nr 0
    86 Ion_Type1_2     9.782085945     2.645886050     4.425886024     0 # molecule nr 1
    87 Ion_Type1_3     10.672039608    3.904536878     3.535886037     0 # molecule nr 2
    88 Ion_Type1_4     8.532785963     4.787886018     2.645886050     0 # molecule nr 3
    89 Ion_Type1_5     8.532785963     4.787886018     4.425886024     0 # molecule nr 4
    90 Ion_Type1_6     6.393632318     3.904536877     3.535886037     0 # molecule nr 5
    91 Ion_Type1_7     7.283585982     2.645886050     2.645886050     0 # molecule nr 6
    92 Ion_Type1_8     7.283585982     2.645886050     4.425886024     0 # molecule nr 7
    93 Ion_Type2_1     9.782085945     3.275186040     3.535886037     0 # molecule nr 8
    94 Ion_Type2_2     8.532785963     4.158586027     3.535886037     0 # molecule nr 9
    95 Ion_Type2_3     7.283585982     3.275186040     3.535886037     0 # molecule nr 10
  • tests/regression/Molecules/ForceAnnealing/testsuite-molecules-force-annealing.at

    r38ac25 r10b1ef  
    3131
    3232
    33 AT_SETUP([Molecules - Force Annealing with Undo])
     33# here, we have only one step in the trajectories
     34AT_SETUP([Molecules - Force Annealing with Undo I])
    3435AT_KEYWORDS([molecules force-annealing undo])
    3536
     
    4041AT_CHECK([../../molecuilder -i $file --select-all-atoms --step-world-time 1 --force-annealing --forces-file test.forces --steps 1 --undo], 0, [stdout], [stderr])
    4142AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/post/test-undo.conf], 0, [ignore], [ignore])
     43
     44AT_CLEANUP
     45
     46
     47# here two steps are present already
     48AT_SETUP([Molecules - Force Annealing with Undo II])
     49AT_KEYWORDS([molecules force-annealing undo])
     50
     51file=test2.conf
     52AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test2.conf $file], 0)
     53AT_CHECK([/bin/cp -f ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/pre/test.forces .], 0)
     54AT_CHECK([chmod u+w $file], 0)
     55AT_CHECK([../../molecuilder -i $file --select-all-atoms --set-world-time 1 --force-annealing --forces-file test.forces --steps 1 --undo], 0, [stdout], [stderr])
     56AT_CHECK([diff $file ${abs_top_srcdir}/tests/regression/Molecules/ForceAnnealing/post/test-undo2.conf], 0, [ignore], [ignore])
    4257
    4358AT_CLEANUP
Note: See TracChangeset for help on using the changeset viewer.