COPASI API  4.16.103
Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | List of all members
CLNAMethod Class Reference

#include <CLNAMethod.h>

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

Public Types

enum  EVStatus { allNeg = 0, nonNegEigenvaluesExist }
 
- 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
 

Public Member Functions

void calculateCovarianceMatrixFull ()
 
int calculateCovarianceMatrixReduced ()
 
int CalculateLNA ()
 
 CLNAMethod (const CCopasiContainer *pParent=NULL)
 
 CLNAMethod (const CLNAMethod &src, const CCopasiContainer *pParent=NULL)
 
virtual bool elevateChildren ()
 
const CMatrix< C_FLOAT64 > & getBMatrixReduced () const
 
const CArrayAnnotationgetBMatrixReducedAnn () const
 
const CMatrix< C_FLOAT64 > & getCovarianceMatrix () const
 
const CArrayAnnotationgetCovarianceMatrixAnn () const
 
const CMatrix< C_FLOAT64 > & getCovarianceMatrixReduced () const
 
const CArrayAnnotationgetCovarianceMatrixReducedAnn () const
 
const CLNAMethod::EVStatusgetEigenValueStatus () const
 
const CModelgetModel () const
 
const CArrayAnnotationgetScaledBMatrixReducedAnn () const
 
const CArrayAnnotationgetScaledCovarianceMatrixAnn () const
 
const CArrayAnnotationgetScaledCovarianceMatrixReducedAnn () const
 
const
CSteadyStateMethod::ReturnCode
getSteadyStateStatus () const
 
const CArrayAnnotationgetUnscaledBMatrixReducedAnn () const
 
const CArrayAnnotationgetUnscaledCovarianceMatrixAnn () const
 
const CArrayAnnotationgetUnscaledCovarianceMatrixReducedAnn () const
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
C_INT32 load (CReadConfig &configBuffer)
 
virtual bool process ()
 
virtual void resizeAllMatrices ()
 
void setEigenValueStatus (CLNAMethod::EVStatus status)
 
void setModel (CModel *model)
 
void setSteadyStateResolution (C_FLOAT64 factor)
 
void setSteadyStateStatus (CSteadyStateMethod::ReturnCode SSStatus)
 
virtual ~CLNAMethod ()
 
- 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 ()
 
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 ()
 

Static Public Member Functions

static CLNAMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::linearNoiseApproximation)
 
- 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)
 

Private Member Functions

void initializeParameter ()
 
void initObjects ()
 

Private Attributes

CMatrix< C_FLOAT64mBMatrixReduced
 
CArrayAnnotationmBMatrixReducedAnn
 
CMatrix< C_FLOAT64mCovarianceMatrix
 
CArrayAnnotationmCovarianceMatrixAnn
 
CMatrix< C_FLOAT64mCovarianceMatrixReduced
 
CArrayAnnotationmCovarianceMatrixReducedAnn
 
CLNAMethod::EVStatus mEVStatus
 
CMatrix< C_FLOAT64mJacobianReduced
 
CMatrix< C_FLOAT64mL
 
CModelmpModel
 
CSteadyStateMethod::ReturnCode mSSStatus
 
C_FLOAT64 mSteadyStateResolution
 

Additional Inherited Members

- 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
}
 
- 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 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
 
- Static Protected Attributes inherited from CCopasiObject
static CRenameHandlersmpRenameHandler = NULL
 

Detailed Description

Definition at line 28 of file CLNAMethod.h.

Member Enumeration Documentation

Enumerator
allNeg 
nonNegEigenvaluesExist 

Definition at line 31 of file CLNAMethod.h.

Constructor & Destructor Documentation

CLNAMethod::CLNAMethod ( const CCopasiContainer pParent = NULL)

Default constructor

Parameters
constCCopasiContainer * pParent (Default: NULL)

Default constructor

Definition at line 29 of file CLNAMethod.cpp.

References initializeParameter(), and initObjects().

Referenced by createMethod().

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

Copy constructor

Parameters
constCLNAMethod & src
constCCopasiContainer * pParent (Default: NULL)

Definition at line 39 of file CLNAMethod.cpp.

References initializeParameter(), and initObjects().

40  :
41  CCopasiMethod(src, pParent),
42  mpModel(NULL),
45 {
47  initObjects();
48 }
C_FLOAT64 mSteadyStateResolution
Definition: CLNAMethod.h:59
CModel * mpModel
Definition: CLNAMethod.h:39
void initializeParameter()
Definition: CLNAMethod.cpp:87
void initObjects()
Definition: CLNAMethod.cpp:50
CSteadyStateMethod::ReturnCode mSSStatus
Definition: CLNAMethod.h:61
CLNAMethod::~CLNAMethod ( )
virtual

Deconstructor

Definition at line 82 of file CLNAMethod.cpp.

References DESTRUCTOR_TRACE.

83 {
85 }
#define DESTRUCTOR_TRACE
Definition: copasi.h:206

Member Function Documentation

void CLNAMethod::calculateCovarianceMatrixFull ( )

Re-calculate covariances for the full system

Definition at line 518 of file CLNAMethod.cpp.

References CMatrix< CType >::array(), C_FLOAT64, C_INT, dgemm_(), CModel::getL0(), CModel::getNumDependentReactionMetabs(), CModel::getNumIndependentReactionMetabs(), mCovarianceMatrix, mCovarianceMatrixReduced, mL, mpModel, and CMatrix< CType >::resize().

Referenced by CalculateLNA().

519 {
520  // the covariance matrix of the full system is calculated from
521  // the covariance matrix of the reduced system by:
522  // mL*mCovarianceMatrixReduced*mL^T, with mL the link matrix
523 
524  C_INT i, j;
525 
526  C_INT numIndependentMetabs = (C_INT)mpModel->getNumIndependentReactionMetabs();
528  C_INT numDependentMetabs = numReactionMetabs - numIndependentMetabs;
529 
530  CMatrix<C_FLOAT64> mL0;
531  mL0 = mpModel->getL0();
532  mL.resize((size_t)numReactionMetabs, (size_t)numIndependentMetabs);
533  mL = 0.0;
534 
535  for (i = 0; i < numIndependentMetabs; i++) mL[(size_t)i][(size_t)i] = 1.0;
536 
537  for (i = 0; i < numDependentMetabs; i++)
538  for (j = 0; j < numIndependentMetabs; j++)
539  mL[(size_t)i + (size_t)numIndependentMetabs][(size_t)j] = mL0[(size_t)i][(size_t)j];
540 
541  CMatrix< C_FLOAT64 > D;
542  D.resize((size_t)numIndependentMetabs, (size_t)numReactionMetabs);
543  D = 0.0;
544 
545  // take care of different memory layouts in C and FORTRAN (e.g. BLAS routines)
546  char transa = 'T';
547  char transb = 'T';
548  C_FLOAT64 alpha = 1.0;
549  C_FLOAT64 beta = 0.0;
550 
551  dgemm_(&transa,
552  &transb,
553  &numReactionMetabs,
554  &numIndependentMetabs,
555  &numIndependentMetabs,
556  &alpha,
557  mL.array(),
558  &numIndependentMetabs,
559  mCovarianceMatrixReduced.array(),
560  &numIndependentMetabs,
561  &beta,
562  D.array(),
563  &numReactionMetabs);
564 
565  // take care of different memory layouts in C and FORTRAN (e.g. BLAS routines)
566  transa = 'N';
567  transb = 'N';
568  alpha = 1.0;
569  beta = 0.0;
570  mCovarianceMatrix.resize((size_t)numReactionMetabs, (size_t)numReactionMetabs);
571  mCovarianceMatrix = 0.0;
572 
573  dgemm_(&transa,
574  &transb,
575  &numReactionMetabs,
576  &numReactionMetabs,
577  &numIndependentMetabs,
578  &alpha,
579  D.array(),
580  &numReactionMetabs,
581  mL.array(),
582  &numIndependentMetabs,
583  &beta,
584  mCovarianceMatrix.array(),
585  &numReactionMetabs);
586 }
CMatrix< C_FLOAT64 > mL
Definition: CLNAMethod.h:57
#define C_INT
Definition: copasi.h:115
CMatrix< C_FLOAT64 > mCovarianceMatrix
Definition: CLNAMethod.h:50
size_t getNumDependentReactionMetabs() const
Definition: CModel.cpp:1133
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
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
size_t getNumIndependentReactionMetabs() const
Definition: CModel.cpp:1130
CModel * mpModel
Definition: CLNAMethod.h:39
#define C_FLOAT64
Definition: copasi.h:92
const CLinkMatrix & getL0() const
Definition: CModel.cpp:1169
int CLNAMethod::calculateCovarianceMatrixReduced ( )

Definition at line 127 of file CLNAMethod.cpp.

References CVectorCore< CType >::array(), CMatrix< CType >::array(), CCopasiVector< T >::begin(), C_FLOAT64, C_INT, C_LOGICAL, CModel::calculateJacobianX(), dgees_(), dgemm_(), dtrsyl_(), CCopasiVector< T >::end(), CCopasiVector< T >::getIndex(), CModel::getMetabolitesX(), CModel::getNumIndependentReactionMetabs(), CModel::getParticleFlux(), CModel::getReactions(), CModelEntity::getStatus(), CMetab::isDependent(), LNA_OK, max, mBMatrixReduced, mCovarianceMatrixReduced, mJacobianReduced, mpModel, CMatrix< CType >::numCols(), CMatrix< CType >::numRows(), CModelEntity::REACTIONS, CMatrix< CType >::resize(), CVector< CType >::resize(), CMatrix< CType >::size(), and CCopasiVector< T >::size().

Referenced by CalculateLNA().

128 {
129  // code snippet: transform something into particle space:
130  // *(metabs[i]->getCompartment())->getValue()*mpModel->getQuantity2NumberFactor();
131 
132  assert(mpModel);
133 
136  const CVector< C_FLOAT64 > & ParticleFlux = mpModel->getParticleFlux();
137 
138  size_t numReacs = reacs.size();
139 
140  // We need the number of independent metabolites determined by
141  // reactions.
142  size_t numMetabs = mpModel->getNumIndependentReactionMetabs();
143 
144  size_t i, j, k;
145  const CMetab * pMetabolite;
146  C_FLOAT64 balance_i, balance_j, BContrib;
147 
148  // calculate covariances
149  // first, set BMatrix (reduced) to zero
150  mBMatrixReduced.resize(numMetabs, numMetabs);
151  mBMatrixReduced = 0.0;
152 
153  // second, set CovarianceMatrixReduced to zero
154  mCovarianceMatrixReduced.resize(numMetabs, numMetabs);
156 
157  // then, calculate the contribution for each reaction
158  // and add these contributions to the respective mBMatrix elements
159  // only consider independent metabolites determined by reactions,
160  // e.g. those that contribute to the reduced stoichiometry matrix.
161  // Note: This could also be computed using mRedStoi in CModel.
162  // However, then it would probably be less efficient for very
163  // big systems since mRedStoi should be sparse there.
164  for (k = 0; k < numReacs; k++)
165  {
166  const CCopasiVector <CChemEqElement> & Balances =
167  reacs[k]->getChemEq().getBalances();
168 
172 
173  for (itRow = Balances.begin(); itRow != itEnd; ++itRow)
174  {
175  pMetabolite = (*itRow)->getMetabolite();
176  i = metabs.getIndex(pMetabolite);
177 
178  if (i < numMetabs)
179  {
180  balance_i = (*itRow)->getMultiplicity();
181 
182  // This check is no longer needed since we check the index for validity, i.e. we are assured to have an independent metabolite
183  if ((pMetabolite->getStatus() != CModelEntity::REACTIONS) || (pMetabolite->isDependent())) balance_i = 0.0;
184 
185  for (itColumn = Balances.begin(); itColumn != itEnd; ++itColumn)
186  {
187  pMetabolite = (*itColumn)->getMetabolite();
188  j = metabs.getIndex(pMetabolite);
189 
190  if (j < numMetabs)
191  {
192  balance_j = (*itColumn)->getMultiplicity();
193 
194  // This check is no longer needed since we check the index for validity, i.e. we are assured to have an independent metabolite
195  if ((pMetabolite->getStatus() != CModelEntity::REACTIONS) || (pMetabolite->isDependent())) balance_j = 0.0;
196 
197  BContrib = ParticleFlux[k] * balance_i * balance_j;
198  mBMatrixReduced[i][j] += BContrib;
199  }
200  }
201  }
202  }
203  }
204 
205  // finally, solve the Lyapunov equation A*C + C*A^T + B = 0 for C
206  // using the Bartels & Stewart algorithm (1972)
207 
208  // 1. (Schur) transform the Jacobian matrix A (reduced) and its transpose At
209 
210  // get the Jacobian (reduced)
211  C_FLOAT64 derivationFactor = 1e-6;
212  C_FLOAT64 resolution = 1e-12;
213  mpModel->calculateJacobianX(mJacobianReduced, derivationFactor, resolution);
214 
215  // copy the Jacobian (reduced) into A
218  C_FLOAT64 * pA = A.array();
219  C_FLOAT64 * pAEnd = pA + A.size();
220  const C_FLOAT64 * pMatrix = mJacobianReduced.array();
221 
222  for (; pA != pAEnd; ++pA, ++pMatrix)
223  {
224  *pA = *pMatrix;
225 
226  if (!finite(*pA) && !isnan(*pA))
227  {
228  if (*pA > 0)
230  else
232  }
233  }
234 
235  char jobvs = 'V'; // Schur vectors are computed
236  char sort = 'N'; // Eigenvalues are not ordered
237  C_INT n = (C_INT)A.numRows();
238  C_INT lda = n > 1 ? n : 1;
239  C_INT sdim; // output
241  wr_A.resize((size_t)n);
243  wi_A.resize((size_t)n);
244  CMatrix< C_FLOAT64> vs_A; // output (unitary matrix)
245  C_INT ldvs_A = n;
246  vs_A.resize((size_t)ldvs_A, (size_t)ldvs_A);
247  CVector< C_FLOAT64 > work = 1;
248  C_INT lwork;
249  C_LOGICAL * pbwork = NULL;
250  C_INT info;
251 
252  // LWORK workspace query
253  lwork = -1;
254  dgees_(&jobvs,
255  &sort,
256  NULL,
257  &n,
258  A.array(),
259  &lda,
260  &sdim,
261  wr_A.array(),
262  wi_A.array(),
263  vs_A.array(),
264  &ldvs_A,
265  work.array(),
266  &lwork,
267  pbwork,
268  &info);
269 
270  if (info != 0)
271  {
272  // TODO(juergen): add appropriate exception message(s)!
273  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCLNA + 1, -mInfo);
274  }
275 
276  lwork = (C_INT) work[0];
277  work.resize((size_t)lwork);
278 
279  dgees_(&jobvs,
280  &sort,
281  NULL,
282  &n,
283  A.array(), // input: matrix / output: real Schur form
284  &lda,
285  &sdim,
286  wr_A.array(),
287  wi_A.array(),
288  vs_A.array(),
289  &ldvs_A,
290  work.array(),
291  &lwork,
292  pbwork,
293  &info);
294 
295  if (info != 0)
296  {
297  // TODO(juergen): add appropriate exception message(s)!
298  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCLNA + 1, -mInfo);
299  }
300 
301  // now, (Schur) transform the transposed Jacobian (reduced)
302 
303  // copy the transposed Jacobian (reduced) into At
306 
307  for (i = 0; i < mJacobianReduced.numRows(); i++)
308  {
309  for (j = 0; j < mJacobianReduced.numCols(); j++)
310  {
311  At[j][i] = mJacobianReduced[i][j];
312 
313  if (!finite(At[j][i]) && !isnan(At[j][i]))
314  {
315  if (At[j][i] > 0)
317  else
319  }
320  }
321  }
322 
323  jobvs = 'V'; // Schur vectors are computed
324  sort = 'N'; // Eigenvalues are not ordered
325  n = (C_INT)At.numRows();
326  lda = n > 1 ? n : 1;
327  // C_INT sdim; // output
328  CVector< C_FLOAT64 > wr_At;
329  wr_At.resize((size_t)n);
330  CVector< C_FLOAT64 > wi_At;
331  wi_At.resize((size_t)n);
332  CMatrix< C_FLOAT64 > vs_At; // output (unitary matrix)
333  C_INT ldvs_At = n;
334  vs_At.resize((size_t)ldvs_At, (size_t)ldvs_At);
335  work = 1;
336  // C_INT lwork;
337  pbwork = NULL;
338  // C_INT info;
339 
340  // LWORK workspace query
341  lwork = -1;
342  dgees_(&jobvs,
343  &sort,
344  NULL,
345  &n,
346  At.array(),
347  &lda,
348  &sdim,
349  wr_At.array(),
350  wi_At.array(),
351  vs_At.array(),
352  &ldvs_At,
353  work.array(),
354  &lwork,
355  pbwork,
356  &info);
357 
358  if (info != 0)
359  {
360  // TODO(juergen): add appropriate exception message(s)!
361  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCLNA + 1, -mInfo);
362  }
363 
364  lwork = (C_INT) work[0];
365  work.resize((size_t)lwork);
366 
367  dgees_(&jobvs,
368  &sort,
369  NULL,
370  &n,
371  At.array(), // input: matrix / output: real Schur form
372  &lda,
373  &sdim,
374  wr_At.array(),
375  wi_At.array(),
376  vs_At.array(),
377  &ldvs_At,
378  work.array(),
379  &lwork,
380  pbwork,
381  &info);
382 
383  if (info != 0)
384  {
385  // TODO(juergen): add appropriate exception message(s)!
386  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCLNA + 1, -mInfo);
387  }
388 
389  // 2. transform the mBMatrixReduced B to new coordinates
390  // BMatrixReduced_transformed = (unitary At)^T * mBMatrixReduced * (unitary A);
391 
392  char transa = 'T'; // (unitary A) will be transposed
393  char transb = 'N'; // mBMatrixReduced will not be transposed
394  C_FLOAT64 alpha = 1.0;
395  C_FLOAT64 beta = 0.0;
397  C_INT ldd = n;
398  D.resize((size_t)n, (size_t)n);
399 
400  dgemm_(&transa,
401  &transb,
402  &n,
403  &n,
404  &n,
405  &alpha,
406  vs_At.array(),
407  &n,
409  &n,
410  &beta,
411  D.array(), // output: multiplied matrix
412  &ldd);
413 
414  transa = 'N';
415  CMatrix< C_FLOAT64 > BMatrixReduced_transformed;
416  C_INT BMatrixReduced_transformed_d = n;
417  BMatrixReduced_transformed.resize((size_t)n, (size_t)n);
418 
419  dgemm_(&transa,
420  &transb,
421  &n,
422  &n,
423  &n,
424  &alpha,
425  D.array(),
426  &n,
427  vs_A.array(), // (unitary At)
428  &n,
429  &beta,
430  BMatrixReduced_transformed.array(),
431  &BMatrixReduced_transformed_d);
432 
433  // 3. Solve the simplified Lyapunov (Sylvester) Equation
434 
435  char trana = 'N'; // no transpose of A
436  char tranb = 'N'; // no transpose of B
437  C_INT isgn = 1; // sign in the equation is "+"
438  C_FLOAT64 scale; // output
439 
440  // DTRSYL solves the real Sylvester matrix equation:
441  //
442  // op(A)*X + X*op(B) = scale*C or
443  // op(A)*X - X*op(B) = scale*C,
444  //
445  // where op(A) = A or A**T, and A and B are both upper quasi-
446  // triangular. A is M-by-M and B is N-by-N; the right hand side C and
447  // the solution X are M-by-N; and scale is an output scale factor, set
448  // <= 1 to avoid overflow in X.
449  dtrsyl_(&trana,
450  &tranb,
451  &isgn,
452  &n,
453  &n,
454  At.array(), // Schur transform of the Jacobian (reduced)
455  &n,
456  A.array(), // Schur transform of the transposed Jacobian (reduced)
457  &n,
458  BMatrixReduced_transformed.array(), // output / input (the coordinate-transformed mBMatrix (reduced))
459  &n,
460  &scale,
461  &info);
462 
463  if (info != 0)
464  {
465  // TODO(juergen): add appropriate exception message(s)!
466  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCLNA + 1, -mInfo);
467  }
468 
469  // 4. Calculate the original matrix C: -(unitary At)*BMatrixReduced_transformed*(unitary A)^T;
470 
471  transa = 'N';
472  transb = 'N';
473  alpha = -1.0;
474  beta = 0.0;
475  ldd = n;
476  D.resize((size_t)n, (size_t)n);
477 
478  dgemm_(&transa,
479  &transb,
480  &n,
481  &n,
482  &n,
483  &alpha,
484  vs_At.array(),
485  &n,
486  BMatrixReduced_transformed.array(), // BMatrixReduced_transformed.array() holds the output of dtrsyl() now
487  &n,
488  &beta,
489  D.array(),
490  &ldd);
491 
492  transa = 'N';
493  transb = 'T';
494  alpha = 1.0;
495  beta = 0.0;
496  mCovarianceMatrixReduced.resize((size_t)n, (size_t)n);
497 
498  dgemm_(&transa,
499  &transb,
500  &n,
501  &n,
502  &n,
503  &alpha,
504  D.array(),
505  &n,
506  vs_A.array(),
507  &n,
508  &beta,
510  &n);
511 
512  return LNA_OK;
513 }
#define C_INT
Definition: copasi.h:115
int dtrsyl_(char *trana, char *tranb, integer *isgn, integer *m, integer *n, doublereal *a, integer *lda, doublereal *b, integer *ldb, doublereal *c__, integer *ldc, doublereal *scale, integer *info)
virtual size_t size() const
const CVector< C_FLOAT64 > & getParticleFlux() const
Definition: CModel.cpp:1045
iterator begin()
virtual size_t numRows() const
Definition: CMatrix.h:138
void calculateJacobianX(CMatrix< C_FLOAT64 > &jacobianX, const C_FLOAT64 &derivationFactor, const C_FLOAT64 &resolution)
Definition: CModel.cpp:2082
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
Definition: CMetab.h:178
#define C_LOGICAL
Definition: copasi.h:122
iterator end()
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
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)
CMatrix< C_FLOAT64 > mBMatrixReduced
Definition: CLNAMethod.h:44
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
bool isDependent() const
Definition: CMetab.cpp:989
CMatrix< C_FLOAT64 > mJacobianReduced
Definition: CLNAMethod.h:54
CModel * mpModel
Definition: CLNAMethod.h:39
virtual size_t getIndex(const CCopasiObject *pObject) const
#define C_FLOAT64
Definition: copasi.h:92
CType * array()
Definition: CVector.h:139
virtual size_t size() const
Definition: CMatrix.h:132
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
int dgees_(char *jobvs, char *sort, L_fp select, integer *n, doublereal *a, integer *lda, integer *sdim, doublereal *wr, doublereal *wi, doublereal *vs, integer *ldvs, doublereal *work, integer *lwork, logical *bwork, integer *info)
const CModelEntity::Status & getStatus() const
const CCopasiVector< CMetab > & getMetabolitesX() const
Definition: CModel.cpp:1057
virtual size_t numCols() const
Definition: CMatrix.h:144
#define LNA_OK
Definition: CLNAMethod.h:23
virtual CType * array()
Definition: CMatrix.h:337
#define max(a, b)
Definition: f2c.h:176
int CLNAMethod::CalculateLNA ( )

the LNA entry point

the LNA entry point

Parameters
statusrefers to the steady-state solution
resrefers to the resolution

Definition at line 601 of file CLNAMethod.cpp.

References allNeg, calculateCovarianceMatrixFull(), calculateCovarianceMatrixReduced(), CSteadyStateMethod::found, CSteadyStateMethod::foundEquilibrium, LNA_NOT_OK, LNA_OK, mBMatrixReduced, mCovarianceMatrix, mCovarianceMatrixReduced, mEVStatus, mpModel, and mSSStatus.

Referenced by process().

602 {
603  assert(mpModel);
604 
606  {
608  {
610  return LNA_OK;
611  }
612  }
613 
614  // something went wrong
615  mBMatrixReduced = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
616  mCovarianceMatrixReduced = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
617  mCovarianceMatrix = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
618  return LNA_NOT_OK;
619 }
void calculateCovarianceMatrixFull()
Definition: CLNAMethod.cpp:518
CMatrix< C_FLOAT64 > mCovarianceMatrix
Definition: CLNAMethod.h:50
CLNAMethod::EVStatus mEVStatus
Definition: CLNAMethod.h:63
#define LNA_NOT_OK
Definition: CLNAMethod.h:24
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
CMatrix< C_FLOAT64 > mBMatrixReduced
Definition: CLNAMethod.h:44
CModel * mpModel
Definition: CLNAMethod.h:39
int calculateCovarianceMatrixReduced()
Definition: CLNAMethod.cpp:127
CSteadyStateMethod::ReturnCode mSSStatus
Definition: CLNAMethod.h:61
#define LNA_OK
Definition: CLNAMethod.h:23
CLNAMethod * CLNAMethod::createMethod ( CCopasiMethod::SubType  subType = CCopasiMethod::linearNoiseApproximation)
static

Create a LNA method. Note: the returned object has to be released after use with delete

Definition at line 21 of file CLNAMethod.cpp.

References CLNAMethod().

Referenced by CLNATask::createMethod().

22 {
23  return new CLNAMethod();
24 }
CLNAMethod(const CCopasiContainer *pParent=NULL)
Definition: CLNAMethod.cpp:29
bool CLNAMethod::elevateChildren ( )
virtual

This methods must be called to elevate subgroups to derived objects. The default implementation does nothing.

Returns
bool success

Reimplemented from CCopasiParameterGroup.

Definition at line 101 of file CLNAMethod.cpp.

References initializeParameter().

102 {
104  return true;
105 }
void initializeParameter()
Definition: CLNAMethod.cpp:87
const CMatrix<C_FLOAT64>& CLNAMethod::getBMatrixReduced ( ) const
inline

Definition at line 101 of file CLNAMethod.h.

References mBMatrixReduced.

102  {return mBMatrixReduced;}
CMatrix< C_FLOAT64 > mBMatrixReduced
Definition: CLNAMethod.h:44
const CArrayAnnotation* CLNAMethod::getBMatrixReducedAnn ( ) const
inline

Definition at line 104 of file CLNAMethod.h.

References mBMatrixReducedAnn.

105  {return mBMatrixReducedAnn;}
CArrayAnnotation * mBMatrixReducedAnn
Definition: CLNAMethod.h:45
const CMatrix<C_FLOAT64>& CLNAMethod::getCovarianceMatrix ( ) const
inline

Definition at line 107 of file CLNAMethod.h.

References mCovarianceMatrix.

108  {return mCovarianceMatrix;}
CMatrix< C_FLOAT64 > mCovarianceMatrix
Definition: CLNAMethod.h:50
const CArrayAnnotation* CLNAMethod::getCovarianceMatrixAnn ( ) const
inline

Definition at line 110 of file CLNAMethod.h.

References mCovarianceMatrixAnn.

Referenced by CLNATask::printResult().

111  {return mCovarianceMatrixAnn;}
CArrayAnnotation * mCovarianceMatrixAnn
Definition: CLNAMethod.h:51
const CMatrix<C_FLOAT64>& CLNAMethod::getCovarianceMatrixReduced ( ) const
inline

Definition at line 113 of file CLNAMethod.h.

References mCovarianceMatrixReduced.

114  {return mCovarianceMatrixReduced;}
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
const CArrayAnnotation* CLNAMethod::getCovarianceMatrixReducedAnn ( ) const
inline

Definition at line 116 of file CLNAMethod.h.

References mCovarianceMatrixReducedAnn.

CArrayAnnotation * mCovarianceMatrixReducedAnn
Definition: CLNAMethod.h:48
const CLNAMethod::EVStatus& CLNAMethod::getEigenValueStatus ( ) const
inline

Definition at line 188 of file CLNAMethod.h.

References mEVStatus.

Referenced by CLNAResultSubwidget::loadAll().

189  {return mEVStatus;}
CLNAMethod::EVStatus mEVStatus
Definition: CLNAMethod.h:63
const CModel * CLNAMethod::getModel ( ) const

Get the Model

Definition at line 657 of file CLNAMethod.cpp.

References mpModel.

Referenced by CLNAResultSubwidget::loadAll().

658 {
659  return this->mpModel;
660 }
CModel * mpModel
Definition: CLNAMethod.h:39
const CArrayAnnotation* CLNAMethod::getScaledBMatrixReducedAnn ( ) const
inline

Definition at line 121 of file CLNAMethod.h.

References mBMatrixReducedAnn.

Referenced by CLNAResultSubwidget::loadBMatrixReduced().

122  {return mBMatrixReducedAnn;}
CArrayAnnotation * mBMatrixReducedAnn
Definition: CLNAMethod.h:45
const CArrayAnnotation* CLNAMethod::getScaledCovarianceMatrixAnn ( ) const
inline

Definition at line 127 of file CLNAMethod.h.

References mCovarianceMatrixAnn.

Referenced by CLNAResultSubwidget::loadCovarianceMatrix().

128  {return mCovarianceMatrixAnn;}
CArrayAnnotation * mCovarianceMatrixAnn
Definition: CLNAMethod.h:51
const CArrayAnnotation* CLNAMethod::getScaledCovarianceMatrixReducedAnn ( ) const
inline

Definition at line 130 of file CLNAMethod.h.

References mCovarianceMatrixReducedAnn.

Referenced by CLNAResultSubwidget::loadCovarianceMatrixReduced().

CArrayAnnotation * mCovarianceMatrixReducedAnn
Definition: CLNAMethod.h:48
const CSteadyStateMethod::ReturnCode& CLNAMethod::getSteadyStateStatus ( ) const
inline

Definition at line 185 of file CLNAMethod.h.

References mSSStatus.

Referenced by CLNAResultSubwidget::loadAll(), and CLNATask::printResult().

186  {return mSSStatus;}
CSteadyStateMethod::ReturnCode mSSStatus
Definition: CLNAMethod.h:61
const CArrayAnnotation* CLNAMethod::getUnscaledBMatrixReducedAnn ( ) const
inline

Definition at line 124 of file CLNAMethod.h.

References mBMatrixReducedAnn.

Referenced by CLNAResultSubwidget::loadBMatrixReduced().

125  {return mBMatrixReducedAnn;}
CArrayAnnotation * mBMatrixReducedAnn
Definition: CLNAMethod.h:45
const CArrayAnnotation* CLNAMethod::getUnscaledCovarianceMatrixAnn ( ) const
inline

Definition at line 133 of file CLNAMethod.h.

References mCovarianceMatrixAnn.

Referenced by CLNAResultSubwidget::loadCovarianceMatrix().

134  {return mCovarianceMatrixAnn;}
CArrayAnnotation * mCovarianceMatrixAnn
Definition: CLNAMethod.h:51
const CArrayAnnotation* CLNAMethod::getUnscaledCovarianceMatrixReducedAnn ( ) const
inline

Definition at line 136 of file CLNAMethod.h.

References mCovarianceMatrixReducedAnn.

Referenced by CLNAResultSubwidget::loadCovarianceMatrixReduced().

CArrayAnnotation * mCovarianceMatrixReducedAnn
Definition: CLNAMethod.h:48
void CLNAMethod::initializeParameter ( )
private

Intialize the method parameter

Definition at line 87 of file CLNAMethod.cpp.

Referenced by CLNAMethod(), and elevateChildren().

88 {
89  /* CCopasiParameter *pParm;
90 
91  assertParameter("Placeholder Factor", CCopasiParameter::UDOUBLE, 1.0e-009);
92 
93  if ((pParm = getParameter("LNA.PlaceholderFactor")) != NULL)
94  {
95  setValue("Placeholder Factor", *pParm->getValue().pUDOUBLE);
96  removeParameter("LNA.PlaceholderFactor");
97  }
98  */
99 }
void CLNAMethod::initObjects ( )
private

Definition at line 50 of file CLNAMethod.cpp.

References mBMatrixReduced, mBMatrixReducedAnn, mCovarianceMatrix, mCovarianceMatrixAnn, mCovarianceMatrixReduced, mCovarianceMatrixReducedAnn, CArrayAnnotation::setDescription(), CArrayAnnotation::setDimensionDescription(), CArrayAnnotation::setMode(), and CArrayAnnotation::VECTOR.

Referenced by CLNAMethod().

51 {
52  CArrayAnnotation * tmp;
53 
54  tmp = new CArrayAnnotation("B matrix (reduced)", this,
57  tmp->setDescription("B matrix (reduced)");
58  tmp->setDimensionDescription(0, "Species (reduced system)");
59  tmp->setDimensionDescription(1, "Species (reduced system)");
60  mBMatrixReducedAnn = tmp;
61 
62  tmp = new CArrayAnnotation("Covariance matrix (reduced)", this,
65  tmp->setDescription("Covariance matrix (reduced)");
66  tmp->setDimensionDescription(0, "Species (reduced system)");
67  tmp->setDimensionDescription(1, "Species (reduced system)");
69 
70  tmp = new CArrayAnnotation("Covariance matrix", this,
73  tmp->setDescription("Covariance matrix");
74  tmp->setDimensionDescription(0, "Species (full system)");
75  tmp->setDimensionDescription(1, "Species (full system)");
77 }
CArrayAnnotation * mCovarianceMatrixReducedAnn
Definition: CLNAMethod.h:48
CMatrix< C_FLOAT64 > mCovarianceMatrix
Definition: CLNAMethod.h:50
void setDescription(const std::string &s)
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
CMatrix< C_FLOAT64 > mBMatrixReduced
Definition: CLNAMethod.h:44
void setMode(size_t d, Mode m)
void setDimensionDescription(size_t d, const std::string &s)
CArrayAnnotation * mCovarianceMatrixAnn
Definition: CLNAMethod.h:51
CArrayAnnotation * mBMatrixReducedAnn
Definition: CLNAMethod.h:45
bool CLNAMethod::isValidProblem ( const CCopasiProblem pProblem)
virtual

Check if the method is suitable for this problem

Returns
bool suitability of the method

Reimplemented from CCopasiMethod.

Definition at line 663 of file CLNAMethod.cpp.

References CCopasiVector< T >::begin(), CCopasiVector< T >::end(), CCopasiMessage::ERROR, CModelEntity::FIXED, CModel::getCompartments(), CCopasiProblem::getModel(), CModel::getNumAssignmentMetabs(), CModel::getNumODEMetabs(), CModel::getReactions(), CCopasiMethod::isValidProblem(), and CCopasiVector< T >::size().

664 {
665  if (!CCopasiMethod::isValidProblem(pProblem)) return false;
666 
667  const CLNAProblem * pP = dynamic_cast<const CLNAProblem *>(pProblem);
668 
669  if (!pP)
670  {
671  //not a CLNAProblem
672  CCopasiMessage(CCopasiMessage::ERROR, "Problem is not a LNA problem.");
673  return false;
674  }
675 
676  CModel * pModel = pP->getModel();
677 
678  if (pModel == NULL)
679  return false;
680 
681  // Check if the model contains species that have assignments or
682  // explicit ODEs.
683  if (pModel->getNumAssignmentMetabs() > 0)
684  {
685  CCopasiMessage(CCopasiMessage::ERROR, "LNA is not applicable for a system with species assignments.");
686  return false;
687  }
688 
689  if (pModel->getNumODEMetabs() > 0)
690  {
691  CCopasiMessage(CCopasiMessage::ERROR, "LNA is not applicable for a system with explicit ODEs for species.");
692  return false;
693  }
694 
695  //if (pModel->getCompartments().size() > 1)
696  // {
697  // CCopasiMessage(CCopasiMessage::ERROR, "LNA is not applicable for a system with more than one compartment.");
698  // return false;
699  //}
700 
701  // Check if the model has a compartment with an assignment or ODE
704 
705  for (; it != end; ++it)
706  if ((*it)->getStatus() != CModelEntity::FIXED)
707  {
708  CCopasiMessage(CCopasiMessage::ERROR, "LNA is not applicable for a system with changing volumes, e.g. compartment assignments or ODEs.");
709  return false;
710  }
711 
712  CCopasiVector< CReaction > & reacs = pModel->getReactions();
713  size_t numReacs = reacs.size();
714  size_t i;
715 
716  for (i = 0; i < numReacs; i++) // for every reaction
717  {
718  // TEST isReversible() == 0
719  if (reacs[i]->isReversible() != 0)
720  {
721  CCopasiMessage(CCopasiMessage::ERROR, "At least one reaction is reversible. That means it is not possible to calculate the LNA. \nYou can use \"Tools|Convert to irreversible\" which will split the reversible reactions \n into two irreversible reactions. However you should check the kinetics afterwards.");
722  return false;
723  }
724  }
725 
726  return true;
727 }
virtual size_t size() const
iterator begin()
size_t getNumODEMetabs() const
Definition: CModel.cpp:1124
virtual bool isValidProblem(const CCopasiProblem *pProblem)
iterator end()
std::vector< CType * >::const_iterator const_iterator
Definition: CCopasiVector.h:57
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
size_t getNumAssignmentMetabs() const
Definition: CModel.cpp:1127
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
Definition: CModel.h:50
CModel * getModel() const
C_INT32 CLNAMethod::load ( CReadConfig configBuffer)

Read some parameters from configuration file

Read some parameters from configuration file.

Definition at line 624 of file CLNAMethod.cpp.

References C_INT32.

625 {
626  C_INT32 Fail = 0;
627  /*
628  if ((Fail = configBuffer.getVariable("SSMCAUnscaled", "C_INT16",
629  (void *) & mSSReder,
630  CReadConfig::LOOP)))
631  return Fail;
632  */
633  return Fail;
634 }
#define C_INT32
Definition: copasi.h:90
bool CLNAMethod::process ( )
virtual

Definition at line 636 of file CLNAMethod.cpp.

References CalculateLNA(), and LNA_OK.

Referenced by CLNATask::process().

637 {
638  return (CalculateLNA() == LNA_OK);
639  // maybe, introduce additional checks here later
640 }
int CalculateLNA()
Definition: CLNAMethod.cpp:601
#define LNA_OK
Definition: CLNAMethod.h:23
void CLNAMethod::resizeAllMatrices ( )
virtual

Resizes all result matrices and updates the corresponding array annotations. This needs to be called before output initialization (in case the output references parts of the matrix) from the task initialization, but it also needs to be called before selecting elements of the matrices in the object selection dialog. The model needs to be set before calling this.

Definition at line 107 of file CLNAMethod.cpp.

References CModel::getMetabolitesX(), CModel::getNumDependentReactionMetabs(), CModel::getNumIndependentReactionMetabs(), mBMatrixReduced, mBMatrixReducedAnn, mCovarianceMatrix, mCovarianceMatrixAnn, mCovarianceMatrixReduced, mCovarianceMatrixReducedAnn, mpModel, CMatrix< CType >::resize(), CArrayAnnotation::resize(), and CArrayAnnotation::setCopasiVector().

Referenced by CLNATask::updateMatrices().

108 {
109  if (!mpModel) return;
110 
115 
120 
125 }
CArrayAnnotation * mCovarianceMatrixReducedAnn
Definition: CLNAMethod.h:48
CMatrix< C_FLOAT64 > mCovarianceMatrix
Definition: CLNAMethod.h:50
size_t getNumDependentReactionMetabs() const
Definition: CModel.cpp:1133
CMatrix< C_FLOAT64 > mCovarianceMatrixReduced
Definition: CLNAMethod.h:47
void setCopasiVector(size_t d, const CCopasiContainer *v)
CMatrix< C_FLOAT64 > mBMatrixReduced
Definition: CLNAMethod.h:44
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
Definition: CLNAMethod.h:39
const CCopasiVector< CMetab > & getMetabolitesX() const
Definition: CModel.cpp:1057
CArrayAnnotation * mCovarianceMatrixAnn
Definition: CLNAMethod.h:51
CArrayAnnotation * mBMatrixReducedAnn
Definition: CLNAMethod.h:45
void CLNAMethod::setEigenValueStatus ( CLNAMethod::EVStatus  status)

Definition at line 647 of file CLNAMethod.cpp.

References mEVStatus.

Referenced by CLNATask::process().

648 {
649  mEVStatus = status;
650 }
CLNAMethod::EVStatus mEVStatus
Definition: CLNAMethod.h:63
void CLNAMethod::setModel ( CModel model)

Set the Model

Definition at line 591 of file CLNAMethod.cpp.

References mpModel.

Referenced by CLNATask::printResult(), and CLNATask::updateMatrices().

592 {
593  mpModel = model;
594 }
CModel * mpModel
Definition: CLNAMethod.h:39
void CLNAMethod::setSteadyStateResolution ( C_FLOAT64  factor)

Definition at line 652 of file CLNAMethod.cpp.

References mSteadyStateResolution.

653 {
654  this->mSteadyStateResolution = resolution;
655 }
C_FLOAT64 mSteadyStateResolution
Definition: CLNAMethod.h:59
void CLNAMethod::setSteadyStateStatus ( CSteadyStateMethod::ReturnCode  SSStatus)

Definition at line 642 of file CLNAMethod.cpp.

References mSSStatus.

Referenced by CLNATask::process().

643 {
644  mSSStatus = SSStatus;
645 }
CSteadyStateMethod::ReturnCode mSSStatus
Definition: CLNAMethod.h:61

Member Data Documentation

CMatrix<C_FLOAT64> CLNAMethod::mBMatrixReduced
private
CArrayAnnotation* CLNAMethod::mBMatrixReducedAnn
private
CMatrix<C_FLOAT64> CLNAMethod::mCovarianceMatrix
private
CArrayAnnotation* CLNAMethod::mCovarianceMatrixAnn
private
CMatrix<C_FLOAT64> CLNAMethod::mCovarianceMatrixReduced
private
CArrayAnnotation* CLNAMethod::mCovarianceMatrixReducedAnn
private
CLNAMethod::EVStatus CLNAMethod::mEVStatus
private

Definition at line 63 of file CLNAMethod.h.

Referenced by CalculateLNA(), getEigenValueStatus(), and setEigenValueStatus().

CMatrix<C_FLOAT64> CLNAMethod::mJacobianReduced
private

Definition at line 54 of file CLNAMethod.h.

Referenced by calculateCovarianceMatrixReduced().

CMatrix<C_FLOAT64> CLNAMethod::mL
private

Definition at line 57 of file CLNAMethod.h.

Referenced by calculateCovarianceMatrixFull().

CModel* CLNAMethod::mpModel
private
CSteadyStateMethod::ReturnCode CLNAMethod::mSSStatus
private

Definition at line 61 of file CLNAMethod.h.

Referenced by CalculateLNA(), getSteadyStateStatus(), and setSteadyStateStatus().

C_FLOAT64 CLNAMethod::mSteadyStateResolution
private

Definition at line 59 of file CLNAMethod.h.

Referenced by setSteadyStateResolution().


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