COPASI API  4.16.103
CModelValue.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /*!
16  \file CModelValue.h
17  \brief Header file of class CModelEntity and CModelValue
18  */
19 
20 #ifndef COPASI_CModelValue
21 #define COPASI_CModelValue
22 
23 #include <string>
24 #include <iostream>
25 
28 
29 class CModel;
30 class CExpression;
31 
32 /**
33  * The base class for CCompartment, CMetab and CModelValue.
34  * CModelEntity is a base class for CCompartment, CMetab and CModelValue.
35  * These three classes have in common that (in the long run) they can each be model variables
36  * (subject to ODEs), constant, or subject to algebraic assignments.
37  * In addition, the CMetab objects can also be subject to reactions, and conservation rules.
38  */
40 {
41 protected:
42  /**
43  * The id of the corresponding parameter in an SBML file.
44  * This value is either set upon importing an SBML file,
45  * or when the object is first exported to an SBML file.
46  */
47  std::string mSBMLId;
48 
49 public:
50  /**
51  * The valid states for metabolites
52  */
53  enum Status
54  {
55  FIXED = 0, //the entity is constant (for species even if they are part of a reaction)
56  ASSIGNMENT, //the entity is changed by an assignment rule
57  REACTIONS, //applies only for species, the species concentration is changed by reactions
58  // DEPENDENT, //applies only for species, the species concentration is determined by conservation rules
59  // UNUSED,
60  ODE, //the entity is changed by an ordinary differential equation
62  };
63 
64  /**
65  * String representation of the states
66  */
67  static const std::string StatusName[];
68 
69  /**
70  * XML representation of the states
71  */
72  static const char * XMLStatus[];
73 
74  /**
75  * Default constructor
76  * @param const std::string & name (default: "NoName")
77  * @param const CCopasiContainer * pParent (default: NULL)
78  */
79  CModelEntity(const std::string & name = "NoName",
80  const CCopasiContainer * pParent = NULL,
81  const std::string & type = "ModelEntity",
83 
84  /**
85  * Copy constructor
86  * @param const CModelValue & src
87  * @param const CCopasiContainer * pParent (default: NULL)
88  */
89  CModelEntity(const CModelEntity & src,
90  const CCopasiContainer * pParent = NULL);
91 
92  /**
93  * Destructor.
94  */
95  ~CModelEntity();
96 
97  /**
98  * Retrieve the key
99  * @return std::string key
100  */
101  virtual const std::string & getKey() const;
102 
103  /**
104  * Retrieve the status of the entity.
105  * @return const CModelEntity::Status & status
106  */
107  const CModelEntity::Status & getStatus() const;
108 
109  /**
110  * Compile the model value. This is only needed for status ASIGNMENT and ODE.
111  * @return bool success
112  */
113  virtual bool compile();
114 
115  /**
116  * Calculate the value or the rate depending whether we have an ASIGNMENT or ODE
117  */
118  virtual void calculate();
119 
120  /**
121  * Check whether the entity is FIXED or not.
122  * @return bool isFixed
123  */
124  inline bool isFixed() const {return mStatus == FIXED;}
125 
126  /**
127  * Retrieve the value
128  */
129  const C_FLOAT64 & getValue() const;
130 
131  /**
132  * Retrieve the initial value
133  */
134  const C_FLOAT64 & getInitialValue() const;
135 
136  /**
137  * Refresh the initial value
138  */
139  virtual void refreshInitialValue();
140 
141  /**
142  * Return rate of production of this entity
143  */
144  const C_FLOAT64 & getRate() const;
145 
146  /**
147  * Set the status
148  * @param const CModelEntity::Status & status
149  */
150  virtual void setStatus(const CModelEntity::Status & status);
151 
152  /**
153  * Set the value
154  * @param const C_FLOAT64 & value
155  */
156  virtual void setValue(const C_FLOAT64 & value);
157 
158  /**
159  * Set the initial value
160  * @param const C_FLOAT64 & initialValue
161  */
162  virtual void setInitialValue(const C_FLOAT64 & initialValue);
163 
164  /**
165  * Set the rate (dmValue/dt)
166  * @param "const C_FLOAT64 &" rate
167  */
168  void setRate(const C_FLOAT64 & rate);
169 
170  /**
171  * Retrieve the object representing the value;
172  */
173  virtual const CCopasiObject * getValueObject() const;
174 
175  /**
176  * Retrieve a pointer to the value;
177  */
178  virtual void * getValuePointer() const;
179 
180  /**
181  * Set the object parent
182  * @param const CCopasiContainer * pParent
183  * @return bool success
184  */
185  virtual bool setObjectParent(const CCopasiContainer * pParent);
186 
187  /**
188  * Retrieve the list of deleted numeric child objects;
189  * @return std::set< const CCopasiObject * > deletedObjects
190  */
191  virtual std::set< const CCopasiObject * > getDeletedObjects() const;
192 
193  /**
194  * Check whether an object must be deleted because its prerequisites can
195  * no longer be fulfilled due to the given deleted objects
196  * @param const DataObjectSet & deletedObjects
197  * @return bool mustBeDeleted
198  */
199  virtual bool mustBeDeleted(const DataObjectSet & deletedObjects) const;
200 
201  /**
202  * Sets the SBMLId.
203  */
204  void setSBMLId(const std::string& id);
205 
206  /**
207  * Returns a reference to the SBML Id.
208  */
209  const std::string& getSBMLId() const;
210 
211  /**
212  * Set the pointer to the initial value
213  * @param C_FLOAT64 * pInitialValue
214  */
215  void setInitialValuePtr(C_FLOAT64 * pInitialValue);
216 
217  /**
218  * Set the pointer to the value
219  * @param C_FLOAT64 * pValue
220  */
221  void setValuePtr(C_FLOAT64 * pValue);
222 
223  /**
224  * Set the expression for non FIXED model values
225  * @param CExpression*
226  * @return bool success
227  */
228  bool setExpressionPtr(CExpression* pExpression);
229 
230  /**
231  * Retrieve the pointer to the expression for non FIXED model values.
232  * @return CExpression*
233  */
234  const CExpression* getExpressionPtr() const;
235 
236  /**
237  * Retrieve the pointer to the expression for non FIXED model values.
238  * @return CExpression*
239  */
241 
242  /**
243  * Set the expression for non FIXED model values
244  * @param CExpression*
245  * @return bool success
246  */
247  bool setInitialExpressionPtr(CExpression* pExpression);
248 
249  /**
250  * Retrieve the pointer to the expression for non FIXED model values.
251  * @return CExpression*
252  */
253  const CExpression* getInitialExpressionPtr() const;
254 
255  /**
256  * Retrieve the pointer to the expression for non FIXED model values.
257  * @return CExpression*
258  */
260 
261  /**
262  * Set the expression for non FIXED model values
263  * @param const std::string & expression
264  * @return bool success
265  */
266  bool setExpression(const std::string & expression);
267 
268  /**
269  * Retrieve the expression for non FIXED model values.
270  * @return std::string expression
271  */
272  std::string getExpression() const;
273 
274  /**
275  * Set the expression for ODE or REACTION model values
276  * @param const std::string & expression
277  * @return bool success
278  */
279  bool setInitialExpression(const std::string & expression);
280 
281  /**
282  * Retrieve the expression for ODE or REACTION model values.
283  * @return std::string expression
284  */
285  std::string getInitialExpression() const;
286 
287  /**
288  * Set whether the model entity is used during simulation
289  * @param const bool & used
290  */
291  void setUsed(const bool & used);
292 
293  /**
294  * Retrieve whether the model value is used during simulation
295  * @return const bool & used
296  */
297  const bool & isUsed() const;
298 
299  /**
300  * Retrieve object referencing the initial value
301  * @return CCopasiObject * initialValueReference
302  */
304 
305  /**
306  * Retrieve object referencing the value
307  * @return CCopasiObject * valueReference
308  */
310 
311  /**
312  * Retrieve object referencing the rate
313  * @return CCopasiObject * rateReference
314  */
316 
317 protected:
318  /**
319  * Pointer to the value of the model entity.
320  */
322 
323  /**
324  * Pointer to the initial value of the model entity.
325  */
327 
328  /**
329  * Rate of change/time.
330  */
332 
333  /**
334  * The infix expression for objects of type ASSIGNMENT or ODE
335  */
337 
338  /**
339  * Optional initial expression
340  */
342 
343 private:
344  /**
345  * Status of the model entity.
346  */
348 
349  /**
350  * Indicates whether the model value is used, i.e., must be
351  * calculated during the simulation
352  */
353  bool mUsed;
354 
355 protected:
360 
361 private:
362  /**
363  * Initialize the contained CCopasiObjects
364  */
365  void initObjects();
366 };
367 
368 /*
369 Table of possible CModelEntity objects with different Status
370 
371  current status corresponding sbml object
372 -------------------------------------------------------------------------------------------------
373 CMetab: Species
374 
375 FIXED implemented constant=true
376 UNUSED implemented ?
377 SUBJECT_TO_REACTION implemented constant=false, boundaryCondition=false
378 DEPENDENT implemented constant=false, boundaryCondition=false
379 ODE implemented constant=false, boundaryCondition=true, rate rule
380 ASSIGNMENT implemented constant=false, boundaryCondition=true, assignment rule
381 TIME -
382 
383 CCompartment: Compartment
384 
385 FIXED implemented constant=true
386 UNUSED not implemented
387 SUBJECT_TO_REACTION -
388 DEPENDENT -
389 ODE implemented constant=false, rate rule
390 ASSIGNMENT implemented constant=false, assignment rule
391 TIME -
392 
393 CModelValue: Parameter
394 
395 FIXED implemented constant=true
396 UNUSED not implemented
397 SUBJECT_TO_REACTION -
398 DEPENDENT -
399 ODE implemented constant=false, rate rule
400 ASSIGNMENT implemented constant=false, rate rule
401 TIME -
402 
403 CModel: implicitly represented in sbml file
404 
405 FIXED -
406 UNUSED -
407 SUBJECT_TO_REACTION -
408 DEPENDENT -
409 ODE -
410 ASSIGNMENT -
411 TIME implemented
412  */
413 
414 /**
415  * CModelValue represents an entity in the model that has a value but is
416  * not a concentration (like species) or a volume (like compartments).
417  * It correspondents to global parameters in SBML
418  */
419 class CModelValue : public CModelEntity
420 {
421 public:
422  /**
423  * Default constructor
424  * @param const std::string & name (default: "NoName")
425  * @param const CCopasiContainer * pParent (default: NULL)
426  */
427  CModelValue(const std::string & name = "NoName",
428  const CCopasiContainer * pParent = NULL);
429 
430  /**
431  * Copy constructor
432  * @param const CModelValue & src
433  * @param const CCopasiContainer * pParent (default: NULL)
434  */
435  CModelValue(const CModelValue & src,
436  const CCopasiContainer * pParent = NULL);
437 
438  /**
439  * Destructor.
440  */
441  ~CModelValue();
442 
443  /**
444  * insert operator
445  */
446  friend std::ostream & operator<<(std::ostream &os, const CModelValue & d);
447 
448 private:
449  /**
450  * Initialize the contained CCopasiObjects
451  */
452  void initObjects();
453 };
454 
455 #endif
const CExpression * getExpressionPtr() const
CCopasiObjectReference< C_FLOAT64 > * mpIValueReference
Definition: CModelValue.h:356
CExpression * mpInitialExpression
Definition: CModelValue.h:341
static const std::string StatusName[]
Definition: CModelValue.h:67
const C_FLOAT64 & getRate() const
const std::string & getSBMLId() const
C_FLOAT64 mRate
Definition: CModelValue.h:331
C_FLOAT64 * mpValue
Definition: CModelValue.h:321
CCopasiObject * getInitialValueReference() const
CCopasiObjectReference< C_FLOAT64 > * mpRateReference
Definition: CModelValue.h:358
virtual void setValue(const C_FLOAT64 &value)
bool setInitialExpression(const std::string &expression)
std::string getExpression() const
#define C_INT32
Definition: copasi.h:90
C_FLOAT64 * mpIValue
Definition: CModelValue.h:326
void initObjects()
void initObjects()
virtual bool compile()
bool isFixed() const
Definition: CModelValue.h:124
const C_FLOAT64 & getInitialValue() const
void setRate(const C_FLOAT64 &rate)
void setValuePtr(C_FLOAT64 *pValue)
virtual const std::string & getKey() const
virtual void setStatus(const CModelEntity::Status &status)
virtual const CCopasiObject * getValueObject() const
std::string getInitialExpression() const
void setUsed(const bool &used)
virtual void calculate()
std::string mSBMLId
Definition: CModelValue.h:47
friend std::ostream & operator<<(std::ostream &os, const CModelValue &d)
virtual void * getValuePointer() const
CCopasiObjectReference< C_FLOAT64 > * mpValueReference
Definition: CModelValue.h:357
const bool & isUsed() const
static const char * XMLStatus[]
Definition: CModelValue.h:72
virtual std::set< const CCopasiObject * > getDeletedObjects() const
Header file of class CCopasiContainer.
long int flag
Definition: f2c.h:52
virtual bool setObjectParent(const CCopasiContainer *pParent)
const C_FLOAT64 & getValue() const
Status mStatus
Definition: CModelValue.h:347
#define C_FLOAT64
Definition: copasi.h:92
bool setInitialExpressionPtr(CExpression *pExpression)
virtual bool mustBeDeleted(const DataObjectSet &deletedObjects) const
CExpression * mpExpression
Definition: CModelValue.h:336
void setInitialValuePtr(C_FLOAT64 *pInitialValue)
bool setExpressionPtr(CExpression *pExpression)
CModelEntity(const std::string &name="NoName", const CCopasiContainer *pParent=NULL, const std::string &type="ModelEntity", const unsigned C_INT32 &flag=CCopasiObject::Container|CCopasiObject::ValueDbl)
Definition: CModelValue.cpp:62
virtual void setInitialValue(const C_FLOAT64 &initialValue)
Definition: CModel.h:50
const CModelEntity::Status & getStatus() const
bool setExpression(const std::string &expression)
CModelValue(const std::string &name="NoName", const CCopasiContainer *pParent=NULL)
CCopasiObject * getRateReference() const
std::set< const CCopasiObject * > DataObjectSet
CModel * mpModel
Definition: CModelValue.h:359
void setSBMLId(const std::string &id)
const CExpression * getInitialExpressionPtr() const
virtual void refreshInitialValue()
CCopasiObject * getValueReference() const