COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
CSSAMethod Class Reference

#include <CSSAMethod.h>

Inheritance diagram for CSSAMethod:
Inheritance graph
[legend]
Collaboration diagram for CSSAMethod:
Collaboration graph
[legend]

Public Member Functions

bool calculate ()
 
 CSSAMethod (const CSSAMethod &src, const CCopasiContainer *pParent=NULL)
 
 CSSAMethod (const CCopasiContainer *pParent=NULL)
 
bool initialize ()
 
TriLogic isMixingStable (int indexEC)
 
bool isReactionReversed (int index) const
 
bool process (CProcessReport *handler)
 
- Public Member Functions inherited from CEFMAlgorithm
void calculateFluxModes ()
 
 CEFMAlgorithm (const CEFMAlgorithm &src, const CCopasiContainer *pParent=NULL)
 
 ~CEFMAlgorithm ()
 
- Public Member Functions inherited from CEFMMethod
 CEFMMethod (const CEFMMethod &src, const CCopasiContainer *pParent=NULL)
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
virtual ~CEFMMethod ()
 
- Public Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiMethod &src, const CCopasiContainer *pParent=NULL)
 
const CCopasiMethod::SubTypegetSubType () const
 
const CCopasiTask::TypegetType () const
 
virtual void load (CReadConfig &configBuffer, CReadConfig::Mode mode=CReadConfig::SEARCH)
 
virtual void print (std::ostream *ostream) const
 
virtual void printResult (std::ostream *ostream) const
 
virtual bool setCallBack (CProcessReport *pCallBack)
 
virtual ~CCopasiMethod ()
 
- Public Member Functions inherited from CCopasiParameterGroup
bool addGroup (const std::string &name)
 
bool addParameter (const CCopasiParameter &parameter)
 
bool addParameter (const std::string &name, const CCopasiParameter::Type type)
 
template<class CType >
bool addParameter (const std::string &name, const CCopasiParameter::Type type, const CType &value)
 
void addParameter (CCopasiParameter *pParameter)
 
CCopasiParameterGroupassertGroup (const std::string &name)
 
template<class CType >
CCopasiParameterassertParameter (const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
 
index_iterator beginIndex () const
 
name_iterator beginName () const
 
 CCopasiParameterGroup (const CCopasiParameterGroup &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameterGroup (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &objectType="ParameterGroup")
 
void clear ()
 
virtual bool elevateChildren ()
 
index_iterator endIndex () const
 
name_iterator endName () const
 
CCopasiParameterGroupgetGroup (const std::string &name)
 
const CCopasiParameterGroupgetGroup (const std::string &name) const
 
CCopasiParameterGroupgetGroup (const size_t &index)
 
const CCopasiParameterGroupgetGroup (const size_t &index) const
 
size_t getIndex (const std::string &name) const
 
std::string getKey (const std::string &name) const
 
std::string getKey (const size_t &index) const
 
virtual const std::string & getName (const size_t &index) const
 
virtual const CObjectInterfacegetObject (const CCopasiObjectName &cn) const
 
CCopasiParametergetParameter (const std::string &name)
 
const CCopasiParametergetParameter (const std::string &name) const
 
CCopasiParametergetParameter (const size_t &index)
 
const CCopasiParametergetParameter (const size_t &index) const
 
CCopasiParameter::Type getType (const std::string &name) const
 
CCopasiParameter::Type getType (const size_t &index) const
 
std::string getUniqueParameterName (const CCopasiParameter *pParameter) const
 
const CCopasiParameter::ValuegetValue (const std::string &name) const
 
const CCopasiParameter::ValuegetValue (const size_t &index) const
 
CCopasiParameter::ValuegetValue (const std::string &name)
 
CCopasiParameter::ValuegetValue (const size_t &index)
 
CCopasiParameterGroupoperator= (const CCopasiParameterGroup &rhs)
 
bool removeParameter (const std::string &name)
 
bool removeParameter (const size_t &index)
 
template<class CType >
bool setValue (const std::string &name, const CType &value)
 
template<class CType >
bool setValue (const size_t &index, const CType &value)
 
size_t size () const
 
bool swap (const size_t &iFrom, const size_t &iTo)
 
bool swap (index_iterator &from, index_iterator &to)
 
virtual ~CCopasiParameterGroup ()
 
- Public Member Functions inherited from CCopasiParameter
 CCopasiParameter (const CCopasiParameter &src, const CCopasiContainer *pParent=NULL)
 
 CCopasiParameter (const std::string &name, const Type &type, const void *pValue=NULL, const CCopasiContainer *pParent=NULL, const std::string &objectType="Parameter")
 
virtual CCopasiObjectName getCN () const
 
virtual const std::string & getKey () const
 
virtual std::string getObjectDisplayName (bool regular=true, bool richtext=false) const
 
const CCopasiParameter::TypegetType () const
 
const ValuegetValue () const
 
ValuegetValue ()
 
virtual voidgetValuePointer () const
 
CCopasiObjectgetValueReference () const
 
bool isValidValue (const C_FLOAT64 &value) const
 
bool isValidValue (const C_INT32 &value) const
 
bool isValidValue (const unsigned C_INT32 &value) const
 
bool isValidValue (const bool &value) const
 
bool isValidValue (const std::string &value) const
 
bool isValidValue (const CCopasiObjectName &value) const
 
bool isValidValue (const std::vector< CCopasiParameter * > &value) const
 
CCopasiParameteroperator= (const CCopasiParameter &rhs)
 
template<class CType >
bool setValue (const CType &value)
 
bool setValue (const std::vector< CCopasiParameter * > &value)
 
virtual ~CCopasiParameter ()
 
- Public Member Functions inherited from CCopasiContainer
virtual bool add (CCopasiObject *pObject, const bool &adopt=true)
 
 CCopasiContainer (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=CCopasiObject::Container)
 
 CCopasiContainer (const CCopasiContainer &src, const CCopasiContainer *pParent=NULL)
 
virtual std::string getChildObjectUnits (const CCopasiObject *pObject) const
 
virtual const objectMapgetObjects () const
 
virtual std::string getUnits () const
 
virtual const CCopasiObjectgetValueObject () const
 
virtual bool remove (CCopasiObject *pObject)
 
virtual ~CCopasiContainer ()
 
- Public Member Functions inherited from CCopasiObject
void addDirectDependency (const CCopasiObject *pObject)
 
 CCopasiObject (const CCopasiObject &src, const CCopasiContainer *pParent=NULL)
 
void clearDirectDependencies ()
 
void clearRefresh ()
 
bool dependsOn (DataObjectSet candidates, const DataObjectSet &context=DataObjectSet()) const
 
void getAllDependencies (DataObjectSet &dependencies, const DataObjectSet &context) const
 
virtual const DataObjectSetgetDirectDependencies (const DataObjectSet &context=DataObjectSet()) const
 
CCopasiContainergetObjectAncestor (const std::string &type) const
 
CCopasiDataModelgetObjectDataModel ()
 
const CCopasiDataModelgetObjectDataModel () const
 
const std::string & getObjectName () const
 
CCopasiContainergetObjectParent () const
 
const std::string & getObjectType () const
 
virtual const
CObjectInterface::ObjectSet
getPrerequisites () const
 
virtual RefreshgetRefresh () const
 
UpdateMethodgetUpdateMethod () const
 
bool hasCircularDependencies (DataObjectSet &candidates, DataObjectSet &verified, const DataObjectSet &context) const
 
bool hasUpdateMethod () const
 
bool isArray () const
 
bool isContainer () const
 
bool isDataModel () const
 
bool isMatrix () const
 
bool isNameVector () const
 
bool isNonUniqueName () const
 
virtual bool isPrerequisiteForContext (const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
 
bool isReference () const
 
bool isRoot () const
 
bool isSeparator () const
 
bool isStaticString () const
 
bool isValueBool () const
 
bool isValueDbl () const
 
bool isValueInt () const
 
bool isValueInt64 () const
 
bool isValueString () const
 
bool isVector () const
 
virtual bool mustBeDeleted (const DataObjectSet &deletedObjects) const
 
void removeDirectDependency (const CCopasiObject *pObject)
 
void setDirectDependencies (const DataObjectSet &directDependencies)
 
bool setObjectName (const std::string &name)
 
virtual bool setObjectParent (const CCopasiContainer *pParent)
 
void setObjectValue (const C_FLOAT64 &value)
 
void setObjectValue (const C_INT32 &value)
 
void setObjectValue (const bool &value)
 
template<class CType >
void setRefresh (CType *pType, void(CType::*method)(void))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_FLOAT64 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const C_INT32 &))
 
template<class CType >
void setUpdateMethod (CType *pType, void(CType::*method)(const bool &))
 
virtual ~CCopasiObject ()
 
- Public Member Functions inherited from CObjectInterface
 CObjectInterface ()
 
virtual ~CObjectInterface ()
 

Protected Member Functions

bool buildExtremeCurrents ()
 
bool buildJacobian ()
 
bool buildKineticMatrix ()
 
bool buildStoichiometry ()
 
bool decomposeJacobian ()
 
template<class CType >
CMatrix< CType > diag (CVector< CType > vector)
 
bool testForMixingStability ()
 
- Protected Member Functions inherited from CEFMAlgorithm
 CEFMAlgorithm (const CCopasiContainer *pParent=NULL)
 
 CEFMAlgorithm (const CCopasiMethod::SubType subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CEFMMethod
 CEFMMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CCopasiMethod
 CCopasiMethod (const CCopasiTask::Type &taskType, const SubType &subType, const CCopasiContainer *pParent=NULL)
 
- Protected Member Functions inherited from CCopasiParameterGroup
 CCopasiParameterGroup ()
 
- Protected Member Functions inherited from CCopasiContainer
template<class CType >
CCopasiObjectaddMatrixReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddObjectReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
template<class CType >
CCopasiObjectaddVectorReference (const std::string &name, CType &reference, const unsigned C_INT32 &flag=0)
 
void initObjects ()
 
- Protected Member Functions inherited from CCopasiObject
 CCopasiObject ()
 
 CCopasiObject (const std::string &name, const CCopasiContainer *pParent=NULL, const std::string &type="CN", const unsigned C_INT32 &flag=0)
 

Protected Attributes

std::vector< CVector< C_FLOAT64 > > mExtremeCurrents
 
std::vector< bool > mIsBackwardReaction
 
std::vector< TriLogicmIsMixingStable
 
C_INT32 mNumReactions
 
CCopasiVectorNS< CReactionmReactions
 
CMatrix< C_FLOAT64mStoichiometry
 
std::vector< std::vector
< C_FLOAT64 > > 
mStoiRows
 
std::vector< CMatrix< C_FLOAT64 > > mTransformedSubJacobians
 
CMatrix< C_FLOAT64mTransposedKineticMatrix
 
- Protected Attributes inherited from CEFMAlgorithm
size_t mhSteps
 
std::vector< size_t > mIndexSet
 
unsigned C_INT32 mMaxStep
 
CTableauMatrixmpCurrentTableau
 
CModelmpModel
 
CTableauMatrixmpNextTableau
 
size_t mReversible
 
unsigned C_INT32 mStep
 
unsigned C_INT32 mStepProcess
 
std::vector< std::vector
< C_FLOAT64 > > 
mStoi
 
- Protected Attributes inherited from CEFMMethod
std::vector< CFluxMode > * mpFluxModes
 
std::vector< const CReaction * > * mpReorderedReactions
 
- Protected Attributes inherited from CCopasiMethod
CProcessReportmpCallBack
 
- Protected Attributes inherited from CCopasiParameter
std::string mKey
 
CCopasiObjectmpValueReference
 
size_t mSize
 
Value mValue
 
- Protected Attributes inherited from CCopasiContainer
objectMap mObjects
 

Friends

CEFMMethodCEFMMethod::createMethod (CCopasiMethod::SubType subType)
 

Additional Inherited Members

- Public Types inherited from CCopasiMethod
enum  SubType {
  unset = 0, RandomSearch, RandomSearchMaster, SimulatedAnnealing,
  CoranaWalk, DifferentialEvolution, ScatterSearch, GeneticAlgorithm,
  EvolutionaryProgram, SteepestDescent, HybridGASA, GeneticAlgorithmSR,
  HookeJeeves, LevenbergMarquardt, NelderMead, SRES,
  Statistics, ParticleSwarm, Praxis, TruncatedNewton,
  Newton, deterministic, LSODAR, directMethod,
  stochastic, tauLeap, adaptiveSA, hybrid,
  hybridLSODA, hybridODE45, DsaLsodar, tssILDM,
  tssILDMModified, tssCSP, mcaMethodReder, scanMethod,
  lyapWolf, sensMethod, EFMAlgorithm, EFMBitPatternTreeAlgorithm,
  EFMBitPatternAlgorithm, Householder, crossSectionMethod, linearNoiseApproximation
}
 
- Public Types inherited from CCopasiParameterGroup
typedef parameterGroup::iterator index_iterator
 
typedef
CCopasiContainer::objectMap::iterator 
name_iterator
 
typedef std::vector
< CCopasiParameter * > 
parameterGroup
 
- Public Types inherited from CCopasiParameter
enum  Type {
  DOUBLE = 0, UDOUBLE, INT, UINT,
  BOOL, GROUP, STRING, CN,
  KEY, FILE, EXPRESSION, INVALID
}
 
- Public Types inherited from CCopasiContainer
typedef std::multimap
< std::string, CCopasiObject * > 
objectMap
 
- Public Types inherited from CCopasiObject
typedef std::set< const
CCopasiObject * > 
DataObjectSet
 
typedef std::vector< Refresh * > DataUpdateSequence
 
- Public Types inherited from CObjectInterface
typedef std::set< const
CObjectInterface * > 
ObjectSet
 
typedef std::vector
< CObjectInterface * > 
UpdateSequence
 
- Static Public Member Functions inherited from CEFMMethod
static CEFMMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::EFMAlgorithm)
 
- Static Public Member Functions inherited from CCopasiObject
static std::vector< Refresh * > buildUpdateSequence (const DataObjectSet &objects, const DataObjectSet &uptoDateObjects, const DataObjectSet &context=DataObjectSet())
 
static void setRenameHandler (CRenameHandler *rh)
 
- Static Public Attributes inherited from CCopasiMethod
static const std::string SubTypeName []
 
static const char * XMLSubType []
 
- Static Public Attributes inherited from CCopasiParameter
static const std::string TypeName []
 
static const char * XMLType []
 
- Static Public Attributes inherited from CCopasiContainer
static const std::vector
< CCopasiContainer * > 
EmptyList
 
- Protected Types inherited from CCopasiObject
enum  Flag {
  Container = 0x1, Vector = 0x2, Matrix = 0x4, NameVector = 0x8,
  Reference = 0x10, ValueBool = 0x20, ValueInt = 0x40, ValueInt64 = 0x80,
  ValueDbl = 0x100, NonUniqueName = 0x200, StaticString = 0x400, ValueString = 0x800,
  Separator = 0x1000, ModelEntity = 0x2000, Array = 0x4000, DataModel = 0x8000,
  Root = 0x10000, Gui = 0x20000
}
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 28 of file CSSAMethod.h.

Constructor & Destructor Documentation

CSSAMethod::CSSAMethod ( const CSSAMethod src,
const CCopasiContainer pParent = NULL 
)

CSSAMethod class. Methods to conduct Stoichiometric Stability Analysis.- Copy constructor.

Parameters
const CSSAMethod &src

Definition at line 35 of file CSSAMethod.cpp.

36  :
37  CEFMAlgorithm(src, pParent)
38 {}
CEFMAlgorithm(const CCopasiContainer *pParent=NULL)
CSSAMethod::CSSAMethod ( const CCopasiContainer pParent = NULL)

Definition at line 40 of file CSSAMethod.cpp.

40  :
41  CEFMAlgorithm(CCopasiMethod::stoichiometricStabilityAnalysis, pParent)
42 {}
CEFMAlgorithm(const CCopasiContainer *pParent=NULL)

Member Function Documentation

bool CSSAMethod::buildExtremeCurrents ( )
protected

Definition at line 418 of file CSSAMethod.cpp.

References CVectorCore< CType >::array(), C_FLOAT64, C_INT32, CEFMAlgorithm::calculateFluxModes(), mExtremeCurrents, mNumReactions, CVector< CType >::resize(), and CVectorCore< CType >::size().

Referenced by calculate().

419 {
420  mExtremeCurrents.clear();
421 
423 
424  std::vector< CFluxMode > fluxmodes = getFluxModes();
425 
426  CVector< C_FLOAT64 > extremecurrent;
427  extremecurrent.resize(mNumReactions);
428 
429  std::vector< CFluxMode >::iterator iter;
430 
431  for (iter = fluxmodes.begin(); iter != fluxmodes.end(); ++iter)
432  {
433  memset(extremecurrent.array(), 0, extremecurrent.size()*sizeof(C_FLOAT64));
434  unsigned C_INT32 i;
435 
436  for (i = 0; i < iter->size(); ++i)
437  {
438  extremecurrent[iter->getReactionIndex(i)] = iter->getMultiplier(i);
439  }
440  }
441 
442  return true;
443 }
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
#define C_INT32
Definition: copasi.h:90
std::vector< CVector< C_FLOAT64 > > mExtremeCurrents
Definition: CSSAMethod.h:74
void calculateFluxModes()
size_t size() const
Definition: CVector.h:100
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
C_INT32 mNumReactions
Definition: CSSAMethod.h:65
bool CSSAMethod::buildJacobian ( )
protected
bool CSSAMethod::buildKineticMatrix ( )
protected

Definition at line 379 of file CSSAMethod.cpp.

References CMatrix< CType >::array(), CCopasiVector< T >::begin(), C_FLOAT64, C_INT64, CCopasiVector< T >::end(), CModel::getMetabolitesX(), CModel::getNumIndependentReactionMetabs(), mIsBackwardReaction, mNumReactions, CEFMAlgorithm::mpModel, mTransposedKineticMatrix, CMatrix< CType >::resize(), and CCopasiVector< T >::size().

Referenced by calculate().

380 {
381  if (!mpModel) return false;
382 
384 
385  C_FLOAT64 num_reactions = mNumReactions;
386 
387  mTransposedKineticMatrix.resize((C_INT64)num_reactions, (C_INT64)num_metabolites);
388  memset(mTransposedKineticMatrix.array(), 0, (int)(num_metabolites * num_reactions * sizeof(C_FLOAT64)));
389 
391 
392  for (int ireac = 0; ireac < mIsBackwardReaction.size(); ++ireac)
393  {
395 
396  if (mIsBackwardReaction[ireac])
397  substrates = mReorderedReactions[ireac]->getChemEq().getProducts();
398  else
399  substrates = mReorderedReactions[ireac]->getChemEq().getSubstrates();
400 
401  for (int jsubst = 0; jsubst < substrates.size(); ++jsubst)
402  {
403  CCopasiVector< CMetab >::iterator found = find(metabOrder.begin(),
404  metabOrder.end(),
405  substrates[jsubst]->getMetabolite());
406 
407  if ((*found)->isDependent()) continue;
408 
409  int kmetab = std::distance(metabOrder.begin(), found);
410  mTransposedKineticMatrix[ireac][kmetab] = substrates[jsubst]->getMultiplicity();
411  }
412  }
413 
414  return true;
415 }
std::vector< bool > mIsBackwardReaction
Definition: CSSAMethod.h:62
virtual size_t size() const
iterator begin()
#define C_INT64
Definition: copasi.h:88
CMatrix< C_FLOAT64 > mTransposedKineticMatrix
Definition: CSSAMethod.h:70
iterator end()
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
size_t getNumIndependentReactionMetabs() const
Definition: CModel.cpp:1130
CModel * mpModel
#define C_FLOAT64
Definition: copasi.h:92
C_INT32 mNumReactions
Definition: CSSAMethod.h:65
const CCopasiVector< CMetab > & getMetabolitesX() const
Definition: CModel.cpp:1057
virtual CType * array()
Definition: CMatrix.h:337
bool CSSAMethod::buildStoichiometry ( )
protected

Definition at line 358 of file CSSAMethod.cpp.

References CMatrix< CType >::array(), C_FLOAT64, CEFMAlgorithm::mpModel, CEFMAlgorithm::mStoi, mStoichiometry, and CMatrix< CType >::resize().

Referenced by calculate().

359 {
360  if (!mpModel) return false;
361 
362  //rebuild the stoichiometric matrix with reversible reactions divided into two.
363 
364  // build the _transposed_ of stoichiometry, with expanded reversible reactions
365  int numRows = mStoi[0].size();
366  int numCols = mStoi.size();
367 
368  mStoichiometry.resize(numRows, numCols);
369  memset(mStoichiometry.array(), 0, numRows * numCols * sizeof(C_FLOAT64));
370 
371  for (int i = 0; i < numRows; ++i)
372  for (int j = 0; j < numCols; ++j)
373  mStoichiometry(i, j) = mStoi[j][i];
374 
375  return true;
376 }
std::vector< std::vector< C_FLOAT64 > > mStoi
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
CModel * mpModel
#define C_FLOAT64
Definition: copasi.h:92
CMatrix< C_FLOAT64 > mStoichiometry
Definition: CSSAMethod.h:56
virtual CType * array()
Definition: CMatrix.h:337
bool CSSAMethod::calculate ( void  )
virtual

Execute the optimization algorithm calling simulation routine when needed. It is noted that this procedure can give feedback of its progress by the callback function set with SetCallback. @ return success;

Reimplemented from CEFMAlgorithm.

Definition at line 152 of file CSSAMethod.cpp.

References buildExtremeCurrents(), buildKineticMatrix(), buildStoichiometry(), CProcessReport::finishItem(), initialize(), CEFMAlgorithm::mhSteps, CCopasiMethod::mpCallBack, CEFMAlgorithm::mpModel, and testForMixingStability().

153 {
154  if (!initialize())
155  {
156  if (mpCallBack)
158 
159  return false;
160  }
161 
162  if (!mpModel)
163  {
164  if (mpCallBack)
166 
167  return false;
168  }
169 
170  //initialize matrices for calculation;
171  // if (mpModel->compileIfNecessary(NULL))
172  // {
176  //}
177  // else
178  // return false;
179 
180  if (!testForMixingStability())
181  {
182  if (mpCallBack)
184 
185  return false;
186  }
187 
188  if (mpCallBack)
190 
191  return true;
192 }
bool testForMixingStability()
Definition: CSSAMethod.cpp:203
bool buildKineticMatrix()
Definition: CSSAMethod.cpp:379
bool initialize()
Definition: CSSAMethod.cpp:46
virtual bool finishItem(const size_t &handle)
bool buildExtremeCurrents()
Definition: CSSAMethod.cpp:418
bool buildStoichiometry()
Definition: CSSAMethod.cpp:358
CModel * mpModel
CProcessReport * mpCallBack
bool CSSAMethod::decomposeJacobian ( )
protected

Definition at line 313 of file CSSAMethod.cpp.

References CMatrix< CType >::array(), C_FLOAT64, C_INT, dgemm_(), diag(), mExtremeCurrents, mStoichiometry, mTransformedSubJacobians, mTransposedKineticMatrix, CMatrix< CType >::numCols(), CMatrix< CType >::numRows(), and CMatrix< CType >::resize().

Referenced by testForMixingStability().

314 {
315  mTransformedSubJacobians.clear();
316 
317  // parameters for the double matrix multiplication with dgemm_
318  char cN = 'N'; // don't transpose matrices
319  C_INT m = mStoichiometry.numRows(); // the leading dimension of the Stoi.M. and of the resulting M.
320  C_INT n = mStoichiometry.numCols(); // the dimensions of matrix diagE, also used as 'k'.
321 
322  C_FLOAT64 alpha = 1.;
323  C_FLOAT64 beta = 0.;
324 
325  CMatrix< C_FLOAT64 > product;
326  product.resize(m, m);
327 
328  std::vector< CVector<C_FLOAT64> >::iterator iter;
329 
330  for (iter = mExtremeCurrents.begin(); iter != mExtremeCurrents.end(); ++iter)
331  {
332  CMatrix<C_FLOAT64> diagE = diag(*iter);
333 
334  // compute N*Ei*kappa^T:
335  // As the representation of the matrices in their arrays is in
336  // transposed (mathematical) order, we compute kappa*Ei*N^T,
337  // which corresponds to
338  // (mTransposedKineticMatrix*diagE)*mStoichiometry
339  C_FLOAT64 dummy[m * n];
340  dgemm_(&cN, &cN,
341  &m, &n, &n, &alpha,
343  diagE.array(), &n,
344  &beta, dummy, &m);
345  dgemm_(&cN, &cN,
346  &m, &m, &n, &alpha,
347  dummy, &m,
348  mStoichiometry.array(), &n,
349  &beta, product.array(), &m);
350 
351  mTransformedSubJacobians.push_back(product);
352  }
353 
354  return true;
355 }
#define C_INT
Definition: copasi.h:115
virtual size_t numRows() const
Definition: CMatrix.h:138
std::vector< CVector< C_FLOAT64 > > mExtremeCurrents
Definition: CSSAMethod.h:74
CMatrix< C_FLOAT64 > mTransposedKineticMatrix
Definition: CSSAMethod.h:70
int dgemm_(char *transa, char *transb, integer *m, integer *n, integer *k, doublereal *alpha, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *beta, doublereal *c, integer *ldc)
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
std::vector< CMatrix< C_FLOAT64 > > mTransformedSubJacobians
Definition: CSSAMethod.h:72
CMatrix< CType > diag(CVector< CType > vector)
Definition: CSSAMethod.h:103
#define C_FLOAT64
Definition: copasi.h:92
CMatrix< C_FLOAT64 > mStoichiometry
Definition: CSSAMethod.h:56
virtual size_t numCols() const
Definition: CMatrix.h:144
virtual CType * array()
Definition: CMatrix.h:337
template<class CType >
CMatrix<CType> CSSAMethod::diag ( CVector< CType >  vector)
inlineprotected

Definition at line 103 of file CSSAMethod.h.

References CMatrix< CType >::array(), CMatrix< CType >::resize(), CVectorCore< CType >::size(), and CMatrix< CType >::size().

Referenced by decomposeJacobian().

104  {
105  CMatrix<CType> matrix;
106 
107  matrix.resize(vector.size(), vector.size());
108  memset(matrix.array(), 0, matrix.size()*sizeof(CType));
109 
110  for (unsigned int i = 0; i < vector.size(); ++i)
111  matrix(i, i) = vector[i];
112 
113  return matrix;
114  }
virtual void resize(size_t rows, size_t cols, const bool &copy=false)
Definition: CMatrix.h:151
size_t size() const
Definition: CVector.h:100
virtual size_t size() const
Definition: CMatrix.h:132
virtual CType * array()
Definition: CMatrix.h:337
bool CSSAMethod::initialize ( )
virtual

Initialize arrays and pointer.

Returns
bool success

Reimplemented from CEFMAlgorithm.

Definition at line 46 of file CSSAMethod.cpp.

References CProcessReport::addItem(), C_INT32, CCopasiVector< T >::cleanup(), CCopasiProblem::getModel(), CCopasiObject::getObjectParent(), CCopasiTask::getProblem(), CModel::getReactions(), CModel::getRedStoi(), CEFMAlgorithm::mhSteps, mIsBackwardReaction, CEFMAlgorithm::mMaxStep, mNumReactions, CCopasiMethod::mpCallBack, CEFMAlgorithm::mpModel, mReactions, CEFMAlgorithm::mReversible, CEFMAlgorithm::mStep, CEFMAlgorithm::mStoi, pTask, and CCopasiParameter::UINT.

Referenced by calculate().

47 {
48  CEFMTask * pTask = dynamic_cast< CEFMTask *>(getObjectParent());
49 
50  if (pTask == NULL) return false;
51 
52  mpModel = pTask->getProblem()->getModel();
53 
54  if (mpModel == NULL) return false;
55 
56  mFluxModes.clear();
58 
59  /* ModelStoi is the transpose of the models stoichiometry matrix */
61 
62  unsigned C_INT32 row, numRows = ModelStoi.numRows();
63  unsigned C_INT32 col, numCols = ModelStoi.numCols();
64 
65  /* Get the reactions from the model */
66  /* Note: We have as many reactions as we have rows in ModelStoi */
68 
69  /* Reversible reaction counter */
70  mReversible = 0;
71 
72  for (row = 0; row < numRows; row++)
73  {
74  if (Reaction[row]->isReversible())
75  mReversible++;
76  }
77 
78  unsigned C_INT32 numOrigRows = numRows;
79  numRows += mReversible;
80  mNumReactions = numRows;
81 
82  mReversible = 0;
83  /* Size the stoichiometry matrix passed to the algorithm */
84  mStoi.resize(numRows);
85  std::vector< std::vector< C_FLOAT64 > >::iterator it = mStoi.begin();
86  std::vector< std::vector< C_FLOAT64 > >::iterator end = mStoi.end();
87 
88  for (; it != end; ++it)
89  it->resize(numCols);
90 
91  /* Vector to keep track of the rearrangements necessary to put the */
92  /* reversible reactions to the top of stoichiometry matrix */
93  mReorderedReactions.resize(numRows);
94  mIsBackwardReaction.resize(numRows);
95 
96  unsigned C_INT32 Insert;
97  unsigned C_INT32 InsertReversible = 0;
98  unsigned C_INT32 InsertIrreversible = numRows - 1;
99 
100  /* Build the transpose of the stoichiometry matrix, */
101 
102  /* sort reversible reactions to the top, count them */
103 
104  /* and keep track of the rearrangement */
105 
106  //for (row = 0; row < numOrigRows; row++)
107  for (row = 0; row < numOrigRows; row++)
108  {
109  if (Reaction[row]->isReversible())
110  {
111  Insert = InsertReversible++;
112  mIsBackwardReaction[Insert] = true;
113 
114  mReversible++;
115  }
116  else
117  {
118  Insert = InsertIrreversible--;
119  mIsBackwardReaction[Insert] = false;
120  }
121 
122  mReorderedReactions[Insert] = Reaction[row];
123 
124  for (col = 0; col < numCols; col++)
125  {
126  mStoi[Insert][col] = ModelStoi(row, col);
127 
128  if (Reaction[row]->isReversible())
129  mStoi[InsertReversible - 1][col] = - ModelStoi(row, col);
130  }
131  }
132 
133  mStep = 0;
134  mMaxStep = numCols;
135 
136  if (mpCallBack)
137  mhSteps =
138  mpCallBack->addItem("Current Step",
140  & mStep,
141  & mMaxStep);
142 
143  return true;
144 }
std::vector< bool > mIsBackwardReaction
Definition: CSSAMethod.h:62
CCopasiProblem * getProblem()
unsigned C_INT32 mMaxStep
std::vector< std::vector< C_FLOAT64 > > mStoi
#define C_INT32
Definition: copasi.h:90
const CMatrix< C_FLOAT64 > & getRedStoi() const
Definition: CModel.cpp:1154
CTSSATask * pTask
size_t addItem(const std::string &name, const std::string &value, const std::string *pEndValue=NULL)
virtual void cleanup()
CCopasiVectorNS< CReaction > mReactions
Definition: CSSAMethod.h:53
CModel * mpModel
unsigned C_INT32 mStep
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
C_INT32 mNumReactions
Definition: CSSAMethod.h:65
size_t mReversible
CProcessReport * mpCallBack
CModel * getModel() const
CCopasiContainer * getObjectParent() const
TriLogic CSSAMethod::isMixingStable ( int  indexEC)

Definition at line 195 of file CSSAMethod.cpp.

References mIsMixingStable.

196 {return mIsMixingStable[indexEC];}
std::vector< TriLogic > mIsMixingStable
Definition: CSSAMethod.h:79
bool CSSAMethod::isReactionReversed ( int  index) const

Definition at line 199 of file CSSAMethod.cpp.

References mIsBackwardReaction.

Referenced by CEFMTask::getFluxModeDescription(), and CEFMTask::getReactionEquation().

200 {return mIsBackwardReaction[index];}
std::vector< bool > mIsBackwardReaction
Definition: CSSAMethod.h:62
bool CSSAMethod::process ( CProcessReport handler)

Definition at line 146 of file CSSAMethod.cpp.

147 {
148  return false;
149 }
bool CSSAMethod::testForMixingStability ( )
protected

Definition at line 203 of file CSSAMethod.cpp.

References C_FLOAT64, C_INT32, decomposeJacobian(), dsyev_(), mExtremeCurrents, mIsMixingStable, CEFMAlgorithm::mStoi, mTransformedSubJacobians, CVectorCore< CType >::size(), TriFalse, TriTrue, and TriUnspecified.

Referenced by calculate().

204 {
206 
207  C_INT32 numECs = mExtremeCurrents.size();
208 
209  C_INT32 ijmax = mTransformedSubJacobians[0].numRows();
210 
211  mIsMixingStable.clear();
212 
213  C_FLOAT64 outarray[ijmax * ijmax];
214  memset(outarray, 0, ijmax * ijmax * sizeof(C_FLOAT64));
215 
216  for (int ecIndex = 0; ecIndex < numECs; ++ecIndex)
217  {
218  C_FLOAT64 *inarray = mTransformedSubJacobians[ecIndex].array();
219 
220  // add matrix and its extremeCurrent - upper triangle only
221  for (int i = 0; i < ijmax; ++i)
222  for (int j = i; j < ijmax; ++j)
223  outarray[i + j * ijmax] = inarray[i + j * ijmax] + inarray[j + i * ijmax];
224 
225  // get the eigenvalues AND eigenvectors:
226  // input to dsyev_()
227  char jobz = 'V';
228  char uplo = 'U';
229  C_INT32 n = ijmax;
230  C_FLOAT64 *A = outarray;
231  C_INT32 lda = ijmax;
232  C_INT32 lwork = 64 * ijmax;
233  // dsyev_() output
234  C_FLOAT64 eigenvalues[ijmax];
235  C_FLOAT64 work[lwork];
236  C_INT32 info;
237 
238  dsyev_(&jobz, &uplo, &n, A, &lda, eigenvalues, work, &lwork, &info);
239 
240  if (info)
241  return false; // maybe raise an exception here, to discriminate from the sane case
242 
243  CVector<C_FLOAT64> EC = mExtremeCurrents[ecIndex];
244 
245  // set the state to 'stable' (1 - stable; 0 - unknown; -1 - not mixing stable)
246  TriLogic state = TriTrue;
247 
248  int partMetabs[ijmax];
249  memset(&partMetabs, 0, ijmax * sizeof(int));
250 
251  for (int j = 0; j < EC.size(); ++j)
252  {
253  if (EC[j])
254  {
255  // if one reaction's kinetic function is not Mass Action Law,
256  // this method is not valid and we can say nothing definite
257  // about the stability of this EC.
258  std::string type = mReorderedReactions[j]->getFunction()->getObjectName();
259 
260  if (type.find("Mass action") == std::string::npos &&
261  type.find("Constant flux") == std::string::npos)
262  {
263  state = TriUnspecified;
264  break;
265  }
266 
267  for (int i = 0; i < ijmax; ++i)
268  {
269  if (mStoi[j][i])
270  {
271  partMetabs[i] = 1;
272  break;
273  }
274  }
275  }
276  }
277 
278  if (state == TriTrue)
279  {
280  // eigenvalues are sorted in rising order, and if the last ev is
281  // not positive, we have still to look after zero evs.
282  if (eigenvalues[ijmax - 1] > 0)
283  state = TriFalse;
284  else
285  {
286  int zeroes = 0;
287 
288  for (int i = 0; i < ijmax && state == 1; ++i)
289  {
290  // only count zero eigenvals if the eigenvector contains a reaction
291  // that is participating in this extreme current.
292  if (eigenvalues[i] == 0)
293  {
294  for (int j = 0; j < ijmax; ++ j)
295  if (partMetabs[j] && outarray[i * ijmax + j])
296  if (++zeroes)
297  break;
298 
299  if (zeroes == 2)
300  state = TriFalse;
301  }
302  }
303  }
304  }
305 
306  mIsMixingStable.push_back(state);
307  }
308 
309  return true;
310 }
bool decomposeJacobian()
Definition: CSSAMethod.cpp:313
std::vector< TriLogic > mIsMixingStable
Definition: CSSAMethod.h:79
std::vector< std::vector< C_FLOAT64 > > mStoi
TriLogic
Definition: copasi.h:125
#define C_INT32
Definition: copasi.h:90
std::vector< CVector< C_FLOAT64 > > mExtremeCurrents
Definition: CSSAMethod.h:74
std::vector< CMatrix< C_FLOAT64 > > mTransformedSubJacobians
Definition: CSSAMethod.h:72
size_t size() const
Definition: CVector.h:100
int dsyev_(char *jobz, char *uplo, integer *n, doublereal *a, integer *lda, doublereal *w, doublereal *work, integer *lwork, integer *info)
#define C_FLOAT64
Definition: copasi.h:92

Friends And Related Function Documentation

Member Data Documentation

std::vector< CVector<C_FLOAT64> > CSSAMethod::mExtremeCurrents
protected

Definition at line 74 of file CSSAMethod.h.

Referenced by buildExtremeCurrents(), decomposeJacobian(), and testForMixingStability().

std::vector< bool > CSSAMethod::mIsBackwardReaction
protected

Definition at line 62 of file CSSAMethod.h.

Referenced by buildKineticMatrix(), initialize(), and isReactionReversed().

std::vector< TriLogic > CSSAMethod::mIsMixingStable
protected

Definition at line 79 of file CSSAMethod.h.

Referenced by isMixingStable(), and testForMixingStability().

C_INT32 CSSAMethod::mNumReactions
protected

Definition at line 65 of file CSSAMethod.h.

Referenced by buildExtremeCurrents(), buildKineticMatrix(), and initialize().

CCopasiVectorNS< CReaction > CSSAMethod::mReactions
protected

Definition at line 53 of file CSSAMethod.h.

Referenced by initialize().

CMatrix<C_FLOAT64> CSSAMethod::mStoichiometry
protected

Definition at line 56 of file CSSAMethod.h.

Referenced by buildStoichiometry(), and decomposeJacobian().

std::vector< std::vector<C_FLOAT64> > CSSAMethod::mStoiRows
protected

Definition at line 59 of file CSSAMethod.h.

std::vector< CMatrix<C_FLOAT64> > CSSAMethod::mTransformedSubJacobians
protected

Definition at line 72 of file CSSAMethod.h.

Referenced by decomposeJacobian(), and testForMixingStability().

CMatrix<C_FLOAT64> CSSAMethod::mTransposedKineticMatrix
protected

Definition at line 70 of file CSSAMethod.h.

Referenced by buildKineticMatrix(), and decomposeJacobian().


The documentation for this class was generated from the following files: