COPASI API  4.16.103
CModel.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2015 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) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_CModel
16 #define COPASI_CModel
17 
18 #include <map>
19 #include <vector>
20 #include <set>
21 #include <string>
22 
24 
25 #include "copasi/model/CState.h"
26 #include "copasi/model/CReaction.h"
27 #include "copasi/model/CEvent.h"
28 #include "copasi/model/CMoiety.h"
31 
36 
39 
40 #ifdef USE_MATH_CONTAINER
41 class CMathContainer;
42 #endif // USE_MATH_CONTAINER
43 
44 //class CCompartment;
45 class CProcessReport;
46 class CArrayAnnotation;
47 class CMathModel;
48 class CExperiment;
49 
50 class CModel : public CModelEntity
51 {
52 public:
53  /**
54  * Enum of valid volume units
55  */
57 
58  /**
59  * String representation of valid volume units
60  */
61  static const char * VolumeUnitNames[];
62 
63  /**
64  * Enum of valid area units
65  */
67 
68  /**
69  * String representation of valid area units
70  */
71  static const char * AreaUnitNames[];
72 
73  /**
74  * Enum of valid length units
75  */
77 
78  /**
79  * String representation of valid length units
80  */
81  static const char * LengthUnitNames[];
82 
83  /**
84  * Enum of valid time units
85  */
87 
88  /**
89  * String representation of valid time units
90  */
91  static const char * TimeUnitNames[];
92 
93  /**
94  * Enum of valid quantity units
95  */
97 
98  /**
99  * String representation of valid quantity units as used in old (up to Build 18)
100  * COPASI files
101  */
102  static const char * QuantityUnitOldXMLNames[];
103 
104  /**
105  * String representation of valid quantity units
106  */
107  static const char * QuantityUnitNames[];
108 
109  /**
110  * Enum of valid model types.
111  */
113 
114  /**
115  * String representation of the valid model types.
116  */
117  static const char * ModelTypeNames[];
118 
119  enum DependencyType {initial = 0, transient, physical};
120 
121 private:
122  /**
123  * Copy constructor
124  * @param "const CModel &" src
125  */
126  CModel(const CModel & src);
127 
128  CModel& operator=(const CModel& src);
129 
130 public:
131  /**
132  * constructor
133  */
134  CModel(CCopasiContainer* pParent);
135 
136  /**
137  * Destructor
138  */
139  ~CModel(); // destructor (deallocation code here)
140 
141  /**
142  * Retrieve the units of the child object.
143  * @return std::string units
144  */
145  virtual std::string getChildObjectUnits(const CCopasiObject * pObject) const;
146 
147  /**
148  * Converts the set of reactions to a set of reactions where all reactions are irreversible.
149  */
150  bool convert2NonReversible();
151 
152 #ifdef WITH_PE_EVENT_CREATION
153  /**
154  * Creates events for all elements of an parameter estimation time course experiment
155  */
156  bool createEventsForTimeseries(CExperiment* experiment = NULL);
157 #endif
158 
159  /**
160  * Loads an object with data coming from a CReadConfig object.
161  * (CReadConfig object reads an input stream)
162  * @param pconfigbuffer reference to a CReadConfig object.
163  * @return Fail
164  */
165  C_INT32 load(CReadConfig &configBuffer);
166 
167  /**
168  * This function must be called to initialize the vector of Metabolites
169  * after finishing adding metabolites to compartments.
170  */
171  void initializeMetabolites();
172 
173  /**
174  * This must be called whenever something is changed in the model
175  * that would make it necessary to recalculate the matrix decomposition
176  */
177  void setCompileFlag(bool flag = true);
178 
179  /**
180  * Compile the model if necessary
181  * @param CProcessReport* pProcessReport
182  * @return bool success
183  */
184  bool compileIfNecessary(CProcessReport* pProcessReport);
185 
186  /**
187  * Force a compile the model.
188  * @param CProcessReport* pProcessReport
189  * @return bool success
190  */
191  bool forceCompile(CProcessReport* pProcessReport);
192 
193  bool buildDependencyGraphs();
194 
195  /**
196  * Build the Stoichiometry Matrix from the chemical equations of the steps
197  */
198  void buildStoi();
199 
200  /**
201  * Build the core of the link matrix L
202  * @param const CMatrix< C_FLOAT64 > & LU
203  */
204  void buildLinkZero();
205 
206  /**
207  * Build the core of the link matrix L
208  * @param const CMatrix< C_FLOAT64 > & LU
209  */
210  //void buildL(const CMatrix< C_FLOAT64 > & LU);
211 
212 #ifdef XXXX
213  /**
214  * LU-Decomposition of the stoichiometry matrix
215  * @param CMatrix< C_FLOAT64 > & LU
216  */
217  void lUDecomposition(CMatrix< C_FLOAT64 > & LU);
218 #endif // XXXX
219 
220  /**
221  * Build the Reduced Stoichiometry Matrix from the LU decomposition
222  */
223  void buildRedStoi();
224 
225  /**
226  * Build the moieties based on the LU decomposition
227  */
228  void buildMoieties();
229 
230 private:
231  /**
232  * compute the actual initial value of all moieties
233  * (from the initial values of the metabolites).
234  */
235  void updateMoietyValues();
236 
237 public:
238  //********** Metabs *****************************
239 
240  /**
241  * Return the metabolites of this model
242  * @return CCopasiVectorN< CMetab > & metabolites
243  */
244  const CCopasiVector< CMetab > & getMetabolites() const;
246 
247  /**
248  * Retrieves the vector of metabolites at it is used in the reduced model.
249  * @return const CCopasiVectorN< CMetab > &metabolites
250  */
253 
254  /**
255  * Get the number of total metabolites
256  * @return C_INT32 totMetab
257  */
258  size_t getNumMetabs() const;
259 
260  /**
261  * Get the number of variable metabolites
262  * @return size_t totMetab
263  */
264  size_t getNumVariableMetabs() const;
265 
266  /**
267  * Get the number of metabolites determined by ODEs
268  * @return size_t dimension
269  */
270  size_t getNumODEMetabs() const;
271 
272  /**
273  * Get the number of metabolites determined by assigments
274  * @return size_t dimension
275  */
276  size_t getNumAssignmentMetabs() const;
277 
278  /**
279  * Get the number of independent metabolites determined by reactions
280  * @return size_t dimension
281  */
282  size_t getNumIndependentReactionMetabs() const;
283 
284  /**
285  * Get the number of dependent metabolites determined by reactions
286  * @return size_t dimension
287  */
288  size_t getNumDependentReactionMetabs() const;
289 
290  //********** additional values *****************************
291 
292  /**
293  * Return the non concentration values of this model
294  * @return CCopasiVectorN< CModelValue > & values
295  */
298 
299  /**
300  * Get the number of non concentration values
301  * @return C_INT32
302  */
303  size_t getNumModelValues() const;
304 
305  /**
306  * Return the non model parameter sets
307  * @return CCopasiVectorN< CModelParameterSet > & modelParameterSets
308  */
311 
312  /**
313  * Retrieve the parameter set
314  * @return const CModelParameterSet & modelParameterSet
315  */
318 
319  /**
320  * Update the model initial values from the active parameter set.
321  */
323 
324  /**
325  * refresh the active parameter set from the model initial values
326  */
328 
329  //********** TT *****************************
330 
331 public:
332  //********** Reactions *****************************
333 
334  /**
335  * Return the vector of reactions
336  * @return CCopasiVectorNS <CReaction> & reactions
337  */
339 
340  /**
341  * Return the vector of reactions
342  * @return const CCopasiVectorS <CReaction> & reactions
343  */
345 
346  /**
347  * Get the total steps
348  * @return size_t total steps;
349  */
350  size_t getTotSteps() const;
351 
352  /**
353  * Retrieve the vector of particle fluxes from the model
354  * @return const CVector< C_FLOAT64 > & particleFlux
355  */
356  const CVector< C_FLOAT64 > & getParticleFlux() const;
357 
358  //********* Events **************************
359 
360  /**
361  * Return the vector of events
362  */
364 
365  /**
366  * Return the vector of events
367  */
368  const CCopasiVectorN < CEvent > & getEvents() const;
369 
370  //******************************************+
371 
372  /**
373  * Return the key of this model
374  * @return string key
375  */
376  const std::string & getKey() const;
377 
378  /**
379  * Return a pointer to the current time
380  */
381  //virtual void * getValuePointer() const;
382 
383  //************** time *********************
384 
385  /**
386  * Set the start time for modeling
387  * @param const C_FLOAT64 & time
388  */
389  void setInitialTime(const C_FLOAT64 & time);
390 
391  /**
392  * Retrieve the initial time
393  * @return const C_FLOAT64 & time
394  */
395  const C_FLOAT64 & getInitialTime() const;
396 
397  /**
398  * Set the actual model time
399  * @param const C_FLOAT64 & time
400  */
401  void setTime(const C_FLOAT64 & time);
402 
403  /**
404  * Retrieve the actual model time
405  * @return const C_FLOAT64 & time
406  */
407  const C_FLOAT64 & getTime() const;
408 
409  //************** compartments *********************
410 
411  /**
412  * Return the compartments of this model
413  * @return CCopasiVectorNS < CCompartment > *
414  */
416 
417  /**
418  * Return the compartments of this model
419  * @return const CCopasiVectorNS < CCompartment > *
420  */
422 
423  //***************************************************
424 
425  /**
426  * Get the Reduced Stoichiometry Matrix of this Model
427  */
428  const CMatrix < C_FLOAT64 > & getRedStoi() const;
429 
430  /**
431  * Get the stoichiometry matrix of this model
432  */
433  const CMatrix < C_FLOAT64 > & getStoi() const;
434 
435  /**
436  * Return the mMoieties of this model
437  * @return CCopasiVectorN < CMoiety > &
438  */
439  const CCopasiVector < CMoiety > & getMoieties() const;
440 
441  /**
442  * Returns the index of the metab
443  * @param const std::string & Target
444  * @return index
445  */
446  size_t findMetabByName(const std::string & Target) const;
447 
448  /**
449  * Returns the index of the moiety
450  * @param const std::string & Target
451  * @return index
452  */
453  size_t findMoiety(const std::string &Target) const;
454 
455  /**
456  * Get the LU decomposition matrix of this model
457  * @return const TNT::Matrix < C_FLOAT64 > & LU
458  */
459  // const CMatrix < C_FLOAT64 > & getmLU() const;
460 
461  /**
462  * Get the link matrix L of the relation: Stoi = L * RedStoi
463  * @return const CLinkMatrixView L
464  */
465  const CLinkMatrixView & getL() const;
466 
467  /**
468  * Get the relevant portion of the link matrix L.
469  * @return const CLinkMatrix & L0
470  */
471  const CLinkMatrix & getL0() const;
472 
473  /**
474  * initialize all values of the model with their initial values
475  */
476  void applyInitialValues();
477 
478  /**
479  * Update all initial values.
480  * @return bool success
481  */
482  bool updateInitialValues();
483 
484  /**
485  * Get the current state of the model, i.e., all current model
486  * quantities.
487  * @return const CState & initialState
488  */
489  const CState & getInitialState() const;
490 
491  /**
492  * Get the current state of the model, i.e., all current model
493  * quantities.
494  * @return const CState & currentState
495  */
496  const CState & getState() const;
497 
498  /**
499  * Set all initial model quantities to the one given by the state and
500  * updates moieties and metabolite concentrations.
501  * @param const CState & state
502  */
503  void setInitialState(const CState & state);
504 
505  /**
506  * Set all independent current model quantities to the one given by the
507  * state.
508  * @param const CState & state
509  */
510  void setState(const CState & state);
511 
512  /**
513  * Construct an intitial update sequence for the given context
514  * @param const CMath::SimulationContextFlag & context
515  * @param const CCopasiObject::DataObjectSet & changedObjects
516  * @param const CCopasiObject::DataObjectSet & requestedObjects
517  * @param CCopasiObject::DataUpdateSequence & updateSequence)
518  * @return bool success
519  */
521  const CCopasiObject::DataObjectSet & changedObjects,
522  const CCopasiObject::DataObjectSet & requestedObjects,
523  CCopasiObject::DataUpdateSequence & updateSequence) const;
524 
525  /**
526  * Construct a transient update sequence for the given context
527  * @param const CMath::SimulationContextFlag & context
528  * @param const CCopasiObject::DataObjectSet & changedObjects
529  * @param const CCopasiObject::DataObjectSet & requestedObjects
530  * @param CCopasiObject::DataUpdateSequence & updateSequence)
531  * @return bool success
532  */
534  const CCopasiObject::DataObjectSet & changedObjects,
535  const CCopasiObject::DataObjectSet & requestedObjects,
536  CCopasiObject::DataUpdateSequence & updateSequence) const;
537 
538  /**
539  * This method calculates all values needed for simulation based on the current
540  * current state. If updateMoities is true the particle numbers of dependent metabolites
541  * of type REACTION are calculated otherwise they are assumed to be synchronized.
542  * @param const bool & updateMoieties
543  */
544  void updateSimulatedValues(const bool & updateMoieties);
545 
546  /**
547  * Calling this method after updateSimulatedValues assure that all model values
548  * even those not needed for simulation are consistent with the current state
549  */
550  void updateNonSimulatedValues(void);
551 
552  /**
553  * Calculate the changes of all model quantities determined by ODEs
554  * for the model in the current state.
555  * The parameter derivatives must at least provide space for
556  * state->getVariableNumberSize() double
557  * &param C_FLOAT64 * derivatives (output)
558  */
559  void calculateDerivatives(C_FLOAT64 * derivatives);
560 
561  /**
562  * Calculate the changes of all model quantities determined by ODEs
563  * for the reduced model in the current state.
564  * The parameter derivatives must at least provide space for
565  * state->getDependentNumberSize() double
566  * &param C_FLOAT64 * derivatives (output)
567  */
568  void calculateDerivativesX(C_FLOAT64 * derivativesX);
569 
570  /**
571  * Calculates the elasticity matrix of the model for the current
572  * state and stores it in the provided matrix.
573  * @param CMatrix< C_FLOAT64 > & elasticityMatrix
574  * @param const C_FLOAT64 & factor,
575  * @param const C_FLOAT64 & resolution
576  */
577  void calculateElasticityMatrix(const C_FLOAT64 & factor,
578  const C_FLOAT64 & resolution);
579 
580  /**
581  * Calculates the jacobian of the full model for the current state
582  * and stores it in the provided matrix. calculateElasticityMatrix()
583  * needs to be called before.
584  * @param CMatrix< C_FLOAT64 > & jacobian
585  * @param const C_FLOAT64 & derivationFactor,
586  * @param const C_FLOAT64 & resolution
587  */
588  void calculateJacobian(CMatrix< C_FLOAT64 > & jacobian,
589  const C_FLOAT64 & derivationFactor,
590  const C_FLOAT64 & resolution);
591 
592  /**
593  * Calculates the Jacobian of the reduced model for the current
594  * state and stores it in the provided matrix. calculateElasticityMatrix()
595  * needs to be called before.
596  * @param const C_FLOAT64 & derivationFactor,
597  * @param const C_FLOAT64 & resolution
598  * @param CMatrix< C_FLOAT64 > & jacobianX
599  */
600  void calculateJacobianX(CMatrix< C_FLOAT64 > & jacobianX,
601  const C_FLOAT64 & derivationFactor,
602  const C_FLOAT64 & resolution);
603 
604  /**
605  * Calculates the divergence for the current state.
606  * calculateElasticityMatrix() needs to be called before.
607  * It makes only sense to use this method if the Jacobian
608  * is not also calculated. In this case it would be more
609  * efficient to use the trace of the Jacobian
610  */
612 
613  /**
614  * Set the unit for volumes. If COPASI recognizes
615  * the unit the conversion factors are set accordingly
616  * and true is returned.
617  * @param const std::string & name
618  * @return bool success
619  */
620  bool setVolumeUnit(const std::string & name);
621 
622  /**
623  * Set the unit for volumes. If COPASI recognizes
624  * the unit the conversion factors are set accordingly
625  * and true is returned.
626  * @param const CModel::VolumeUnit & unit
627  * @return bool success
628  */
629  bool setVolumeUnit(const CModel::VolumeUnit & unit);
630 
631  /**
632  * Get the unit for volumes
633  * @return std::string volumeUnit
634  */
635  std::string getVolumeUnitName() const;
636 
637  /**
638  * Get the unit for volumes
639  * @return CModel::VolumeUnit volumeUnit
640  */
642 
643  /**
644  * Set the unit for areas.
645  * @param const std::string & name
646  * @return bool success
647  */
648  bool setAreaUnit(const std::string & name);
649 
650  /**
651  * Set the unit for areas.
652  * @param const CModel::AreaUnit & unit
653  * @return bool success
654  */
655  bool setAreaUnit(const CModel::AreaUnit & unit);
656 
657  /**
658  * Get the unit for areas
659  * @return std::string areaUnit
660  */
661  std::string getAreaUnitName() const;
662 
663  /**
664  * Get the unit for areas
665  * @return CModel::AreaUnit areaUnit
666  */
668 
669  /**
670  * Set the unit for lengths.
671  * @param const std::string & name
672  * @return bool success
673  */
674  bool setLengthUnit(const std::string & name);
675 
676  /**
677  * Set the unit for lengths.
678  * @param const CModel::LengthUnit & unit
679  * @return bool success
680  */
681  bool setLengthUnit(const CModel::LengthUnit & unit);
682 
683  /**
684  * Get the unit for lengths
685  * @return std::string lengthUnit
686  */
687  std::string getLengthUnitName() const;
688 
689  /**
690  * Get the unit for lengths
691  * @return CModel::LengthUnit lengthUnit
692  */
694 
695  /**
696  * Set the unit for time. If COPASI recognizes
697  * the unit the conversion factors are set accordingly
698  * and true is returned.
699  * @param const std::string & name
700  * @return bool success
701  */
702  bool setTimeUnit(const std::string & name);
703 
704  /**
705  * Set the unit for time. If COPASI recognizes
706  * the unit the conversion factors are set accordingly
707  * and true is returned.
708  * @param const const CModel::TimeUnit & unit
709  * @return bool success
710  */
711  bool setTimeUnit(const CModel::TimeUnit & unit);
712 
713  /**
714  * Get the unit for time
715  * @return std::string timeUnit
716  */
717  std::string getTimeUnitName() const;
718 
719  /**
720  * Get the unit for time
721  * @return CModel::TimeUnit timeUnit
722  */
724 
725  /**
726  * Set the unit for quantities. If COPASI recognizes
727  * the unit the conversion factors are set accordingly
728  * and true is returned.
729  * @param const std::string & name
730  * @return bool success
731  */
732  bool setQuantityUnit(const std::string & name);
733 
734  /**
735  * Set the unit for quantities. If COPASI recognizes
736  * the unit the conversion factors are set accordingly
737  * and true is returned.
738  * @param const CModel::QuantityUnit & unit
739  * @return bool success
740  */
741  bool setQuantityUnit(const CModel::QuantityUnit & unit);
742 
743  /**
744  * Get the unit for quantities
745  * @return std::string quantityUnit
746  */
747  std::string getQuantityUnitName() const;
748  std::string getQuantityUnitOldXMLName() const;
749 
750  /**
751  * Get the unit for quantities
752  * @return CModel::QuantityUnit quantityUnit
753  */
755 
756  /**
757  * Set the type of the model
758  * @param const ModelType & modelType
759  */
760  void setModelType(const ModelType & modelType);
761 
762  /**
763  * Retrieve the type of the model.
764  * @return const ModelType & modelType
765  */
766  const ModelType & getModelType() const;
767 
768  /**
769  * Set the Avogadro number used for the model.
770  * @param const C_FLOAT64 & avogadro
771  */
772  void setAvogadro(const C_FLOAT64 & avogadro);
773 
774  /**
775  * Retrieve the Avogadro number.
776  */
777  const C_FLOAT64 & getAvogadro() const;
778 
779  /**
780  * Get the conversion factor quantity -> number
781  */
782  const C_FLOAT64 & getQuantity2NumberFactor() const;
783 
784  /**
785  * Get the conversion factor number -> quantity
786  */
787  const C_FLOAT64 & getNumber2QuantityFactor() const;
788 
789  //************ create/remove model entities *******************
790 
791  /**
792  * Add a metabolite to the model
793  * @param const std::string & name
794  * @param const std::string & compartment
795  * @param const C_FLOAT64 & iconc (default 1.0)
796  * @param const CMetab::Status & status (default CMetab::METAB_VARIABL)
797  * @return bool success (false if failed)
798  * @see CMetab for more information
799  */
800  CMetab* createMetabolite(const std::string & name,
801  const std::string & compartment,
802  const C_FLOAT64 & iconc = 1.0,
804 
805  /* Remove a metabolite from the model */
806  bool removeMetabolite(const std::string & key,
807  const bool & recursive = true);
808  bool removeMetabolite(const size_t index,
809  const bool & recursive = true);
810  bool removeMetabolite(const CMetab* pMetabolite,
811  const bool & recursive = true);
812 
813  /**
814  * Appends pointers to all model objects, which are dependent on the candidates
815  * to appropriate lists.
816  * @param const std::set< const CCopasiObject * > & candidates
817  * @param std::set< const CCopasiObject * > & dependentReactions
818  * @param std::set< const CCopasiObject * > & dependentMetabolites
819  * @param std::set< const CCopasiObject * > & dependentCompartments
820  * @param std::set< const CCopasiObject * > & dependentModelValues
821  * @param std::set< const CCopasiObject * > & dependentEvents
822  * @return bool objectsAppended
823  */
824  bool appendDependentModelObjects(const std::set< const CCopasiObject * > & candidates,
825  std::set< const CCopasiObject * > & dependentReactions,
826  std::set< const CCopasiObject * > & dependentMetabolites,
827  std::set< const CCopasiObject * > & dependentCompartments,
828  std::set< const CCopasiObject * > & dependentModelValues,
829  std::set< const CCopasiObject * > & dependentEvents) const;
830 
831  /**
832  * Appends pointers to reactions which are dependent on the candidates to the
833  * list.
834  * @param std::set< const CCopasiObject * > candidates
835  * @param std::set< const CCopasiObject * > & dependents
836  * @return bool objectsAppended
837  */
838  bool appendDependentReactions(std::set< const CCopasiObject * > candidates,
839  std::set< const CCopasiObject * > & dependents) const;
840 
841 private:
842  /**
843  * Appends pointers to metabolites which are dependent on the candidates to the
844  * list.
845  * @param std::set< const CCopasiObject * > candidates
846  * @param std::set< const CCopasiObject * > & dependents
847  * @return bool objectsAppended
848  */
849  bool appendDependentMetabolites(std::set< const CCopasiObject * > candidates,
850  std::set< const CCopasiObject * > & dependents) const;
851 
852  /**
853  * Appends pointers to compartments which are dependent on the candidates to the
854  * list.
855  * @param std::set< const CCopasiObject * > candidates
856  * @param std::set< const CCopasiObject * > & dependents
857  * @return bool objectsAppended
858  */
859  bool appendDependentCompartments(std::set< const CCopasiObject * > candidates,
860  std::set< const CCopasiObject * > & dependents) const;
861 
862  /**
863  * Appends a pointers to model values which are dependent on the candidates to the
864  * list.
865  * @param std::set< const CCopasiObject * > candidates
866  * @param std::set< const CCopasiObject * > & dependents
867  * @return bool objectsAppended
868  */
869  bool appendDependentModelValues(std::set< const CCopasiObject * > candidates,
870  std::set< const CCopasiObject * > & dependents) const;
871 
872  /**
873  * Appends a pointers to events which are dependent on the candidates to the
874  * list.
875  * @param std::set< const CCopasiObject * > candidates
876  * @param std::set< const CCopasiObject * > & dependents
877  * @return bool objectsAppended
878  */
879  bool appendDependentEvents(std::set< const CCopasiObject * > candidates,
880  std::set< const CCopasiObject * > & dependents) const;
881 
882  /**
883  * Construct a update sequence for the given context
884  * @param CMathDependencyGraph & dependencyGraph
885  * @param const CMath::SimulationContextFlag & context
886  * @param const CCopasiObject::DataObjectSet & changedObjects
887  * @param const CCopasiObject::DataObjectSet & requestedObjects
888  * @param CCopasiObject::DataUpdateSequence & updateSequence)
889  * @return bool success
890  */
891  bool getUpdateSequence(CMathDependencyGraph & dependencyGraph,
892  const CMath::SimulationContextFlag & context,
893  const CCopasiObject::DataObjectSet & changedObjects,
894  const CCopasiObject::DataObjectSet & requestedObjects,
895  CCopasiObject::DataUpdateSequence & updateSequence) const;
896 
897 public:
898  /**
899  * Remove all model objects which depend on the deleted objects
900  * @param const std::set<const CCopasiObject*> & deletedObjects
901  */
902  void removeDependentModelObjects(const std::set<const CCopasiObject*> & deletedObjects);
903 
904  /**
905  * Add a compartment to the model
906  * @param const std::string &name
907  * @param const C_FLOAT64 & volume (default 1.0)
908  * @return bool success (false if failed)
909  */
910  CCompartment* createCompartment(const std::string & name,
911  const C_FLOAT64 & volume = 1.0);
912 
913  /** Remove a Compartment from the model */
914  bool removeCompartment(const size_t index,
915  const bool & recursive = true);
916 
917  /** Remove a Compartment from the model */
918  bool removeCompartment(const std::string & key,
919  const bool & recursive = true);
920 
921  /** Remove a Compartment from the model */
922  bool removeCompartment(const CCompartment * pCompartment,
923  const bool & recursive = true);
924 
925  /**
926  * Add a new reaction to the model
927  * @param const std::string &name
928  * @return bool success (false if failed)
929  */
930  CReaction* createReaction(const std::string &name);
931 
932  /** Remove a reaction from the model using its pointer*/
933  bool removeReaction(const CReaction * pReaction,
934  const bool & recursive = true);
935 
936  /** Remove a reaction from the model using its key*/
937  bool removeReaction(const std::string & key,
938  const bool & recursive = true);
939 
940  /** Remove a reaction from the model using its index*/
941  bool removeReaction(const size_t index,
942  const bool & recursive = true);
943 
944  /** Remove a local reaction parameter from the model */
945  bool removeLocalReactionParameter(const std::string & key,
946  const bool & recursive = true);
947 
948  /**
949  * Add a new event to the model
950  * @param const std::string &name
951  * @return bool success (false if failed)
952  */
953  CEvent* createEvent(const std::string &name);
954 
955  /**
956  * Remove an event from the model
957  * @param const size_t index
958  * @param const bool & recursive (default: true)
959  * @return bool success
960  */
961  bool removeEvent(const size_t index,
962  const bool & recursive = true);
963 
964  /**
965  * Remove an event from the model
966  * @param const std::string & key
967  * @param const bool & recursive (default: true)
968  * @return bool success
969  */
970  bool removeEvent(const std::string & key,
971  const bool & recursive = true);
972 
973  /**
974  * Remove an event from the model
975  * @param const CEvent * pEvent
976  * @param const bool & recursive (default: true)
977  * @return bool success
978  */
979  bool removeEvent(const CEvent * pEvent,
980  const bool & recursive = true);
981 
982  /**
983  * Add a non concentration value to the model
984  * @param const std::string &name
985  * @param const C_FLOAT64 & value (default 0.0)
986  */
987  CModelValue* createModelValue(const std::string & name,
988  const C_FLOAT64 & value = 0.0);
989 
990  bool removeModelValue(const CModelValue * pModelValue,
991  const bool & recursive = true);
992  bool removeModelValue(const std::string & key,
993  const bool & recursive = true);
994  bool removeModelValue(const size_t index,
995  const bool & recursive = true);
996 
997  //*************************
998 
999  /**
1000  * Retrieve the state template
1001  * @return const CModel::CStateTemplate & stateTemplate
1002  */
1003  const CStateTemplate & getStateTemplate() const;
1004 
1005  /**
1006  * Retrieve the state template
1007  * @return const CModel::CStateTemplate & stateTemplate
1008  */
1010 
1011  /**
1012  * Retrieve the list of objects which are up to date after a call
1013  * to apply assignment.
1014  * @return const std::set< const CCopasiObject * > & uptoDateObjects
1015  */
1016  const std::set< const CCopasiObject * > & getUptoDateObjects() const;
1017 
1018  /**
1019  * Retrieve the sequence of refresh calls to be executed for updating the
1020  * initial values
1021  * @return const std::vector< Refresh * > & initialRefreshSequence
1022  */
1023  const std::vector< Refresh * > & getListOfInitialRefreshes() const;
1024 
1025  /**
1026  * Retrieve the sequence of refresh calls to be executed for updating the
1027  * simulated values
1028  * @return const std::vector< Refresh * > & simulatedRefreshSequence
1029  */
1030  const std::vector< Refresh * > & getListOfSimulatedRefreshes() const;
1031 
1032  /**
1033  * Retrieve the sequence of refresh calls to be executed for updating the
1034  * constant values
1035  * @return const std::vector< Refresh * > & constantRefreshSequence
1036  */
1037  const std::vector< Refresh * > & getListOfConstantRefreshes() const;
1038 
1039  /**
1040  * Retrieve the sequence of refresh calls to be executed for updating the
1041  * non simulated values
1042  * @return const std::vector< Refresh * > & nonsimulatedRefreshSequence
1043  */
1044  const std::vector< Refresh * > & getListOfNonSimulatedRefreshes() const;
1045 
1046  /**
1047  * Check whether the model contains reversible reactions
1048  * @return bool hasReversibleReaction
1049  */
1050  bool hasReversibleReaction() const;
1051 
1052  /**
1053  * check if the model is suitable for stochastic simulation
1054  **/
1055  std::string suitableForStochasticSimulation() const;
1056 
1057  /**
1058  * Check whether the model is autonomous
1059  * @return const bool &isAutonomous
1060  */
1061  const bool & isAutonomous() const;
1062 
1063  /**
1064  * Check whether the given object is a part of state variable
1065  * @param const CCopasiObject * pObject
1066  * @return bool isStateVariable
1067  */
1068  bool isStateVariable(const CCopasiObject * pObject) const;
1069 
1070  /**
1071  * Retrieve the corresponding transient state object of the given object
1072  * @param const CCopasiObject * pObject
1073  * @return CCopasiObject * correspondingTransientObject
1074  */
1076 
1077  /**
1078  * Build the update sequence used to calculate all initial values depending
1079  * on the changed objects. For metabolites the initial particle number is
1080  * updated by default unless itself is in the list of changed objects. In
1081  * that case the initial concentration is updated.
1082  * @param std::set< const CCopasiObject * > & changedObjects
1083  * @return std::vector< Refresh * > initialRefreshSequence
1084  */
1085  std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > & changedObjects);
1086 
1087  /**
1088  * Builds and executes the the update sequence used to calculate all initial
1089  * values depending on the changed objects. For metabolites the initial particle
1090  * number is updated by default unless itself is in the list of changed objects. In
1091  * that case the initial concentration is updated.
1092  *
1093  * @param std::set< const CCopasiObject * > & changedObjects
1094 
1095  * @see buildInitialRefreshSequence(std::set< const CCopasiObject * > & changedObjects)
1096  */
1097  void updateInitialValues(std::set< const CCopasiObject * > & changedObjects);
1098 
1099  /**
1100  * Builds and executes the the update sequence used to calculate all initial
1101  * values depending on the changed objects For metabolites the initial particle
1102  * number is updated by default unless itself is in the list of changed objects. In
1103  * that case the initial concentration is updated.
1104  *
1105  * @param std::set< const CCopasiObject * > & changedObjects
1106 
1107  * @see updateInitialValues(std::set< const CCopasiObject * > & changedObjects)
1108  */
1109  void updateInitialValues(const CCopasiObject * changedObject);
1110 
1111  /**
1112  * Initialize a vector of individual absolute tolerances
1113  * @param const C_FLOAT64 & baseTolerance
1114  * @param const bool & reducedModel
1115  * @return CVector< C_FLOAT64 > absoluteTolerances
1116  */
1117  CVector< C_FLOAT64 > initializeAtolVector(const C_FLOAT64 & baseTolerance, const bool & reducedModel) const;
1118 
1119  /**
1120  * generates a string that contains a text description of all model parameters
1121  * (initial values and reaction parameters)
1122  */
1123  std::string printParameterOverview();
1124 
1125  /**
1126  * Retrieve the time units
1127  * @return std::string timeUnits
1128  */
1129  std::string getTimeUnitsDisplayString() const;
1130 
1131  /**
1132  * Retrieve the frequency units
1133  * @return std::string frequencyUnits
1134  */
1135  std::string getFrequencyUnitsDisplayString() const;
1136 
1137  /**
1138  * Retrieve the volume units
1139  * @return std::string volumeUnits
1140  */
1141  std::string getVolumeUnitsDisplayString() const;
1142 
1143  /**
1144  * Retrieve the area units
1145  * @return std::string volumeUnits
1146  */
1147  std::string getAreaUnitsDisplayString() const;
1148 
1149  /**
1150  * Retrieve the length units
1151  * @return std::string volumeUnits
1152  */
1153  std::string getLengthUnitsDisplayString() const;
1154 
1155  /**
1156  * Retrieve the volume rate units
1157  * @return std::string volumeRateUnits
1158  */
1159  std::string getVolumeRateUnitsDisplayString() const;
1160 
1161  /**
1162  * Retrieve the concentration units
1163  * @return std::string concentrationUnits
1164  */
1165  std::string getConcentrationUnitsDisplayString() const;
1166 
1167  /**
1168  * Retrieve the concentration rate units
1169  * @return std::string concentrationRateUnits
1170  */
1171  std::string getConcentrationRateUnitsDisplayString() const;
1172 
1173  /**
1174  * Retrieve the quantity units
1175  * @return std::string quantityUnits
1176  */
1177  std::string getQuantityUnitsDisplayString() const;
1178 
1179  /**
1180  * Retrieve the quantity rate units
1181  * @return std::string quantityRateUnits
1182  */
1183  std::string getQuantityRateUnitsDisplayString() const;
1184 
1185  /**
1186  * List all trees which introduce discrete changes.
1187  * @return std::vector< const CEvaluationTree * > treesWithDiscontinuities
1188  */
1189  std::vector< const CEvaluationTree * > getTreesWithDiscontinuities() const;
1190 
1191 private:
1192 
1193  bool compile();
1194 
1195  /**
1196  * Handles unused metabolites and moves them to the end of mMetabolites.
1197  * Rows of the stoichiometry matrix dealing with unused metabolites are removed.
1198  * @return bool found
1199  */
1200  bool handleUnusedMetabolites();
1201 
1202  /**
1203  * Initialize the contained CCopasiObjects
1204  */
1205  void initObjects();
1206 
1207  /**
1208  * Clear all references to moieties
1209  */
1210  void clearMoieties();
1211 
1212  /**
1213  * Build the state template for the model.
1214  * @return bool success
1215  */
1216  bool buildStateTemplate();
1217 
1218  /**
1219  * Build the update sequence used by updateInitialValues to update all
1220  * initial values.
1221  * @return bool success
1222  */
1223  bool buildInitialSequence();
1224 
1225  /**
1226  * Build the update sequence used by applyInitialValues to update values.
1227  * @return bool success
1228  */
1230 
1231  /**
1232  * Build the update sequence used by updateSimulatedValues.
1233  * @return bool success
1234  */
1235  bool buildSimulatedSequence();
1236 
1237  /**
1238  * Build the update sequence used by updateNonSimulatedValues.
1239  * @return bool success
1240  */
1242 
1243  /**
1244  * Build the user order for the state template
1245  * @return bool success
1246  */
1247  bool buildUserOrder();
1248 
1249  /**
1250  * This updates the annotations of the link matrix and the stoichiometry matrix
1251  */
1252  void updateMatrixAnnotations();
1253 
1254  /**
1255  * Determine whether the model is autonomous
1256  */
1257  void determineIsAutonomous();
1258 
1259  /**
1260  * Compile the events
1261  * @return bool success
1262  */
1263  bool compileEvents();
1264 
1265 #ifdef COPASI_DEBUG
1266 public:
1267  void check() const;
1268 #endif
1269 
1270  // Attributes
1271 private:
1273 
1275 
1276  /**
1277  * The state template for the model
1278  */
1280 
1281  /**
1282  * This is the list of objects which contains all objects which
1283  * are up to date after a call to updateSimulatedValues
1284  */
1285  std::set< const CCopasiObject * > mSimulatedUpToDateObjects;
1286 
1290 
1291  /**
1292  * The volume unit used in the Model
1293  */
1295 
1296  /**
1297  * The volume unit used in the Model
1298  */
1300 
1301  /**
1302  * The volume unit used in the Model
1303  */
1305 
1306  /**
1307  * The time unit used in the Model
1308  */
1310 
1311  /**
1312  * The quantity unit used in the Model
1313  */
1315 
1316  /**
1317  * The type of the model
1318  */
1320 
1321  /**
1322  * for array of compartments
1323  */
1325 
1326  /**
1327  * Vector of reference to metabolites
1328  */
1330 
1331  /**
1332  * Vector of reference to metabolites in reduced model representation
1333  */
1335 
1336  /**
1337  * for array of steps
1338  */
1340 
1341  /**
1342  * for array of events
1343  */
1345 
1346  /**
1347  * Vectors of fluxes of the reactions.
1348  */
1350 
1351  /**
1352  * vector of non concentration values in the model
1353  */
1355 
1356  /**
1357  * The parameter set of the model itself
1358  */
1360 
1361  /**
1362  * Vector of parameter sets
1363  */
1365 
1366  /**
1367  * The key of the currently active parameter set.
1368  */
1370 
1371  /**
1372  * for array of conserved moieties
1373  */
1375 
1376  /**
1377  * Stoichiometry Matrix
1378  */
1380 
1381  /**
1382  * Column and Row Annotation for the reduced Stoichiometry Matrix
1383  */
1385 
1386  /**
1387  * Stoichiometry Matrix
1388  */
1390 
1391  /**
1392  * Reduced Stoichiometry Matrix
1393  */
1395 
1396  /**
1397  * Column and Row Annotation for the reduced Stoichiometry Matrix
1398  */
1400 
1401  /**
1402  * The elasticity matrix d(Flux_i)/dx_j
1403  */
1405 
1406  /**
1407  * Vector for storing the row interchanges during LU-Decomposition
1408  */
1409  // CVector< size_t > mRowLU;
1410 
1411  /**
1412  * Vector for storing the row and column interchanges needed to calculate
1413  * the full Jacobian in user order.
1414  */
1416 
1417  /**
1418  * The number of unused metabs in the model
1419  */
1421 
1422  /**
1423  * The number of metabs determined by ODEs in the model
1424  */
1426 
1427  /**
1428  * The number of metabs determined by reactions in the model
1429  */
1431 
1432  /**
1433  * The number of metabs determined by assignments in the model
1434  */
1436 
1437  /**
1438  * The number of metabs determined by reactions which can be calculated
1439  * through moieties
1440  */
1442 
1443  /**
1444  * This matrix stores L
1445  */
1447 
1448  /**
1449  * Column and Row Annotation for the Link Matrix
1450  */
1452 
1453  /**
1454  * This is used to return a view to L
1455  */
1457 
1458  /**
1459  * The Avogadro number used for this model.
1460  */
1462 
1463  /**
1464  * Factor to convert from quantity to particle number
1465  * taking into account the unit for substance quantities
1466  */
1468 
1469  /**
1470  * Factor to convert from particle number to quantity
1471  * taking into account the unit for substance quantities
1472  */
1474 
1475  /**
1476  * indicates whether a recalculation of the stoichiometry matrix decomposition is
1477  * necessary
1478  */
1480 
1481  /**
1482  * A pointer to the process report. If not NULL the compile progress is
1483  * reported to it.
1484  */
1486 
1487  /**
1488  * An ordered list of refresh methods needed by the updateInitialValues
1489  */
1490  std::vector< Refresh * > mInitialRefreshes;
1491 
1492  /**
1493  * An ordered list of refresh methods needed by the updateSimulatedValues
1494  */
1495  std::vector< Refresh * > mSimulatedRefreshes;
1496 
1497  /**
1498  * An ordered list of refresh methods needed by the applyInitialValues
1499  * to update values which stay constant during simulation.
1500  */
1501  std::vector< Refresh * > mApplyInitialValuesRefreshes;
1502 
1503  /**
1504  * An ordered list of refresh methods needed to update all model values
1505  * which are not calculated during simulation
1506  */
1507  std::vector< Refresh * > mNonSimulatedRefreshes;
1508 
1509  /**
1510  * A flag indicating whether the state template has to be reordered
1511  */
1513 
1514  /**
1515  * A flag indicating whether the model is autonomous.
1516  */
1518 
1519  /**
1520  * A Boolean value indicating whether we need to rebuild the initial
1521  * value refresh sequence
1522  */
1524 
1525  /****** Below will be removed when the math model completed ******/
1526 
1527  /**
1528  * The mathematical model. This is currently part of the model. It is
1529  * envisioned that this will be the class all tasks will operate on, since it
1530  * eventually will have the all the mathematical relevant information.
1531  */
1533 
1534 #ifdef USE_MATH_CONTAINER
1535  CMathContainer * mpMathContainer;
1536 #endif // USE_MATH_CONTAINER
1537 
1538  // Operations
1539 public:
1540  /**
1541  * Evaluate all root values for the current state of the model. If
1542  * ignoreDiscrete is true discrete roots evaluate to 1.0.
1543  * @param CVectorCore< C_FLOAT64 > & rootValues
1544  * @param const bool & ignoreDiscrete
1545  */
1546  void evaluateRoots(CVectorCore< C_FLOAT64 > & rootValues,
1547  const bool & ignoreDiscrete);
1548 
1549  /**
1550  * Process events scheduled at the given which a are checked for
1551  * equality or not
1552  * @param const C_FLOAT64 & time
1553  * @param const bool & equality
1554  * @param CProcessQueue::resolveSimultaneousAssignments pResolveSimultaneousAssignments
1555  * @return bool stateChanged
1556  */
1557  bool processQueue(const C_FLOAT64 & time,
1558  const bool & equality,
1559  CProcessQueue::resolveSimultaneousAssignments pResolveSimultaneousAssignments
1560  );
1561 
1562  /**
1563  * Check whether the roots which have value 1 lead to firing of
1564  * events and schedule them if needed.
1565  * @param const C_FLOAT64 & time
1566  * @param const bool & equality
1567  * @param const bool & correct
1568  * @param const CVector< C_INT > & roots
1569  */
1570  void processRoots(const C_FLOAT64 & time,
1571  const bool & equality,
1572  const bool & correct,
1573  const CVector< C_INT > & roots);
1574 
1575  /**
1576  * Retrieve the next execution time scheduled in the process queue
1577  * @return const C_FLOAT64 & processQueueExecutionTime
1578  */
1579  const C_FLOAT64 & getProcessQueueExecutionTime() const;
1580 
1581  /**
1582  * Retrieve the number of roots used in checking for discontinuities.
1583  * @return size_t numRoots
1584  */
1585  size_t getNumRoots() const;
1586 
1587  /**
1588  * Calculate the time derivative of all roots
1589  * @param CVector< C_FLOAT64 > & rootDerivatives
1590  */
1591  void calculateRootDerivatives(CVector< C_FLOAT64 > & rootDerivatives);
1592 
1593  /**
1594  * Retrieve a vector of root finders
1595  * @return const CVector< CMathTrigger::CRootFinder * > & rootFinders
1596  */
1598 
1599  const CMathModel* getMathModel() const;
1601 
1602 #ifdef USE_MATH_CONTAINER
1603  /**
1604  * Retrieve the container of all mathematical objects
1605  * @return const CMathContainer * pMathContainer
1606  */
1607  const CMathContainer* getMathContainer() const;
1608 
1609  /**
1610  * Retrieve the container of all mathematical objects
1611  * @return CMathContainer * pMathContainer
1612  */
1613  CMathContainer * getMathContainer();
1614 #endif // USE_MATH_CONTAINER
1615 };
1616 
1617 #endif // CModel
Definition: CEvent.h:152
static const char * LengthUnitNames[]
Definition: CModel.h:81
void initObjects()
Definition: CModel.cpp:3833
CArrayAnnotation * mpRedStoiAnnotation
Definition: CModel.h:1399
CModel::AreaUnit getAreaUnitEnum() const
Definition: CModel.cpp:2198
const C_FLOAT64 & getAvogadro() const
Definition: CModel.cpp:2349
static const char * ModelTypeNames[]
Definition: CModel.h:117
const CModelParameterSet & getModelParameterSet() const
Definition: CModel.cpp:1072
Header file of class CModelEntity and CModelValue.
bool setAreaUnit(const std::string &name)
Definition: CModel.cpp:2182
CEvent * createEvent(const std::string &name)
Definition: CModel.cpp:2928
CCopasiObject * getCorrespondingTransientObject(const CCopasiObject *pObject) const
Definition: CModel.cpp:4032
bool setVolumeUnit(const std::string &name)
Definition: CModel.cpp:2159
CCopasiVectorN< CEvent > & getEvents()
Definition: CModel.cpp:1110
std::string getTimeUnitsDisplayString() const
Definition: CModel.cpp:4531
LengthUnit mLengthUnit
Definition: CModel.h:1304
CCopasiVectorN< CEvent > mEvents
Definition: CModel.h:1344
const CLinkMatrixView & getL() const
Definition: CModel.cpp:1166
const CCopasiVector< CMetab > & getMetabolites() const
Definition: CModel.cpp:1051
bool mIsAutonomous
Definition: CModel.h:1517
std::string getConcentrationRateUnitsDisplayString() const
Definition: CModel.cpp:4607
C_FLOAT64 calculateDivergence() const
Definition: CModel.cpp:2153
bool buildUserOrder()
Definition: CModel.cpp:1349
std::string getFrequencyUnitsDisplayString() const
Definition: CModel.cpp:4539
const CCopasiVectorN< CModelValue > & getModelValues() const
Definition: CModel.cpp:1060
CModel::QuantityUnit getQuantityUnitEnum() const
Definition: CModel.cpp:2331
size_t mNumMetabolitesReactionIndependent
Definition: CModel.h:1441
std::string getQuantityUnitOldXMLName() const
Definition: CModel.cpp:2326
const CVector< CMathTrigger::CRootFinder * > & getRootFinders() const
Definition: CModel.cpp:4717
bool removeMetabolite(const std::string &key, const bool &recursive=true)
Definition: CModel.cpp:2667
bool setLengthUnit(const std::string &name)
Definition: CModel.cpp:2204
void buildRedStoi()
Definition: CModel.cpp:829
void evaluateRoots(CVectorCore< C_FLOAT64 > &rootValues, const bool &ignoreDiscrete)
Definition: CModel.cpp:4679
void updateNonSimulatedValues(void)
Definition: CModel.cpp:1892
CModelParameterSet mParameterSet
Definition: CModel.h:1359
CMatrix< C_FLOAT64 > mElasticities
Definition: CModel.h:1404
size_t getNumMetabs() const
Definition: CModel.cpp:1118
AreaUnit
Definition: CModel.h:66
const CVector< C_FLOAT64 > & getParticleFlux() const
Definition: CModel.cpp:1045
const std::vector< Refresh * > & getListOfConstantRefreshes() const
Definition: CModel.cpp:4139
void setInitialState(const CState &state)
Definition: CModel.cpp:1774
bool setTimeUnit(const std::string &name)
Definition: CModel.cpp:2227
void applyActiveParameterSet()
Definition: CModel.cpp:1082
void updateSimulatedValues(const bool &updateMoieties)
Definition: CModel.cpp:1851
void calculateJacobianX(CMatrix< C_FLOAT64 > &jacobianX, const C_FLOAT64 &derivationFactor, const C_FLOAT64 &resolution)
Definition: CModel.cpp:2082
bool removeCompartment(const size_t index, const bool &recursive=true)
Definition: CModel.cpp:2720
std::string getTimeUnitName() const
Definition: CModel.cpp:2238
bool buildNonSimulatedSequence()
Definition: CModel.cpp:1678
std::string getQuantityRateUnitsDisplayString() const
Definition: CModel.cpp:4657
CCopasiVectorNS< CCompartment > mCompartments
Definition: CModel.h:1324
Definition: CState.h:305
DependencyType
Definition: CModel.h:119
std::string printParameterOverview()
Definition: CModel.cpp:4411
std::string getVolumeRateUnitsDisplayString() const
Definition: CModel.cpp:4571
const CMathModel * getMathModel() const
Definition: CModel.cpp:4722
CLinkMatrixView mLView
Definition: CModel.h:1456
const std::set< const CCopasiObject * > & getUptoDateObjects() const
Definition: CModel.cpp:1178
void calculateJacobian(CMatrix< C_FLOAT64 > &jacobian, const C_FLOAT64 &derivationFactor, const C_FLOAT64 &resolution)
Definition: CModel.cpp:2006
CModelValue * createModelValue(const std::string &name, const C_FLOAT64 &value=0.0)
Definition: CModel.cpp:2838
size_t getNumODEMetabs() const
Definition: CModel.cpp:1124
CMatrix< C_FLOAT64 > mStoi
Definition: CModel.h:1389
#define C_INT32
Definition: copasi.h:90
CMatrix< C_FLOAT64 > mRedStoi
Definition: CModel.h:1394
bool buildStateTemplate()
Definition: CModel.cpp:1262
CLinkMatrix mL
Definition: CModel.h:1446
void updateMoietyValues()
Definition: CModel.cpp:896
Definition: CMetab.h:178
void applyInitialValues()
Definition: CModel.cpp:1236
std::vector< Refresh * > mNonSimulatedRefreshes
Definition: CModel.h:1507
CCopasiVectorN< CModelValue > mValues
Definition: CModel.h:1354
const std::vector< Refresh * > & getListOfSimulatedRefreshes() const
Definition: CModel.cpp:4136
std::vector< Refresh * > DataUpdateSequence
const CMatrix< C_FLOAT64 > & getRedStoi() const
Definition: CModel.cpp:1154
const CCopasiVector< CMoiety > & getMoieties() const
Definition: CModel.cpp:1163
void calculateRootDerivatives(CVector< C_FLOAT64 > &rootDerivatives)
Definition: CModel.cpp:4712
size_t mNumMetabolitesUnused
Definition: CModel.h:1420
size_t getTotSteps() const
Definition: CModel.cpp:1136
VolumeUnit mVolumeUnit
Definition: CModel.h:1294
VolumeUnit
Definition: CModel.h:56
bool hasReversibleReaction() const
Definition: CModel.cpp:3892
CMathModel * mpMathModel
Definition: CModel.h:1532
ModelType
Definition: CModel.h:112
void setInitialTime(const C_FLOAT64 &time)
Definition: CModel.cpp:1181
CCopasiVector< CMetab > mMetabolites
Definition: CModel.h:1329
bool removeModelValue(const CModelValue *pModelValue, const bool &recursive=true)
Definition: CModel.cpp:2903
bool appendDependentReactions(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2472
std::set< const CCopasiObject * > mSimulatedUpToDateObjects
Definition: CModel.h:1285
LengthUnit
Definition: CModel.h:76
std::vector< Refresh * > mApplyInitialValuesRefreshes
Definition: CModel.h:1501
std::string getLengthUnitsDisplayString() const
Definition: CModel.cpp:4563
CStateTemplate mStateTemplate
Definition: CModel.h:1279
CArrayAnnotation * mpLinkMatrixAnnotation
Definition: CModel.h:1451
bool getInitialUpdateSequence(const CMath::SimulationContextFlag &context, const CCopasiObject::DataObjectSet &changedObjects, const CCopasiObject::DataObjectSet &requestedObjects, CCopasiObject::DataUpdateSequence &updateSequence) const
Definition: CModel.cpp:1792
const C_FLOAT64 & getQuantity2NumberFactor() const
Definition: CModel.cpp:2354
bool appendDependentModelObjects(const std::set< const CCopasiObject * > &candidates, std::set< const CCopasiObject * > &dependentReactions, std::set< const CCopasiObject * > &dependentMetabolites, std::set< const CCopasiObject * > &dependentCompartments, std::set< const CCopasiObject * > &dependentModelValues, std::set< const CCopasiObject * > &dependentEvents) const
Definition: CModel.cpp:2364
CVector< C_FLOAT64 > mParticleFluxes
Definition: CModel.h:1349
C_FLOAT64 mNumber2QuantityFactor
Definition: CModel.h:1473
const C_FLOAT64 & getNumber2QuantityFactor() const
Definition: CModel.cpp:2357
size_t getNumVariableMetabs() const
Definition: CModel.cpp:1121
const std::vector< Refresh * > & getListOfNonSimulatedRefreshes() const
Definition: CModel.cpp:4142
size_t getNumDependentReactionMetabs() const
Definition: CModel.cpp:1133
size_t findMetabByName(const std::string &Target) const
Definition: CModel.cpp:1198
std::string getVolumeUnitsDisplayString() const
Definition: CModel.cpp:4547
bool mReorderNeeded
Definition: CModel.h:1512
void setState(const CState &state)
Definition: CModel.cpp:1785
void removeDependentModelObjects(const std::set< const CCopasiObject * > &deletedObjects)
Definition: CModel.cpp:2859
bool compile()
Definition: CModel.cpp:381
bool buildDependencyGraphs()
Definition: CModel.cpp:547
void determineIsAutonomous()
Definition: CModel.cpp:3959
size_t mNumMetabolitesAssignment
Definition: CModel.h:1435
void clearMoieties()
Definition: CModel.cpp:1257
void processRoots(const C_FLOAT64 &time, const bool &equality, const bool &correct, const CVector< C_INT > &roots)
Definition: CModel.cpp:4692
CReaction * createReaction(const std::string &name)
Definition: CModel.cpp:2760
void refreshActiveParameterSet()
Definition: CModel.cpp:1105
const bool & isAutonomous() const
Definition: CModel.cpp:3956
CCopasiVector< CMetab > mMetabolitesX
Definition: CModel.h:1334
const C_FLOAT64 & getInitialTime() const
Definition: CModel.cpp:1184
std::vector< Refresh * > mInitialRefreshes
Definition: CModel.h:1490
bool appendDependentCompartments(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2538
void calculateElasticityMatrix(const C_FLOAT64 &factor, const C_FLOAT64 &resolution)
Definition: CModel.cpp:1968
void initializeMetabolites()
Definition: CModel.cpp:942
bool mCompileIsNecessary
Definition: CModel.h:1479
std::string getLengthUnitName() const
Definition: CModel.cpp:2215
QuantityUnit mQuantityUnit
Definition: CModel.h:1314
CModel::LengthUnit getLengthUnitEnum() const
Definition: CModel.cpp:2220
std::vector< Refresh * > mSimulatedRefreshes
Definition: CModel.h:1495
bool handleUnusedMetabolites()
Definition: CModel.cpp:723
bool appendDependentMetabolites(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2501
CState mInitialState
Definition: CModel.h:1272
bool getTransientUpdateSequence(const CMath::SimulationContextFlag &context, const CCopasiObject::DataObjectSet &changedObjects, const CCopasiObject::DataObjectSet &requestedObjects, CCopasiObject::DataUpdateSequence &updateSequence) const
Definition: CModel.cpp:1804
std::vector< const CEvaluationTree * > getTreesWithDiscontinuities() const
Definition: CModel.cpp:4059
bool buildApplyInitialValuesSequence()
Definition: CModel.cpp:1627
CCopasiVectorN< CModelParameterSet > mParameterSets
Definition: CModel.h:1364
const CCopasiVectorN< CModelParameterSet > & getModelParameterSets() const
Definition: CModel.cpp:1066
TimeUnit
Definition: CModel.h:86
void buildStoi()
Definition: CModel.cpp:642
const std::string & getKey() const
Definition: CModel.cpp:1142
size_t findMoiety(const std::string &Target) const
Definition: CModel.cpp:1216
CMathDependencyGraph mTransientDependencies
Definition: CModel.h:1288
Header file of class CCopasiContainer.
size_t getNumIndependentReactionMetabs() const
Definition: CModel.cpp:1130
const C_FLOAT64 & getTime() const
Definition: CModel.cpp:1190
void setCompileFlag(bool flag=true)
Definition: CModel.cpp:607
bool processQueue(const C_FLOAT64 &time, const bool &equality, CProcessQueue::resolveSimultaneousAssignments pResolveSimultaneousAssignments)
Definition: CModel.cpp:4685
TimeUnit mTimeUnit
Definition: CModel.h:1309
bool mBuildInitialSequence
Definition: CModel.h:1523
CProcessReport * mpCompileHandler
Definition: CModel.h:1485
long int flag
Definition: f2c.h:52
static const char * AreaUnitNames[]
Definition: CModel.h:71
void setTime(const C_FLOAT64 &time)
Definition: CModel.cpp:1187
void calculateDerivativesX(C_FLOAT64 *derivativesX)
Definition: CModel.cpp:1941
std::string getAreaUnitName() const
Definition: CModel.cpp:2193
std::string getConcentrationUnitsDisplayString() const
Definition: CModel.cpp:4587
bool getUpdateSequence(CMathDependencyGraph &dependencyGraph, const CMath::SimulationContextFlag &context, const CCopasiObject::DataObjectSet &changedObjects, const CCopasiObject::DataObjectSet &requestedObjects, CCopasiObject::DataUpdateSequence &updateSequence) const
Definition: CModel.cpp:1816
CCopasiVectorNS< CCompartment > & getCompartments()
Definition: CModel.cpp:1145
std::string getQuantityUnitsDisplayString() const
Definition: CModel.cpp:4647
void updateMatrixAnnotations()
Definition: CModel.cpp:863
void buildLinkZero()
Definition: CModel.cpp:3946
CModel::TimeUnit getTimeUnitEnum() const
Definition: CModel.cpp:2243
virtual std::string getChildObjectUnits(const CCopasiObject *pObject) const
Definition: CModel.cpp:246
iterator(* resolveSimultaneousAssignments)(const std::multimap< CKey, CAction > &, const C_FLOAT64 &, const bool &, const size_t &)
CMathDependencyGraph mInitialDependencies
Definition: CModel.h:1287
size_t mNumMetabolitesReaction
Definition: CModel.h:1430
std::string getQuantityUnitName() const
Definition: CModel.cpp:2321
#define C_FLOAT64
Definition: copasi.h:92
const CState & getInitialState() const
Definition: CModel.cpp:1768
bool compileIfNecessary(CProcessReport *pProcessReport)
Definition: CModel.cpp:612
std::string mActiveParameterSetKey
Definition: CModel.h:1369
CMatrix< C_FLOAT64 > mStoiInternal
Definition: CModel.h:1379
size_t getNumAssignmentMetabs() const
Definition: CModel.cpp:1127
CModel & operator=(const CModel &src)
void buildMoieties()
Definition: CModel.cpp:905
const CStateTemplate & getStateTemplate() const
Definition: CModel.cpp:1172
size_t getNumModelValues() const
Definition: CModel.cpp:1139
CCopasiVectorNS< CReaction > mSteps
Definition: CModel.h:1339
ModelType mType
Definition: CModel.h:1319
~CModel()
Definition: CModel.cpp:227
const ModelType & getModelType() const
Definition: CModel.cpp:2339
AreaUnit mAreaUnit
Definition: CModel.h:1299
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
bool setQuantityUnit(const std::string &name)
Definition: CModel.cpp:2250
bool appendDependentEvents(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2593
const C_FLOAT64 & getProcessQueueExecutionTime() const
Definition: CModel.cpp:4702
bool updateInitialValues()
Definition: CModel.cpp:1461
void calculateDerivatives(C_FLOAT64 *derivatives)
Definition: CModel.cpp:1903
const CLinkMatrix & getL0() const
Definition: CModel.cpp:1169
bool compileEvents()
Definition: CModel.cpp:4116
std::string getAreaUnitsDisplayString() const
Definition: CModel.cpp:4555
CVector< C_FLOAT64 > initializeAtolVector(const C_FLOAT64 &baseTolerance, const bool &reducedModel) const
Definition: CModel.cpp:4368
Definition: CModel.h:50
C_FLOAT64 mAvogadro
Definition: CModel.h:1461
Header file of class CEvent.
bool convert2NonReversible()
Definition: CModel.cpp:3205
const std::vector< Refresh * > & getListOfInitialRefreshes() const
Definition: CModel.cpp:4133
const CState & getState() const
Definition: CModel.cpp:1771
void setAvogadro(const C_FLOAT64 &avogadro)
Definition: CModel.cpp:2342
std::string getVolumeUnitName() const
Definition: CModel.cpp:2170
const CCopasiVector< CMetab > & getMetabolitesX() const
Definition: CModel.cpp:1057
CModel::VolumeUnit getVolumeUnitEnum() const
Definition: CModel.cpp:2175
const CMatrix< C_FLOAT64 > & getStoi() const
Definition: CModel.cpp:1160
static const char * TimeUnitNames[]
Definition: CModel.h:91
std::vector< Refresh * > buildInitialRefreshSequence(std::set< const CCopasiObject * > &changedObjects)
Definition: CModel.cpp:4164
std::set< const CCopasiObject * > DataObjectSet
size_t mNumMetabolitesODE
Definition: CModel.h:1425
void setModelType(const ModelType &modelType)
Definition: CModel.cpp:2336
size_t getNumRoots() const
Definition: CModel.cpp:4707
std::string suitableForStochasticSimulation() const
Definition: CModel.cpp:3901
CArrayAnnotation * mpStoiAnnotation
Definition: CModel.h:1384
static const char * QuantityUnitOldXMLNames[]
Definition: CModel.h:102
bool buildInitialSequence()
Definition: CModel.cpp:1395
C_FLOAT64 mQuantity2NumberFactor
Definition: CModel.h:1467
bool removeLocalReactionParameter(const std::string &key, const bool &recursive=true)
Definition: CModel.cpp:2818
CCopasiVector< CMoiety > mMoieties
Definition: CModel.h:1374
CVector< size_t > mJacobianPivot
Definition: CModel.h:1415
bool isStateVariable(const CCopasiObject *pObject) const
Definition: CModel.cpp:3983
bool appendDependentModelValues(std::set< const CCopasiObject * > candidates, std::set< const CCopasiObject * > &dependents) const
Definition: CModel.cpp:2566
CMathDependencyGraph mPhysicalDependencies
Definition: CModel.h:1289
C_INT32 load(CReadConfig &configBuffer)
Definition: CModel.cpp:255
bool removeEvent(const size_t index, const bool &recursive=true)
Definition: CModel.cpp:2945
bool removeReaction(const CReaction *pReaction, const bool &recursive=true)
Definition: CModel.cpp:2792
CCompartment * createCompartment(const std::string &name, const C_FLOAT64 &volume=1.0)
Definition: CModel.cpp:2698
static const char * QuantityUnitNames[]
Definition: CModel.h:107
static const char * VolumeUnitNames[]
Definition: CModel.h:61
CState mCurrentState
Definition: CModel.h:1274
bool forceCompile(CProcessReport *pProcessReport)
Definition: CModel.cpp:636
bool buildSimulatedSequence()
Definition: CModel.cpp:1483
QuantityUnit
Definition: CModel.h:96
CMetab * createMetabolite(const std::string &name, const std::string &compartment, const C_FLOAT64 &iconc=1.0, const CModelEntity::Status &status=CModelEntity::REACTIONS)
Definition: CModel.cpp:2622
CModel(const CModel &src)