COPASI API  4.16.103
CStochMethod.cpp
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2002 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifdef WIN32
16 # pragma warning (disable: 4786)
17 # pragma warning (disable: 4243)
18 // warning C4355: 'this' : used in base member initializer list
19 # pragma warning (disable: 4355)
20 #endif // WIN32
21 
22 #include <limits.h>
23 
24 #include <vector>
25 #include <numeric>
26 #include <limits>
27 #include <set>
28 
29 #include "copasi.h"
30 #include "CStochMethod.h"
31 #include "CStochDirectMethod.h"
34 #include "function/CFunction.h"
36 #include "CTrajectoryMethod.h"
37 #include "CTrajectoryProblem.h"
38 #include "model/CState.h"
39 #include "model/CCompartment.h"
40 #include "model/CModel.h"
41 
43 {
44  // Here several checks will be performed to validate the model
45  return 2; // suggest next reaction method
46 }
47 
49  CTrajectoryMethod(CCopasiMethod::stochastic, pParent)
50 {
53 }
54 
56  const CCopasiContainer * pParent):
57  CTrajectoryMethod(src, pParent)
58 {
61 }
62 
64 {
65  delete mpRandomGenerator;
66  mpRandomGenerator = NULL;
67 }
68 
70 {
71  CCopasiParameter *pParm;
72 
73  assertParameter("Max Internal Steps", CCopasiParameter::INT, (C_INT32) 1000000);
74  assertParameter("Subtype", CCopasiParameter::UINT, (unsigned C_INT32) 2);
75  assertParameter("Use Random Seed", CCopasiParameter::BOOL, false);
76  assertParameter("Random Seed", CCopasiParameter::UINT, (unsigned C_INT32) 1);
77 
78  // Check whether we have a method with the old parameter names
79  if ((pParm = getParameter("STOCH.MaxSteps")) != NULL)
80  {
81  setValue("Max Internal Steps", *pParm->getValue().pINT);
82  removeParameter("STOCH.MaxSteps");
83 
84  if ((pParm = getParameter("STOCH.Subtype")) != NULL)
85  {
86  setValue("Subtype", *pParm->getValue().pUINT);
87  removeParameter("STOCH.Subtype");
88  }
89 
90  if ((pParm = getParameter("STOCH.UseRandomSeed")) != NULL)
91  {
92  setValue("Use Random Seed", *pParm->getValue().pBOOL);
93  removeParameter("STOCH.UseRandomSeed");
94  }
95 
96  if ((pParm = getParameter("STOCH.RandomSeed")) != NULL)
97  {
98  setValue("Random Seed", *pParm->getValue().pUINT);
99  removeParameter("STOCH.RandomSeed");
100  }
101  }
102 }
103 
105 {
107  return true;
108 }
109 
111 {
112  // write the current state to the model:
113  //mpProblem->getModel()->setState(mpCurrentState); //?
114 
115  // check for possible overflows:
116  size_t i;
117  size_t imax;
118 
119  // :TODO: Bug 774: This assumes that the number of variable metabs is the number
120  // of metabs determined by reaction. In addition they are expected at the beginning of the
121  // MetabolitesX which is not the case if we have metabolites of type ODE.
122  for (i = 0, imax = mpProblem->getModel()->getNumVariableMetabs(); i < imax; i++)
123  if (mpProblem->getModel()->getMetabolitesX()[i]->getValue() >= mMaxIntBeforeStep)
124  {
125  CCopasiMessage(CCopasiMessage::EXCEPTION, "at least one particle number got to big.");
126  // TODO:throw exception or something like that
127  }
128 
129  // do several steps:
130  C_FLOAT64 time = mpCurrentState->getTime();
131  C_FLOAT64 endtime = time + deltaT;
132 
133  size_t Steps = 0;
134 
135  while (time < endtime)
136  {
137  time = doSingleStep(time, endtime);
138  mpCurrentState->setTime(time);
139 
140  if (++Steps > mMaxSteps)
141  {
143  }
144  }
145 
147  mpCurrentState->setTime(time);
148 
149  // get back the particle numbers:
150 
151  /* Set the variable Metabolites */
153 
154  for (i = 0, imax = mpProblem->getModel()->getNumVariableMetabs(); i < imax; i++, Dbl++)
155  *Dbl = mpProblem->getModel()->getMetabolitesX()[i]->getValue();
156 
157  return NORMAL;
158 }
159 
160 void CStochMethod::start(const CState * initialState)
161 {
162  /* get configuration data */
163  mMaxSteps = * getValue("Max Internal Steps").pINT;
164 
165  bool useRandomSeed = * getValue("Use Random Seed").pBOOL;
166  unsigned C_INT32 randomSeed = * getValue("Random Seed").pUINT;
167 
168  if (useRandomSeed) mpRandomGenerator->initialize(randomSeed);
169 
170  //mpCurrentState is initialized. This state is not used internally in the
171  //stochastic solver, but it is used for returning the result after each step.
172  *mpCurrentState = *initialState;
173 
175  assert(mpModel);
176 
178  mDoCorrection = true;
179  else
180  mDoCorrection = false;
181 
183 
184  size_t i;
185 
186  //initialize the vector of ints that contains the particle numbers
187  //for the discrete simulation. This also floors all particle numbers in the model.
188  mNumbers.resize(mpModel->getMetabolitesX().size());
189 
190  for (i = 0; i < mNumbers.size(); ++i)
191  {
192  mNumbers[i] = (C_INT64) mpModel->getMetabolitesX()[i]->getValue();
193  mpModel->getMetabolitesX()[i]->setValue((C_FLOAT64) mNumbers[i]);
194  mpModel->getMetabolitesX()[i]->refreshConcentration();
195  }
196 
198 
199  mpModel->updateSimulatedValues(false); //for assignments
200  //mpModel->updateNonSimulatedValues(); //for assignments
201 
203 
204  mAmu.clear(); mAmuOld.clear();
205 
206  for (i = 0; i < mNumReactions; i++)
207  {
208  mAmu.push_back(0);
209  mAmuOld.push_back(0);
210  }
211 
214 
215  // call init of the specific simulation method
217 
218  mMaxStepsReached = false;
219  return;
220 }
221 
223 {
224  //mA0Old = mA0;
225  mA0 = 0;
226 
227  for (size_t i = 0; i < mNumReactions; i++)
228  {
229  mAmuOld[i] = mAmu[i];
230  calculateAmu(i);
231  mA0 += mAmu[i];
232  }
233 
234  return 0;
235 }
236 
238 {
239  C_FLOAT64 rate_factor = mpModel->getReactions()[index]->calculateParticleFlux();
240 
241  if (rate_factor < 0.0)
242  {
243  // TODO CRITICAL Create a warning message
244  rate_factor = 0.0;
245  }
246 
247  if (!mDoCorrection)
248  {
249  mAmu[index] = rate_factor;
250  return 0;
251  }
252 
253  // We need the product of the cmu and hmu for this step.
254  // We calculate this in one go, as there are fewer steps to
255  // perform and we eliminate some possible rounding errors.
256  C_FLOAT64 amu = 1; // initially
257  //size_t total_substrates = 0;
258  C_INT32 num_ident = 0;
259  C_INT64 number = 0;
260  C_INT64 lower_bound;
261  // substrate_factor - The substrates, raised to their multiplicities,
262  // multiplied with one another. If there are, e.g. m substrates of type m,
263  // and n of type N, then substrate_factor = M^m * N^n.
264  C_FLOAT64 substrate_factor = 1;
265  // First, find the reaction associated with this index.
266  // Keep a pointer to this.
267  // Iterate through each substrate in the reaction
268  const std::vector<CStochBalance> & substrates = mLocalSubstrates[index];
269 
270  int flag = 0;
271 
272  for (size_t i = 0; i < substrates.size(); i++)
273  {
274  num_ident = substrates[i].mMultiplicity;
275 
276  if (num_ident > 1)
277  {
278  flag = 1;
279  number = mNumbers[substrates[i].mIndex];
280  lower_bound = number - num_ident;
281  substrate_factor = substrate_factor * pow((double) number, (int)(num_ident - 1)); //optimization
282 
283  number--; //optimization
284 
285  while (number > lower_bound)
286  {
287  amu *= number;
288  number--;
289  }
290  }
291  }
292 
293  if ((amu == 0) || (substrate_factor == 0)) // at least one substrate particle number is zero
294  {
295  mAmu[index] = 0;
296  return 0;
297  }
298 
299  // rate_factor is the rate function divided by substrate_factor.
300  // It would be more efficient if this was generated directly, since in effect we
301  // are multiplying and then dividing by the same thing (substrate_factor)!
302 
303  if (flag)
304  {
305  //cout << "Rate factor = " << rate_factor << endl;
306  amu *= rate_factor / substrate_factor;
307  mAmu[index] = amu;
308  }
309  else
310  {
311  mAmu[index] = rate_factor;
312  }
313 
314  return 0;
315 }
316 
318 {
319  // Change the particle numbers according to which step took place.
320  // First, get the vector of balances in the reaction we've got.
321  // (This vector expresses the number change of each metabolite
322  // in the reaction.) Then step through each balance, using its
323  // multiplicity to calculate a new value for the associated
324  // metabolite. Finally, update the metabolite.
325 
326  const std::vector<CStochBalance> & bals = mLocalBalances[rxn];
327 
328  std::vector<CStochBalance>::const_iterator bi;
329  CMetab* pTmpMetab;
330 
331  for (bi = bals.begin(); bi != bals.end(); bi++)
332  {
333  mNumbers[bi->mIndex] = mNumbers[bi->mIndex] + bi->mMultiplicity;
334  pTmpMetab = mpModel->getMetabolitesX()[bi->mIndex];
335  pTmpMetab->setValue((C_FLOAT64) mNumbers[bi->mIndex]);
336  pTmpMetab->refreshConcentration();
337  }
338 
339  if (mHasAssignments)
340  {
341  // this is less efficient but can deal with assignments.
342  //TODO: handle dependencies for assignments also.
343  mpModel->setTime(time);
345 
346  //now potentially species with assignments have non integer
347  //particle numbers. This needs to be rounded. Also the updated
348  //particle numbers need to be copied to the vector of integers.
349  //(the integer values may be used to calculate the propensities for
350  //higher order kinetics).
351  size_t i, imax = mNumbers.size();
352 
353  for (i = 0; i < imax; ++i)
354  {
355  if (mpModel->getMetabolitesX()[i]->getStatus() == CModelEntity::ASSIGNMENT)
356  {
357  mNumbers[i] = (C_INT64) mpModel->getMetabolitesX()[i]->getValue();
358  mpModel->getMetabolitesX()[i]->setValue((C_FLOAT64) mNumbers[i]);
359  mpModel->getMetabolitesX()[i]->refreshConcentration();
360  }
361  }
362 
363  //now the propensities can be updated
365  }
366  else
367  {
368  const std::set<size_t> & dep_nodes = mDG.getDependents(rxn);
369 
370  std::set<size_t>::const_iterator it;
371  size_t ii;
372 
373  for (it = dep_nodes.begin(); it != dep_nodes.end(); it++)
374  {
375  ii = *it;
376  mAmuOld[ii] = mAmu[ii];
377  calculateAmu(ii);
378  }
379 
380  //mA0Old = mA0;
381 
382  mA0 = 0;
383  mA0 = std::accumulate(mAmu.begin(), mAmu.end(), mA0);
384  }
385 
386  return 0;
387 }
388 
390 {
392  C_FLOAT64 sum = 0;
393  size_t index = 0;
394 
395  while (index < (mpModel->getReactions().size() - 1))
396  {
397  sum += mAmu[index] /* /mA0 */;
398 
399  if (rand1 <= sum)
400  {return index;}
401 
402  index++;
403  }
404 
405  return index;
406 }
407 
409 {
410  if (mA0 == 0) return std::numeric_limits<C_FLOAT64>::infinity();
411 
413  return - 1 * log(rand2) / mA0;
414 }
415 
417 {
418  if (mAmu[reaction_index] == 0) return std::numeric_limits<C_FLOAT64>::infinity();
419 
421  return - 1 * log(rand2) / mAmu[reaction_index];
422 }
423 
425 {
426  mDG.clear();
427  std::vector< std::set<std::string>* > DependsOn;
428  std::vector< std::set<std::string>* > Affects;
429  size_t i, j;
430  // Do for each reaction:
431 
432  for (i = 0; i < mNumReactions; i++)
433  {
434  // Get the set of metabolites which affect the value of amu for this
435  // reaction i.e. the set on which amu depends. This may be more than
436  // the set of substrates, since the kinetics can involve other
437  // reactants, e.g. catalysts. We thus need to step through the
438  // rate function and pick out every reactant which can vary.
439  DependsOn.push_back(getDependsOn(i));
440  // Get the set of metabolites which are affected when this reaction takes place
441  Affects.push_back(getAffects(i));
442  }
443 
444  // For each possible pair of reactions i and j, if the intersection of
445  // Affects(i) with DependsOn(j) is non-empty, add a dependency edge from i to j.
446  mDG.resize(mNumReactions);
447 
448  for (i = 0; i < mNumReactions; i++)
449  {
450  for (j = 0; j < mNumReactions; j++)
451  {
452  // Determine whether the intersection of these two sets is non-empty
453  // Could also do this with set_intersection generic algorithm, but that
454  // would require operator<() to be defined on the set elements.
455 
456  std::set<std::string>::iterator iter = Affects[i]->begin();
457 
458  for (; iter != Affects[i]->end(); iter++)
459  {
460  if (DependsOn[j]->count(*iter))
461  {
462  // The set intersection is non-empty
463  mDG.addDependent(i, j);
464  break;
465  }
466  }
467  }
468 
469  // Ensure that self edges are included
470  //mDG.addDependent(i, i);
471  }
472 
473  // Create local copy of balances and substrates list
474  CStochBalance bb;
475  C_INT32 maxBalance = 0;
476 
477  mLocalBalances.clear();
478  mLocalBalances.resize(mNumReactions);
479  mLocalSubstrates.clear();
480  mLocalSubstrates.resize(mNumReactions);
481 
482  for (i = 0; i < mNumReactions; i++)
483  {
484  const CCopasiVector<CChemEqElement> * bbb;
485 
486  bbb = &mpModel->getReactions()[i]->getChemEq().getBalances();
487 
488  //TODO clear old local balances and substrates
489  for (j = 0; j < bbb->size(); j++)
490  {
491  //bb.mIndex = mpModel->getMetabolites().getIndex((*bbb)[j]->getMetabolite().getObjectName(());
492  //bb.mIndex = mpModel->findMetabByKey((*bbb)[j]->getMetaboliteKey());
493  assert((*bbb)[j]->getMetabolite());
494  bb.mIndex = mpModel->getMetabolitesX().getIndex((*bbb)[j]->getMetabolite());
495  bb.mMultiplicity = static_cast<C_INT32>(floor((*bbb)[j]->getMultiplicity() + 0.5));
496 
497  if (((*bbb)[j]->getMetabolite()->getStatus()) != CModelEntity::FIXED)
498  {
499  if (bb.mMultiplicity > maxBalance) maxBalance = bb.mMultiplicity;
500 
501  mLocalBalances[i].push_back(bb);
502  }
503  }
504 
505  bbb = &mpModel->getReactions()[i]->getChemEq().getSubstrates();
506 
507  for (j = 0; j < bbb->size(); j++)
508  {
509  //bb.mIndex = mpModel->getMetabolites().getIndex((*bbb)[j]->getMetabolite().getObjectName(());
510  //bb.mIndex = mpModel->findMetabByKey((*bbb)[j]->getMetaboliteKey());
511  assert((*bbb)[j]->getMetabolite());
512  bb.mIndex = mpModel->getMetabolitesX().getIndex((*bbb)[j]->getMetabolite());
513  bb.mMultiplicity = static_cast<C_INT32>(floor((*bbb)[j]->getMultiplicity() + 0.5));
514 
515  if (1)
516  {
517  mLocalSubstrates[i].push_back(bb);
518  }
519  }
520  }
521 
522  mMaxBalance = maxBalance;
524 
525  // Delete the memory allocated in getDependsOn() and getAffects()
526  // since this is allocated in other functions.
527  for (i = 0; i < mNumReactions; i++)
528  {
529  delete DependsOn[i];
530  delete Affects[i];
531  }
532 }
533 
534 std::set<std::string> *CStochMethod::getDependsOn(size_t reaction_index)
535 {
536  std::set<std::string> *retset = new std::set<std::string>;
537 
538  size_t i, imax = mpModel->getReactions()[reaction_index]->getFunctionParameters().size();
539  size_t j, jmax;
540 
541  for (i = 0; i < imax; ++i)
542  {
543  if (mpModel->getReactions()[reaction_index]->getFunctionParameters()[i]->getUsage() == CFunctionParameter::PARAMETER)
544  continue;
545 
546  //metablist = mpModel->getReactions()[reaction_index]->getParameterMappingMetab(i);
547  const std::vector <std::string> & metabKeylist =
548  mpModel->getReactions()[reaction_index]->getParameterMappings()[i];
549  jmax = metabKeylist.size();
550 
551  for (j = 0; j < jmax; ++j)
552  {
553  retset->insert(metabKeylist[j]);
554  }
555  }
556 
557  return retset;
558 }
559 
560 std::set<std::string> *CStochMethod::getAffects(size_t reaction_index)
561 {
562  std::set<std::string> *retset = new std::set<std::string>;
563 
564  // Get the balances associated with the reaction at this index
565  // XXX We first get the chemical equation, then the balances, since the getBalances method in CReaction is unimplemented!
566  const CCopasiVector<CChemEqElement> & balances = mpModel->getReactions()[reaction_index]->getChemEq().getBalances();
567 
568  for (size_t i = 0; i < balances.size(); i++)
569  {
570  if (!balances[i]->getMetabolite()) continue;
571 
572  if (fabs(balances[i]->getMultiplicity()) >= 0.1)
573  if (balances[i]->getMetabolite()->getStatus() != CModelEntity::FIXED)
574  {
575  retset->insert(balances[i]->getMetabolite()->getKey());
576  }
577  }
578 
579  return retset;
580 }
581 
582 //virtual
584 {
585  if (!CTrajectoryMethod::isValidProblem(pProblem)) return false;
586 
587  const CTrajectoryProblem * pTP = dynamic_cast<const CTrajectoryProblem *>(pProblem);
588 
589  if (pTP->getDuration() < 0.0)
590  {
591  //back integration not possible
593  return false;
594  }
595 
596  if (pTP->getModel()->getTotSteps() < 1)
597  {
598  //at least one reaction necessary
600  return false;
601  }
602 
603  //check for rules
604  size_t i, imax = pTP->getModel()->getNumModelValues();
605 
606  for (i = 0; i < imax; ++i)
607  {
608  if (pTP->getModel()->getModelValues()[i]->getStatus() == CModelEntity::ODE)
609  {
610  //ode rule found
612  return false;
613  }
614  }
615 
616  imax = pTP->getModel()->getNumMetabs();
617 
618  for (i = 0; i < imax; ++i)
619  {
620  if (pTP->getModel()->getMetabolites()[i]->getStatus() == CModelEntity::ODE)
621  {
622  //ode rule found
624  return false;
625  }
626  }
627 
628  imax = pTP->getModel()->getCompartments().size();
629 
630  for (i = 0; i < imax; ++i)
631  {
632  if (pTP->getModel()->getCompartments()[i]->getStatus() == CModelEntity::ODE)
633  {
634  //ode rule found
636  return false;
637  }
638  }
639 
640  // if (modelHasAssignments(pTP->getModel()))
641  // {
642  // CCopasiMessage(CCopasiMessage::EXCEPTION, MCTrajectoryMethod + 19);
643  // return false;
644  //}
645  // this test is disabled since we have preliminary support for assignments
646 
647  //TODO: rewrite CModel::suitableForStochasticSimulation() to use
648  // CCopasiMessage
649  std::string message = pTP->getModel()->suitableForStochasticSimulation();
650 
651  if (message != "")
652  {
653  //model not suitable, message describes the problem
654  CCopasiMessage(CCopasiMessage::ERROR, message.c_str());
655  return false;
656  }
657 
658  if (* getValue("Max Internal Steps").pINT <= 0)
659  {
660  //max steps should be at least 1
662  return false;
663  }
664 
665  //events are not supported at the moment
666  if (pTP->getModel()->getEvents().size() > 0)
667  {
669  return false;
670  }
671 
672  return true;
673 }
674 
675 //static
677 {
678  size_t i, imax = pModel->getNumModelValues();
679 
680  for (i = 0; i < imax; ++i)
681  {
682  if (pModel->getModelValues()[i]->getStatus() == CModelEntity::ASSIGNMENT)
683  if (pModel->getModelValues()[i]->isUsed())
684  {
685  //used assignment found
686  return true;
687  }
688  }
689 
690  imax = pModel->getNumMetabs();
691 
692  for (i = 0; i < imax; ++i)
693  {
694  if (pModel->getMetabolites()[i]->getStatus() == CModelEntity::ASSIGNMENT)
695  if (pModel->getMetabolites()[i]->isUsed())
696  {
697  //used assignment found
698  return true;
699  }
700  }
701 
702  imax = pModel->getCompartments().size();
703 
704  for (i = 0; i < imax; ++i)
705  {
706  if (pModel->getCompartments()[i]->getStatus() == CModelEntity::ASSIGNMENT)
707  if (pModel->getCompartments()[i]->isUsed())
708  {
709  //used assignment found
710  return true;
711  }
712  }
713 
714  return false;
715 }
size_t generateReactionIndex()
bool mMaxStepsReached
Definition: CStochMethod.h:176
std::vector< C_FLOAT64 > mAmu
Definition: CStochMethod.h:57
virtual void initMethod(C_FLOAT64 start_time)=0
virtual C_FLOAT64 doSingleStep(C_FLOAT64 time, C_FLOAT64 endtime)=0
std::set< std::string > * getAffects(size_t reaction_index)
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
C_INT32 updatePropensities()
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
std::set< std::string > * getDependsOn(size_t reaction_index)
std::vector< std::vector< CStochBalance > > mLocalBalances
Definition: CStochMethod.h:257
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
virtual C_FLOAT64 getRandomOO()
Definition: CRandom.cpp:254
virtual size_t size() const
void addDependent(const size_t &node, const size_t &dependent)
std::vector< C_FLOAT64 > mAmuOld
Definition: CStochMethod.h:67
bool mDoCorrection
Definition: CStochMethod.h:72
size_t getNumMetabs() const
Definition: CModel.cpp:1118
void initializeParameter()
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
virtual bool elevateChildren()
CModel * mpModel
Definition: CStochMethod.h:246
Definition: CState.h:305
const std::set< size_t > & getDependents(const size_t &node) const
CTrajectoryProblem * mpProblem
virtual void setValue(const C_FLOAT64 &value)
size_t getIndex(const CModelEntity *entity) const
Definition: CState.cpp:231
#define C_INT64
Definition: copasi.h:88
std::vector< std::vector< CStochBalance > > mLocalSubstrates
Definition: CStochMethod.h:262
CDependencyGraph mDG
Definition: CStochMethod.h:252
#define C_UNUSED(p)
Definition: copasi.h:220
#define C_INT32
Definition: copasi.h:90
static C_INT32 checkModel(CModel *pmodel)
Definition: CMetab.h:178
virtual bool isValidProblem(const CCopasiProblem *pProblem)
void setTime(const C_FLOAT64 &time)
Definition: CState.cpp:326
size_t getTotSteps() const
Definition: CModel.cpp:1136
void resize(const size_t &n)
size_t mNumReactions
Definition: CStochMethod.h:269
bool removeParameter(const std::string &name)
#define MCTrajectoryMethod
static CRandom * createGenerator(CRandom::Type type=CRandom::mt19937, unsigned C_INT32 seed=0)
Definition: CRandom.cpp:49
size_t getNumVariableMetabs() const
Definition: CModel.cpp:1121
const C_FLOAT64 & getDuration() const
virtual const std::string & getKey() const
C_INT32 mMultiplicity
Definition: CStochMethod.h:42
bool mHasAssignments
Definition: CStochMethod.h:79
virtual void start(const CState *initialState)
const Value & getValue() const
bool setValue(const std::string &name, const CType &value)
unsigned C_INT32 * pUINT
CCopasiParameter * getParameter(const std::string &name)
C_INT32 updateSystemState(size_t reaction_index, const C_FLOAT64 &time)
long int flag
Definition: f2c.h:52
void setTime(const C_FLOAT64 &time)
Definition: CModel.cpp:1187
void refreshConcentration()
Definition: CMetab.cpp:281
size_t mMaxSteps
Definition: CStochMethod.h:164
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
const C_FLOAT64 & getTime() const
Definition: CState.cpp:325
CStochMethod(const CCopasiContainer *pParent=NULL)
virtual size_t getIndex(const CCopasiObject *pObject) const
#define C_FLOAT64
Definition: copasi.h:92
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
size_t getNumModelValues() const
Definition: CModel.cpp:1139
C_INT32 calculateAmu(size_t reaction_index)
const ModelType & getModelType() const
Definition: CModel.cpp:2339
C_INT64 mMaxIntBeforeStep
Definition: CStochMethod.h:174
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
void setupDependencyGraphAndBalances()
CCopasiParameter * assertParameter(const std::string &name, const CCopasiParameter::Type type, const CType &defaultValue)
Definition: CModel.h:50
const CState & getState() const
Definition: CModel.cpp:1771
CRandom * mpRandomGenerator
Definition: CStochMethod.h:241
C_FLOAT64 generateReactionTime()
const CCopasiVector< CMetab > & getMetabolitesX() const
Definition: CModel.cpp:1057
C_FLOAT64 mA0
Definition: CStochMethod.h:62
std::vector< C_INT64 > mNumbers
Definition: CStochMethod.h:267
std::string suitableForStochasticSimulation() const
Definition: CModel.cpp:3901
C_INT32 mMaxBalance
Definition: CStochMethod.h:169
virtual bool isValidProblem(const CCopasiProblem *pProblem)
CModel * getModel() const
virtual Status step(const double &deltaT)
C_FLOAT64 * beginIndependent()
Definition: CState.cpp:328
virtual void initialize(unsigned C_INT32 seed=CRandom::getSystemSeed())
Definition: CRandom.cpp:162
size_t mFirstMetabIndex
Definition: CStochMethod.h:274
static bool modelHasAssignments(const CModel *pModel)
#define max(a, b)
Definition: f2c.h:176