Exemple #1
0
void CEFMAlgorithm::calculateFluxModes()
{
  bool Continue = true;

  if (mStoi.size())
    {
      /* initialize the current tableau matrix */
      pdelete(mpCurrentTableau);
      mpCurrentTableau = new CTableauMatrix(mStoi, mReversible);

      /* Do the iteration */
      mIndexSet.resize(mMaxStep);

      for (mStep = 0; mStep < mMaxStep; mStep++)
        mIndexSet[mStep] = mStep;

      while (findMinimalCombinationIndex() && Continue)
        {
          calculateNextTableau();
          mStepProcess++;

          if (mpCallBack)
            Continue &= mpCallBack->progressItem(mhSteps);

          static_cast<CCopasiTask *>(getObjectParent())->output(COutputInterface::DURING);
        }

      /* Build the elementary flux modes to be returned */
      if (Continue)
        buildFluxModes();

      /* Delete the current / final tableau matrix */
      pdelete(mpCurrentTableau);
    }

  if (mpCallBack)
    Continue &= mpCallBack->finishItem(mhSteps);
}
bool CBitPatternTreeMethod::calculate()
{
  bool Continue = true;

  if (!initialize())
    {
      if (mpCallBack)
        mpCallBack->finishItem(mhProgressCounter);

      return false;
    }

  while (mpStepMatrix->getNumUnconvertedRows() > 0 &&
         Continue)
    {
#ifdef COPASI_DEBUG
      DebugFile << "Step Matrix:" << std::endl;
      DebugFile << *mpStepMatrix << std::endl;
#endif // COPASI_DEBUG
      mStep = mpStepMatrix->getFirstUnconvertedRow();

      std::vector< CStepMatrixColumn * > PositiveColumns;
      std::vector< CStepMatrixColumn * > NegativeColumns;
      std::vector< CStepMatrixColumn * > NullColumns;

      if (mpStepMatrix->splitColumns(PositiveColumns,
                                     NegativeColumns,
                                     NullColumns))
        {
          // Process each step.
          // We need to update the bit pattern tree.
          pdelete(mpNullTree);
          mpNullTree = new CBitPatternTree(NullColumns);

          // Bit pattern tree containing the positive columns
          CBitPatternTree PositiveTree(PositiveColumns);

          // Convert the negative columns into a bit pattern tree
          CBitPatternTree NegativeTree(NegativeColumns);

          // Iterate over all combinations and add/remove columns to the step matrix
          mProgressCounter2 = 0;
          mProgressCounter2Max = PositiveTree.size() * NegativeTree.size();

          if (mpCallBack)
            mhProgressCounter2 =
              mpCallBack->addItem("Combinations",
                                  CCopasiParameter::UINT,
                                  & mProgressCounter2,
                                  & mProgressCounter2Max);

          combine(PositiveTree.getRoot(), NegativeTree.getRoot());

          if (mpCallBack)
            mpCallBack->finishItem(mhProgressCounter2);

          Continue &= mContinueCombination;

          if (Continue)
            {
              // We can now destroy all negative columns, which removes them from
              // the step matrix.
              mpStepMatrix->removeInvalidColumns(NegativeColumns);

              // Remove columns of the step matrix which are no longer extreme rays.
              findRemoveInvalidColumns(NullColumns);

              // We compact the step matrix which has empty columns due to the removal of columns above.
              mpStepMatrix->compact();

              // Now we can convert the processed row.
              mpStepMatrix->convertRow();
            }
        }

      mProgressCounter = mProgressCounterMax - mpStepMatrix->getNumUnconvertedRows();

      if (mpCallBack)
        Continue &= mpCallBack->progressItem(mhProgressCounter);
    }

  if (Continue)
    {
      buildFluxModes();
    }

  if (mpCallBack)
    Continue &= mpCallBack->finishItem(mhProgressCounter);

  return true;
}