COPASI API  4.16.103
CTrajAdaptiveSA.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/trajectory/CTrajAdaptiveSA.h,v $
3 // $Revision: 1.2 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:34:14 $
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 #ifndef COPASI_CTrajAdaptiveSA
15 #define COPASI_CTrajAdaptiveSA
16 
17 //#define ANALYZ_HYBRID
18 
19 #include <set>
20 #include <vector>
21 
24 #include "copasi/model/CState.h"
25 
26 #define EPS 0.03
27 #define UPPER_LIMIT 20
28 #define SSA_MULTIPLE 10
29 #define SSA_UPPER_NUM 100
30 
31 class CModel;
32 class CMetab;
33 class CTrajectoryProblem;
34 class CRandom;
35 
37 {
38  friend CTrajectoryMethod *
40 
41 private:
43  {
44  public:
45  // Operations
46  /**
47  * Default constructor
48  */
50 
51  /**
52  * Copy constructor
53  * @param const CReactionDependencies & src
54  */
56 
57  /**
58  * Destructor
59  */
61 
62  /**
63  * Assignment operator
64  * @param const CReactionDependencies & rhs
65  * @return CReactionDependencies &
66  */
68 
69  // Attributes
70  /**
71  * Species Index
72  */
74 
75  /**
76  * Vector of multiplier to calculate the new state
77  */
79 
80  /**
81  * Vector of pointers to method internal species values to calculate the new state.
82  */
84 
85  /**
86  * Vector of pointers to model species values to calculate the new state.
87  */
89 
90  /**
91  * Vector of refresh methods which need to be executed to update all values required for simulation
92  */
93  std::vector< Refresh * > mCalculations;
94 
95  /**
96  * A vector of indexes of reaction which propensities have to be recalculated.
97  */
99 
100  /**
101  * Vector of multiplier to calculate the new propensity.
102  */
104 
105  /**
106  * Vector of pointers to method internal species values to calculate the new propensity.
107  */
109 
110  /**
111  * Vector of pointers to model species values to calculate the new propensity.
112  */
114 
115  /**
116  * A pointer to the particle flux of the reaction.
117  */
119  };
120 
121 protected:
122  /**
123  * Default constructor.
124  * @param const CCopasiContainer * pParent (default: NULL)
125  */
126  CTrajAdaptiveSA(const CCopasiContainer * pParent = NULL);
127 
128  /**
129  * Calculate the propensity of the indexed reaction
130  * @param const size_t & index
131  */
132  const C_FLOAT64 & calculateAmu(const size_t & index);
133 
134  /**
135  * Fire the next reaction if it fire before the endTime
136  * @param const C_FLOAT64 & curTime
137  * @param const C_FLOAT64 & endTime
138  * @return C_FLOAT64 timeAfterStep
139  */
140  C_FLOAT64 doSingleSSAStep(const C_FLOAT64 & curTime, const C_FLOAT64 & endTime);
141 
142  /**
143  * Fire the next reaction if it fire before the endTime
144  * @param const C_FLOAT64 & curTime
145  * @param const C_FLOAT64 & endTime
146  * @return C_FLOAT64 timeAfterStep
147  */
148  C_FLOAT64 doSingleTauLeapStep(const C_FLOAT64 & curTime, const C_FLOAT64 & endTime);
149 
150 public:
151  /**
152  * Copy constructor.
153  * @param const CTrajAdaptiveSA & src,
154  * @param const CCopasiContainer * pParent (Default: NULL)
155  */
156  CTrajAdaptiveSA(const CTrajAdaptiveSA & src,
157  const CCopasiContainer * pParent = NULL);
158 
159  /**
160  * Destructor.
161  */
163 
164  /**
165  * This methods must be called to elevate subgroups to
166  * derived objects. The default implementation does nothing.
167  * @return bool success
168  */
169  virtual bool elevateChildren();
170 
171  /**
172  * Chooses a stochastic method adequate for the problem
173  */
175 
176  /**
177  * This instructs the method to calculate a time step of deltaT
178  * starting with the current state, i.e., the result of the previous
179  * step.
180  * The new state (after deltaT) is expected in the current state.
181  * The return value is the actual timestep taken.
182  * @param "const double &" deltaT
183  * @return Status status
184  */
185  virtual Status step(const double & deltaT);
186 
187  /**
188  * This instructs the method to prepare for integration
189  * starting with the initialState given.
190  * @param "const CState *" initialState
191  */
192  virtual void start(const CState * initialState);
193 
194  /**
195  * Check if the method is suitable for this problem
196  * @return bool suitability of the method
197  */
198  virtual bool isValidProblem(const CCopasiProblem * pProblem);
199 
200 private:
201  /**
202  * Initialize the method parameter
203  */
204  void initializeParameter();
205 
206  /********************************************************************************************
207  The following variables are created for hybrid tauLeap method
208  ********************************************************************************************/
209  /**
210  * The tolerance ratio x(t+t')< eps*x(t)
211  */
213 
214  /**
215  * The counter to count the time of doing single SSA
216  */
218 
219  /**
220  * The upper fires of the j-th reactions
221  */
223 
224  /**
225  * The number of fires
226  */
229 
230  /**
231  * The mean and variance of species
232  */
235 
236  /**
237  * The species pointer for average, variance, and population (ordered)
238  */
239  // CVector< C_FLOAT64 * > mOrderedSpeciesMean;
240  // CVector< C_FLOAT64 * > mOrderedSpeciesVariance;
241  // CVector< C_FLOAT64 * > mOrderedSpecies;
243 
244  /**
245  * The temporary species
246  */
248 
249  /**
250  * Vector of refresh methods which need to be executed to update all values required for simulation
251  */
252  std::vector< Refresh * > mTauCalculations;
253 
254  /**
255  * The Ordered reaction
256  */
258 
259 #ifdef ANALYZ_HYBRID
260  /**
261  * Counters for statisitcs of hybrid method
262  */
263  C_INT32 SSAStepCnt, SLTStepCnt, HYDStepCnt;
264  C_FLOAT32 SSAStepTime, SLTStepTime, HYDStepTime;
265 #endif
266 
267 protected:
268 
269  /**
270  * The random number generator
271  */
273 
274  /**
275  * A pointer to the instance of CModel being used.
276  */
278 
279  /**
280  * The particle and reaction numbers
281  */
283 
284  /**
285  * max number of single stochastic steps to do in one step()
286  */
287  unsigned C_INT32 mMaxSteps;
288 
289  /**
290  * The time the next reaction fires
291  */
293 
294  /**
295  * The index of the next reaction which fires
296  */
298 
299  /**
300  * A boolean flag indicating whether correction for higher order reactions need to be applied
301  */
303 
304  /**
305  * Number of variable metabolites.
306  */
308 
309  /**
310  * A vector of reaction propensities
311  */
313 
314  /**
315  * The ordered propensity function
316  */
318 
319  /**
320  * The method internal state which contains particle rounded particle numbers.
321  */
323 
324  /**
325  * A vector containing dependency information to minimize the required updates.
326  */
327  std::vector< CReactionDependencies > mReactionDependencies;
328 
329  /**
330  * The Ordered reaction
331  */
333 
334  /**
335  * Total propensity (sum over mAmu[i])
336  */
338 
339  /**
340  * A boolean flag indicating whether the maximum steps have been reached. This
341  * is used to avoid multiple messages.
342  */
344 };
345 
346 #endif // COPASI_CTrajAdaptiveSA
CVector< size_t > mMaxReactionFiring
virtual bool elevateChildren()
size_t mNumReactionSpecies
std::vector< Refresh * > mCalculations
Definition: CState.h:305
CRandom * mpRandomGenerator
CVector< C_FLOAT64 * > mMethodSubstrates
size_t mFirstReactionSpeciesIndex
CVector< C_FLOAT64 > mAvgDX
#define C_INT32
Definition: copasi.h:90
CVector< const C_FLOAT64 * > mPartitionedAmu
Definition: CMetab.h:178
const C_FLOAT64 & calculateAmu(const size_t &index)
CVector< C_FLOAT64 > mReactionFiring
C_FLOAT64 mSSAStepCounter
CReactionDependencies & operator=(const CReactionDependencies &rhs)
CVector< C_FLOAT64 > mSpeciesAfterTau
std::vector< CReactionDependencies > mReactionDependencies
static CTrajAdaptiveSA * createTauLeapMethod()
C_FLOAT64 doSingleTauLeapStep(const C_FLOAT64 &curTime, const C_FLOAT64 &endTime)
std::vector< Refresh * > mTauCalculations
static CTrajectoryMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::deterministic)
unsigned C_INT32 mMaxSteps
virtual Status step(const double &deltaT)
CVector< C_FLOAT64 > mAmu
#define C_FLOAT64
Definition: copasi.h:92
Definition: CModel.h:50
virtual bool isValidProblem(const CCopasiProblem *pProblem)
CVector< const CReactionDependencies * > mPartitionedDependencies
C_FLOAT64 mNextReactionTime
virtual void start(const CState *initialState)
C_FLOAT64 doSingleSSAStep(const C_FLOAT64 &curTime, const C_FLOAT64 &endTime)
CVector< C_FLOAT64 > mSigDX
CTrajAdaptiveSA(const CCopasiContainer *pParent=NULL)
CVector< C_FLOAT64 * > mPartitionedReactionFiring
#define C_FLOAT32
Definition: copasi.h:93
C_FLOAT64 * mpMethodSpecies