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).
File:
1 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);
Note: See TracChangeset for help on using the changeset viewer.