COPASI API  4.16.103
CMathObject.h
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 #ifndef COPASI_CObject
7 #define COPASI_CObject
8 
9 #include <set>
10 #include <map>
11 
13 #include "copasi/math/CMathEnum.h"
14 
15 class CMathExpression;
16 class CMathContainer;
17 class CExpression;
18 class CCopasiObject;
19 class CMetab;
20 class CEvaluationNode;
21 
23 {
24  friend std::ostream &operator<<(std::ostream &os, const CMathObject & o);
25 
26 public:
27  /**
28  * Default Constructor
29  */
30  CMathObject();
31 
32  /**
33  * Destructor
34  */
35  virtual ~CMathObject();
36 
37  /**
38  * Copy an existing object
39  * @param const CMathObject & src
40  * @param CMathContainer & container
41  * @param const size_t & valueOffset
42  * @param const size_t & objectOffset
43  */
44  void copy(const CMathObject & src, CMathContainer & container, const size_t & valueOffset, const size_t & objectOffset);
45 
46  /**
47  * Retrieve the CN of the object
48  * @return CCopasiObjectName
49  */
50  virtual CCopasiObjectName getCN() const;
51 
52  /**
53  * Retrieve a descendant object by its CN.
54  * @param const CCopasiObjectName & cn
55  * @return const CObjectInterface * pObject
56  */
57  virtual const CObjectInterface * getObject(const CCopasiObjectName & cn) const;
58 
59  /**
60  * Retrieve the prerequisites, i.e., the objects which need to be evaluated
61  * before this.
62  * @return const CObjectInterface::ObjectSet & prerequisites
63  */
64  virtual const CObjectInterface::ObjectSet & getPrerequisites() const;
65 
66  /**
67  * Check whether a given object is a prerequisite for a context.
68  * @param const CObjectInterface * pObject
69  * @param const CMath::SimulationContextFlag & context
70  * @param const CObjectInterface::ObjectSet & changedObjects
71  * @return bool isPrerequisiteForContext
72  */
73  virtual bool isPrerequisiteForContext(const CObjectInterface * pObject,
74  const CMath::SimulationContextFlag & context,
75  const CObjectInterface::ObjectSet & changedObjects) const;
76 
77  /**
78  * This is the output method for any object. The default implementation
79  * provided with CCopasiObject uses the ostream operator<< of the object
80  * to print the object.To override this default behavior one needs to
81  * reimplement the virtual print function.
82  * @param std::ostream * ostream
83  */
84  virtual void print(std::ostream * ostream) const;
85 
86  /**
87  * Retrieve a pointer to the value of the object
88  */
89  virtual void * getValuePointer() const;
90 
91  /**
92  * Calculate the objects value
93  */
94  void calculate();
95 
96  /**
97  * Initialize a single mathematical object and advance relevant pointers
98  * @param CMathObject *& pObject
99  * @param C_FLOAT64 *& pValue
100  * @param const CMath::Value & valueType
101  * @param const CMath::EntityType & entityType
102  * @param const CMath::SimulationType & simulationType
103  * @param const bool & isIntensiveProperty
104  * @param const bool & isInitialValue
105  * @param const CCopasiObject * pDataObject
106  */
107  static void initialize(CMathObject *& pObject,
108  C_FLOAT64 *& pValue,
109  const CMath::ValueType & valueType,
110  const CMath::EntityType & entityType,
111  const CMath::SimulationType & simulationType,
112  const bool & isIntensiveProperty,
113  const bool & isInitialValue,
114  const CCopasiObject * pDataObject);
115 
116  /**
117  * Compile
118  * @param CMathContainer & container
119  * @return bool §success
120  */
121  bool compile(CMathContainer & container);
122 
123  /**
124  * Retrieve the pointer to the data object
125  * @return const CCopasiObject * pDataObject
126  */
127  const CCopasiObject * getDataObject() const;
128 
129  /**
130  * Retrieve the value type
131  * @return const CMath::ValueType & valueType
132  */
133  const CMath::ValueType & getValueType() const;
134 
135  /**
136  * Retrieve the entity type
137  * @return const CMath::EntityType & entityType
138  */
139  const CMath::EntityType & getEntityType() const;
140 
141  /**
142  * Retrieve the simulation type
143  * @return const CMath::SimulationType & simulationType
144  */
146 
147  /**
148  * Set the simulation type
149  * @param const CMath::SimulationType & simulationType
150  */
151  void setSimulationType(const CMath::SimulationType & simulationType);
152 
153  /**
154  * Check whether the object is an intensive property
155  * @return const bool & isIntensiveProperty
156  */
157  const bool & isIntensiveProperty() const;
158 
159  /**
160  * Check whether the object is an initial value
161  * @return const bool & isInitialValue
162  */
163  const bool & isInitialValue() const;
164 
165  /**
166  * Set the expression's infix and compile the object.
167  * @param const std::string & infix,
168  * @param const bool & isBoolean,
169  * @param CMathContainer & container
170  * @return bool success
171  */
172  bool setExpression(const std::string & infix,
173  const bool & isBoolean,
174  CMathContainer & container);
175 
176  /**
177  * Set the expression and compile the object.
178  * @param const CExpression & expression,
179  * @param CMathContainer & container
180  * @return bool success
181  */
182  bool setExpression(const CExpression & expression,
183  CMathContainer & container);
184 
185  /**
186  * Set the expression and compile the object.
187  * @param CMathExpression * pMathExpression,
188  * @return bool success
189  */
190  bool setExpressionPtr(CMathExpression * pMathExpression);
191 
192  /**
193  * Retrieve a pointer to the math expression.
194  * @return const CMathExpression * pExpression
195  */
196  const CMathExpression * getExpressionPtr() const;
197 
198 private:
199  /**
200  * Compile initial value objects
201  * @param CMathContainer & container
202  * @return bool success
203  */
204  bool compileInitialValue(CMathContainer & container);
205 
206  /**
207  * Compile value objects
208  * @param CMathContainer & container
209  * @return bool success
210  */
211  bool compileValue(CMathContainer & container);
212 
213  /**
214  * Compile value rate objects
215  * @param CMathContainer & container
216  * @return bool success
217  */
218  bool compileRate(CMathContainer & container);
219 
220  /**
221  * Compile the reactions particle flux
222  * @param CMathContainer & container
223  * @return bool success
224  */
225  bool compileParticleFlux(CMathContainer & container);
226 
227  /**
228  * Compile the reactions flux
229  * @param CMathContainer & container
230  * @return bool success
231  */
232  bool compileFlux(CMathContainer & container);
233 
234  /**
235  * Compile the reactions propensity
236  * @param CMathContainer & container
237  * @return bool success
238  */
239  bool compilePropensity(CMathContainer & container);
240 
241  /**
242  * Compile the total mass of a moiety.
243  * @param CMathContainer & container
244  * @return bool success
245  */
246  bool compileTotalMass(CMathContainer & container);
247 
248  /**
249  * Compile the dependent mass of a moiety.
250  * @param CMathContainer & container
251  * @return bool success
252  */
253  bool compileDependentMass(CMathContainer & container);
254 
255  /**
256  * Common compile steps after an expression has been created.
257  */
258  void compileExpression();
259 
260  /**
261  * Create and compile an expression based on the given expression.
262  * @param const CExpression * pExpression
263  * @param CMathContainer & container
264  * @return bool success
265  */
266  bool createConvertedExpression(const CExpression * pExpression,
267  CMathContainer & container);
268 
269  /**
270  * Create and compile an expression for an intensive value of a species.
271  * @param const CMetab * pSpecies
272  * @param CMathContainer & container
273  * @return bool success
274  */
275  bool createIntensiveValueExpression(const CMetab * pSpecies,
276  CMathContainer & container);
277 
278  /**
279  * Create and compile an expression for an extensive value of a species.
280  * @param const CMetab * pSpecies
281  * @param CMathContainer & container
282  * @return bool success
283  */
284  bool createExtensiveValueExpression(const CMetab * pSpecies,
285  CMathContainer & container);
286 
287  /**
288  * Create and compile an expression for an intensive rate of a species.
289  * @param const CMetab * pSpecies
290  * @param CMathContainer & container
291  * @return bool success
292  */
293  bool createIntensiveRateExpression(const CMetab * pSpecies,
294  CMathContainer & container);
295 
296  /**
297  * Create and compile an expression for an extensive rate of a species determined
298  * by an ODE.
299  * @param const CMetab * pSpecies
300  * @param CMathContainer & container
301  * @return bool success
302  */
303  bool createExtensiveODERateExpression(const CMetab * pSpecies,
304  CMathContainer & container);
305 
306  /**
307  * Create and compile an expression for an extensive rate of a species determined
308  * by reactions
309  * @param const CMetab * pSpecies
310  * @param CMathContainer & container
311  * @return bool success
312  */
313  bool createExtensiveReactionRateExpression(const CMetab * pSpecies,
314  CMathContainer & container);
315 
317 
318  /**
319  * The expression which determines the value of the object.
320  */
322 
323  /**
324  * A pointer to value of the object
325  */
327 
328  /**
329  * The prerequisites, i.e., the objects which need to be evaluated before this.
330  */
332 
333  /**
334  * The type of the object
335  */
337 
338  /**
339  * The entity type the object belongs
340  */
342 
343  /**
344  * The simulation type
345  */
347 
348  /**
349  * A flag indicating whether this is an intensive or extensive property.
350  */
352 
353  /**
354  * A flag indicating whether this is an initial value, i.e, which dependency graph
355  * is used to update the object.
356  */
358 
359  /**
360  * A pointer to the corresponding intensive property if it exists otherwise NULL
361  */
363 
364  /**
365  * A pointer to the data object
366  */
368 };
369 
370 std::ostream &operator<<(std::ostream &os, const CMathObject & o);
371 
372 #endif // COPASI_CObject
const CMathExpression * getExpressionPtr() const
friend std::ostream & operator<<(std::ostream &os, const CMathObject &o)
CObjectInterface::ObjectSet mPrerequisites
Definition: CMathObject.h:331
void setSimulationType(const CMath::SimulationType &simulationType)
const CMath::EntityType & getEntityType() const
bool createExtensiveReactionRateExpression(const CMetab *pSpecies, CMathContainer &container)
SimulationType
Definition: CMathEnum.h:182
void copy(const CMathObject &src, CMathContainer &container, const size_t &valueOffset, const size_t &objectOffset)
Definition: CMathObject.cpp:64
const CMath::SimulationType & getSimulationType() const
bool compilePropensity(CMathContainer &container)
const CMathObject * mpIntensiveProperty
Definition: CMathObject.h:362
virtual CCopasiObjectName getCN() const
bool mIsIntensiveProperty
Definition: CMathObject.h:351
void compileExpression()
C_FLOAT64 * mpValue
Definition: CMathObject.h:326
bool compile(CMathContainer &container)
CMath::EntityType mEntityType
Definition: CMathObject.h:341
Definition: CMetab.h:178
virtual const CObjectInterface::ObjectSet & getPrerequisites() const
virtual void * getValuePointer() const
static C_FLOAT64 InvalidValue
Definition: CMathObject.h:316
bool compileRate(CMathContainer &container)
EntityType
Definition: CMathEnum.h:195
bool compileTotalMass(CMathContainer &container)
ValueType
Definition: CMathEnum.h:163
const bool & isInitialValue() const
CMath::ValueType mValueType
Definition: CMathObject.h:336
bool mIsInitialValue
Definition: CMathObject.h:357
bool setExpression(const std::string &infix, const bool &isBoolean, CMathContainer &container)
bool compileInitialValue(CMathContainer &container)
bool createIntensiveValueExpression(const CMetab *pSpecies, CMathContainer &container)
virtual void print(std::ostream *ostream) const
bool compileValue(CMathContainer &container)
std::ostream & operator<<(std::ostream &os, const CMathObject &o)
std::set< const CObjectInterface * > ObjectSet
const CMath::ValueType & getValueType() const
bool compileParticleFlux(CMathContainer &container)
#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
virtual const CObjectInterface * getObject(const CCopasiObjectName &cn) const
bool compileDependentMass(CMathContainer &container)
const CCopasiObject * mpDataObject
Definition: CMathObject.h:367
const bool & isIntensiveProperty() const
virtual ~CMathObject()
Definition: CMathObject.cpp:59
bool createIntensiveRateExpression(const CMetab *pSpecies, CMathContainer &container)
CMathExpression * mpExpression
Definition: CMathObject.h:321
bool compileFlux(CMathContainer &container)
void calculate()
bool createExtensiveValueExpression(const CMetab *pSpecies, CMathContainer &container)
bool createExtensiveODERateExpression(const CMetab *pSpecies, CMathContainer &container)
bool createConvertedExpression(const CExpression *pExpression, CMathContainer &container)
bool setExpressionPtr(CMathExpression *pMathExpression)
const CCopasiObject * getDataObject() const
virtual bool isPrerequisiteForContext(const CObjectInterface *pObject, const CMath::SimulationContextFlag &context, const CObjectInterface::ObjectSet &changedObjects) const
CMath::SimulationType mSimulationType
Definition: CMathObject.h:346