示例#1
0
bool CEFMMethod::initialize()
{
  CEFMTask * pTask = dynamic_cast< CEFMTask * >(getObjectParent());

  if (pTask == NULL)
    {
      CCopasiMessage(CCopasiMessage::ERROR, MCEFMAnalysis + 1);
      return false;
    }

  CEFMProblem * pProblem = dynamic_cast< CEFMProblem *>(pTask->getProblem());

  if (pProblem == NULL)
    {
      CCopasiMessage(CCopasiMessage::ERROR, MCEFMAnalysis + 2);
      return false;
    }

  mpFluxModes = & pProblem->getFluxModes();
  mpReorderedReactions = & pProblem->getReorderedReactions();

  mpReorderedReactions->clear();
  mpFluxModes->clear();

  return true;
}
bool CBitPatternTreeMethod::initialize()
{
  if (!CEFMMethod::initialize())
    {
      return false;
    }

  pdelete(mpStepMatrix);
  mReactionForward.clear();

  mContinueCombination = true;

  CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent());

  if (pTask == NULL) return false;

  mpModel = pTask->getProblem()->getModel();

  if (mpModel == NULL) return false;

  // We first build the kernel matrix
  CMatrix< C_INT64 > KernelMatrix;
  buildKernelMatrix(KernelMatrix);
#ifdef COPASI_DEBUG
  DebugFile << "Original Kernel Matrix:" << std::endl;
  DebugFile << KernelMatrix << std::endl;
#endif // COPASI_DEBUG
  mMinimumSetSize = KernelMatrix.numCols() - 2;
#ifdef COPASI_DEBUG
  DebugFile << "MinSetSize = " << mMinimumSetSize << std::endl;
#endif // COPASI_DEBUG

  // Now we create the initial step matrix
  mpStepMatrix = new CStepMatrix(KernelMatrix);

  mProgressCounter = 0;
  mProgressCounterMax = mpStepMatrix->getNumUnconvertedRows();

  if (mpCallBack)
    mhProgressCounter =
      mpCallBack->addItem("Current Step",
                          CCopasiParameter::UINT,
                          & mProgressCounter,
                          & mProgressCounterMax);

  return true;
}
示例#3
0
bool CEFMAlgorithm::initialize()
{
  if (!CEFMMethod::initialize())
    {
      return false;
    }

  CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent());

  if (pTask == NULL) return false;

  mpModel = pTask->getProblem()->getModel();

  if (mpModel == NULL) return false;

  mpFluxModes->clear();

  /* ModelStoi is the transpose of the models stoichiometry matrix */
  const CTransposeView< CMatrix< C_FLOAT64 > > ModelStoi(mpModel->getStoi());

  size_t row, numRows = ModelStoi.numRows();
  size_t col, numCols = ModelStoi.numCols();

  /* Size the stoichiometry matrix passed to the algorithm */
  mStoi.resize(numRows);
  std::vector< std::vector< C_FLOAT64 > >::iterator it = mStoi.begin();
  std::vector< std::vector< C_FLOAT64 > >::iterator end = mStoi.end();

  for (; it != end; ++it)
    it->resize(numCols);

  /* Get the reactions from the model */
  /* Note: We have as many reactions as we have rows in ModelStoi */
  const CCopasiVectorNS < CReaction > & Reaction = mpModel->getReactions();

  /* Vector to keep track of the rearrangements necessary to put the */
  /* reversible reactions to the top of stoichiometry matrix */
  mpReorderedReactions->resize(numRows);

  /* Reversible reaction counter */
  mReversible = 0;
  size_t Insert;
  size_t InsertReversible = 0;
  size_t InsertIrreversible = numRows - 1;

  /* Build the transpose of the stoichiometry matrix, */

  /* sort reversible reactions to the top, count them */

  /* and keep track of the rearrangement */
  for (row = 0; row < numRows; row++)
    {
      if (Reaction[row]->isReversible())
        {
          Insert = InsertReversible++;
          mReversible++;
        }
      else
        Insert = InsertIrreversible--;

      (*mpReorderedReactions)[Insert] = Reaction[row];

      for (col = 0; col < numCols; col++)
        mStoi[Insert][col] = ModelStoi(row, col);
    }

  mStep = 0;
  mStepProcess = 0;
  mMaxStep = (unsigned C_INT32) numCols;

  if (mpCallBack)
    mhSteps =
      mpCallBack->addItem("Current Step",
                          mStepProcess,
                          & mMaxStep);

  return true;
}