COPASI API  4.16.103
Public Member Functions | Private Member Functions | Private Attributes | List of all members
CStochNextReactionMethod Class Reference

#include <CStochNextReactionMethod.h>

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

Public Member Functions

 CStochNextReactionMethod ()
 
C_FLOAT64 doSingleStep (C_FLOAT64 time, C_FLOAT64 endTime)
 
- Public Member Functions inherited from CStochMethod
 CStochMethod (const CStochMethod &src, const CCopasiContainer *pParent=NULL)
 
virtual bool elevateChildren ()
 
virtual bool isValidProblem (const CCopasiProblem *pProblem)
 
virtual void start (const CState *initialState)
 
virtual Status step (const double &deltaT)
 
 ~CStochMethod ()
 
- Public Member Functions inherited from CTrajectoryMethod
 CTrajectoryMethod (const CTrajectoryMethod &src, const CCopasiContainer *pParent=NULL)
 
const CVector< C_INT > & getRoots () const
 
void setCurrentState (CState *currentState)
 
void setProblem (CTrajectoryProblem *problem)
 
virtual void stateChanged ()
 
 ~CTrajectoryMethod ()
 
- 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 ()
 

Private Member Functions

void initMethod (C_FLOAT64 start_time)
 
void setupPriorityQueue (C_FLOAT64 start_time=0)
 
void updatePriorityQueue (size_t reaction_index, C_FLOAT64 time)
 

Private Attributes

CIndexedPriorityQueue mPQ
 

Additional Inherited Members

- Public Types inherited from CTrajectoryMethod
enum  Status { FAILURE = -1, NORMAL = 0, ROOT = 1 }
 
- 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 CTrajectoryMethod
static CTrajectoryMethodcreateMethod (CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
 
- 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
}
 
- Protected Member Functions inherited from CStochMethod
C_INT32 calculateAmu (size_t reaction_index)
 
 CStochMethod (const CCopasiContainer *pParent=NULL)
 
size_t generateReactionIndex ()
 
C_FLOAT64 generateReactionTime ()
 
C_FLOAT64 generateReactionTime (size_t reaction_index)
 
void setupDependencyGraphAndBalances ()
 
C_INT32 updatePropensities ()
 
C_INT32 updateSystemState (size_t reaction_index, const C_FLOAT64 &time)
 
- Protected Member Functions inherited from CTrajectoryMethod
 CTrajectoryMethod (const CCopasiMethod::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)
 
- Static Protected Member Functions inherited from CStochMethod
static bool modelHasAssignments (const CModel *pModel)
 
- Protected Attributes inherited from CStochMethod
C_FLOAT64 mA0
 
std::vector< C_FLOAT64mAmu
 
std::vector< C_FLOAT64mAmuOld
 
CDependencyGraph mDG
 
bool mDoCorrection
 
size_t mFirstMetabIndex
 
bool mHasAssignments
 
std::vector< std::vector
< CStochBalance > > 
mLocalBalances
 
std::vector< std::vector
< CStochBalance > > 
mLocalSubstrates
 
std::vector< C_INT64mNumbers
 
size_t mNumReactions
 
CModelmpModel
 
CRandommpRandomGenerator
 
- Protected Attributes inherited from CTrajectoryMethod
CStatempCurrentState
 
CTrajectoryProblemmpProblem
 
CVector< C_INTmRoots
 
- 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 29 of file CStochNextReactionMethod.h.

Constructor & Destructor Documentation

CStochNextReactionMethod::CStochNextReactionMethod ( )

Default constructor

Definition at line 23 of file CStochNextReactionMethod.cpp.

24  : CStochMethod()
25 {}
CStochMethod(const CCopasiContainer *pParent=NULL)

Member Function Documentation

C_FLOAT64 CStochNextReactionMethod::doSingleStep ( C_FLOAT64  time,
C_FLOAT64  endTime 
)
virtual

Do one iteration of the simulation

Returns
Current simulation time or -1 if error.

Implements CStochMethod.

Definition at line 32 of file CStochNextReactionMethod.cpp.

References C_FLOAT64, CCopasiMessage::EXCEPTION, MCTrajectoryMethod, mPQ, CIndexedPriorityQueue::topIndex(), CIndexedPriorityQueue::topKey(), updatePriorityQueue(), and CStochMethod::updateSystemState().

33 {
34  C_FLOAT64 steptime = mPQ.topKey();
35 
36  // We need to throw an exception if mA0 is NaN
37  if (isnan(steptime))
38  {
40  }
41 
42  if (steptime >= endTime)
43  {
44  return endTime;
45  }
46  else
47  {
48  size_t reaction_index = mPQ.topIndex();
49  updateSystemState(reaction_index, steptime);
50  updatePriorityQueue(reaction_index, steptime);
51  //printDebugInfo();
52  return steptime;
53  }
54 }
#define MCTrajectoryMethod
void updatePriorityQueue(size_t reaction_index, C_FLOAT64 time)
C_INT32 updateSystemState(size_t reaction_index, const C_FLOAT64 &time)
#define C_FLOAT64
Definition: copasi.h:92
void CStochNextReactionMethod::initMethod ( C_FLOAT64  start_time)
privatevirtual

Initialization.

Implements CStochMethod.

Definition at line 27 of file CStochNextReactionMethod.cpp.

References setupPriorityQueue().

28 {
29  setupPriorityQueue(start_time);
30 }
void setupPriorityQueue(C_FLOAT64 start_time=0)
void CStochNextReactionMethod::setupPriorityQueue ( C_FLOAT64  start_time = 0)
private

print internal information (for debugging) Set up the priority queue.

Parameters
start_timeThe time at which the simulation starts.

Definition at line 61 of file CStochNextReactionMethod.cpp.

References CIndexedPriorityQueue::buildHeap(), C_FLOAT64, CIndexedPriorityQueue::clear(), CStochMethod::generateReactionTime(), CModel::getReactions(), CStochMethod::mpModel, mPQ, CIndexedPriorityQueue::pushPair(), and CCopasiVector< T >::size().

Referenced by initMethod().

62 {
63  C_FLOAT64 time;
64 
65  mPQ.clear();
66 
67  for (size_t i = 0; i < mpModel->getReactions().size(); i++)
68  {
69  time = start_time + generateReactionTime(i);
70  mPQ.pushPair(i, time);
71  }
72 
73  mPQ.buildHeap();
74 }
virtual size_t size() const
CModel * mpModel
Definition: CStochMethod.h:246
#define C_FLOAT64
Definition: copasi.h:92
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
C_FLOAT64 generateReactionTime()
size_t pushPair(const size_t index, const C_FLOAT64 key)
void CStochNextReactionMethod::updatePriorityQueue ( size_t  reaction_index,
C_FLOAT64  time 
)
private

Update the priority queue

Definition at line 76 of file CStochNextReactionMethod.cpp.

References C_FLOAT64, CStochMethod::generateReactionTime(), CDependencyGraph::getDependents(), CIndexedPriorityQueue::getKey(), CStochMethod::mAmu, CStochMethod::mAmuOld, CStochMethod::mDG, CStochMethod::mHasAssignments, CStochMethod::mNumReactions, mPQ, and CIndexedPriorityQueue::updateNode().

Referenced by doSingleStep().

77 {
78  //first the new time for the currently fired reaction
79  C_FLOAT64 new_time = time + generateReactionTime(reaction_index);
80  mPQ.updateNode(reaction_index, new_time);
81 
82  //now the updates for the other reactions (whose propensities may have changed)
83 
84  //if the model contains assignment we use a less efficient loop over all reactions since
85  // we do not know the exact dependencies
86  if (mHasAssignments)
87  {
88  size_t i;
89 
90  for (i = 0; i < mNumReactions; ++i)
91  {
92  if (i != reaction_index)
93  {
94  if (mAmu[i] == mAmuOld[i])
95  continue;
96 
97  C_FLOAT64 new_time;
98 
99  if (mAmuOld[i] > 0)
100  {
101  new_time = time + (mAmuOld[i] / mAmu[i]) * (mPQ.getKey(i) - time);
102  }
103  else
104  {
105  new_time = time + generateReactionTime(i);
106  }
107 
108  mPQ.updateNode(i, new_time);
109  }
110  }
111  }
112  else
113  {
114  const std::set<size_t> & dep_nodes = mDG.getDependents(reaction_index);
115  std::set<size_t>::const_iterator di;
116 
117  for (di = dep_nodes.begin(); di != dep_nodes.end(); ++di)
118  {
119  if (*di != reaction_index)
120  {
121  size_t index = *di;
122  C_FLOAT64 new_time;
123 
124  if (mAmuOld[index] > 0)
125  {
126  new_time = time + (mAmuOld[index] / mAmu[index]) * (mPQ.getKey(index) - time);
127  }
128  else
129  {
130  new_time = time + generateReactionTime(index);
131  }
132 
133  mPQ.updateNode(index, new_time);
134  }
135  }
136  }
137 }
std::vector< C_FLOAT64 > mAmu
Definition: CStochMethod.h:57
std::vector< C_FLOAT64 > mAmuOld
Definition: CStochMethod.h:67
const std::set< size_t > & getDependents(const size_t &node) const
CDependencyGraph mDG
Definition: CStochMethod.h:252
C_FLOAT64 getKey(const size_t index) const
size_t mNumReactions
Definition: CStochMethod.h:269
bool mHasAssignments
Definition: CStochMethod.h:79
void updateNode(const size_t index, const C_FLOAT64 key)
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 generateReactionTime()

Member Data Documentation

CIndexedPriorityQueue CStochNextReactionMethod::mPQ
private

The set of putative reactions and associated times at which each reaction occurs. This is represented as a priority queue, indexed on the reaction time.

Definition at line 38 of file CStochNextReactionMethod.h.

Referenced by doSingleStep(), setupPriorityQueue(), and updatePriorityQueue().


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