COPASI API  4.16.103
CMathContainer.cpp
Go to the documentation of this file.
1 // Copyright (C) 2011 - 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 #include "CMathContainer.h"
7 #include "CMathExpression.h"
8 
9 #include "model/CModel.h"
10 #include "model/CCompartment.h"
11 #include "model/CMetab.h"
12 #include "model/CModelValue.h"
13 #include "model/CObjectLists.h"
16 
18  CCopasiContainer("Math Container", NULL, "CMathContainer"),
19  mpModel(NULL),
20  mpAvogadro(NULL),
21  mpQuantity2NumberFactor(NULL),
22  mValues(),
23  mInitialExtensiveValues(),
24  mInitialIntensiveValues(),
25  mInitialExtensiveRates(),
26  mInitialIntensiveRates(),
27  mInitialParticleFluxes(),
28  mInitialFluxes(),
29  mInitialTotalMasses(),
30  mInitialEventTriggers(),
31  mExtensiveValues(),
32  mIntensiveValues(),
33  mExtensiveRates(),
34  mIntensiveRates(),
35  mParticleFluxes(),
36  mFluxes(),
37  mTotalMasses(),
38  mEventTriggers(),
39  mEventDelays(),
40  mEventPriorities(),
41  mEventAssignments(),
42  mEventRoots(),
43  mEventRootStates(),
44  mPropensities(),
45  mDependentMasses(),
46  mDiscontinuous(),
47  mFixedCount(0),
48  mEventTargetCount(0),
49  mODECount(0),
50  mIndependentCount(0),
51  mDependentCount(0),
52  mAssignmentCount(0),
53  mInitialState(),
54  mState(),
55  mStateReduced(),
56  mInitialDependencies(),
57  mTransientDependencies(),
58  mSynchronizeInitialValuesSequenceExtensive(),
59  mSynchronizeInitialValuesSequenceIntensive(),
60  mApplyInitialValuesSequence(),
61  mSimulationValuesSequence(),
62  mSimulationValuesSequenceReduced(),
63  mInitialStateValueExtensive(),
64  mInitialStateValueIntensive(),
65  mStateValues(),
66  mReducedStateValues(),
67  mSimulationRequiredValues(),
68  mObjects(),
69  mEvents(),
70  mReactions(),
71  mCreateDiscontinuousPointer(),
72  mDataObject2MathObject(),
73  mDataValue2MathObject(),
74  mDiscontinuityEvents("Discontinuities", this),
75  mDiscontinuityInfix2Object(),
76  mTriggerInfix2Event()
77 {}
78 
80  CCopasiContainer("Math Container", NULL, "CMathContainer"),
81  mpModel(&model),
82  mpAvogadro(NULL),
83  mpQuantity2NumberFactor(NULL),
84  mValues(),
85  mInitialExtensiveValues(),
86  mInitialIntensiveValues(),
87  mInitialExtensiveRates(),
88  mInitialIntensiveRates(),
89  mInitialParticleFluxes(),
90  mInitialFluxes(),
91  mInitialTotalMasses(),
92  mInitialEventTriggers(),
93  mExtensiveValues(),
94  mIntensiveValues(),
95  mExtensiveRates(),
96  mIntensiveRates(),
97  mParticleFluxes(),
98  mFluxes(),
99  mTotalMasses(),
100  mEventTriggers(),
101  mEventDelays(),
102  mEventPriorities(),
103  mEventAssignments(),
104  mEventRoots(),
105  mEventRootStates(),
106  mPropensities(),
107  mDependentMasses(),
108  mDiscontinuous(),
109  mFixedCount(0),
110  mEventTargetCount(0),
111  mODECount(0),
112  mIndependentCount(0),
113  mDependentCount(0),
114  mAssignmentCount(0),
115  mInitialState(),
116  mState(),
117  mStateReduced(),
118  mInitialDependencies(),
119  mTransientDependencies(),
120  mSynchronizeInitialValuesSequenceExtensive(),
121  mSynchronizeInitialValuesSequenceIntensive(),
122  mApplyInitialValuesSequence(),
123  mSimulationValuesSequence(),
124  mSimulationValuesSequenceReduced(),
125  mInitialStateValueExtensive(),
126  mInitialStateValueIntensive(),
127  mStateValues(),
128  mReducedStateValues(),
129  mSimulationRequiredValues(),
130  mObjects(),
131  mEvents(),
132  mReactions(),
133  mDataObject2MathObject(),
134  mDataValue2MathObject(),
135  mDiscontinuityEvents("Discontinuities", this),
136  mDiscontinuityInfix2Object(),
137  mTriggerInfix2Event()
138 {
139  // We do not want the model to know about the math container therefore we
140  // do not use &model in the constructor of CCopasiContainer
142 
143  mpAvogadro = mpModel->getObject(CCopasiObjectName("Reference=Avogadro Constant"));
144  mpQuantity2NumberFactor = mpModel->getObject(CCopasiObjectName("Reference=Quantity Conversion Factor"));
145 
146  init();
147 }
148 
150  CCopasiContainer(src, NULL),
151  mpModel(src.mpModel),
152  mpAvogadro(src.mpAvogadro),
153  mpQuantity2NumberFactor(src.mpQuantity2NumberFactor),
154  mValues(src.mValues),
155  mInitialExtensiveValues(),
156  mInitialIntensiveValues(),
157  mInitialExtensiveRates(),
158  mInitialIntensiveRates(),
159  mInitialParticleFluxes(),
160  mInitialFluxes(),
161  mInitialTotalMasses(),
162  mInitialEventTriggers(),
163  mExtensiveValues(),
164  mIntensiveValues(),
165  mExtensiveRates(),
166  mIntensiveRates(),
167  mParticleFluxes(),
168  mFluxes(),
169  mTotalMasses(),
170  mEventTriggers(),
171  mEventDelays(),
172  mEventPriorities(),
173  mEventAssignments(),
174  mEventRoots(),
175  mEventRootStates(),
176  mPropensities(),
177  mDependentMasses(),
178  mDiscontinuous(),
179  mFixedCount(src.mFixedCount),
180  mEventTargetCount(src.mEventTargetCount),
181  mODECount(src.mODECount),
182  mIndependentCount(src.mIndependentCount),
183  mDependentCount(src.mDependentCount),
184  mAssignmentCount(src.mAssignmentCount),
185  mInitialState(),
186  mState(),
187  mStateReduced(),
188  mInitialDependencies(),
189  mTransientDependencies(),
190  mSynchronizeInitialValuesSequenceExtensive(),
191  mSynchronizeInitialValuesSequenceIntensive(),
192  mApplyInitialValuesSequence(),
193  mSimulationValuesSequence(),
194  mSimulationValuesSequenceReduced(),
195  mInitialStateValueExtensive(),
196  mInitialStateValueIntensive(),
197  mStateValues(),
198  mReducedStateValues(),
199  mSimulationRequiredValues(),
200  mObjects(src.mObjects.size()),
201  mEvents(src.mEvents.size()),
202  mReactions(src.mReactions.size()),
203  mDataObject2MathObject(),
204  mDataValue2MathObject(),
205  mDiscontinuityEvents("Discontinuities", this),
206  mDiscontinuityInfix2Object(),
207  mTriggerInfix2Event()
208 {
209  // We do not want the model to know about the math container therefore we
210  // do not use &model in the constructor of CCopasiContainer
212 
213  // Determine the offsets
214  // We have to cast all pointers to size_t to avoid pointer overflow.
215  size_t ValueOffset = ((size_t) mValues.array()) - ((size_t) src.mValues.array());
216  size_t ObjectOffset = ((size_t) mObjects.array()) - ((size_t) src.mObjects.array());
217 
219  (C_FLOAT64 *)((size_t) src.mInitialExtensiveValues.array() + ValueOffset));
221  (C_FLOAT64 *)((size_t) src.mInitialIntensiveValues.array() + ValueOffset));
223  (C_FLOAT64 *)((size_t) src.mInitialExtensiveRates.array() + ValueOffset));
225  (C_FLOAT64 *)((size_t) src.mInitialIntensiveRates.array() + ValueOffset));
227  (C_FLOAT64 *)((size_t) src.mInitialParticleFluxes.array() + ValueOffset));
229  (C_FLOAT64 *)((size_t) src.mInitialFluxes.array() + ValueOffset));
231  (C_FLOAT64 *)((size_t) src.mInitialTotalMasses.array() + ValueOffset));
233  (C_FLOAT64 *)((size_t) src.mInitialEventTriggers.array() + ValueOffset));
234 
236  (C_FLOAT64 *)((size_t) src.mExtensiveValues.array() + ValueOffset));
238  (C_FLOAT64 *)((size_t) src.mIntensiveValues.array() + ValueOffset));
240  (C_FLOAT64 *)((size_t) src.mExtensiveRates.array() + ValueOffset));
242  (C_FLOAT64 *)((size_t) src.mIntensiveRates.array() + ValueOffset));
244  (C_FLOAT64 *)((size_t) src.mParticleFluxes.array() + ValueOffset));
246  (C_FLOAT64 *)((size_t) src.mFluxes.array() + ValueOffset));
248  (C_FLOAT64 *)((size_t) src.mTotalMasses.array() + ValueOffset));
250  (C_FLOAT64 *)((size_t) src.mEventTriggers.array() + ValueOffset));
251 
253  (C_FLOAT64 *)((size_t) src.mEventDelays.array() + ValueOffset));
255  (C_FLOAT64 *)((size_t) src.mEventPriorities.array() + ValueOffset));
257  (C_FLOAT64 *)((size_t) src.mEventAssignments.array() + ValueOffset));
259  (C_FLOAT64 *)((size_t) src.mEventRoots.array() + ValueOffset));
261  (C_FLOAT64 *)((size_t) src.mEventRootStates.array() + ValueOffset));
263  (C_FLOAT64 *)((size_t) src.mPropensities.array() + ValueOffset));
265  (C_FLOAT64 *)((size_t) src.mDependentMasses.array() + ValueOffset));
267  (C_FLOAT64 *)((size_t) src.mDiscontinuous.array() + ValueOffset));
268 
270  (C_FLOAT64 *)((size_t) src.mInitialState.array() + ValueOffset));
272  (C_FLOAT64 *)((size_t) src.mState.array() + ValueOffset));
274  (C_FLOAT64 *)((size_t) src.mStateReduced.array() + ValueOffset));
275 
276  // Update the mappings
277  std::map< CCopasiObject *, CMathObject * >::const_iterator itData = src.mDataObject2MathObject.begin();
278  std::map< CCopasiObject *, CMathObject * >::const_iterator endData = src.mDataObject2MathObject.end();
279 
280  for (; itData != endData; ++itData)
281  {
282  mDataObject2MathObject[itData->first] = (CMathObject *)(((size_t) itData->second) + ObjectOffset);
283  }
284 
285  std::map< C_FLOAT64 *, CMathObject * >::const_iterator itValue = src.mDataValue2MathObject.begin();
286  std::map< C_FLOAT64 *, CMathObject * >::const_iterator endValue = src.mDataValue2MathObject.end();
287 
288  for (; itValue != endValue; ++itValue)
289  {
290  mDataValue2MathObject[itValue->first] = (CMathObject *)(((size_t) itValue->second) + ObjectOffset);
291  }
292 
293  // Copy the objects
294  CMathObject * pObject = mObjects.array();
295  CMathObject * pObjectEnd = pObject + mObjects.size();
296  const CMathObject * pObjectSrc = src.mObjects.array();
297 
298  for (; pObject != pObjectEnd; ++pObject, ++pObjectSrc)
299  {
300  pObject->copy(*pObjectSrc, *this, ValueOffset, ObjectOffset);
301  }
302 
303  CMathEventN * pEvent = mEvents.array();
304  CMathEventN * pEventEnd = pEvent + mEvents.size();
305  const CMathEventN * pEventSrc = src.mEvents.array();
306 
307  for (; pEvent != pEventEnd; ++pEvent, ++pEventSrc)
308  {
309  pEvent->copy(*pEventSrc, *this, ValueOffset, ObjectOffset);
310  }
311 
312  CMathReaction * pReaction = mReactions.array();
313  CMathReaction * pReactionEnd = pReaction + mReactions.size();
314  const CMathReaction * pReactionSrc = src.mReactions.array();
315 
316  for (; pReaction != pReactionEnd; ++pReaction, ++pReactionSrc)
317  {
318  pReaction->copy(*pReactionSrc, *this, ValueOffset, ObjectOffset);
319  }
320 
322 }
323 
325 {}
326 
328 {
329  return mValues;
330 }
331 
333 {
334  return mValues;
335 }
336 
338 {
339  assert(mValues.size() == values.size());
340 
341  mValues = values;
342 }
343 
345 {
346  return mInitialState;
347 }
348 
350 {
351  return mInitialState;
352 }
353 
355 {
356  assert(mInitialState.size() == initialState.size());
357 
358  memcpy(mInitialState.array(), initialState.array(), mInitialState.size() * sizeof(C_FLOAT64));
359 }
360 
362 {
363  return mState;
364 }
365 
367 {
368  return mState;
369 }
370 
372 {
373  assert(mState.size() == state.size());
374 
375  memcpy(mState.array(), state.array(), mState.size() * sizeof(C_FLOAT64));
376 }
377 
379 {
380  return mStateReduced;
381 }
382 
384 {
385  return mStateReduced;
386 }
387 
389 {
390  assert(mStateReduced.size() == stateReduced.size());
391 
392  memcpy(mStateReduced.array(), stateReduced.array(), mStateReduced.size() * sizeof(C_FLOAT64));
393 }
394 
396 {
397  switch (framework)
398  {
401  break;
402 
405  break;
406  }
407 }
408 
410 {
411  C_FLOAT64 * pInitial = mInitialExtensiveValues.array();
412  C_FLOAT64 * pTransient = mExtensiveValues.array();
413 
414  memcpy(pTransient, pInitial, (pTransient - pInitial) * sizeof(C_FLOAT64));
415 
417 }
418 
419 void CMathContainer::updateSimulatedValues(const bool & useMoieties)
420 {
421  if (useMoieties)
422  {
424  }
425  else
426  {
428  }
429 }
430 
432 {
433  UpdateSequence::const_iterator it = updateSequence.begin();
434  UpdateSequence::const_iterator end = updateSequence.end();
435 
436  for (; it != end; ++it)
437  {
438  static_cast< CMathObject * >(*it)->calculate();
439  }
440 }
441 
443 {
444  C_FLOAT64 * pValue = mInitialState.array();
445  C_FLOAT64 * pValueEnd = pValue + mInitialState.size();
446  CMathObject * pObject = mObjects.array();
447 
448  for (; pValue != pValueEnd; ++pValue, ++pObject)
449  {
450  const CCopasiObject * pDataObject = pObject->getDataObject();
451 
452  if (pDataObject != NULL)
453  {
454  *pValue = *(C_FLOAT64 *)pDataObject->getValuePointer();
455  }
456  }
457 
458  return;
459 }
460 
462 {
463  C_FLOAT64 * pValue = mInitialState.array();
464  C_FLOAT64 * pValueEnd = pValue + mInitialState.size();
465  CMathObject * pObject = mObjects.array();
466 
467  for (; pValue != pValueEnd; ++pValue, ++pObject)
468  {
469  const CCopasiObject * pDataObject = pObject->getDataObject();
470 
471  if (pDataObject != NULL)
472  {
473  *(C_FLOAT64 *)pDataObject->getValuePointer() = *pValue;
474  }
475  }
476 
477  return;
478 }
479 
481 {
482  C_FLOAT64 * pValue = mState.array();
483  C_FLOAT64 * pValueEnd = pValue + mState.size();
484  CMathObject * pObject = mObjects.array();
485 
486  for (; pValue != pValueEnd; ++pValue, ++pObject)
487  {
488  const CCopasiObject * pDataObject = pObject->getDataObject();
489 
490  if (pDataObject != NULL)
491  {
492  *pValue = *(C_FLOAT64 *)pDataObject->getValuePointer();
493  }
494  }
495 
496  return;
497 }
498 
500 {
501  C_FLOAT64 * pValue = mState.array();
502  C_FLOAT64 * pValueEnd = pValue + mState.size();
503  CMathObject * pObject = mObjects.array();
504 
505  for (; pValue != pValueEnd; ++pValue, ++pObject)
506  {
507  const CCopasiObject * pDataObject = pObject->getDataObject();
508 
509  if (pDataObject != NULL)
510  {
511  *(C_FLOAT64 *)pDataObject->getValuePointer() = *pValue;
512  }
513  }
514 
515  return;
516 }
517 
518 // virtual
520 {
521  return mpModel->getCN();
522 }
523 
524 // virtual
526 {
527  std::vector< CCopasiContainer * > ListOfContainer;
528  ListOfContainer.push_back(mpModel);
529 
530  const CObjectInterface * pObject = NULL;
531  CCopasiObjectName ModelCN = mpModel->getCN();
532 
533  if (cn.getPrimary() != ModelCN.getPrimary())
534  {
535  pObject = mpModel->getObjectDataModel()->ObjectFromCN(ListOfContainer, ModelCN + "," + cn);
536  }
537  else
538  {
539  pObject = mpModel->getObjectDataModel()->ObjectFromCN(ListOfContainer, cn);
540  }
541 
542  const CMathObject * pMathObject = getMathObject(pObject);
543 
544  if (pMathObject != NULL)
545  {
546  return pMathObject;
547  }
548 
549  std::cout << "Data Object " << cn << " (0x" << pObject << ") has no corresponding Math Object." << std::endl;
550 
551  return pObject;
552 }
553 
555 {
556  if (pObject == NULL)
557  return NULL;
558 
559  std::map< CCopasiObject *, CMathObject * >::const_iterator found =
560  mDataObject2MathObject.find(const_cast<CCopasiObject*>(static_cast< const CCopasiObject * >(pObject)));
561 
562  if (found != mDataObject2MathObject.end())
563  {
564  return found->second;
565  }
566 
567  return NULL;
568 }
569 
571 {
572  if (pDataValue == NULL)
573  return NULL;
574 
575  // Check whether we point to a math value.
576  const C_FLOAT64 * pValues = mValues.array();
577 
578  if (pValues <= pDataValue && pDataValue < pValues + mValues.size())
579  {
580  return const_cast< CMathObject * >(mObjects.array() + (pDataValue - pValues));
581  }
582 
583  std::map< C_FLOAT64 *, CMathObject * >::const_iterator found =
584  mDataValue2MathObject.find(const_cast< C_FLOAT64 * >(pDataValue));
585 
586  if (found != mDataValue2MathObject.end())
587  {
588  return found->second;
589  }
590 
591  return NULL;
592 }
593 
595 {
596  return getMathObject(mpModel->getObject(cn));
597 }
598 
600 {
601  allocate();
602 
603  CMath::sPointers Pointers;
604  initializePointers(Pointers);
605 #ifdef COPASI_DEBUG
606  printPointers(Pointers);
607 #endif
608 
610 
611  initializeObjects(Pointers);
612  initializeEvents(Pointers);
613 
614  compileObjects();
615  compileEvents();
616 
617  // These are only used during initialization for setting up the tracking of
618  // discontinuities and are cleared afterwards.
621  mTriggerInfix2Event.clear();
622 
623  // TODO We may have unused event triggers and roots due to optimization
624  // in the discontinuities.
626 
628  CMathReaction * pReaction = mReactions.array();
629  CMathReaction * pReactionEnd = pReaction + mReactions.size();
631 
632  for (; pReaction != pReactionEnd; ++itReaction, ++pReaction)
633  {
634  pReaction->initialize(*itReaction, *this);
635  }
636 
638 
639 #ifdef COPASI_DEBUG
640  CMathObject *pObject = mObjects.array();
641  CMathObject *pObjectEnd = pObject + mObjects.size();
642 
643  for (; pObject != pObjectEnd; ++pObject)
644  {
645  std::cout << *pObject;
646  }
647 
648  std::cout << std::endl;
649 #endif // COPASI_DEBUG
650 }
651 
653 {
654  return *mpModel;
655 }
656 
658  const bool & replaceDiscontinuousNodes)
659 {
661 
662  return copyBranch(pSrc, Variables, replaceDiscontinuousNodes);
663 }
664 
666  const CMath::Variables< CEvaluationNode * > & variables,
667  const bool & replaceDiscontinuousNodes)
668 {
670  CEvaluationNode * pCopy = NULL;
671 
672  while (itNode.next() != itNode.end())
673  {
674  if (*itNode == NULL)
675  {
676  continue;
677  }
678 
679  // We need to replace variables, expand called trees, and handle discrete nodes.
680  switch ((int) itNode->getType())
681  {
682  // Handle object nodes which are of type CN
684  {
685  // We need to map the object to a math object if possible.
686  const CObjectInterface * pObject =
687  getObject(static_cast< const CEvaluationNodeObject *>(*itNode)->getObjectCN());
688 
689  // Create a converted node
690  pCopy = createNodeFromObject(pObject);
691  }
692  break;
693 
694  // Handle object nodes which are of type POINTER
696  {
697  const CObjectInterface * pObject =
698  getMathObject(static_cast< const CEvaluationNodeObject *>(*itNode)->getObjectValuePtr());
699 
700  // Create a converted node
701  pCopy = createNodeFromObject(pObject);
702  }
703  break;
704 
705  // Handle variables
707  {
708  size_t Index =
709  static_cast< const CEvaluationNodeVariable * >(*itNode)->getIndex();
710 
711  if (Index != C_INVALID_INDEX &&
712  Index < variables.size())
713  {
714  pCopy = variables[Index]->copyBranch();
715  }
716  else
717  {
719  }
720  }
721  break;
722 
723  // Handle call nodes
726  {
727  const CEvaluationNode * pCalledNode =
728  static_cast< const CEvaluationNodeCall * >(*itNode)->getCalledTree()->getRoot();
729 
730  pCopy = copyBranch(pCalledNode, itNode.context(), replaceDiscontinuousNodes);
731 
732  // The variables have been copied into place we need to delete them.
733  std::vector< CEvaluationNode * >::iterator it = itNode.context().begin();
734  std::vector< CEvaluationNode * >::iterator end = itNode.context().end();
735 
736  for (; it != end; ++it)
737  {
738  delete *it;
739  }
740  }
741  break;
742 
743  // Handle discrete nodes
748 
749  if (replaceDiscontinuousNodes)
750  {
751  // The node is replaced with a pointer to a math object value.
752  // The math object is calculated by an assignment with the target being the
753  // math object
754  pCopy = replaceDiscontinuousNode(*itNode, itNode.context());
755  }
756  else
757  {
758  pCopy = itNode->copyNode(itNode.context());
759  }
760 
761  break;
762 
763  default:
764  pCopy = itNode->copyNode(itNode.context());
765  break;
766  }
767 
768  if (itNode.parentContextPtr() != NULL)
769  {
770  itNode.parentContextPtr()->push_back(pCopy);
771  }
772  }
773 
774  // assert(pCopy != NULL);
775 
776  return pCopy;
777 }
778 
781  const std::vector< CEvaluationNode * > & children)
782 {
783  bool success = true;
784 
785  CEvaluationNode * pNode = pSrc->copyNode(children);
786  std::string DiscontinuityInfix = pNode->buildInfix();
787 
788  // Check whether we have the discontinuous node already created. This can happen if the
789  // discontinuity was part of an expression for a variable in a function call.
790  std::map< std::string, CMathObject * >::iterator itObject = mDiscontinuityInfix2Object.find(DiscontinuityInfix);
791 
792  if (itObject != mDiscontinuityInfix2Object.end())
793  {
794  // No need to copy we have already on object
795  CMathObject * pDiscontinuity = itObject->second;
796 
797  // We need to advance both creation pointer to assure that we have the correct allocation
800 
801  pdelete(pNode);
802 
803  // Return a pointer to a node pointing to the value of discontinuous object.
804  return new CEvaluationNodeObject((C_FLOAT64 *) pDiscontinuity->getValuePointer());
805  }
806 
807  // We have a new discontinuity
810 
811  // Map the discontinuity infix to the discontinuous object.
812  mDiscontinuityInfix2Object[DiscontinuityInfix] = pDiscontinuity;
813 
814  // Create the expression to calculate the discontinuous object
815  CMathExpression * pExpression = new CMathExpression("DiscontinuousExpression", *this);
816  success &= static_cast< CEvaluationTree * >(pExpression)->setRoot(pNode);
817  success &= pDiscontinuity->setExpressionPtr(pExpression);
818 
819  CMathEventN * pEvent = NULL;
820 
821  // Check whether we have already an event with the current trigger
822  std::string TriggerInfix = createDiscontinuityTriggerInfix(pNode);
823  std::map< std::string, CMathEventN * >::iterator itEvent = mTriggerInfix2Event.find(TriggerInfix);
824 
825  // We need to create an event.
826  if (itEvent == mTriggerInfix2Event.end())
827  {
829 
830  // Set the trigger
831  pEvent->setTriggerExpression(TriggerInfix, *this);
832 
833  // Map the trigger infix to the event.
834  mTriggerInfix2Event[TriggerInfix] = pEvent;
835  }
836  else
837  {
838  pEvent = itEvent->second;
839  }
840 
842 
843  // Add the current discontinuity as an assignment.
844  pEvent->addAssignment(pDiscontinuity, pDiscontinuity);
845 
846  // Return a pointer to a node pointing to the value of discontinuous object.
847  return new CEvaluationNodeObject((C_FLOAT64 *) pDiscontinuity->getValuePointer());
848 }
849 
851 {
852  size_t nLocalReactionParameters =
854  size_t nExtensiveValues = mpModel->getStateTemplate().size() + nLocalReactionParameters;
855  size_t nIntensiveValues = mpModel->getNumMetabs();
856 
857  size_t nReactions = mpModel->getReactions().size();
858  size_t nMoieties = mpModel->getMoieties().size();
859 
860  size_t nDiscontinuities = 0;
861  size_t nEvents = 0;
862  size_t nEventAssignments = 0;
863  size_t nEventRoots = 0;
864 
865  // Determine the space requirements for events.
866  // We need to create events for nodes which are capable of introducing
867  // discontinuous changes.
869  nDiscontinuities += mDiscontinuityEvents.size();
870  nEvents += nDiscontinuities;
871 
872  // User defined events
873  const CCopasiVector< CEvent > & Events = mpModel->getEvents();
875  CCopasiVector< CEvent >::const_iterator endEvent = Events.end();
876 
877  nEvents += Events.size();
878  mEvents.resize(nEvents);
879 
880  CMathEventN * pEvent = mEvents.array();
881 
882  for (; itEvent != endEvent; ++itEvent, ++pEvent)
883  {
884  CMathEventN::allocate(pEvent, *itEvent, *this);
885 
886  nEventRoots += pEvent->getTrigger().getRoots().size();
887  nEventAssignments += pEvent->getAssignments().size();
888  }
889 
890  itEvent = mDiscontinuityEvents.begin();
891  endEvent = mDiscontinuityEvents.end();
892 
893  for (; itEvent != endEvent; ++itEvent, ++pEvent)
894  {
895  CMathEventN::allocate(pEvent, *itEvent, *this);
896  nEventRoots += pEvent->getTrigger().getRoots().size();
897 
898  // We do not have to allocate an assignment as discontinuity object suffices
899  // as target and assignment expression.
900  }
901 
902  mValues.resize(4 * (nExtensiveValues + nIntensiveValues) +
903  5 * nReactions +
904  3 * nMoieties +
905  nDiscontinuities +
906  4 * nEvents + nEventAssignments + 2 * nEventRoots);
907  mValues = std::numeric_limits< C_FLOAT64 >::quiet_NaN();
908 
909  C_FLOAT64 * pArray = mValues.array();
910 
911  mInitialExtensiveValues = CVectorCore< C_FLOAT64 >(nExtensiveValues, pArray);
912  pArray += nExtensiveValues;
913  mInitialIntensiveValues = CVectorCore< C_FLOAT64 >(nIntensiveValues, pArray);
914  pArray += nIntensiveValues;
915  mInitialExtensiveRates = CVectorCore< C_FLOAT64 >(nExtensiveValues, pArray);
916  pArray += nExtensiveValues;
917  mInitialIntensiveRates = CVectorCore< C_FLOAT64 >(nIntensiveValues, pArray);
918  pArray += nIntensiveValues;
919  mInitialParticleFluxes = CVectorCore< C_FLOAT64 >(nReactions, pArray);
920  pArray += nReactions;
921  mInitialFluxes = CVectorCore< C_FLOAT64 >(nReactions, pArray);
922  pArray += nReactions;
923  mInitialTotalMasses = CVectorCore< C_FLOAT64 >(nMoieties, pArray);
924  pArray += nMoieties;
926  pArray += nEvents;
927 
928  mExtensiveValues = CVectorCore< C_FLOAT64 >(nExtensiveValues, pArray);
929  pArray += nExtensiveValues;
930  mIntensiveValues = CVectorCore< C_FLOAT64 >(nIntensiveValues, pArray);
931  pArray += nIntensiveValues;
932  mExtensiveRates = CVectorCore< C_FLOAT64 >(nExtensiveValues, pArray);
933  pArray += nExtensiveValues;
934  mIntensiveRates = CVectorCore< C_FLOAT64 >(nIntensiveValues, pArray);
935  pArray += nIntensiveValues;
936  mParticleFluxes = CVectorCore< C_FLOAT64 >(nReactions, pArray);
937  pArray += nReactions;
938  mFluxes = CVectorCore< C_FLOAT64 >(nReactions, pArray);
939  pArray += nReactions;
940  mTotalMasses = CVectorCore< C_FLOAT64 >(nMoieties, pArray);
941  pArray += nMoieties;
942  mEventTriggers = CVectorCore< C_FLOAT64 >(nEvents, pArray);
943  pArray += nEvents;
944 
945  mEventDelays = CVectorCore< C_FLOAT64 >(nEvents, pArray);
946  pArray += nEvents;
947  mEventPriorities = CVectorCore< C_FLOAT64 >(nEvents, pArray);
948  pArray += nEvents;
949  mEventAssignments = CVectorCore< C_FLOAT64 >(nEventAssignments, pArray);
950  pArray += nEventAssignments;
951  mEventRoots = CVectorCore< C_FLOAT64 >(nEventRoots, pArray);
952  pArray += nEventRoots;
953  mEventRootStates = CVectorCore< C_FLOAT64 >(nEventRoots, pArray);
954  pArray += nEventRoots;
955  mPropensities = CVectorCore< C_FLOAT64 >(nReactions, pArray);
956  pArray += nReactions;
957  mDependentMasses = CVectorCore< C_FLOAT64 >(nMoieties, pArray);
958  pArray += nMoieties;
959  mDiscontinuous = CVectorCore< C_FLOAT64 >(nDiscontinuities, pArray);
960  pArray += nDiscontinuities;
961 
962  assert(pArray == mValues.array() + mValues.size());
963 
965 
967  mValues.array());
972 }
973 
975 {
976  std::set< const CModelEntity * > EventTargets = CObjectLists::getEventTargets(mpModel);
977 
978  std::vector< const CModelEntity * > FixedEntities;
979  std::vector< const CModelEntity * > FixedEventTargetEntities;
980 
981  const CStateTemplate & StateTemplate = mpModel->getStateTemplate();
982 
983  // Determine which fixed entities are modified by events and which not.
984  CModelEntity *const* ppEntities = StateTemplate.beginFixed();
985  CModelEntity *const* ppEntitiesEnd = StateTemplate.endFixed();
986 
987  for (; ppEntities != ppEntitiesEnd; ++ppEntities)
988  {
989  if ((*ppEntities)->getStatus() == CModelEntity::ASSIGNMENT)
990  continue;
991 
992  if (EventTargets.find(*ppEntities) == EventTargets.end())
993  {
994  FixedEntities.push_back(*ppEntities);
995  }
996  else
997  {
998  FixedEventTargetEntities.push_back(*ppEntities);
999  }
1000  }
1001 
1002  // Process fixed entities which are not event targets.
1003  initializeMathObjects(FixedEntities, CMath::Fixed, p);
1004  mFixedCount = FixedEntities.size();
1005 
1006  // Process local reaction parameters
1007  std::vector<const CCopasiObject*> LocalReactionParameter =
1009  initializeMathObjects(LocalReactionParameter, p);
1010  mFixedCount += LocalReactionParameter.size();
1011 
1012  // Process fixed entities which are event targets.
1013  initializeMathObjects(FixedEventTargetEntities, CMath::EventTarget, p);
1014  mEventTargetCount = FixedEventTargetEntities.size();
1015 
1016  // The simulation time
1017  // Extensive Initial Value
1020  CMath::Value, CMath::Model, CMath::Time, false, true,
1022 
1023  // Extensive Value
1026  CMath::Value, CMath::Model, CMath::Time, false, false,
1028 
1029  // Initial Extensive Rate
1031  CMath::Rate, CMath::Model, CMath::Time, false, true,
1033  // Extensive Rate
1036  CMath::Rate, CMath::Model, CMath::Time, false, false,
1038 
1039  // Process entities which are determined by ODEs
1040  std::vector< const CModelEntity * > ODEEntities;
1041 
1042  ppEntities = StateTemplate.beginIndependent();
1043  ppEntitiesEnd = StateTemplate.endIndependent();
1044 
1045  for (; ppEntities != ppEntitiesEnd && (*ppEntities)->getStatus() == CModelEntity::ODE; ++ppEntities)
1046  {
1047  ODEEntities.push_back(*ppEntities);
1048  }
1049 
1050  initializeMathObjects(ODEEntities, CMath::ODE, p);
1051  mODECount = ODEEntities.size();
1052 
1053  // Process independent species
1054  std::vector< const CModelEntity * > IndependentSpecies;
1055 
1056  ppEntities = StateTemplate.beginIndependent();
1057  ppEntitiesEnd = StateTemplate.endIndependent();
1058 
1059  for (; ppEntities != ppEntitiesEnd; ++ppEntities)
1060  {
1061  if ((*ppEntities)->getStatus() != CModelEntity::REACTIONS)
1062  continue;
1063 
1064  IndependentSpecies.push_back(*ppEntities);
1065  }
1066 
1067  initializeMathObjects(IndependentSpecies, CMath::Independent, p);
1068  mIndependentCount = IndependentSpecies.size();
1069 
1070  // Process dependent species
1071  std::vector< const CModelEntity * > DependentSpecies;
1072 
1073  ppEntities = StateTemplate.beginDependent();
1074  ppEntitiesEnd = StateTemplate.endDependent();
1075 
1076  for (; ppEntities != ppEntitiesEnd && (*ppEntities)->getStatus() == CModelEntity::REACTIONS; ++ppEntities)
1077  {
1078  DependentSpecies.push_back(*ppEntities);
1079  }
1080 
1081  initializeMathObjects(DependentSpecies, CMath::Dependent, p);
1082  mDependentCount = DependentSpecies.size();
1083 
1084  // Process entities which are determined by assignments
1085  std::vector< const CModelEntity * > AssignmentEntities;
1086 
1087  // We continue with the pointer ppEntities
1088  ppEntitiesEnd = StateTemplate.endFixed();
1089 
1090  for (; ppEntities != ppEntitiesEnd && (*ppEntities)->getStatus() == CModelEntity::ASSIGNMENT; ++ppEntities)
1091  {
1092  AssignmentEntities.push_back(*ppEntities);
1093  }
1094 
1095  initializeMathObjects(AssignmentEntities, CMath::Assignment, p);
1096  mAssignmentCount = AssignmentEntities.size();
1097 
1098  // Process Reactions
1100 
1101  // Process Moieties
1103 
1104  // Process Discontinuous Objects
1105  size_t n, nDiscontinuous = mDiscontinuous.size();
1106 
1107  for (n = 0; n != nDiscontinuous; ++n)
1108  {
1111  false, false, NULL);
1112  }
1113 }
1114 
1116 {
1117  // Initialize events.
1118  CMathEventN * pEvent = mEvents.array();
1119  CMathEventN * pEventEnd = pEvent + mEvents.size();
1120 
1121  for (; pEvent != pEventEnd; ++pEvent)
1122  {
1123  pEvent->initialize(p);
1124  }
1125 
1126  return;
1127 }
1128 
1130 {
1131  bool success = true;
1132 
1133  CMathObject *pObject = mObjects.array();
1134  CMathObject *pObjectEnd = pObject + mObjects.size();
1135 
1136  for (; pObject != pObjectEnd; ++pObject)
1137  {
1138  success &= pObject->compile(*this);
1139  }
1140 
1141  return success;
1142 }
1143 
1145 {
1146  bool success = true;
1147 
1148  CMathEventN * pItEvent = mEvents.array();
1151 
1152  for (; itEvent != endEvent; ++pItEvent, ++itEvent)
1153  {
1154  success &= pItEvent->compile(*itEvent, *this);
1155  }
1156 
1157  // Events representing discontinuities are already compiled.
1158 
1159  return success;
1160 }
1161 
1163 {
1164  CEvaluationNode * pNode = NULL;
1165 
1166  if (pObject == NULL)
1167  {
1168  // We have an invalid value, i.e. NaN
1170  }
1171  else if (pObject == mpAvogadro ||
1172  pObject == mpQuantity2NumberFactor)
1173  {
1174  pNode = new CEvaluationNodeNumber(*(C_FLOAT64 *) pObject->getValuePointer());
1175  }
1176  else
1177  {
1178  pNode = new CEvaluationNodeObject((C_FLOAT64 *) pObject->getValuePointer());
1179  }
1180 
1181  return pNode;
1182 }
1183 
1185 {
1186  CEvaluationNode * pNode = NULL;
1187  CMathObject * pMathObject = NULL;
1188 
1189  if (pDataValue != NULL)
1190  {
1191  pMathObject = getMathObject(pDataValue);
1192 
1193  if (pMathObject != NULL)
1194  {
1195  pNode = new CEvaluationNodeObject((C_FLOAT64 *) pMathObject->getValuePointer());
1196  }
1197  else
1198  {
1199  // We must have a constant value like the conversion factor from the model.
1200  pNode = new CEvaluationNodeNumber(*pDataValue);
1201  }
1202  }
1203  else
1204  {
1205  // We have an invalid value, i.e. NaN
1207  }
1208 
1209  return pNode;
1210 }
1211 
1213 {
1214  CMathObject *pObject = mObjects.array();
1215  CMathObject *pObjectEnd = pObject + (mExtensiveValues.array() - mInitialExtensiveValues.array());
1216 
1217  for (; pObject != pObjectEnd; ++pObject)
1218  {
1220  }
1221 
1222  pObjectEnd = mObjects.array() + mObjects.size();
1223 
1224  for (; pObject != pObjectEnd; ++pObject)
1225  {
1227  }
1228 
1229 #ifdef COPASI_DEBUG_TRACE
1230  std::ofstream InitialDependencies("InitialDependencies.dot");
1231  mInitialDependencies.exportDOTFormat(InitialDependencies, "InitialDependencies");
1232 
1233  std::ofstream TransientDependencies("TransientDependencies.dot");
1234  mTransientDependencies.exportDOTFormat(TransientDependencies, "TransientDependencies");
1235 #endif // COPASI_DEBUG_TRACE
1236 
1240 
1241  return;
1242 }
1243 
1245 {
1246  // TODO CRITICAL Issue 1170: We need to add elements of the stoichiometry, reduced stoichiometry,
1247  // and link matrices.
1248 
1249  // Collect all the changed objects, which are all transient values
1252  const CMathObject * pObject = mObjects.array();
1253  const CMathObject * pObjectEnd = pObject + (mInitialExtensiveRates.array() - mValues.array());
1254 
1255  for (; pObject != pObjectEnd; ++pObject)
1256  {
1257  if (pObject->getEntityType() != CMath::Species)
1258  {
1259  mInitialStateValueExtensive.insert(pObject);
1260  mInitialStateValueIntensive.insert(pObject);
1261  }
1262  else if (pObject->isIntensiveProperty())
1263  {
1264  mInitialStateValueIntensive.insert(pObject);
1265  }
1266  else
1267  {
1268  mInitialStateValueExtensive.insert(pObject);
1269  }
1270  }
1271 
1272  // Collect all the requested objects
1273  CObjectInterface::ObjectSet RequestedExtensive;
1274  CObjectInterface::ObjectSet RequestedIntensive;
1275  pObject = mObjects.array();
1276 
1277  for (; pObject != pObjectEnd; ++pObject)
1278  {
1279  if (pObject->getEntityType() != CMath::Species)
1280  {
1281  continue;
1282  }
1283  else if (pObject->isIntensiveProperty())
1284  {
1285  RequestedExtensive.insert(pObject);
1286  }
1287  else
1288  {
1289  RequestedIntensive.insert(pObject);
1290  }
1291  }
1292 
1293  pObjectEnd = mObjects.array() + (mExtensiveValues.array() - mValues.array());
1294 
1295  for (; pObject != pObjectEnd; ++pObject)
1296  {
1297  RequestedExtensive.insert(pObject);
1298  RequestedIntensive.insert(pObject);
1299  }
1300 
1301  // Build the update sequence
1304  RequestedExtensive,
1308  RequestedIntensive,
1310 }
1311 
1313 {
1314  // Collect all the changed objects, which are all transient values
1316  const CMathObject * pObject = mObjects.array() + (mExtensiveValues.array() - mValues.array());
1317  const CMathObject * pObjectEnd = mObjects.array() + (mEventDelays.array() - mValues.array());
1318 
1319  for (; pObject != pObjectEnd; ++pObject)
1320  {
1321  Changed.insert(pObject);
1322  }
1323 
1324  // Collect all the requested objects
1325  CObjectInterface::ObjectSet Requested;
1326  pObjectEnd = mObjects.array() + mObjects.size();
1327 
1328  for (; pObject != pObjectEnd; ++pObject)
1329  {
1330  Requested.insert(pObject);
1331  }
1332 
1333  // Build the update sequence
1335 }
1336 
1338 {
1339  mStateValues.clear();
1340  mReducedStateValues.clear();
1341  mSimulationRequiredValues.clear();
1342 
1343  // Collect all the state objects, which are transient values of simulation type:
1344  // Time, ODE, Independent, and Dependent (not for reduced model)
1345 
1346  const CMathObject * pObject = mObjects.array() + (mExtensiveValues.array() - mValues.array());
1347  const CMathObject * pObjectEnd = mObjects.array() + (mExtensiveRates.array() - mValues.array());
1348 
1349  for (; pObject != pObjectEnd; ++pObject)
1350  {
1351  switch (pObject->getSimulationType())
1352  {
1353  case CMath::Time:
1354  case CMath::ODE:
1355  case CMath::Independent:
1356  mStateValues.insert(pObject);
1357  mReducedStateValues.insert(pObject);
1358  break;
1359 
1360  case CMath::Dependent:
1361  mStateValues.insert(pObject);
1362  break;
1363 
1364  default:
1365  break;
1366  }
1367  }
1368 
1369  // Collect all objects required for simulation, which are transient rates values of simulation type:
1370  // ODE, Independent, and Dependent (not needed for reduced model) and EventRoots
1371  // The additional cost for calculating the rates for dependent species is neglected.
1372  pObject = mObjects.array() + (mExtensiveRates.array() - mValues.array()) + mFixedCount + mEventTargetCount + 1 /* Time */;
1373  pObjectEnd = mObjects.array() + (mIntensiveRates.array() - mValues.array());
1374 
1375  for (; pObject != pObjectEnd; ++pObject)
1376  {
1377  mSimulationRequiredValues.insert(pObject);
1378  }
1379 
1380  pObject = mObjects.array() + (mEventRoots.array() - mValues.array());
1381  pObjectEnd = mObjects.array() + (mEventRootStates.array() - mValues.array());
1382 
1383  for (; pObject != pObjectEnd; ++pObject)
1384  {
1385  mSimulationRequiredValues.insert(pObject);
1386  }
1387 
1388  // Build the update sequence
1391 }
1392 
1394 {
1403 
1409  p.pFluxes = mFluxes.array();
1412 
1421 
1422  C_FLOAT64 * pValues = mValues.array();
1423  CMathObject * pObjects = mObjects.array();
1424 
1425  p.pInitialExtensiveValuesObject = pObjects + (p.pInitialExtensiveValues - pValues);
1426  p.pInitialIntensiveValuesObject = pObjects + (p.pInitialIntensiveValues - pValues);
1427  p.pInitialExtensiveRatesObject = pObjects + (p.pInitialExtensiveRates - pValues);
1428  p.pInitialIntensiveRatesObject = pObjects + (p.pInitialIntensiveRates - pValues);
1429  p.pInitialParticleFluxesObject = pObjects + (p.pInitialParticleFluxes - pValues);
1430  p.pInitialFluxesObject = pObjects + (p.pInitialFluxes - pValues);
1431  p.pInitialTotalMassesObject = pObjects + (p.pInitialTotalMasses - pValues);
1432  p.pInitialEventTriggersObject = pObjects + (p.pInitialEventTriggers - pValues);
1433 
1434  p.pExtensiveValuesObject = pObjects + (p.pExtensiveValues - pValues);
1435  p.pIntensiveValuesObject = pObjects + (p.pIntensiveValues - pValues);
1436  p.pExtensiveRatesObject = pObjects + (p.pExtensiveRates - pValues);
1437  p.pIntensiveRatesObject = pObjects + (p.pIntensiveRates - pValues);
1438  p.pParticleFluxesObject = pObjects + (p.pParticleFluxes - pValues);
1439  p.pFluxesObject = pObjects + (p.pFluxes - pValues);
1440  p.pTotalMassesObject = pObjects + (p.pTotalMasses - pValues);
1441  p.pEventTriggersObject = pObjects + (p.pEventTriggers - pValues);
1442 
1443  p.pEventDelaysObject = pObjects + (p.pEventDelays - pValues);
1444  p.pEventPrioritiesObject = pObjects + (p.pEventPriorities - pValues);
1445  p.pEventAssignmentsObject = pObjects + (p.pEventAssignments - pValues);
1446  p.pEventRootsObject = pObjects + (p.pEventRoots - pValues);
1447  p.pEventRootStatesObject = pObjects + (p.pEventRootStates - pValues);
1448  p.pPropensitiesObject = pObjects + (p.pPropensities - pValues);
1449  p.pDependentMassesObject = pObjects + (p.pDependentMasses - pValues);
1450  p.pDiscontinuousObject = pObjects + (p.pDiscontinuous - pValues);
1451 }
1452 
1453 #ifdef COPASI_DEBUG
1454 void CMathContainer::printPointers(CMath::sPointers & p)
1455 {
1456  size_t Index;
1457  std::cout << "Values:" << std::endl;
1459  std::cout << " mInitialExtensiveValues:[" << Index << "]" << ((mInitialExtensiveValues.size() <= Index) ? " Error" : "") << std::endl;
1461  std::cout << " mInitialIntensiveValues:[" << Index << "]" << ((mInitialIntensiveValues.size() <= Index) ? " Error" : "") << std::endl;
1463  std::cout << " mInitialExtensiveRates:[" << Index << "]" << ((mInitialExtensiveRates.size() <= Index) ? " Error" : "") << std::endl;
1465  std::cout << " mInitialIntensiveRates:[" << Index << "]" << ((mInitialIntensiveRates.size() <= Index) ? " Error" : "") << std::endl;
1467  std::cout << " mInitialParticleFluxes:[" << Index << "]" << ((mInitialParticleFluxes.size() <= Index) ? " Error" : "") << std::endl;
1468  Index = p.pInitialFluxes - mInitialFluxes.array();
1469  std::cout << " mInitialFluxes:[" << Index << "]" << ((mInitialFluxes.size() <= Index) ? " Error" : "") << std::endl;
1471  std::cout << " mInitialTotalMasses:[" << Index << "]" << ((mInitialTotalMasses.size() <= Index) ? " Error" : "") << std::endl;
1473  std::cout << " mInitialEventTriggers:[" << Index << "]" << ((mInitialEventTriggers.size() <= Index) ? " Error" : "") << std::endl;
1474 
1475  Index = p.pExtensiveValues - mExtensiveValues.array();
1476  std::cout << " mExtensiveValues:[" << Index << "]" << ((mExtensiveValues.size() <= Index) ? " Error" : "") << std::endl;
1477  Index = p.pIntensiveValues - mIntensiveValues.array();
1478  std::cout << " mIntensiveValues:[" << Index << "]" << ((mIntensiveValues.size() <= Index) ? " Error" : "") << std::endl;
1479  Index = p.pExtensiveRates - mExtensiveRates.array();
1480  std::cout << " mExtensiveRates:[" << Index << "]" << ((mExtensiveRates.size() <= Index) ? " Error" : "") << std::endl;
1481  Index = p.pIntensiveRates - mIntensiveRates.array();
1482  std::cout << " mIntensiveRates:[" << Index << "]" << ((mIntensiveRates.size() <= Index) ? " Error" : "") << std::endl;
1483  Index = p.pParticleFluxes - mParticleFluxes.array();
1484  std::cout << " mParticleFluxes:[" << Index << "]" << ((mParticleFluxes.size() <= Index) ? " Error" : "") << std::endl;
1485  Index = p.pFluxes - mFluxes.array();
1486  std::cout << " mFluxes:[" << Index << "]" << ((mFluxes.size() <= Index) ? " Error" : "") << std::endl;
1487  Index = p.pTotalMasses - mTotalMasses.array();
1488  std::cout << " mTotalMasses:[" << Index << "]" << ((mTotalMasses.size() <= Index) ? " Error" : "") << std::endl;
1489  Index = p.pEventTriggers - mEventTriggers.array();
1490  std::cout << " mEventTriggers:[" << Index << "]" << ((mEventTriggers.size() <= Index) ? " Error" : "") << std::endl;
1491 
1492  Index = p.pEventDelays - mEventDelays.array();
1493  std::cout << " mEventDelays:[" << Index << "]" << ((mEventDelays.size() <= Index) ? " Error" : "") << std::endl;
1494  Index = p.pEventPriorities - mEventPriorities.array();
1495  std::cout << " mEventPriorities:[" << Index << "]" << ((mEventPriorities.size() <= Index) ? " Error" : "") << std::endl;
1497  std::cout << " mEventAssignments:[" << Index << "]" << ((mEventAssignments.size() <= Index) ? " Error" : "") << std::endl;
1498  Index = p.pEventRoots - mEventRoots.array();
1499  std::cout << " mEventRoots:[" << Index << "]" << ((mEventRoots.size() <= Index) ? " Error" : "") << std::endl;
1500  Index = p.pEventRootStates - mEventRootStates.array();
1501  std::cout << " mEventRootStates:[" << Index << "]" << ((mEventRootStates.size() <= Index) ? " Error" : "") << std::endl;
1502  Index = p.pPropensities - mPropensities.array();
1503  std::cout << " mPropensities:[" << Index << "]" << ((mPropensities.size() <= Index) ? " Error" : "") << std::endl;
1504  Index = p.pDependentMasses - mDependentMasses.array();
1505  std::cout << " mDependentMasses:[" << Index << "]" << ((mDependentMasses.size() <= Index) ? " Error" : "") << std::endl;
1506  Index = p.pDiscontinuous - mDiscontinuous.array();
1507  std::cout << " mDiscontinuous:[" << Index << "]" << ((mDiscontinuous.size() <= Index) ? " Error" : "") << std::endl;
1508  std::cout << std::endl;
1509 }
1510 #endif // COAPSI_DEBUG
1511 
1513 {
1514  C_FLOAT64 * pValues = mValues.array();
1515  CMathObject * pObjects = mObjects.array();
1516 
1517  size_t nDiscontinuous = mDiscontinuous.size();
1518  size_t nEvents = mEvents.size() - nDiscontinuous;
1519 
1522 
1523  /*
1524  mCreateDiscontinuousPointer.pEventDelay = pObjects + (mEventDelays.array() - pValues) + nEvents;
1525  mCreateDiscontinuousPointer.pEventPriority = pObjects + (mEventPriorities.array() - pValues) + nEvents;
1526  mCreateDiscontinuousPointer.pEventAssignment = pObjects + (mEventAssignments.array() - pValues) + nEventAssignments;
1527  mCreateDiscontinuousPointer.pEventTrigger = pObjects + (mEventTriggers.array() - pValues) + nEvents;
1528  mCreateDiscontinuousPointer.pEventRoot = pObjects + (mEventRoots.array() - pValues) + nEventRoots;
1529  */
1530 }
1531 
1532 // static
1534 {
1535  const CMetab * pSpecies = dynamic_cast< const CMetab * >(pEntity);
1536 
1537  if (pSpecies != NULL)
1538  {
1539  return CMath::Species;
1540  }
1541  else if (dynamic_cast< const CCompartment * >(pEntity) != NULL)
1542  {
1543  return CMath::Compartment;
1544  }
1545  else if (dynamic_cast< const CModelValue * >(pEntity) != NULL)
1546  {
1547  return CMath::GlobalQuantity;
1548  }
1549 
1551 }
1552 
1553 void CMathContainer::initializeMathObjects(const std::vector<const CModelEntity*> & entities,
1554  const CMath::SimulationType & simulationType,
1555  CMath::sPointers & p)
1556 {
1557  // Process entities.
1558  std::vector<const CModelEntity*>::const_iterator it = entities.begin();
1559  std::vector<const CModelEntity*>::const_iterator end = entities.end();
1560 
1561  CMath::EntityType EntityType;
1562 
1563  for (; it != end; ++it)
1564  {
1565  EntityType = getEntityType(*it);
1566 
1567  // Extensive Initial Value
1568 
1569  // The simulation type for initial values is either CMath::Assignment or CMath::Fixed
1570  // We must check whether the initial value must be calculated, i.e., whether it has
1571  // dependencies or not. In case of species it always possible that is must be calculated.
1572 
1573  CMath::SimulationType SimulationType = CMath::Fixed;
1574  CCopasiObject * pObject = (*it)->getInitialValueReference();
1575 
1576  if (EntityType == CMath::Species)
1577  {
1578  SimulationType = CMath::Conversion;
1579  }
1580  else if ((simulationType == CMath::Assignment && (*it)->getExpression() != "") ||
1581  (*it)->getInitialExpression() != "")
1582  {
1583  SimulationType = CMath::Assignment;
1584  }
1585 
1586  map(pObject, p.pInitialExtensiveValuesObject);
1588  CMath::Value, EntityType, SimulationType, false, true,
1589  pObject);
1590 
1591  // Extensive Value
1592  SimulationType = simulationType;
1593 
1594  if (EntityType == CMath::Species &&
1595  (simulationType == CMath::EventTarget ||
1596  simulationType == CMath::Assignment))
1597  {
1598  SimulationType = CMath::Conversion;
1599  }
1600 
1601  map((*it)->getValueReference(), p.pExtensiveValuesObject);
1603  CMath::Value, EntityType, SimulationType, false, false,
1604  (*it)->getValueReference());
1605 
1606  // Initial Extensive Rate
1607  SimulationType = simulationType;
1608 
1609  if (simulationType == CMath::EventTarget)
1610  {
1611  SimulationType = CMath::Fixed;
1612  }
1613 
1615  CMath::Rate, EntityType, SimulationType, false, true,
1616  (*it)->getRateReference());
1617 
1618  // Extensive Rate
1619  map((*it)->getRateReference(), p.pExtensiveRatesObject);
1621  CMath::Rate, EntityType, SimulationType, false, false,
1622  (*it)->getRateReference());
1623 
1624  // Species have intensive values in addition to the extensive ones.
1625  if (EntityType == CMath::Species)
1626  {
1627  const CMetab *pSpecies = static_cast<const CMetab*>(*it);
1628 
1629  // Intensive Initial Value
1630 
1631  // The simulation type for initial values is either CMath::Assignment or CMath::Conversion
1632  // In case of species it always possible that is must be calculated.
1633  SimulationType = CMath::Conversion;
1634 
1635  if (simulationType == CMath::Assignment)
1636  {
1637  SimulationType = CMath::Assignment;
1638  }
1639 
1642  CMath::Value, CMath::Species, SimulationType, true, true,
1643  pSpecies->getInitialConcentrationReference());
1644 
1645  // Intensive Value
1646  SimulationType = CMath::Conversion;
1647 
1648  if (simulationType == CMath::EventTarget ||
1649  simulationType == CMath::Assignment)
1650  {
1651  SimulationType = simulationType;
1652  }
1653 
1656  CMath::Value, CMath::Species, SimulationType, true, false,
1657  pSpecies->getConcentrationReference());
1658 
1659  // Initial Intensive Rate
1662  pSpecies->getConcentrationRateReference());
1663 
1664  // Intensive Rate
1668  pSpecies->getConcentrationRateReference());
1669  }
1670  }
1671 }
1672 
1673 void CMathContainer::initializeMathObjects(const std::vector<const CCopasiObject *> & parameters,
1674  CMath::sPointers & p)
1675 {
1676  // Process parameters.
1677  std::vector<const CCopasiObject *>::const_iterator it = parameters.begin();
1678  std::vector<const CCopasiObject *>::const_iterator end = parameters.end();
1679 
1680  for (; it != end; ++it)
1681  {
1682  // Extensive Initial Value
1683  map(const_cast< CCopasiObject * >(*it), p.pInitialExtensiveValuesObject);
1686  *it);
1687 
1688  // Extensive Value
1691  NULL);
1692 
1693  // Initial Extensive Rate
1696  NULL);
1697 
1698  // Extensive Rate
1701  NULL);
1702  }
1703 }
1704 
1706  CMath::sPointers & p)
1707 {
1708  // Process reactions.
1711 
1712  for (; it != end; ++it)
1713  {
1714  // Initial Particle Flux
1717  (*it)->getParticleFluxReference());
1718 
1719  // Particle Flux
1720  map((*it)->getParticleFluxReference(), p.pParticleFluxesObject);
1723  (*it)->getParticleFluxReference());
1724 
1725  // Initial Flux
1728  (*it)->getFluxReference());
1729 
1730  // Flux
1731  map((*it)->getFluxReference(), p.pFluxesObject);
1734  (*it)->getFluxReference());
1735 
1736  // Propensity
1737  map((*it)->getPropensityReference(), p.pPropensitiesObject);
1740  (*it)->getPropensityReference());
1741  }
1742 }
1743 
1745  CMath::sPointers & p)
1746 {
1747  // Process reactions.
1750 
1751  for (; it != end; ++it)
1752  {
1753  // Initial Total Mass
1756  (*it)->getTotalNumberReference());
1757 
1758  // Total Mass
1759  map((*it)->getTotalNumberReference(), p.pTotalMassesObject);
1762  (*it)->getTotalNumberReference());
1763 
1764  // Dependent
1765  map((*it)->getDependentNumberReference(), p.pDependentMassesObject);
1768  (*it)->getDependentNumberReference());
1769  }
1770 }
1771 
1772 // static
1774 {
1775  const CCopasiObject::DataObjectSet & Dependencies = pObject->getDirectDependencies();
1776 
1777  if (Dependencies.find(pObject->getObjectParent()) != Dependencies.end())
1778  {
1779  return Dependencies.size() > 1;
1780  }
1781 
1782  return Dependencies.size() > 0;
1783 }
1784 
1785 void CMathContainer::map(CCopasiObject * pDataObject, CMathObject * pMathObject)
1786 {
1787  if (pDataObject != NULL)
1788  {
1789  mDataObject2MathObject[pDataObject] = pMathObject;
1790  mDataValue2MathObject[(C_FLOAT64 *) pDataObject->getValuePointer()] = pMathObject;
1791  }
1792 }
1793 
1795 {
1796  assert(mValues.array() <= pValue && pValue < mValues.array() + mValues.size());
1797 
1798  const C_FLOAT64 * pInitialValue = pValue;
1799 
1800  if (mExtensiveValues.array() <= pValue && pValue < mEventDelays.array())
1801  {
1802  pInitialValue = mInitialExtensiveValues.array() + (pValue - mExtensiveValues.array());
1803  }
1804 
1805  return const_cast< C_FLOAT64 * >(pInitialValue);
1806 }
1807 
1809 {
1811  //size_t i, imax;
1812 
1813  // We need to create events for nodes which are capable of introducing
1814  // discontinuous changes.
1815 
1816  // Retrieve expression trees which contain discontinuities.
1817  std::vector< const CEvaluationTree * > TreesWithDiscontinuities = mpModel->getTreesWithDiscontinuities();
1818  std::vector< const CEvaluationTree * >::const_iterator it = TreesWithDiscontinuities.begin();
1819  std::vector< const CEvaluationTree * >::const_iterator end = TreesWithDiscontinuities.end();
1820 
1821  for (; it != end; ++it)
1822  {
1824  }
1825 }
1826 
1828 {
1831 
1832  while (itNode.next() != itNode.end())
1833  {
1834  if (*itNode == NULL)
1835  {
1836  continue;
1837  }
1838 
1839  switch ((int) itNode->getType())
1840  {
1846  break;
1847 
1848  // Call nodes may include discontinuities but each called tree is handled
1849  // separately.
1852  createDiscontinuityEvents(static_cast< const CEvaluationNodeCall * >(*itNode)->getCalledTree());
1853  break;
1854 
1855  default:
1856  break;
1857  }
1858  }
1859 
1860  return;
1861 }
1862 
1864 {
1865  // We can create a data event without knowing the variables as the number
1866  // of roots is independent from the variable value.
1867  CEvent * pEvent = new CEvent();
1868  pEvent->setType(CEvent::Discontinuity);
1869  mDiscontinuityEvents.add(pEvent, true);
1870 
1872 }
1873 
1875 {
1876  std::string TriggerInfix;
1877 
1878  // We need to define a data event for each discontinuity.
1879  switch ((int) pNode->getType())
1880  {
1882  TriggerInfix = static_cast< const CEvaluationNode * >(pNode->getChild())->buildInfix();
1883  break;
1884 
1887  TriggerInfix = "sin(PI*(" + static_cast< const CEvaluationNode * >(pNode->getChild())->buildInfix() + ")) > 0";
1888  break;
1889 
1891  TriggerInfix = "sin(PI*(" + static_cast< const CEvaluationNode * >(pNode->getChild())->buildInfix();
1892  TriggerInfix += ")) > 0 || sin(PI*(" + static_cast< const CEvaluationNode * >(pNode->getChild()->getSibling())->buildInfix() + ")) > 0";
1893  break;
1894 
1895  default:
1896  fatalError();
1897  break;
1898  }
1899 
1900  return TriggerInfix;
1901 }
CVector< CMathObject > mObjects
Definition: CEvent.h:152
CCopasiDataModel * getObjectDataModel()
virtual bool setObjectParent(const CCopasiContainer *pParent)
CVectorCore< C_FLOAT64 > mEventAssignments
C_FLOAT64 * pDiscontinuous
Definition: CMathEnum.h:114
std::map< CCopasiObject *, CMathObject * > mDataObject2MathObject
void setStateReduced(const CVectorCore< C_FLOAT64 > &stateReduced)
CMathObject * pInitialTotalMassesObject
Definition: CMathEnum.h:122
CMathObject * pEventRootsObject
Definition: CMathEnum.h:137
C_FLOAT64 * pPropensities
Definition: CMathEnum.h:112
CVectorCore< C_FLOAT64 > mParticleFluxes
CMathObject * pDiscontinuousObject
Definition: CMathEnum.h:141
CVector< C_FLOAT64 > mValues
std::string createDiscontinuityTriggerInfix(const CEvaluationNode *pNode)
CMathObject * pIntensiveValuesObject
Definition: CMathEnum.h:126
const CEvaluationTree * getCalledTree() const
const CMath::EntityType & getEntityType() const
C_FLOAT64 * pInitialExtensiveRates
Definition: CMathEnum.h:91
#define pdelete(p)
Definition: copasi.h:215
Header file of class CModelEntity and CModelValue.
bool compile(CEvent *pDataEvent, CMathContainer &container)
Definition: CMathEvent.cpp:916
C_FLOAT64 * pEventRoots
Definition: CMathEnum.h:110
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
static std::vector< const CCopasiObject * > getListOfConstObjects(ListType t, const CModel *model)
CObjectInterface::ObjectSet mInitialStateValueExtensive
const CVector< CRoot > & getRoots() const
Definition: CMathEvent.cpp:287
virtual CCopasiObjectName getCN() const
CMathObject * getMathObject(const CObjectInterface *pObject) const
void copy(const CMathEventN &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
Definition: CMathEvent.cpp:894
SimulationType
Definition: CMathEnum.h:182
void setTriggerExpression(const std::string &infix, CMathContainer &container)
Definition: CMathEvent.cpp:972
CEvaluationNode * copyNode(CEvaluationNode *child1, CEvaluationNode *child2) const
virtual size_t size() const
C_FLOAT64 * pEventDelays
Definition: CMathEnum.h:107
C_FLOAT64 * pEventRootStates
Definition: CMathEnum.h:111
sDiscontinuous mCreateDiscontinuousPointer
void copy(const CMathObject &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
Definition: CMathObject.cpp:64
CMathObject * pExtensiveValuesObject
Definition: CMathEnum.h:125
size_t getNumMetabs() const
Definition: CModel.cpp:1118
CCopasiObject * getInitialValueReference() const
const CObjectInterface * mpQuantity2NumberFactor
const CMath::SimulationType & getSimulationType() const
iterator begin()
void updateSimulatedValues(const bool &useMoieties)
CMathObject * pInitialExtensiveValuesObject
Definition: CMathEnum.h:116
#define fatalError()
const Type & getType() const
CObjectInterface::UpdateSequence mSimulationValuesSequence
CObjectInterface * ObjectFromCN(const std::vector< CCopasiContainer * > &listOfContainer, const CCopasiObjectName &objName) const
CVectorCore< C_FLOAT64 > mExtensiveValues
void initializePointers(CMath::sPointers &pointers)
std::string buildInfix() const
std::map< C_FLOAT64 *, CMathObject * > mDataValue2MathObject
void resize(size_t size, const bool &copy=false)
Definition: CVector.h:301
C_FLOAT64 * pTotalMasses
Definition: CMathEnum.h:104
CVectorCore< C_FLOAT64 > mInitialIntensiveValues
#define C_INVALID_INDEX
Definition: copasi.h:222
void setInitialState(const CVectorCore< C_FLOAT64 > &initialState)
CMathObject * pEventRootStatesObject
Definition: CMathEnum.h:138
C_FLOAT64 * pInitialFluxes
Definition: CMathEnum.h:94
CEvaluationNode * copyBranch(const CEvaluationNode *pSrc, const bool &replaceDiscontinuousNodes)
CVectorCore< C_FLOAT64 > mTotalMasses
C_FLOAT64 * pParticleFluxes
Definition: CMathEnum.h:102
CModelEntity ** endDependent()
Definition: CState.cpp:211
C_FLOAT64 * getInitialValuePointer(const C_FLOAT64 *pValue) const
void updateInitialValues(const CModelParameter::Framework &framework)
size_t mDependentCount
bool compile(CMathContainer &container)
const CNodeIteratorMode::State & next()
Definition: CMetab.h:178
const size_t & size() const
Definition: CState.cpp:242
CObjectInterface::ObjectSet mInitialStateValueIntensive
CMathDependencyGraph mTransientDependencies
CMathObject * pExtensiveRatesObject
Definition: CMathEnum.h:127
virtual void * getValuePointer() const
CModelEntity ** beginDependent()
Definition: CState.cpp:210
const CCopasiVector< CMoiety > & getMoieties() const
Definition: CModel.cpp:1163
CVectorCore< C_FLOAT64 > mPropensities
void addAssignment(CMathObject *pTarget, CMathObject *pExpression)
Definition: CMathEvent.cpp:991
C_FLOAT64 * pIntensiveRates
Definition: CMathEnum.h:101
CMathObject * pFluxesObject
Definition: CMathEnum.h:130
std::map< std::string, CMathObject * > mDiscontinuityInfix2Object
CCopasiObjectName getPrimary() const
CObjectInterface::ObjectSet mReducedStateValues
C_FLOAT64 * pInitialEventTriggers
Definition: CMathEnum.h:96
const CObjectInterface * mpAvogadro
CObjectInterface::UpdateSequence mSynchronizeInitialValuesSequenceIntensive
CVectorCore< C_FLOAT64 > mStateReduced
CObjectInterface::UpdateSequence mSimulationValuesSequenceReduced
std::map< std::string, CMathEventN * > mTriggerInfix2Event
EntityType
Definition: CMathEnum.h:195
C_FLOAT64 * pIntensiveValues
Definition: CMathEnum.h:99
iterator end()
std::vector< CType * >::const_iterator const_iterator
Definition: CCopasiVector.h:57
void initializeMathObjects(const std::vector< const CModelEntity * > &entities, const CMath::SimulationType &simulationType, CMath::sPointers &pointers)
CObjectInterface::UpdateSequence mSynchronizeInitialValuesSequenceExtensive
CObjectInterface::ObjectSet mStateValues
void initializeObjects(CMath::sPointers &pointers)
void createSynchronizeInitialValuesSequence()
C_FLOAT64 * pInitialIntensiveRates
Definition: CMathEnum.h:92
CModelEntity ** endFixed()
Definition: CState.cpp:213
void createApplyInitialValuesSequence()
CMathObject * pParticleFluxesObject
Definition: CMathEnum.h:129
CMathObject * pInitialIntensiveValuesObject
Definition: CMathEnum.h:117
CMathObject * pInitialIntensiveRatesObject
Definition: CMathEnum.h:119
C_FLOAT64 * pInitialParticleFluxes
Definition: CMathEnum.h:93
C_FLOAT64 * pEventPriorities
Definition: CMathEnum.h:108
CObjectInterface::UpdateSequence mApplyInitialValuesSequence
C_FLOAT64 * pExtensiveRates
Definition: CMathEnum.h:100
bool setTriggerExpression(const std::string &expression)
Definition: CEvent.cpp:474
CVectorCore< C_FLOAT64 > mEventTriggers
void initialize(CMath::sPointers &pointers)
Definition: CMathEvent.cpp:868
virtual bool add(const CType &src)
CVectorCore< C_FLOAT64 > mEventRoots
CCopasiObject * getConcentrationRateReference() const
Definition: CMetab.cpp:867
C_FLOAT64 * pExtensiveValues
Definition: CMathEnum.h:98
void applyUpdateSequence(const CObjectInterface::UpdateSequence &updateSequence)
bool getUpdateSequence(const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects, const CObjectInterface::ObjectSet &requestedObjects, CObjectInterface::UpdateSequence &updateSequence)
void exportDOTFormat(std::ostream &os, const std::string &name) const
void initializeDiscontinuousCreationPointer()
Context * parentContextPtr()
CModelEntity ** beginFixed()
Definition: CState.cpp:212
void createDiscontinuityEvents()
void copy(const CMathReaction &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
size_t mAssignmentCount
void initializeEvents(CMath::sPointers &pointers)
C_FLOAT64 * pEventAssignments
Definition: CMathEnum.h:109
CVectorCore< C_FLOAT64 > mDiscontinuous
CModelEntity ** beginIndependent()
Definition: CState.cpp:208
std::vector< const CEvaluationTree * > getTreesWithDiscontinuities() const
Definition: CModel.cpp:4059
CVectorCore< C_FLOAT64 > mInitialEventTriggers
const CVectorCore< C_FLOAT64 > & getState() const
CMathObject * pEventTriggersObject
Definition: CMathEnum.h:132
C_FLOAT64 * pInitialExtensiveValues
Definition: CMathEnum.h:89
CVectorCore< C_FLOAT64 > mEventRootStates
size_t mIndependentCount
CMathObject * pInitialEventTriggersObject
Definition: CMathEnum.h:123
const CVector< CAssignment > & getAssignments() const
CEvaluationNode * replaceDiscontinuousNode(const CEvaluationNode *pSrc, const std::vector< CEvaluationNode * > &children)
CVectorCore< C_FLOAT64 > mEventDelays
CMathObject * pEventAssignmentsObject
Definition: CMathEnum.h:136
size_t size() const
Definition: CVector.h:100
CVectorCore< C_FLOAT64 > mDependentMasses
std::set< const CObjectInterface * > ObjectSet
virtual const DataObjectSet & getDirectDependencies(const DataObjectSet &context=DataObjectSet()) const
CVectorCore< C_FLOAT64 > mState
iterator addObject(const CObjectInterface *pObject)
CVectorCore< C_FLOAT64 > mInitialState
CObjectInterface::ObjectSet mSimulationRequiredValues
static CMath::EntityType getEntityType(const CModelEntity *pEntity)
const CVectorCore< C_FLOAT64 > & getValues() const
CMathObject * pEventDelaysObject
Definition: CMathEnum.h:134
static bool hasDependencies(const CCopasiObject *pObject)
#define C_FLOAT64
Definition: copasi.h:92
static void initialize(CMathObject *&pObject, C_FLOAT64 *&pValue, const CMath::ValueType &valueType, const CMath::EntityType &entityType, const CMath::SimulationType &simulationType, const bool &isIntensiveProperty, const bool &isInitialValue, const CCopasiObject *pDataObject)
Definition: CMathObject.cpp:23
CEvaluationNode * createNodeFromObject(const CObjectInterface *pMathObject)
const CModel & getModel() const
CVectorCore< C_FLOAT64 > mExtensiveRates
CType * array()
Definition: CVector.h:139
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
CCopasiVector< CEvent > mDiscontinuityEvents
const bool & isIntensiveProperty() const
CVectorCore< C_FLOAT64 > mInitialTotalMasses
void setType(const Type &type)
Definition: CEvent.cpp:704
void createDependencyGraphs()
size_t mEventTargetCount
CVectorCore< C_FLOAT64 > mIntensiveValues
CVectorCore< C_FLOAT64 > mIntensiveRates
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
CMathObject * pInitialExtensiveRatesObject
Definition: CMathEnum.h:118
static void allocate(CMathEventN *pEvent, const CEvent *pDataEvent, const CMathContainer &container)
Definition: CMathEvent.cpp:838
CVectorCore< C_FLOAT64 > mInitialExtensiveValues
CVectorCore< C_FLOAT64 > mInitialFluxes
virtual void clear()
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
virtual void * getValuePointer() const
const CTrigger & getTrigger() const
Definition: CMathEvent.cpp:863
const CVectorCore< C_FLOAT64 > & getInitialState() const
Definition: CModel.h:50
CVector< CMathReaction > mReactions
CMathObject * pEventPrioritiesObject
Definition: CMathEnum.h:135
C_FLOAT64 * pEventTriggers
Definition: CMathEnum.h:105
void calculate()
CEvaluationNode * createNodeFromValue(const C_FLOAT64 *pDataValue)
virtual ~CMathContainer()
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
virtual void * getValuePointer() const =0
CVectorCore< C_FLOAT64 > mInitialIntensiveRates
virtual const Data & getData() const
Definition: CCopasiNode.h:118
const CModelEntity::Status & getStatus() const
CMathDependencyGraph mInitialDependencies
CMathObject * pInitialFluxesObject
Definition: CMathEnum.h:121
CMathObject * pPropensitiesObject
Definition: CMathEnum.h:139
CNodeIteratorMode::State end() const
void createUpdateSimulationValuesSequence()
CMathObject * pDependentMassesObject
Definition: CMathEnum.h:140
CConcentrationReference * getInitialConcentrationReference() const
Definition: CMetab.cpp:861
C_FLOAT64 * pInitialTotalMasses
Definition: CMathEnum.h:95
const CVectorCore< C_FLOAT64 > & getStateReduced() const
void createDiscontinuityDataEvent(const CEvaluationNode *pNode)
C_FLOAT64 * pInitialIntensiveValues
Definition: CMathEnum.h:90
CCopasiNode< Data > * getChild()
Definition: CCopasiNode.h:210
C_FLOAT64 * pDependentMasses
Definition: CMathEnum.h:113
CCopasiObject * getRateReference() const
std::set< const CCopasiObject * > DataObjectSet
void setValues(const CVectorCore< C_FLOAT64 > &values)
CVectorCore< C_FLOAT64 > mFluxes
CVectorCore< C_FLOAT64 > mInitialParticleFluxes
CVectorCore< C_FLOAT64 > mEventPriorities
void map(CCopasiObject *pDataObject, CMathObject *pMathObject)
CModelEntity ** endIndependent()
Definition: CState.cpp:209
CEvaluationNode * getRoot()
CVectorCore< C_FLOAT64 > mInitialExtensiveRates
virtual CCopasiObjectName getCN() const
C_FLOAT64 * pFluxes
Definition: CMathEnum.h:103
static std::set< const CModelEntity * > getEventTargets(const CModel *pModel)
CCopasiContainer * getObjectParent() const
std::vector< CObjectInterface * > UpdateSequence
CVector< CMathEventN > mEvents
void setState(const CVectorCore< C_FLOAT64 > &state)
CMathObject * pIntensiveRatesObject
Definition: CMathEnum.h:128
bool setExpressionPtr(CMathExpression *pMathExpression)
void initialize(const CReaction *pReaction, CMathContainer &container)
const CCopasiObject * getDataObject() const
CMathObject * pInitialParticleFluxesObject
Definition: CMathEnum.h:120
CMathObject * pTotalMassesObject
Definition: CMathEnum.h:131
CConcentrationReference * getConcentrationReference() const
Definition: CMetab.cpp:864
CCopasiObject * getValueReference() const