diff --git a/copasi/math/CMathDependencyGraph.cpp b/copasi/math/CMathDependencyGraph.cpp index fd5b241a1b..14eaf5def4 100644 --- a/copasi/math/CMathDependencyGraph.cpp +++ b/copasi/math/CMathDependencyGraph.cpp @@ -162,8 +162,24 @@ bool CMathDependencyGraph::getUpdateSequence(CCore::CUpdateSequence & updateSequ #endif // DEBUG_OUTPUT } - CObjectInterface::ObjectSet::const_iterator it = changedObjects.begin(); - CObjectInterface::ObjectSet::const_iterator end = changedObjects.end(); + CObjectInterface::ObjectSet::const_iterator it = requestedObjects.begin(); + CObjectInterface::ObjectSet::const_iterator end = requestedObjects.end(); + CObjectInterface::ObjectSet Prerequisites; + + for (; it != end && success; ++it) + (*it)->appendPrerequisites(Prerequisites); + + CObjectInterface::ObjectSet ChangedObjects(changedObjects); + + it = Prerequisites.begin(); + end = Prerequisites.end(); + + for (; it != end; ++it) + if ((*it)->getPrerequisites().empty()) + ChangedObjects.insert(*it); + + it = ChangedObjects.begin(); + end = ChangedObjects.end(); // Mark all nodes which are changed or need to be calculated for (; it != end && success; ++it) diff --git a/copasi/math/CMathEvent.cpp b/copasi/math/CMathEvent.cpp index 2f9afd8d26..3c86f0e797 100644 --- a/copasi/math/CMathEvent.cpp +++ b/copasi/math/CMathEvent.cpp @@ -1388,12 +1388,13 @@ void CMathEvent::createUpdateSequences() const CObjectInterface::ObjectSet & SimulationValues = mpContainer->getSimulationUpToDateObjects(); CObjectInterface::ObjectSet Requested; + Requested.insert(mpDelay); mpContainer->getTransientDependencies().getUpdateSequence(mDelaySequence, CCore::SimulationContext::Default, StateValues, Requested, SimulationValues); Requested.clear(); + CObjectInterface::ObjectSet EventTargets; - CObjectInterface::ObjectSet Changed(StateValues); CAssignment * pAssignment = mAssignments.array(); CAssignment * pAssignmentEnd = pAssignment + mAssignments.size(); @@ -1401,16 +1402,6 @@ void CMathEvent::createUpdateSequences() { Requested.insert(pAssignment->getAssignment()); - CObjectInterface::ObjectSet Prerequisites; - pAssignment->getAssignment()->appendPrerequisites(Prerequisites); - - CObjectInterface::ObjectSet::const_iterator it = Prerequisites.begin(); - CObjectInterface::ObjectSet::const_iterator end = Prerequisites.end(); - - for (; it != end; ++it) - if ((*it)->getPrerequisites().empty()) - Changed.insert(*it); - const CMathObject * pTarget = pAssignment->getTarget(); if (pTarget == NULL) continue; @@ -1433,7 +1424,7 @@ void CMathEvent::createUpdateSequences() } } - mpContainer->getTransientDependencies().getUpdateSequence(mTargetValuesSequence, CCore::SimulationContext::Default, Changed, Requested, SimulationValues); + mpContainer->getTransientDependencies().getUpdateSequence(mTargetValuesSequence, CCore::SimulationContext::Default, StateValues, Requested, SimulationValues); // We need to add the total mass of the moieties to the state values. CObjectInterface::ObjectSet ExtendedStateValues = StateValues;