COPASI API  4.16.103
CStochDirectMethod.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/trajectory/CStochDirectMethod.h,v $
3 // $Revision: 1.18 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:34:13 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_CStochDirectMethod
24 #define COPASI_CStochDirectMethod
25 
26 #include <set>
27 #include <vector>
28 
32 #include "copasi/model/CState.h"
33 
34 class CModel;
35 class CMetab;
36 class CTrajectoryProblem;
37 class CRandom;
38 
40 {
41  friend CTrajectoryMethod *
43 
44 private:
46  {
47  public:
48  // Operations
49  /**
50  * Default constructor
51  */
53 
54  /**
55  * Copy constructor
56  * @param const CReactionDependencies & src
57  */
59 
60  /**
61  * Destructor
62  */
64 
65  /**
66  * Assignment operator
67  * @param const CReactionDependencies & rhs
68  * @return CReactionDependencies &
69  */
71 
72  // Attributes
73 
74  /**
75  * Vector of multiplier to calculate the new state
76  */
78 
79  /**
80  * Vector of pointers to method internal species values to calculate the new state.
81  */
83 
84  /**
85  * Vector of pointers to model species values to calculate the new state.
86  */
88 
89  /**
90  * Vector of refresh methods which need to be executed to update all values required for simulation
91  */
92  std::vector< Refresh * > mCalculations;
93 
94  /**
95  * A vector of indexes of reaction which propensities have to be recalculated.
96  */
98 
99  /**
100  * Vector of multiplier to calculate the new propensity.
101  */
103 
104  /**
105  * Vector of pointers to method internal species values to calculate the new propensity.
106  */
108 
109  /**
110  * Vector of pointers to model species values to calculate the new propensity.
111  */
113 
114  /**
115  * A pointer to the particle flux of the reaction.
116  */
118  };
119 
120 protected:
121  /**
122  * Default constructor.
123  * @param const CCopasiContainer * pParent (default: NULL)
124  */
125  CStochDirectMethod(const CCopasiContainer * pParent = NULL);
126 
127  /**
128  * Calculate the propensity of the indexed reaction
129  * @param const size_t & index
130  */
131  void calculateAmu(const size_t & index);
132 
133  /**
134  * Fire the next reaction if it fire before the endTime
135  * @param const C_FLOAT64 & curTime
136  * @param const C_FLOAT64 & endTime
137  * @return C_FLOAT64 timeAfterStep
138  */
139  C_FLOAT64 doSingleStep(const C_FLOAT64 & curTime, const C_FLOAT64 & endTime);
140 
141 public:
142  /**
143  * Copy constructor.
144  * @param const CStochDirectMethod & src,
145  * @param const CCopasiContainer * pParent (Default: NULL)
146  */
148  const CCopasiContainer * pParent = NULL);
149 
150  /**
151  * Destructor.
152  */
154 
155  /**
156  * This methods must be called to elevate subgroups to
157  * derived objects. The default implementation does nothing.
158  * @return bool success
159  */
160  virtual bool elevateChildren();
161 
162  /**
163  * This instructs the method to calculate a time step of deltaT
164  * starting with the current state, i.e., the result of the previous
165  * step.
166  * The new state (after deltaT) is expected in the current state.
167  * The return value is the actual timestep taken.
168  * @param "const double &" deltaT
169  * @return Status status
170  */
171  virtual Status step(const double & deltaT);
172 
173  /**
174  * This instructs the method to prepare for integration
175  * starting with the initialState given.
176  * @param "const CState *" initialState
177  */
178  virtual void start(const CState * initialState);
179 
180  /**
181  * Check if the method is suitable for this problem
182  * @return bool suitability of the method
183  */
184  virtual bool isValidProblem(const CCopasiProblem * pProblem);
185 
186 private:
187  /**
188  * Initialize the method parameter
189  */
190  void initializeParameter();
191 
192 protected:
193 
194  /**
195  * The random number generator
196  */
198 
199  /**
200  * A pointer to the instance of CModel being used.
201  */
203 
204  /**
205  * The particle and reaction numbers
206  */
208 
209  /**
210  * max number of single stochastic steps to do in one step()
211  */
212  unsigned C_INT32 mMaxSteps;
213 
214  /**
215  * The time the next reaction fires
216  */
218 
219  /**
220  * The index of the next reaction which fires
221  */
223 
224  /**
225  * A boolean flag indicating whether correction for higher order reactions need to be applied
226  */
228 
229  /**
230  * A vector of reaction propensities
231  */
233 
234  /**
235  * Total propensity (sum over mAmu[i])
236  */
238 
239  /**
240  * The method internal state which contains particle rounded particle numbers.
241  */
243 
244  /**
245  * A vector containing dependency information to minimize the required updates.
246  */
247  std::vector< CReactionDependencies > mReactionDependencies;
248 
249  /**
250  * A boolean flag indicating whether the maximum steps have been reached. This
251  * is used to avoid multiple messages.
252  */
254 };
255 
256 #endif // COPASI_CStochDirectMethod
virtual bool isValidProblem(const CCopasiProblem *pProblem)
CReactionDependencies & operator=(const CReactionDependencies &rhs)
void calculateAmu(const size_t &index)
CVector< C_FLOAT64 > mAmu
Definition: CState.h:305
std::vector< CReactionDependencies > mReactionDependencies
#define C_INT32
Definition: copasi.h:90
Definition: CMetab.h:178
virtual void start(const CState *initialState)
C_FLOAT64 doSingleStep(const C_FLOAT64 &curTime, const C_FLOAT64 &endTime)
unsigned C_INT32 mMaxSteps
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
CStochDirectMethod(const CCopasiContainer *pParent=NULL)
#define C_FLOAT64
Definition: copasi.h:92
virtual bool elevateChildren()
Definition: CModel.h:50
virtual Status step(const double &deltaT)