Exemplo n.º 1
0
/**
 *   Updates the system according to the probabilistic
 *   number of firings mK[i] of each reaction i
 */
bool CTauLeapMethod::updateSystem()
{
  // Save the current state in case we need to role back.
  CVector< C_FLOAT64 > OldState = mContainerState;

  CMathReaction * pReaction = mReactions.array();
  CMathReaction * pReactionEnd = pReaction + mNumReactions;
  const C_FLOAT64 * pK = mK.array();

  const C_FLOAT64 * pKEnd = pK + mNumReactions;

  for (; pReaction != pReactionEnd; ++pK, ++pReaction)
    {
      pReaction->fireMultiple(*pK);
    }

  const C_FLOAT64 * pSpecies = mContainerState.array() + mFirstReactionSpeciesIndex;

  const C_FLOAT64 * pSpeciesEnd = pSpecies + mNumReactionSpecies;

  for (; pSpecies != pSpeciesEnd; ++pSpecies)
    {
      if (*pSpecies < -0.5)
        {
          // We need to undo the changes
          mContainerState = OldState;
          return false;
        }
    }

  return true;
}