COPASI API  4.16.103
Public Member Functions | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
stress_test Class Reference

#include <stress_test.h>

Collaboration diagram for stress_test:
Collaboration graph
[legend]

Public Member Functions

void run (const std::vector< std::string > &filenames)
 
 stress_test ()
 
virtual ~stress_test ()
 

Protected Member Functions

void normalizeAndSimplifyExpressions (const Model *pModel)
 
void normalizeAndSimplifyFunctionDefinitions (const Model *pModel)
 
void normalizeFunctionDB ()
 
void normalizeMath (const std::string &filename)
 

Static Protected Member Functions

static bool normalize_names (ASTNode *pNode, const Reaction *pReaction, const Model *pModel)
 

Protected Attributes

unsigned int mDifferentNormalform
 
std::map< std::string,
unsigned int > 
mExpressionMappings
 
std::multimap< std::string,
CNormalFraction * > 
mNormalizedCOPASIFunctionDefinitions
 
std::vector< CNormalFraction * > mNormalizedExpressions
 
std::vector< std::pair
< std::string, CNormalFraction * > > 
mNormalizedFunctionDefinitions
 
unsigned int mNumConstantFluxKinetics
 
unsigned int mNumCOPASIFunctions
 
unsigned int mNumExceeded
 
unsigned int mNumExceededCOPASIFunctions
 
unsigned int mNumExceededFunctions
 
unsigned int mNumExpressions
 
unsigned int mNumFailed
 
unsigned int mNumFailedCOPASIFunctions
 
unsigned int mNumFailedFunctions
 
unsigned int mNumFiles
 
unsigned int mNumFunctionDefinitions
 
unsigned int mNumKineticFunctions
 
unsigned int mNumMappedKineticExpressions
 
unsigned int mNumMassActionsKinetics
 
unsigned int mNumSBO
 
unsigned int mNumUnmappedKineticExpressions
 
CCopasiDataModelmpDataModel
 
std::set< double > mProcessTimes
 
std::map< int, std::vector
< CNormalFraction * > > 
mSBOMap
 
struct timeval mTV1
 
struct timeval mTV2
 
struct timezone mTZ1
 
struct timezone mTZ2
 
std::map< CNormalFraction *, int > mUnknownCategories
 
std::vector< std::string > mUnreadableFiles
 

Detailed Description

Definition at line 50 of file stress_test.h.

Constructor & Destructor Documentation

stress_test::stress_test ( )

Constructor.

Definition at line 57 of file stress_test.cpp.

References CCopasiRootContainer::addDatamodel(), CCopasiRootContainer::init(), and mpDataModel.

60  mNumExpressions(0),
61  mNumExceeded(0),
62  mNumFailed(0),
66  mNumFiles(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 }
unsigned int mNumExceededCOPASIFunctions
Definition: stress_test.h:162
unsigned int mNumExceeded
Definition: stress_test.h:159
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
unsigned int mDifferentNormalform
Definition: stress_test.h:177
unsigned int mNumMassActionsKinetics
Definition: stress_test.h:166
unsigned int mNumUnmappedKineticExpressions
Definition: stress_test.h:169
unsigned int mNumFailed
Definition: stress_test.h:160
unsigned int mNumSBO
Definition: stress_test.h:178
unsigned int mNumCOPASIFunctions
Definition: stress_test.h:161
unsigned int mNumMappedKineticExpressions
Definition: stress_test.h:168
unsigned int mNumFiles
Definition: stress_test.h:164
unsigned int mNumKineticFunctions
Definition: stress_test.h:165
static CCopasiDataModel * addDatamodel()
unsigned int mNumFunctionDefinitions
Definition: stress_test.h:155
unsigned int mNumFailedFunctions
Definition: stress_test.h:157
unsigned int mNumConstantFluxKinetics
Definition: stress_test.h:167
static void init(int argc, char *argv[], const bool &withGui=false)
stress_test::~stress_test ( )
virtual

Destructor.

Definition at line 85 of file stress_test.cpp.

References CCopasiRootContainer::destroy(), mNormalizedCOPASIFunctionDefinitions, mNormalizedExpressions, and mNormalizedFunctionDefinitions.

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 }
std::multimap< std::string, CNormalFraction * > mNormalizedCOPASIFunctionDefinitions
Definition: stress_test.h:172
std::vector< std::pair< std::string, CNormalFraction * > > mNormalizedFunctionDefinitions
Definition: stress_test.h:171
std::vector< CNormalFraction * > mNormalizedExpressions
Definition: stress_test.h:170

Member Function Documentation

bool stress_test::normalize_names ( ASTNode *  pNode,
const Reaction *  pReaction,
const Model *  pModel 
)
staticprotected

Definition at line 1305 of file stress_test.cpp.

Referenced by normalizeAndSimplifyExpressions().

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 }
void stress_test::normalizeAndSimplifyExpressions ( const Model *  pModel)
protected

Normalizes all expressions but the function definitions in the given model. void normalizeExpressions(const Model* pModel); Normalizes the function definitions in the given model. void normalizeFunctionDefinitions(const Model* pModel); Normalizes all expressions but the function definitions in the given model.

Normalizes all expressions but the function definitions in the given model.

Definition at line 412 of file stress_test.cpp.

References are_equal(), create_expression(), create_simplified_normalform(), CReaction::getFunction(), CCopasiDataModel::getModel(), CCopasiObject::getObjectName(), CModel::getReactions(), mDifferentNormalform, mExpressionMappings, mNormalizedCOPASIFunctionDefinitions, mNumExceeded, mNumExpressions, mNumFailed, mNumKineticFunctions, mNumMappedKineticExpressions, mNumSBO, mNumUnmappedKineticExpressions, mpDataModel, mProcessTimes, mSBOMap, mTV1, mTV2, mTZ1, mTZ2, mUnknownCategories, normalize_names(), and CCopasiVector< T >::size().

Referenced by normalizeMath().

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 }
std::set< double > mProcessTimes
Definition: stress_test.h:184
std::map< int, std::vector< CNormalFraction * > > mSBOMap
Definition: stress_test.h:175
static bool normalize_names(ASTNode *pNode, const Reaction *pReaction, const Model *pModel)
const std::string & getObjectName() const
unsigned int mNumExceeded
Definition: stress_test.h:159
virtual size_t size() const
unsigned int mNumExpressions
Definition: stress_test.h:158
CCopasiDataModel * mpDataModel
Definition: stress_test.h:179
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)
std::map< std::string, unsigned int > mExpressionMappings
Definition: stress_test.h:174
unsigned int mNumMappedKineticExpressions
Definition: stress_test.h:168
std::multimap< std::string, CNormalFraction * > mNormalizedCOPASIFunctionDefinitions
Definition: stress_test.h:172
unsigned int mNumKineticFunctions
Definition: stress_test.h:165
ASTNode * create_expression(const ASTNode *pSource, const ListOfFunctionDefinitions *pFunctions)
CCopasiVectorNS< CReaction > & getReactions()
Definition: CModel.cpp:1039
struct timezone mTZ2
Definition: stress_test.h:183
struct timezone mTZ1
Definition: stress_test.h:181
struct timeval mTV2
Definition: stress_test.h:182
const char * id
Definition: stdsoap2.h:1262
std::map< CNormalFraction *, int > mUnknownCategories
Definition: stress_test.h:176
void stress_test::normalizeAndSimplifyFunctionDefinitions ( const Model *  pModel)
protected

Normalizes the function definitions in the given model.

Definition at line 983 of file stress_test.cpp.

References create_simplified_normalform(), expand_function_calls(), mNormalizedFunctionDefinitions, mNumExceededFunctions, mNumFailedFunctions, mNumFunctionDefinitions, mProcessTimes, mTV1, mTV2, mTZ1, and mTZ2.

Referenced by normalizeMath().

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 }
std::set< double > mProcessTimes
Definition: stress_test.h:184
unsigned int mNumExceededFunctions
Definition: stress_test.h:156
struct timeval mTV1
Definition: stress_test.h:180
CNormalFraction * create_simplified_normalform(const ASTNode *pSource)
unsigned int mNumFunctionDefinitions
Definition: stress_test.h:155
unsigned int mNumFailedFunctions
Definition: stress_test.h:157
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)
struct timezone mTZ1
Definition: stress_test.h:181
struct timeval mTV2
Definition: stress_test.h:182
void stress_test::normalizeFunctionDB ( )
protected

Normalizes COPASIs function database.

Normalizes all expressions but the function definitions in the given model. void stress_test::normalizeExpressions(const Model* pModel) { expressions can occur in assignments, initial assignments, kinetic laws event triggers, event delays, event assignments and stiochiometric expressions const InitialAssignment* pInitialAssignment = NULL; const ASTNode* pMath = NULL; ASTNode* pNewMath = NULL; CNormalFraction* pFraction = NULL; initial assignments unsigned int i, iMax = pModel->getListOfInitialAssignments()->size(); for (i = 0;i < iMax;++i) { pInitialAssignment = pModel->getInitialAssignment(i); assert(pInitialAssignment != NULL); pMath = pInitialAssignment->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } rules const Rule* pRule = NULL; iMax = pModel->getListOfRules()->size(); for (i = 0;i < iMax;++i) { pRule = pModel->getRule(i); assert(pRule != NULL); pMath = pRule->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } kinetic laws + stoichiometric expressions const Reaction* pReaction = NULL; iMax = pModel->getListOfReactions()->size(); for (i = 0;i < iMax;++i) { pReaction = pModel->getReaction(i); assert(pReaction != NULL); const KineticLaw* pLaw = pReaction->getKineticLaw(); if (pLaw != NULL) { pMath = pLaw->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } const SpeciesReference* pSpeciesReference = NULL; substrates unsigned j, jMax = pReaction->getListOfReactants()->size(); for (j = 0;j < jMax;++j) { pSpeciesReference = pReaction->getReactant(j); assert(pSpeciesReference != NULL); if (pSpeciesReference->isSetStoichiometryMath()) { const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath(); assert(pSMath != NULL); pMath = pSMath->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } } products jMax = pReaction->getListOfProducts()->size(); for (j = 0;j < jMax;++j) { pSpeciesReference = pReaction->getProduct(j); assert(pSpeciesReference != NULL); if (pSpeciesReference->isSetStoichiometryMath()) { const StoichiometryMath* pSMath = pSpeciesReference->getStoichiometryMath(); assert(pSMath != NULL); pMath = pSMath->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } } } events const Event* pEvent = NULL; const Trigger* pTrigger = NULL; const Delay* pDelay = NULL; iMax = pModel->getListOfEvents()->size(); for (i = 0;i < iMax;++i) { pEvent = pModel->getEvent(i); assert(pEvent != NULL); trigger pTrigger = pEvent->getTrigger(); assert(pTrigger != NULL); pMath = pTrigger->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); }

delay if (pEvent->isSetDelay()) { pDelay = pEvent->getDelay(); assert(pDelay != NULL); pMath = pDelay->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } }

event assignments unsigned int j, jMax = pEvent->getListOfEventAssignments()->size(); const EventAssignment* pEventAssignment = NULL; for (j = 0;j < jMax;++j) { pEventAssignment = pEvent->getEventAssignment(j); assert(pEventAssignment != NULL); pMath = pEventAssignment->getMath(); if (pMath != NULL) { pNewMath = create_expression(pMath, pModel); assert(pNewMath != NULL); pFraction = create_normalform(pNewMath); delete pNewMath; assert(pFraction != NULL); this->mNormalizedExpressions.push_back(pFraction); } } } } Normalizes the function definitions in the given model. void stress_test::normalizeFunctionDefinitions(const Model* pModel) { const FunctionDefinition* pFunDef = NULL; const ASTNode* pRoot = NULL; ASTNode* pNewRoot = NULL; CNormalFraction* pFraction = NULL; unsigned int i, iMax = pModel->getListOfFunctionDefinitions()->size(); for (i = 0;i < iMax;++i) { pFunDef = pModel->getFunctionDefinition(i); pRoot = pFunDef->getMath(); the actual function is the last child if (pRoot != NULL && pRoot->getNumChildren() > 0) { function definitons have to be expanded const ASTNode* pMath = pRoot->getChild(pRoot->getNumChildren() - 1); assert(pMath != NULL); pNewRoot = expand_function_calls(pMath, pModel); assert(pNewRoot != NULL); pFraction = create_normalform(pNewRoot); assert(pFraction != NULL); mNormalizedFunctionDefinitions.push_back(pFraction); } } } Normalizes COPASIs function database.

Definition at line 1248 of file stress_test.cpp.

References expand_function_calls(), CCopasiRootContainer::getFunctionList(), CCopasiObject::getObjectName(), CEvaluationTree::getRoot(), CFunctionDB::loadedFunctions(), mNormalizedCOPASIFunctionDefinitions, mNumCOPASIFunctions, mNumExceededCOPASIFunctions, mNumFailedCOPASIFunctions, mProcessTimes, mTV1, mTV2, mTZ1, mTZ2, CNormalTranslation::normAndSimplifyReptdly(), CEvaluationNode::printRecursively(), and CCopasiVector< T >::size().

Referenced by run().

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 }
std::set< double > mProcessTimes
Definition: stress_test.h:184
CCopasiVectorN< CFunction > & loadedFunctions()
static CNormalFraction * normAndSimplifyReptdly(const CEvaluationTree *tree0, unsigned int depth=0)
const std::string & getObjectName() const
unsigned int mNumExceededCOPASIFunctions
Definition: stress_test.h:162
virtual size_t size() const
unsigned int mNumFailedCOPASIFunctions
Definition: stress_test.h:163
struct timeval mTV1
Definition: stress_test.h:180
unsigned int mNumCOPASIFunctions
Definition: stress_test.h:161
std::multimap< std::string, CNormalFraction * > mNormalizedCOPASIFunctionDefinitions
Definition: stress_test.h:172
static CFunctionDB * getFunctionList()
struct timezone mTZ2
Definition: stress_test.h:183
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
struct timeval mTV2
Definition: stress_test.h:182
CEvaluationNode * getRoot()
void stress_test::normalizeMath ( const std::string &  filename)
protected

Loads an sbml model from the given file and normalized all mathematical expressions in the SBML model.

Definition at line 372 of file stress_test.cpp.

References CCopasiDataModel::getCurrentSBMLDocument(), CCopasiDataModel::importSBML(), mNumFiles, mpDataModel, mUnreadableFiles, normalizeAndSimplifyExpressions(), and normalizeAndSimplifyFunctionDefinitions().

Referenced by run().

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 }
SBMLDocument * getCurrentSBMLDocument()
CCopasiDataModel * mpDataModel
Definition: stress_test.h:179
bool importSBML(const std::string &fileName, CProcessReport *pImportHandler=NULL, const bool &deleteOldData=true)
void normalizeAndSimplifyExpressions(const Model *pModel)
unsigned int mNumFiles
Definition: stress_test.h:164
void normalizeAndSimplifyFunctionDefinitions(const Model *pModel)
std::vector< std::string > mUnreadableFiles
Definition: stress_test.h:173
void stress_test::run ( const std::vector< std::string > &  filenames)

Goes through the list of files, loads each file and normalizes the mathematical expressions in the contained model.

Definition at line 121 of file stress_test.cpp.

References are_equal(), mDifferentNormalform, mExpressionMappings, mNormalizedCOPASIFunctionDefinitions, mNormalizedFunctionDefinitions, mNumCOPASIFunctions, mNumExceeded, mNumExceededCOPASIFunctions, mNumExceededFunctions, mNumExpressions, mNumFailed, mNumFailedCOPASIFunctions, mNumFailedFunctions, mNumFiles, mNumFunctionDefinitions, mNumKineticFunctions, mNumMappedKineticExpressions, mNumSBO, mNumUnmappedKineticExpressions, mProcessTimes, mSBOMap, mUnknownCategories, mUnreadableFiles, normalizeFunctionDB(), and normalizeMath().

Referenced by main().

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 }
void normalizeFunctionDB()
std::set< double > mProcessTimes
Definition: stress_test.h:184
std::map< int, std::vector< CNormalFraction * > > mSBOMap
Definition: stress_test.h:175
unsigned int mNumExceededCOPASIFunctions
Definition: stress_test.h:162
unsigned int mNumExceeded
Definition: stress_test.h:159
unsigned int mNumFailedCOPASIFunctions
Definition: stress_test.h:163
unsigned int mNumExpressions
Definition: stress_test.h:158
unsigned int mNumExceededFunctions
Definition: stress_test.h:156
void normalizeMath(const std::string &filename)
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
unsigned int mNumSBO
Definition: stress_test.h:178
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
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
unsigned int mNumFunctionDefinitions
Definition: stress_test.h:155
unsigned int mNumFailedFunctions
Definition: stress_test.h:157
std::vector< std::string > mUnreadableFiles
Definition: stress_test.h:173
std::vector< std::pair< std::string, CNormalFraction * > > mNormalizedFunctionDefinitions
Definition: stress_test.h:171
std::map< CNormalFraction *, int > mUnknownCategories
Definition: stress_test.h:176

Member Data Documentation

unsigned int stress_test::mDifferentNormalform
protected

Definition at line 177 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

std::map<std::string, unsigned int> stress_test::mExpressionMappings
protected

Definition at line 174 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

std::multimap<std::string, CNormalFraction*> stress_test::mNormalizedCOPASIFunctionDefinitions
protected
std::vector<CNormalFraction*> stress_test::mNormalizedExpressions
protected

Definition at line 170 of file stress_test.h.

Referenced by ~stress_test().

std::vector<std::pair<std::string, CNormalFraction*> > stress_test::mNormalizedFunctionDefinitions
protected

Definition at line 171 of file stress_test.h.

Referenced by normalizeAndSimplifyFunctionDefinitions(), run(), and ~stress_test().

unsigned int stress_test::mNumConstantFluxKinetics
protected

Definition at line 167 of file stress_test.h.

unsigned int stress_test::mNumCOPASIFunctions
protected

Definition at line 161 of file stress_test.h.

Referenced by normalizeFunctionDB(), and run().

unsigned int stress_test::mNumExceeded
protected

Definition at line 159 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumExceededCOPASIFunctions
protected

Definition at line 162 of file stress_test.h.

Referenced by normalizeFunctionDB(), and run().

unsigned int stress_test::mNumExceededFunctions
protected

Definition at line 156 of file stress_test.h.

Referenced by normalizeAndSimplifyFunctionDefinitions(), and run().

unsigned int stress_test::mNumExpressions
protected

Definition at line 158 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumFailed
protected

Definition at line 160 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumFailedCOPASIFunctions
protected

Definition at line 163 of file stress_test.h.

Referenced by normalizeFunctionDB(), and run().

unsigned int stress_test::mNumFailedFunctions
protected

Definition at line 157 of file stress_test.h.

Referenced by normalizeAndSimplifyFunctionDefinitions(), and run().

unsigned int stress_test::mNumFiles
protected

Definition at line 164 of file stress_test.h.

Referenced by normalizeMath(), and run().

unsigned int stress_test::mNumFunctionDefinitions
protected

Definition at line 155 of file stress_test.h.

Referenced by normalizeAndSimplifyFunctionDefinitions(), and run().

unsigned int stress_test::mNumKineticFunctions
protected

Definition at line 165 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumMappedKineticExpressions
protected

Definition at line 168 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumMassActionsKinetics
protected

Definition at line 166 of file stress_test.h.

unsigned int stress_test::mNumSBO
protected

Definition at line 178 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

unsigned int stress_test::mNumUnmappedKineticExpressions
protected

Definition at line 169 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

CCopasiDataModel* stress_test::mpDataModel
protected

Definition at line 179 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), normalizeMath(), and stress_test().

std::set<double> stress_test::mProcessTimes
protected
std::map<int, std::vector<CNormalFraction*> > stress_test::mSBOMap
protected

Definition at line 175 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

struct timeval stress_test::mTV1
protected
struct timeval stress_test::mTV2
protected
struct timezone stress_test::mTZ1
protected
struct timezone stress_test::mTZ2
protected
std::map<CNormalFraction*, int> stress_test::mUnknownCategories
protected

Definition at line 176 of file stress_test.h.

Referenced by normalizeAndSimplifyExpressions(), and run().

std::vector<std::string> stress_test::mUnreadableFiles
protected

Definition at line 173 of file stress_test.h.

Referenced by normalizeMath(), and run().


The documentation for this class was generated from the following files: