COPASI API  4.16.103
stress_test.cpp
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/compareExpressions/stresstest/stress_test.cpp,v $
3 // $Revision: 1.16 $
4 // $Name: $
5 // $Author: gauges $
6 // $Date: 2011/05/04 17:35:52 $
7 // End CVS Header
8 
9 // Copyright (C) 2011 - 2010 by Pedro Mendes, Virginia Tech Intellectual
10 // Properties, Inc., University of Heidelberg, and The University
11 // of Manchester.
12 // All rights reserved.
13 
14 // Copyright (C) 2008 by Pedro Mendes, Virginia Tech Intellectual
15 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
16 // and The University of Manchester.
17 // All rights reserved.
18 
19 #include "stress_test.h"
20 
21 #include <iostream>
22 
23 #define COPASI_MAIN
24 
26 
27 #include "sbml/SBMLDocument.h"
28 #include "sbml/Model.h"
29 #include "sbml/FunctionDefinition.h"
30 #include "sbml/Rule.h"
31 #include "sbml/InitialAssignment.h"
32 #include "sbml/Reaction.h"
33 #include "sbml/KineticLaw.h"
34 #include "sbml/SpeciesReference.h"
35 #include "sbml/Event.h"
36 #include "sbml/Delay.h"
37 #include "sbml/Trigger.h"
38 #include "sbml/EventAssignment.h"
39 #include "sbml/StoichiometryMath.h"
40 #include "sbml/math/ASTNode.h"
41 #include "sbml/math/MathML.h"
42 
47 
51 
52 #include "copasi/model/CModel.h"
53 
54 /**
55  * Constructor.
56  */
57 stress_test::stress_test(): mNumFunctionDefinitions(0),
58  mNumExceededFunctions(0),
59  mNumFailedFunctions(0),
60  mNumExpressions(0),
61  mNumExceeded(0),
62  mNumFailed(0),
63  mNumCOPASIFunctions(0),
64  mNumExceededCOPASIFunctions(0),
65  mNumFailedCOPASIFunctions(0),
66  mNumFiles(0),
67  mNumKineticFunctions(0),
68  mNumMassActionsKinetics(0),
69  mNumConstantFluxKinetics(0),
70  mNumMappedKineticExpressions(0),
71  mNumUnmappedKineticExpressions(0),
72  mDifferentNormalform(0),
73  mNumSBO(0),
74  mpDataModel(NULL)
75 {
76  // Create the root container.
77  CCopasiRootContainer::init(false, 0, NULL);
78  // Create the global data model.
80 }
81 
82 /**
83  * Destructor.
84  */
86 {
87  // delete normalforms of expressions
88  std::vector<CNormalFraction*>::iterator it = mNormalizedExpressions.begin(), endit = mNormalizedExpressions.end();
89 
90  while (it != endit)
91  {
92  delete *it;
93  ++it;
94  }
95 
96  // delete normalforms of function definitions
97  std::vector<std::pair<std::string, CNormalFraction*> >::iterator it2 = mNormalizedFunctionDefinitions.begin(), endit2 = mNormalizedFunctionDefinitions.end();
98 
99  while (it2 != endit2)
100  {
101  delete it2->second;
102  ++it2;
103  }
104 
105  // delete normalforms of COPASI function definitions
106  std::multimap<std::string, CNormalFraction*>::iterator it5 = mNormalizedCOPASIFunctionDefinitions.begin(), endit5 = mNormalizedCOPASIFunctionDefinitions.end();
107 
108  while (it5 != endit5)
109  {
110  delete it5->second;
111  ++it5;
112  }
113 
115 }
116 
117 /**
118  * Goes through the list of files, loads each file and normalizes the
119  * mathematical expressions in the contained model.
120  */
121 void stress_test::run(const std::vector<std::string>& filenames)
122 {
123  // first normalize the COPASIm function database
124  // these normalized functions are later ued to compare
125  // against kinetic expressions and function definitions
127 
128  std::vector<std::string>::const_iterator it = filenames.begin(), endit = filenames.end();
129 
130  while (it != endit)
131  {
132  std::cout << "Processing " << *it << std::endl;
133  this->normalizeMath(*it);
134  ++it;
135  }
136 
137  // output some statistics
138  std::cout << "number of COPASI function definitions: " << mNumCOPASIFunctions << std::endl;
139  std::cout << "number of exceeded COPASI function definitions: " << mNumExceededCOPASIFunctions << std::endl;
140  std::cout << "number of failed COPASI function definitions: " << mNumFailedCOPASIFunctions << std::endl;
141 
142  if (!mUnreadableFiles.empty())
143  {
144 
145  std::cout << "the following " << mUnreadableFiles.size() << " files could not be read: " << std::endl;
146  std::vector<std::string>::const_iterator it = mUnreadableFiles.begin(), endit = mUnreadableFiles.end();
147 
148  while (it != endit)
149  {
150  std::cout << *it << std::endl;
151  ++it;
152  }
153  }
154 
155  std::cout << mNumFiles << " files have been processed." << std::endl;
156  std::cout << "number of function definitions: " << mNumFunctionDefinitions << std::endl;
157  std::cout << "number of exceeded function definitions: " << mNumExceededFunctions << std::endl;
158  std::cout << "number of failed function definitions: " << mNumFailedFunctions << std::endl;
159  std::cout << "number of expressions: " << mNumExpressions << std::endl;
160  std::cout << "number of exceeded expressions: " << mNumExceeded << std::endl;
161  std::cout << "number of failed expressions: " << mNumFailed << std::endl;
162  // now we compare the normalized function definitons from all files to the
163  // normalized function definitions from the COPASI fucntion database
164  std::multimap<std::string, CNormalFraction*>::iterator it2 = mNormalizedCOPASIFunctionDefinitions.begin(), endit2 = mNormalizedCOPASIFunctionDefinitions.end();
165  --endit;
166 
167  while (it2 != endit2)
168  {
169  std::multimap<std::string, CNormalFraction*>::iterator it3 = it2, endit3 = mNormalizedCOPASIFunctionDefinitions.end();
170  ++it3;
171 
172  while (it3 != endit3)
173  {
174  if (are_equal(it2->second, it3->second))
175  {
176  std::cout << "The functions \"" << it2->first << "\" and \"" << it3->first << "\" in the COPASI database are equal." << std::endl;
177  }
178 
179  ++it3;
180  }
181 
182  ++it2;
183  }
184 
185  std::vector<std::pair<std::string, CNormalFraction*> >::iterator it5 = mNormalizedFunctionDefinitions.begin(), endit5 = mNormalizedFunctionDefinitions.end();
186  unsigned int numClassified = 0;
187  unsigned int numDubious = 0;
188 
189  while (it5 != endit5)
190  {
191  std::multimap<std::string, CNormalFraction*>::iterator it3 = mNormalizedCOPASIFunctionDefinitions.begin(), endit3 = mNormalizedCOPASIFunctionDefinitions.end();
192  bool found = false;
193 
194  while (it3 != endit3)
195  {
196  if (are_equal(it5->second, it3->second))
197  {
198  if (found == true)
199  {
200  ++numDubious;
201  --numClassified;
202  break;
203  }
204  else
205  {
206  found = true;
207  ++numClassified;
208  }
209  }
210 
211  ++it3;
212  }
213 
214  ++it5;
215  }
216 
217  std::cout << "Number of function definitons that could be classified: " << numClassified << std::endl;
218  std::cout << "Number of function definitons that were classified incorrectly: " << numDubious << std::endl;
219  std::cout << "Number of function definitons that could not be classified: " << mNormalizedFunctionDefinitions.size() - numClassified - numDubious << std::endl;
220  std::cout << "Number of kinetic expressions: " << mNumKineticFunctions << std::endl;
221  std::cout << "Number of kinetic expressions that could be mapped to a function definition: " << mNumMappedKineticExpressions << std::endl;
222  std::cout << "Number of kinetic expressions that could not be mapped to a function definition: " << mNumUnmappedKineticExpressions << std::endl;
223  std::cout << "List of the number of expressions mapped to a certain function definition: " << std::endl;
224  std::map<std::string, unsigned int>::iterator it6 = mExpressionMappings.begin(), endit6 = mExpressionMappings.end();
225 
226  while (it6 != endit6)
227  {
228  std::cout << it6->first << " : " << it6->second << std::endl;
229  ++it6;
230  }
231 
232  std::cout << "There are " << mSBOMap.size() << " different SBO Terms." << std::endl;
233  std::map<int, std::vector<CNormalFraction*> >::iterator sboIt = mSBOMap.begin(), sboEndit = mSBOMap.end();
234 
235  while (sboIt != sboEndit)
236  {
237  std::cout << "There are " << sboIt->second.size() << " expressions for SBO term " << sboIt->first << "." << std::endl;
238  ++sboIt;
239  }
240 
241  std::cout << "Number of kinetic expressions with sbo terms: " << mNumSBO << std::endl;
242  std::cout << "Number of kinetic expressions with sbo terms that could not be normalized to the same normalform: " << mDifferentNormalform << std::endl;
243  std::cout << "The expressions that could not be mapped are divided into " << mUnknownCategories.size() << " different expressions." << std::endl;
244  std::map<CNormalFraction*, int>::const_iterator catIt = mUnknownCategories.begin(), catEndit = mUnknownCategories.end();
245  unsigned int moreThanOne = 0;
246  unsigned int moreThanFive = 0;
247  unsigned int moreThanTen = 0;
248  unsigned int moreThanTwenty = 0;
249  unsigned int numMoreThanOne = 0;
250  unsigned int numMoreThanFive = 0;
251  unsigned int numMoreThanTen = 0;
252  unsigned int numMoreThanTwenty = 0;
253 
254  while (catIt != catEndit)
255  {
256  if (catIt->second > 20)
257  {
258  ++moreThanTwenty;
259  numMoreThanTwenty += catIt->second;
260  std::cout << "Expression with more than 20 instances: " << catIt->first->toString() << std::endl;
261  }
262  else if (catIt->second > 10)
263  {
264  ++moreThanTen;
265  numMoreThanTen += catIt->second;
266  }
267  else if (catIt->second > 5)
268  {
269  ++moreThanFive;
270  numMoreThanFive += catIt->second;
271  }
272  else if (catIt->second > 1)
273  {
274  ++moreThanOne;
275  numMoreThanOne += catIt->second;
276  }
277 
278  ++catIt;
279  }
280 
281  std::cout << moreThanTwenty << " uncategorized expressions have more than 20 instances (" << numMoreThanTwenty << " total)" << std::endl;
282  std::cout << moreThanTen << " uncategorized expressions have more than 10 instances (" << numMoreThanTen << " total)" << std::endl;
283  std::cout << moreThanFive << " uncategorized expressions have more than 5 instances (" << numMoreThanFive << " total)" << std::endl;
284  std::cout << moreThanOne << " uncategorized expressions have more than 1 instance (" << numMoreThanOne << " total)" << std::endl;
285  std::cout << mUnknownCategories.size() - (moreThanTwenty + moreThanTen + moreThanFive + moreThanOne) << " uncategorized expression are unique." << std::endl;
286  std::set<double>::reverse_iterator timeIt = mProcessTimes.rbegin(), timeEndit = mProcessTimes.rend();
287  unsigned int num = 0;
288 
289  while (timeIt != timeEndit && (*timeIt) > 600)
290  {
291  ++num;
292  ++timeIt;
293  }
294 
295  if (num != 0)
296  {
297  std::cout << "Number of expression taking more than 10 minutes: " << num << std::endl;
298  num = 0;
299  }
300 
301  while (timeIt != timeEndit && (*timeIt) > 60)
302  {
303  ++num;
304  ++timeIt;
305  }
306 
307  if (num != 0)
308  {
309  std::cout << "Number of expression taking more than 1 minute: " << num << std::endl;
310  }
311 
312  while (timeIt != timeEndit && (*timeIt) > 10)
313  {
314  ++num;
315  ++timeIt;
316  }
317 
318  if (num != 0)
319  {
320  std::cout << "Number of expression taking more than 10 seconds: " << num << std::endl;
321  }
322 
323  while (timeIt != timeEndit && (*timeIt) > 1)
324  {
325  ++num;
326  ++timeIt;
327  }
328 
329  if (num != 0)
330  {
331  std::cout << "Number of expression taking more than 1 second: " << num << std::endl;
332  }
333 
334  while (timeIt != timeEndit && (*timeIt) > 0.1)
335  {
336  ++num;
337  ++timeIt;
338  }
339 
340  if (num != 0)
341  {
342  std::cout << "Number of expression taking more than 1/10 seconds: " << num << std::endl;
343  }
344 
345  while (timeIt != timeEndit && (*timeIt) > 0.01)
346  {
347  ++num;
348  ++timeIt;
349  }
350 
351  if (num != 0)
352  {
353  std::cout << "Number of expression taking more than 1/100 seconds: " << num << std::endl;
354  }
355 
356  while (timeIt != timeEndit)
357  {
358  ++num;
359  ++timeIt;
360  }
361 
362  if (num != 0)
363  {
364  std::cout << "Number of expression taking less than 1/100 seconds: " << num << std::endl;
365  }
366 }
367 
368 /**
369  * Loads an sbml model from the given file and
370  * normalized all mathematical expressions in the SBML model.
371  */
372 void stress_test::normalizeMath(const std::string& filename)
373 {
374  bool result = false;
375 
376  if (this->mpDataModel != NULL)
377  {
378  try
379  {
380  result = this->mpDataModel->importSBML(filename);
381  ++mNumFiles;
382  }
383  catch (...)
384  {
385  mUnreadableFiles.push_back(filename);
386  }
387 
388  if (result == true)
389  {
390  const SBMLDocument* pDocument = this->mpDataModel->getCurrentSBMLDocument();
391 
392  if (pDocument != NULL)
393  {
394  const Model* pModel = pDocument->getModel();
395 
396  if (pModel != NULL)
397  {
398  //this->normalizeFunctionDefinitions(pModel);
399  //this->normalizeExpressions(pModel);
401  this->normalizeAndSimplifyExpressions(pModel);
402  }
403  }
404  }
405  }
406 }
407 
408 /**
409  * Normalizes all expressions but the function definitions in the given
410  * model.
411  */
413 {
414  // expressions can occur in assignments, initial assignments, kinetic laws event triggers,
415  // event delays, event assignments and stiochiometric expressions
416  const InitialAssignment* pInitialAssignment = NULL;
417  const ASTNode* pMath = NULL;
418  ASTNode* pNewMath = NULL;
419  CNormalFraction* pFraction = NULL;
420  // initial assignments
421  unsigned int i, iMax = pModel->getListOfInitialAssignments()->size();
422 
423  for (i = 0; i < iMax; ++i)
424  {
425  pInitialAssignment = pModel->getInitialAssignment(i);
426  assert(pInitialAssignment != NULL);
427  pMath = pInitialAssignment->getMath();
428 
429  if (pMath != NULL)
430  {
431  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
432  assert(pNewMath != NULL);
433 
434  try
435  {
436  gettimeofday(&mTV1, &mTZ1);
437  pFraction = create_simplified_normalform(pNewMath);
438  gettimeofday(&mTV2, &mTZ2);
439  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
440 
441  if (mTV2.tv_usec < mTV1.tv_usec)
442  {
443  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
444  }
445  else
446  {
447  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
448  }
449 
450  mProcessTimes.insert(timeDiff);
451  }
452  catch (recursion_limit_exception e)
453  {
454  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
455  ++mNumExceeded;
456  }
457  catch (...)
458  {
459  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
460  ++mNumFailed;
461  }
462 
463  ++mNumExpressions;
464  delete pNewMath;
465  assert(pFraction != NULL);
466  // this->mNormalizedExpressions.push_back(pFraction);
467  }
468  }
469 
470  // rules
471  const Rule* pRule = NULL;
472  iMax = pModel->getListOfRules()->size();
473 
474  for (i = 0; i < iMax; ++i)
475  {
476  pRule = pModel->getRule(i);
477  assert(pRule != NULL);
478  pMath = pRule->getMath();
479 
480  if (pMath != NULL)
481  {
482  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
483  assert(pNewMath != NULL);
484 
485  try
486  {
487  gettimeofday(&mTV1, &mTZ1);
488  pFraction = create_simplified_normalform(pNewMath);
489  assert(pFraction != NULL);
490  // this->mNormalizedExpressions.push_back(pFraction);
491  gettimeofday(&mTV2, &mTZ2);
492  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
493 
494  if (mTV2.tv_usec < mTV1.tv_usec)
495  {
496  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
497  }
498  else
499  {
500  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
501  }
502 
503  mProcessTimes.insert(timeDiff);
504  }
505  catch (recursion_limit_exception e)
506  {
507  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
508  ++mNumExceeded;
509  }
510  catch (...)
511  {
512  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
513  ++mNumFailed;
514  }
515 
516  ++mNumExpressions;
517  delete pNewMath;
518  }
519  }
520 
521  // kinetic laws + stoichiometric expressions
522  const Reaction* pReaction = NULL;
523  iMax = pModel->getListOfReactions()->size();
524 
525  for (i = 0; i < iMax; ++i)
526  {
527  pReaction = pModel->getReaction(i);
528  assert(pReaction != NULL);
529  const KineticLaw* pLaw = pReaction->getKineticLaw();
530  int sboTerm = pLaw->getSBOTerm();
531 
532  if (pLaw != NULL)
533  {
534  pMath = pLaw->getMath();
535 
536  if (pMath != NULL)
537  {
538  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
539  // we normalize the names of all named nodes
540  bool result = stress_test::normalize_names(pNewMath, pReaction, pModel);
541  assert(result == true);
542  assert(pNewMath != NULL);
543 
544  try
545  {
546  gettimeofday(&mTV1, &mTZ1);
547  pFraction = create_simplified_normalform(pNewMath);
548  gettimeofday(&mTV2, &mTZ2);
549  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
550 
551  if (mTV2.tv_usec < mTV1.tv_usec)
552  {
553  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
554  }
555  else
556  {
557  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
558  }
559 
560  mProcessTimes.insert(timeDiff);
561  assert(pFraction != NULL);
563  // find the COPASI Reaction that corresponds to this reaction
564  std::string id = pReaction->getId();
565  const CReaction* pCOPASIReaction = NULL;
566  unsigned int z = 0, zMax = this->mpDataModel->getModel()->getReactions().size();
567 
568  while (z < zMax)
569  {
570  if (this->mpDataModel->getModel()->getReactions()[z]->getSBMLId() == id)
571  {
572  pCOPASIReaction = this->mpDataModel->getModel()->getReactions()[z];
573  break;
574  }
575 
576  ++z;
577  }
578 
579  assert(pCOPASIReaction != NULL);
580 
581  if (dynamic_cast<const CMassAction*>(pCOPASIReaction->getFunction()) == NULL)
582  {
583  if (pCOPASIReaction->getFunction()->getObjectName().find("Constant flux") != std::string::npos)
584  {
586 
587  if (mExpressionMappings.find("Constant Flux") == mExpressionMappings.end())
588  {
589  mExpressionMappings["Constant Flux"] = 1;
590  }
591  else
592  {
593  mExpressionMappings["Constant Flux"] = mExpressionMappings["Constant Flux"] + 1;
594  }
595  }
596  else
597  {
598  // compare with the normalized expressions from the
599  // function definitions
600  std::multimap<std::string, CNormalFraction*>::iterator it = mNormalizedCOPASIFunctionDefinitions.begin(), endit = mNormalizedCOPASIFunctionDefinitions.end();
601  bool found = false;
602 
603  while (it != endit)
604  {
605  if (are_equal(pFraction, it->second))
606  {
607  // we found a match
608  found = true;
609 
610  if (mExpressionMappings.find(it->first) == mExpressionMappings.end())
611  {
612  mExpressionMappings[it->first] = 1;
613  }
614  else
615  {
616  mExpressionMappings[it->first] = mExpressionMappings[it->first] + 1;
617  }
618 
619  break;
620  }
621 
622  ++it;
623  }
624 
625  if (found)
626  {
628  }
629  else
630  {
632  // compare against the other unmapped functions
633  std::map<CNormalFraction*, int>::iterator catIt = mUnknownCategories.begin(), catEndit = mUnknownCategories.end();
634  found = false;
635 
636  while (catIt != catEndit)
637  {
638  if (are_equal(pFraction, catIt->first))
639  {
640  found = true;
641  ++(catIt->second);
642  }
643 
644  ++catIt;
645  }
646 
647  if (!found)
648  {
649  mUnknownCategories[pFraction] = 1;
650  }
651  }
652  }
653  }
654  else
655  {
657 
658  if (mExpressionMappings.find("Mass Action") == mExpressionMappings.end())
659  {
660  mExpressionMappings["Mass Action"] = 1;
661  }
662  else
663  {
664  mExpressionMappings["Mass Action"] = mExpressionMappings["Mass Action"] + 1;
665  }
666  }
667 
668  // this->mNormalizedExpressions.push_back(pFraction);
669  if (sboTerm != -1)
670  {
671  ++mNumSBO;
672 
673  if (mSBOMap.find(sboTerm) == mSBOMap.end())
674  {
675  std::vector<CNormalFraction*> v;
676  v.push_back(pFraction);
677  mSBOMap[sboTerm] = v;
678  }
679  else
680  {
681  if (!are_equal(pFraction, mSBOMap[sboTerm][0]))
682  {
683  std::cout << "Some expressions for SBO term " << sboTerm << " can not be normalized to the same normal form." << std::endl;
685  }
686 
687  mSBOMap[sboTerm].push_back(pFraction);
688  }
689  }
690 
691  //delete pFraction;
692  }
693  catch (recursion_limit_exception e)
694  {
695  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
696  ++mNumExceeded;
697  }
698  catch (...)
699  {
700  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
701  ++mNumFailed;
702  }
703 
704  delete pNewMath;
705  ++mNumExpressions;
706  }
707  }
708 
709  const SpeciesReference* pSpeciesReference = NULL;
710 
711  // substrates
712  unsigned j, jMax = pReaction->getListOfReactants()->size();
713 
714  for (j = 0; j < jMax; ++j)
715  {
716  pSpeciesReference = pReaction->getReactant(j);
717  assert(pSpeciesReference != NULL);
718 
719  if (pSpeciesReference->isSetStoichiometryMath())
720  {
721  const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath();
722  assert(pSMath != NULL);
723  pMath = pSMath->getMath();
724 
725  if (pMath != NULL)
726  {
727  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
728  assert(pNewMath != NULL);
729 
730  try
731  {
732  gettimeofday(&mTV1, &mTZ1);
733  pFraction = create_simplified_normalform(pNewMath);
734  gettimeofday(&mTV2, &mTZ2);
735  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
736 
737  if (mTV2.tv_usec < mTV1.tv_usec)
738  {
739  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
740  }
741  else
742  {
743  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
744  }
745 
746  mProcessTimes.insert(timeDiff);
747  assert(pFraction != NULL);
748  // this->mNormalizedExpressions.push_back(pFraction);
749  }
750  catch (recursion_limit_exception e)
751  {
752  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
753  ++mNumExceeded;
754  }
755  catch (...)
756  {
757  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
758  ++mNumFailed;
759  }
760 
761  ++mNumExpressions;
762  delete pNewMath;
763  }
764  }
765  }
766 
767  // products
768  jMax = pReaction->getListOfProducts()->size();
769 
770  for (j = 0; j < jMax; ++j)
771  {
772  pSpeciesReference = pReaction->getProduct(j);
773  assert(pSpeciesReference != NULL);
774 
775  if (pSpeciesReference->isSetStoichiometryMath())
776  {
777  const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath();
778  assert(pSMath != NULL);
779  pMath = pSMath->getMath();
780 
781  if (pMath != NULL)
782  {
783  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
784  assert(pNewMath != NULL);
785 
786  try
787  {
788  gettimeofday(&mTV1, &mTZ1);
789  pFraction = create_simplified_normalform(pNewMath);
790  gettimeofday(&mTV2, &mTZ2);
791  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
792 
793  if (mTV2.tv_usec < mTV1.tv_usec)
794  {
795  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
796  }
797  else
798  {
799  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
800  }
801 
802  mProcessTimes.insert(timeDiff);
803  assert(pFraction != NULL);
804  // this->mNormalizedExpressions.push_back(pFraction);
805  }
806  catch (recursion_limit_exception e)
807  {
808  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
809  ++mNumExceeded;
810  }
811  catch (...)
812  {
813  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
814  ++mNumFailed;
815  }
816 
817  ++mNumExpressions;
818  delete pNewMath;
819  }
820  }
821  }
822  }
823 
824  // events
825  const Event* pEvent = NULL;
826  const Trigger* pTrigger = NULL;
827  const Delay* pDelay = NULL;
828  iMax = pModel->getListOfEvents()->size();
829 
830  for (i = 0; i < iMax; ++i)
831  {
832  pEvent = pModel->getEvent(i);
833  assert(pEvent != NULL);
834  // trigger
835  pTrigger = pEvent->getTrigger();
836  assert(pTrigger != NULL);
837  pMath = pTrigger->getMath();
838 
839  if (pMath != NULL)
840  {
841  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
842  assert(pNewMath != NULL);
843 
844  try
845  {
846  gettimeofday(&mTV1, &mTZ1);
847  pFraction = create_simplified_normalform(pNewMath);
848  gettimeofday(&mTV2, &mTZ2);
849  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
850 
851  if (mTV2.tv_usec < mTV1.tv_usec)
852  {
853  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
854  }
855  else
856  {
857  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
858  }
859 
860  mProcessTimes.insert(timeDiff);
861  assert(pFraction != NULL);
862  // this->mNormalizedExpressions.push_back(pFraction);
863  }
864  catch (recursion_limit_exception e)
865  {
866  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
867  ++mNumExceeded;
868  }
869  catch (...)
870  {
871  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
872  ++mNumFailed;
873  }
874 
875  ++mNumExpressions;
876  delete pNewMath;
877  }
878 
879  // delay
880  if (pEvent->isSetDelay())
881  {
882  pDelay = pEvent->getDelay();
883  assert(pDelay != NULL);
884  pMath = pDelay->getMath();
885 
886  if (pMath != NULL)
887  {
888  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
889  assert(pNewMath != NULL);
890 
891  try
892  {
893  gettimeofday(&mTV1, &mTZ1);
894  pFraction = create_simplified_normalform(pNewMath);
895  gettimeofday(&mTV2, &mTZ2);
896  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
897 
898  if (mTV2.tv_usec < mTV1.tv_usec)
899  {
900  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
901  }
902  else
903  {
904  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
905  }
906 
907  mProcessTimes.insert(timeDiff);
908  assert(pFraction != NULL);
909  // this->mNormalizedExpressions.push_back(pFraction);
910  }
911  catch (recursion_limit_exception e)
912  {
913  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
914  ++mNumExceeded;
915  }
916  catch (...)
917  {
918  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
919  ++mNumFailed;
920  }
921 
922  ++mNumExpressions;
923  delete pNewMath;
924  }
925  }
926 
927  // event assignments
928  unsigned int j, jMax = pEvent->getListOfEventAssignments()->size();
929  const EventAssignment* pEventAssignment = NULL;
930 
931  for (j = 0; j < jMax; ++j)
932  {
933  pEventAssignment = pEvent->getEventAssignment(j);
934  assert(pEventAssignment != NULL);
935  pMath = pEventAssignment->getMath();
936 
937  if (pMath != NULL)
938  {
939  pNewMath = create_expression(pMath, pModel->getListOfFunctionDefinitions());
940  assert(pNewMath != NULL);
941 
942  try
943  {
944  gettimeofday(&mTV1, &mTZ1);
945  pFraction = create_simplified_normalform(pNewMath);
946  gettimeofday(&mTV2, &mTZ2);
947  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
948 
949  if (mTV2.tv_usec < mTV1.tv_usec)
950  {
951  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
952  }
953  else
954  {
955  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
956  }
957 
958  mProcessTimes.insert(timeDiff);
959  assert(pFraction != NULL);
960  // this->mNormalizedExpressions.push_back(pFraction);
961  }
962  catch (recursion_limit_exception e)
963  {
964  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewMath) << "\"." << std::endl;
965  ++mNumExceeded;
966  }
967  catch (...)
968  {
969  std::cerr << "expression \"" << writeMathMLToString(pNewMath) << "\" could not be normalized." << std::endl;
970  ++mNumFailed;
971  }
972 
973  ++mNumExpressions;
974  delete pNewMath;
975  }
976  }
977  }
978 }
979 
980 /**
981  * Normalizes the function definitions in the given model.
982  */
984 {
985  const FunctionDefinition* pFunDef = NULL;
986  const ASTNode* pRoot = NULL;
987  ASTNode* pNewRoot = NULL;
988  CNormalFraction* pFraction = NULL;
989  unsigned int i, iMax = pModel->getListOfFunctionDefinitions()->size();
990 
991  for (i = 0; i < iMax; ++i)
992  {
993  pFunDef = pModel->getFunctionDefinition(i);
994  pRoot = pFunDef->getMath();
995 
996  // the actual function is the last child
997  if (pRoot != NULL && pRoot->getNumChildren() > 0)
998  {
999  // function definitons have to be expanded
1000  const ASTNode* pMath = pRoot->getChild(pRoot->getNumChildren() - 1);
1001  assert(pMath != NULL);
1002  pNewRoot = expand_function_calls(pMath, pModel->getListOfFunctionDefinitions());
1003  assert(pNewRoot != NULL);
1004 
1005  try
1006  {
1007  gettimeofday(&mTV1, &mTZ1);
1008  pFraction = create_simplified_normalform(pNewRoot);
1009  gettimeofday(&mTV2, &mTZ2);
1010  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
1011 
1012  if (mTV2.tv_usec < mTV1.tv_usec)
1013  {
1014  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
1015  }
1016  else
1017  {
1018  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
1019  }
1020 
1021  mProcessTimes.insert(timeDiff);
1022  assert(pFraction != NULL);
1023  mNormalizedFunctionDefinitions.push_back(std::pair<std::string, CNormalFraction*>(pFunDef->getId(), pFraction));
1024  }
1025  catch (recursion_limit_exception e)
1026  {
1027  std::cerr << "recursion limit exceeded for expression \"" << writeMathMLToString(pNewRoot) << "\"." << std::endl;
1029  }
1030  catch (...)
1031  {
1032  std::cerr << "expression \"" << writeMathMLToString(pNewRoot) << "\" could not be normalized." << std::endl;
1034  }
1035 
1037  }
1038  }
1039 }
1040 
1041 /**
1042  * Normalizes all expressions but the function definitions in the given
1043  * model.
1044 void stress_test::normalizeExpressions(const Model* pModel)
1045 {
1046  // expressions can occur in assignments, initial assignments, kinetic laws event triggers,
1047  // event delays, event assignments and stiochiometric expressions
1048  const InitialAssignment* pInitialAssignment = NULL;
1049  const ASTNode* pMath = NULL;
1050  ASTNode* pNewMath = NULL;
1051  CNormalFraction* pFraction = NULL;
1052  // initial assignments
1053  unsigned int i, iMax = pModel->getListOfInitialAssignments()->size();
1054  for (i = 0;i < iMax;++i)
1055  {
1056  pInitialAssignment = pModel->getInitialAssignment(i);
1057  assert(pInitialAssignment != NULL);
1058  pMath = pInitialAssignment->getMath();
1059  if (pMath != NULL)
1060  {
1061  pNewMath = create_expression(pMath, pModel);
1062  assert(pNewMath != NULL);
1063  pFraction = create_normalform(pNewMath);
1064  delete pNewMath;
1065  assert(pFraction != NULL);
1066  // this->mNormalizedExpressions.push_back(pFraction);
1067  }
1068  }
1069  // rules
1070  const Rule* pRule = NULL;
1071  iMax = pModel->getListOfRules()->size();
1072  for (i = 0;i < iMax;++i)
1073  {
1074  pRule = pModel->getRule(i);
1075  assert(pRule != NULL);
1076  pMath = pRule->getMath();
1077  if (pMath != NULL)
1078  {
1079  pNewMath = create_expression(pMath, pModel);
1080  assert(pNewMath != NULL);
1081  pFraction = create_normalform(pNewMath);
1082  delete pNewMath;
1083  assert(pFraction != NULL);
1084  // this->mNormalizedExpressions.push_back(pFraction);
1085  }
1086  }
1087  // kinetic laws + stoichiometric expressions
1088  const Reaction* pReaction = NULL;
1089  iMax = pModel->getListOfReactions()->size();
1090  for (i = 0;i < iMax;++i)
1091  {
1092  pReaction = pModel->getReaction(i);
1093  assert(pReaction != NULL);
1094  const KineticLaw* pLaw = pReaction->getKineticLaw();
1095  if (pLaw != NULL)
1096  {
1097  pMath = pLaw->getMath();
1098  if (pMath != NULL)
1099  {
1100  pNewMath = create_expression(pMath, pModel);
1101  assert(pNewMath != NULL);
1102  pFraction = create_normalform(pNewMath);
1103  delete pNewMath;
1104  assert(pFraction != NULL);
1105  // this->mNormalizedExpressions.push_back(pFraction);
1106  }
1107  }
1108  const SpeciesReference* pSpeciesReference = NULL;
1109  // substrates
1110  unsigned j, jMax = pReaction->getListOfReactants()->size();
1111  for (j = 0;j < jMax;++j)
1112  {
1113  pSpeciesReference = pReaction->getReactant(j);
1114  assert(pSpeciesReference != NULL);
1115  if (pSpeciesReference->isSetStoichiometryMath())
1116  {
1117  const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath();
1118  assert(pSMath != NULL);
1119  pMath = pSMath->getMath();
1120  if (pMath != NULL)
1121  {
1122  pNewMath = create_expression(pMath, pModel);
1123  assert(pNewMath != NULL);
1124  pFraction = create_normalform(pNewMath);
1125  delete pNewMath;
1126  assert(pFraction != NULL);
1127  // this->mNormalizedExpressions.push_back(pFraction);
1128  }
1129  }
1130  }
1131  // products
1132  jMax = pReaction->getListOfProducts()->size();
1133  for (j = 0;j < jMax;++j)
1134  {
1135  pSpeciesReference = pReaction->getProduct(j);
1136  assert(pSpeciesReference != NULL);
1137  if (pSpeciesReference->isSetStoichiometryMath())
1138  {
1139  const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath();
1140  assert(pSMath != NULL);
1141  pMath = pSMath->getMath();
1142  if (pMath != NULL)
1143  {
1144  pNewMath = create_expression(pMath, pModel);
1145  assert(pNewMath != NULL);
1146  pFraction = create_normalform(pNewMath);
1147  delete pNewMath;
1148  assert(pFraction != NULL);
1149  // this->mNormalizedExpressions.push_back(pFraction);
1150  }
1151  }
1152  }
1153  }
1154  // events
1155  const Event* pEvent = NULL;
1156  const Trigger* pTrigger = NULL;
1157  const Delay* pDelay = NULL;
1158  iMax = pModel->getListOfEvents()->size();
1159  for (i = 0;i < iMax;++i)
1160  {
1161  pEvent = pModel->getEvent(i);
1162  assert(pEvent != NULL);
1163  // trigger
1164  pTrigger = pEvent->getTrigger();
1165  assert(pTrigger != NULL);
1166  pMath = pTrigger->getMath();
1167  if (pMath != NULL)
1168  {
1169  pNewMath = create_expression(pMath, pModel);
1170  assert(pNewMath != NULL);
1171  pFraction = create_normalform(pNewMath);
1172  delete pNewMath;
1173  assert(pFraction != NULL);
1174  // this->mNormalizedExpressions.push_back(pFraction);
1175  }
1176 
1177  // delay
1178  if (pEvent->isSetDelay())
1179  {
1180  pDelay = pEvent->getDelay();
1181  assert(pDelay != NULL);
1182  pMath = pDelay->getMath();
1183  if (pMath != NULL)
1184  {
1185  pNewMath = create_expression(pMath, pModel);
1186  assert(pNewMath != NULL);
1187  pFraction = create_normalform(pNewMath);
1188  delete pNewMath;
1189  assert(pFraction != NULL);
1190  // this->mNormalizedExpressions.push_back(pFraction);
1191  }
1192  }
1193 
1194  // event assignments
1195  unsigned int j, jMax = pEvent->getListOfEventAssignments()->size();
1196  const EventAssignment* pEventAssignment = NULL;
1197  for (j = 0;j < jMax;++j)
1198  {
1199  pEventAssignment = pEvent->getEventAssignment(j);
1200  assert(pEventAssignment != NULL);
1201  pMath = pEventAssignment->getMath();
1202  if (pMath != NULL)
1203  {
1204  pNewMath = create_expression(pMath, pModel);
1205  assert(pNewMath != NULL);
1206  pFraction = create_normalform(pNewMath);
1207  delete pNewMath;
1208  assert(pFraction != NULL);
1209  // this->mNormalizedExpressions.push_back(pFraction);
1210  }
1211  }
1212  }
1213 }
1214  */
1215 
1216 /**
1217  * Normalizes the function definitions in the given model.
1218 void stress_test::normalizeFunctionDefinitions(const Model* pModel)
1219 {
1220  const FunctionDefinition* pFunDef = NULL;
1221  const ASTNode* pRoot = NULL;
1222  ASTNode* pNewRoot = NULL;
1223  CNormalFraction* pFraction = NULL;
1224  unsigned int i, iMax = pModel->getListOfFunctionDefinitions()->size();
1225  for (i = 0;i < iMax;++i)
1226  {
1227  pFunDef = pModel->getFunctionDefinition(i);
1228  pRoot = pFunDef->getMath();
1229  // the actual function is the last child
1230  if (pRoot != NULL && pRoot->getNumChildren() > 0)
1231  {
1232  // function definitons have to be expanded
1233  const ASTNode* pMath = pRoot->getChild(pRoot->getNumChildren() - 1);
1234  assert(pMath != NULL);
1235  pNewRoot = expand_function_calls(pMath, pModel);
1236  assert(pNewRoot != NULL);
1237  pFraction = create_normalform(pNewRoot);
1238  assert(pFraction != NULL);
1239  // mNormalizedFunctionDefinitions.push_back(pFraction);
1240  }
1241  }
1242 }
1243  */
1244 
1245 /**
1246  * Normalizes COPASIs function database.
1247  */
1249 {
1251  assert(pFunctionDB != NULL);
1252  CCopasiVectorN< CFunction > & loadedFunctions = pFunctionDB->loadedFunctions();
1253  unsigned int i = 0, iMax = loadedFunctions.size();
1254 
1255  while (i < iMax)
1256  {
1257  CEvaluationTree* pTree = loadedFunctions[i];
1258  assert(pTree != NULL);
1259 
1260  if (dynamic_cast<const CFunction*>(pTree) != NULL && dynamic_cast<const CMassAction*>(pTree) == NULL)
1261  {
1262  // make sure it is not mass action
1263  try
1264  {
1265  CEvaluationNode* pExpanded = expand_function_calls(pTree->getRoot(), pFunctionDB);
1266  assert(pExpanded != NULL);
1267  gettimeofday(&mTV1, &mTZ1);
1269  gettimeofday(&mTV2, &mTZ2);
1270  double timeDiff = mTV2.tv_sec - mTV1.tv_sec;
1271 
1272  if (mTV2.tv_usec < mTV1.tv_usec)
1273  {
1274  timeDiff -= (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
1275  }
1276  else
1277  {
1278  timeDiff += (mTV2.tv_usec - mTV1.tv_usec) / 1e6;
1279  }
1280 
1281  mProcessTimes.insert(timeDiff);
1282  delete pExpanded;
1283  assert(pFraction != NULL);
1284  mNormalizedCOPASIFunctionDefinitions.insert(std::pair<const std::string, CNormalFraction*>(pTree->getObjectName(), pFraction));
1286  }
1287  catch (recursion_limit_exception e)
1288  {
1289  std::cerr << "recursion limit exceeded for expression:" << std::endl;
1290  pTree->getRoot()->printRecursively();
1292  }
1293  catch (...)
1294  {
1295  std::cerr << "expression could not be normalized: " << std::endl;
1296  pTree->getRoot()->printRecursively();
1298  }
1299  }
1300 
1301  ++i;
1302  }
1303 }
1304 
1305 bool stress_test::normalize_names(ASTNode* pNode, const Reaction* pReaction, const Model* pModel)
1306 {
1307  bool result = true;
1308  std::vector<std::pair<ASTNode*, unsigned int> > nodeStack;
1309  std::map<std::string, std::string> replacementMap;
1310 
1311 
1312  unsigned int compartment_index = 1;
1313  unsigned int species_index = 1;
1314  unsigned int reaction_index = 1;
1315  unsigned int parameter_index = 1;
1316  std::ostringstream os;
1317  // first we collect all ids
1318  ASTNode* pCurrent = pNode;
1319  unsigned int iMax;
1320  nodeStack.push_back(std::pair<ASTNode*, unsigned int>(NULL, 0));
1321  std::map<std::string, std::string>::const_iterator pos;
1322 
1323  while (pCurrent != NULL)
1324  {
1325  // if the object is already on the node stack, we go
1326  // either to the next child or one up
1327  if (pCurrent == nodeStack.back().first)
1328  {
1329  ++nodeStack.back().second;
1330 
1331  if (nodeStack.back().second == pCurrent->getNumChildren())
1332  {
1333  // we are done here and we have to go one up
1334  nodeStack.erase(--nodeStack.end());
1335  pCurrent = nodeStack.back().first;
1336  }
1337  else
1338  {
1339  // next child
1340  pCurrent = pCurrent->getChild(nodeStack.back().second);
1341  }
1342  }
1343  else
1344  {
1345  iMax = pCurrent->getNumChildren();
1346 
1347  // if there are children, add the node to
1348  // the node stack
1349  if (iMax > 0)
1350  {
1351  nodeStack.push_back(std::pair<ASTNode*, unsigned int>(pCurrent, 0));
1352  pCurrent = pCurrent->getChild(0);
1353  }
1354  else
1355  {
1356  if (pCurrent->isName())
1357  {
1358  // check if the name is the id of a compartment, a species, a reaction
1359  // a global parameter or one of the reaction parameters
1360  // if so, we add a new entry to out replacement map
1361  // we check in the order parameters, species, compartment and reaction
1362  // because that should result in the least tests
1363  std::string id = pCurrent->getName();
1364  // do we already know this id?
1365  pos = replacementMap.find(id);
1366 
1367  if (pos == replacementMap.end())
1368  {
1369  // if not, we create a replacement
1370  if ((pReaction->getKineticLaw() != NULL && pReaction->getKineticLaw()->getParameter(id) != NULL) || pModel->getParameter(id) != NULL)
1371  {
1372  os.str("");
1373  os << "K_" << parameter_index;
1374  replacementMap.insert(std::pair<std::string, std::string>(id, os.str()));
1375  pCurrent->setName(os.str().c_str());
1376  ++parameter_index;
1377 
1378  }
1379  else if (pModel->getSpecies(id) != NULL)
1380  {
1381  os.str("");
1382  os << "S_" << species_index;
1383  replacementMap.insert(std::pair<std::string, std::string>(id, os.str()));
1384  pCurrent->setName(os.str().c_str());
1385  ++species_index;
1386  }
1387  else if (pModel->getCompartment(id) != NULL)
1388  {
1389  os.str("");
1390  os << "C_" << compartment_index;
1391  replacementMap.insert(std::pair<std::string, std::string>(id, os.str()));
1392  pCurrent->setName(os.str().c_str());
1393  ++compartment_index;
1394  }
1395  else if (pModel->getReaction(id) != NULL)
1396  {
1397  os.str("");
1398  os << "R_" << reaction_index;
1399  replacementMap.insert(std::pair<std::string, std::string>(id, os.str()));
1400  pCurrent->setName(os.str().c_str());
1401  ++reaction_index;
1402  }
1403  else
1404  {
1405  // lets see if there are any for these
1406  assert(false);
1407  }
1408  }
1409  else
1410  {
1411  pCurrent->setName(pos->second.c_str());
1412  }
1413  }
1414 
1415  // continue with the parent
1416  pCurrent = nodeStack.back().first;
1417  }
1418  }
1419 
1420  }
1421 
1422  return result;
1423 }
1424 
1425 
1426 int main(int argc, char** argv)
1427 {
1428  if (argc > 1)
1429  {
1430  int i = 1;
1431  std::vector<std::string> filenames;
1432 
1433  while (i < argc)
1434  {
1435  filenames.push_back(argv[i]);
1436  ++i;
1437  }
1438 
1439  stress_test test;
1440  test.run(filenames);
1441  }
1442  else
1443  {
1444  std::cerr << "Usage: stresstest SBMLFILE1 [SBMLFILE2 ...]" << std::endl;
1445  }
1446 }
1447 
1448 
1449 
void normalizeFunctionDB()
std::set< double > mProcessTimes
Definition: stress_test.h:184
CCopasiVectorN< CFunction > & loadedFunctions()
std::map< int, std::vector< CNormalFraction * > > mSBOMap
Definition: stress_test.h:175
SBMLDocument * getCurrentSBMLDocument()
static CNormalFraction * normAndSimplifyReptdly(const CEvaluationTree *tree0, unsigned int depth=0)
static bool normalize_names(ASTNode *pNode, const Reaction *pReaction, const Model *pModel)
const std::string & getObjectName() const
unsigned int mNumExceededCOPASIFunctions
Definition: stress_test.h:162
unsigned int mNumExceeded
Definition: stress_test.h:159
virtual size_t size() const
unsigned int mNumFailedCOPASIFunctions
Definition: stress_test.h:163
unsigned int mNumExpressions
Definition: stress_test.h:158
CCopasiDataModel * mpDataModel
Definition: stress_test.h:179
unsigned int mNumExceededFunctions
Definition: stress_test.h:156
void normalizeMath(const std::string &filename)
int main(int argc, char **argv)
bool importSBML(const std::string &fileName, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void normalizeAndSimplifyExpressions(const Model *pModel)
bool are_equal(const CNormalFraction *pLHS, const CNormalFraction *pRHS)
unsigned int mDifferentNormalform
Definition: stress_test.h:177
unsigned int mNumUnmappedKineticExpressions
Definition: stress_test.h:169
unsigned int mNumFailed
Definition: stress_test.h:160
struct timeval mTV1
Definition: stress_test.h:180
unsigned int mNumSBO
Definition: stress_test.h:178
const CFunction * getFunction() const
Definition: CReaction.cpp:252
CNormalFraction * create_simplified_normalform(const ASTNode *pSource)
unsigned int mNumCOPASIFunctions
Definition: stress_test.h:161
std::map< std::string, unsigned int > mExpressionMappings
Definition: stress_test.h:174
unsigned int mNumMappedKineticExpressions
Definition: stress_test.h:168
void run(const std::vector< std::string > &filenames)
unsigned int mNumFiles
Definition: stress_test.h:164
std::multimap< std::string, CNormalFraction * > mNormalizedCOPASIFunctionDefinitions
Definition: stress_test.h:172
unsigned int mNumKineticFunctions
Definition: stress_test.h:165
static CFunctionDB * getFunctionList()
static CCopasiDataModel * addDatamodel()
virtual ~stress_test()
Definition: stress_test.cpp:85
ASTNode * create_expression(const ASTNode *pSource, const ListOfFunctionDefinitions *pFunctions)
unsigned int mNumFunctionDefinitions
Definition: stress_test.h:155
unsigned int mNumFailedFunctions
Definition: stress_test.h:157
void normalizeAndSimplifyFunctionDefinitions(const Model *pModel)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
std::vector< std::string > mUnreadableFiles
Definition: stress_test.h:173
static void init(int argc, char *argv[], const bool &withGui=false)
struct timezone mTZ2
Definition: stress_test.h:183
std::vector< std::pair< std::string, CNormalFraction * > > mNormalizedFunctionDefinitions
Definition: stress_test.h:171
ASTNode * expand_function_calls(const ASTNode *pNode, const ListOfFunctionDefinitions *pFunctions)
void printRecursively(std::ostream &os, int indent=0) const
struct timezone mTZ1
Definition: stress_test.h:181
std::vector< CNormalFraction * > mNormalizedExpressions
Definition: stress_test.h:170
struct timeval mTV2
Definition: stress_test.h:182
CEvaluationNode * getRoot()
std::map< CNormalFraction *, int > mUnknownCategories
Definition: stress_test.h:176