COPASI API  4.16.103
CMathTrigger.h
Go to the documentation of this file.
1 // Copyright (C) 2011 - 2014 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_CMathTrigger
7 #define COPASI_CMathTrigger
8 
9 #include <stack>
10 
12 
14 {
15 public:
17  {
18  friend class CMathTrigger;
19 
20  // Operations
21  public:
22  /**
23  * Default constructor
24  * @param const CCopasiContainer * pParent (default: NULL)
25  */
26  CRootFinder(const CCopasiContainer * pParent = NULL);
27 
28  /**
29  * Copy constructor
30  * @param "const CRoot &" src
31  * @param "const CCopasiContainer * pParent (default: NULL)
32  */
33  CRootFinder(const CRootFinder & src,
34  const CCopasiContainer * pParent = NULL);
35 
36  /**
37  * Destructor
38  */
39  virtual ~CRootFinder();
40 
41  /**
42  * Initialize the contained object references.
43  */
44  void initObjects();
45 
46  /**
47  * Compile the root finder
48  * @param std::vector< CCopasiContainer * > listOfContainer
49  */
50  bool compile(std::vector< CCopasiContainer * > listOfContainer);
51 
52  /**
53  * Determine whether the root only changes during discrete events.
54  * The root must be compiled before calling this method.
55  * @param const std::set< const CCopasiObject *> & stateVariables
56  */
57  void determineDiscrete(const std::set< const CCopasiObject * > & stateVariables);
58 
59  /**
60  * Check whether the root change only during discrete events.
61  * @return const bool & isDiscrete
62  */
63  const bool & isDiscrete() const;
64 
65  /**
66  * Check whether the root is checked for equality.
67  * @return const bool & isEquality
68  */
69  const bool & isEquality() const;
70 
71  /**
72  * Check whether the root's current state is true .
73  * @return bool isTrue
74  */
75  bool isTrue() const;
76 
77  /**
78  * Retrieve the expression evaluating the truth value
79  * @return CEvalutionNode * trueExpression
80  */
82 
83  /**
84  * Toggle the root status dependent on the
85  * processed equality status
86  * @param const C_FLOAT64 & time
87  * @param const bool & equality
88  * @param const bool & continuous
89  */
90  void toggle(const C_FLOAT64 & time,
91  const bool & equality,
92  const bool & continous);
93 
94  /**
95  * Toggle the root status dependent on the
96  * processed equality status
97  * @param const C_FLOAT64 & time
98  */
99  void toggle(const C_FLOAT64 & time);
100 
101  /**
102  * Initialize all values of the math model with their initial values.
103  */
104  void applyInitialValues();
105 
106  /**
107  * Determine the truth value for the initial conditions.
108  */
109  void calculateTrueValue();
110 
111  /**
112  * Retrieve a pointer to the current value of the root.
113  */
115 
116  // Attributes
117  private:
118  /**
119  * This expression calculates the root
120  */
122 
123  /**
124  * A pointer to the value of the root expression
125  */
127 
128  /**
129  * This indicates whether the root is checked for equality
130  */
131  bool mEquality;
132 
133  /**
134  * This indicates whether the root changes only discretely
135  */
136  bool mDiscrete;
137 
138  /**
139  * Indicates the truth value of the root active
140  * This should be a bool but the CExpressionTree only handles double
141  */
143 
144  /**
145  * The time at which the last toggle of the truth value occurred
146  */
148  };
149 
150  // Operations
151 public:
152  /**
153  * Default constructor
154  * @param const CCopasiContainer * pParent (default: NULL)
155  */
156  CMathTrigger(const CCopasiContainer * pParent = NULL);
157 
158  /**
159  * Copy constructor
160  * @param "const CMathTrigger &" src
161  * @param "const CCopasiContainer * pParent (default: NULL)
162  */
163  CMathTrigger(const CMathTrigger & src,
164  const CCopasiContainer * pParent = NULL);
165 
166  /**
167  * Destructor
168  */
169  virtual ~CMathTrigger();
170 
171  /**
172  * Initialize all values of the math model with their initial values.
173  */
174  void applyInitialValues();
175 
176  /**
177  * Determine the true value for the initial conditions.
178  */
179  void calculateTrueValue();
180 
181  /**
182  * Determine the activity for the initial conditions.
183  */
185 
186  /**
187  * Calculate the current trigger value.
188  * @return value
189  */
190  bool calculate();
191 
192  /**
193  * Compile the trigger
194  * @param const CExpression * pTriggerExpression
195  * @param std::vector< CCopasiContainer * > listOfContainer
196  * @return bool success
197  */
198  bool compile(const CExpression * pTriggerExpression,
199  std::vector< CCopasiContainer * > listOfContainer);
200 
201  /**
202  * Retrieve the list of root finders
203  * @return CCopasiVector< CRootFinder > & rootFinders
204  */
206 
207 private:
208  bool compile(const CEvaluationNode * pSource,
209  CEvaluationNode * & pTrueExpression);
210  bool compileAND(const CEvaluationNode * pSource,
211  CEvaluationNode * & pTrueExpression);
212  bool compileOR(const CEvaluationNode * pSource,
213  CEvaluationNode * & pTrueExpression);
214  bool compileXOR(const CEvaluationNode * pSource,
215  CEvaluationNode * & pTrueExpression);
216  bool compileEQ(const CEvaluationNode * pSource,
217  CEvaluationNode * & pTrueExpression);
218  bool compileNE(const CEvaluationNode * pSource,
219  CEvaluationNode * & pTrueExpression);
220  bool compileLT(const CEvaluationNode * pSource,
221  CEvaluationNode * & pTrueExpression);
222  bool compileLE(const CEvaluationNode * pSource,
223  CEvaluationNode * & pTrueExpression);
224  bool compileGT(const CEvaluationNode * pSource,
225  CEvaluationNode * & pTrueExpression);
226  bool compileGE(const CEvaluationNode * pSource,
227  CEvaluationNode * & pTrueExpression);
228  bool compileNOT(const CEvaluationNode * pSource,
229  CEvaluationNode * & pTrueExpression);
230  bool compileFUNCTION(const CEvaluationNode * pSource,
231  CEvaluationNode * & pTrueExpression);
232  bool compileEXPRESSION(const CEvaluationNode * pSource,
233  CEvaluationNode * & pTrueExpression);
234  bool compileVARIABLE(const CEvaluationNode * pSource,
235  CEvaluationNode * & pTrueExpression);
236 
237  CEvaluationNode * copyBranch(const CEvaluationNode * pSource);
238 
239  // Attributes
240 private:
241  /**
242  * This expression evaluates whether
243  * the trigger value is true.
244  */
246 
247  /**
248  * A vector containing the root expression.
249  */
251 
252  /**
253  * A stack to map variable nodes to the value nodes provided
254  * in the function call
255  */
256  std::stack< std::vector< const CEvaluationNode * > > mFunctionVariableMap;
257 };
258 
259 #endif // COPASI_CMathTrigger
Header file of class CExpression.
CCopasiVector< CRootFinder > mRootFinders
Definition: CMathTrigger.h:250
bool compileNE(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compile(std::vector< CCopasiContainer * > listOfContainer)
bool compileOR(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
CEvaluationNode * copyBranch(const CEvaluationNode *pSource)
bool compileFUNCTION(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
CExpression mTrueExpression
Definition: CMathTrigger.h:245
bool compileNOT(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
void applyInitialValues()
CEvaluationNode * getTrueExpression() const
const bool & isDiscrete() const
bool compileLT(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compileEXPRESSION(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
std::stack< std::vector< const CEvaluationNode * > > mFunctionVariableMap
Definition: CMathTrigger.h:256
bool compileGT(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compileAND(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compileLE(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compileGE(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
void determineDiscrete(const std::set< const CCopasiObject * > &stateVariables)
bool compileVARIABLE(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
CRootFinder(const CCopasiContainer *pParent=NULL)
virtual ~CMathTrigger()
void calculateInitialActivity()
void toggle(const C_FLOAT64 &time, const bool &equality, const bool &continous)
CMathTrigger(const CCopasiContainer *pParent=NULL)
#define C_FLOAT64
Definition: copasi.h:92
bool compileXOR(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
void calculateTrueValue()
const bool & isEquality() const
bool compileEQ(const CEvaluationNode *pSource, CEvaluationNode *&pTrueExpression)
bool compile(const CExpression *pTriggerExpression, std::vector< CCopasiContainer * > listOfContainer)
CCopasiVector< CRootFinder > & getRootFinders()