COPASI API  4.16.103
stress_test.h
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.h,v $
3 // $Revision: 1.8 $
4 // $Name: $
5 // $Author: bergmann $
6 // $Date: 2012/04/19 15:00:42 $
7 // End CVS Header
8 
9 // Copyright (C) 2012 - 2011 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 #ifndef STRESS_TEST_H__
20 #define STRESS_TEST_H__
21 
22 #include <string>
23 #include <vector>
24 #include <map>
25 #include <set>
26 #ifdef WIN32
27 #include <time.h>
28 #include <windows.h>
29 #include <sys/timeb.h>
30 #if defined(_MSC_VER) || defined(_MSC_EXTENSIONS)
31 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000Ui64
32 #else
33 #define DELTA_EPOCH_IN_MICROSECS 11644473600000000ULL
34 #endif
35 #else
36 #include <sys/time.h>
37 #endif
38 
39 class CNormalFraction;
40 class Model;
41 class CCopasiDataModel;
42 class ASTNode;
43 class Reaction;
44 
45 // This test reads all models from the biomodels database and normalizes all
46 // mathematical expressions it finds in there.
47 // Later on, it will do the same for the functions in COPASIs function database
48 // and compare the expressions from the model to those in the function database
49 // in order to find out if they are the same.
51 {
52 #ifdef WIN32
53  struct timeval
54  {
55  time_t tv_sec; /* seconds */
56  long tv_usec; /* and microseconds */
57  };
58 
59  struct timezone
60  {
61  int tz_minuteswest; /* minutes W of Greenwich */
62  int tz_dsttime; /* type of dst correction */
63  };
64 
65  int gettimeofday(struct timeval *tv, struct timezone *tz)
66  {
67  FILETIME ft;
68  unsigned __int64 tmpres = 0;
69  static int tzflag;
70 
71  if (NULL != tv)
72  {
73  GetSystemTimeAsFileTime(&ft);
74 
75  tmpres |= ft.dwHighDateTime;
76  tmpres <<= 32;
77  tmpres |= ft.dwLowDateTime;
78 
79  /*converting file time to unix epoch*/
80  tmpres -= DELTA_EPOCH_IN_MICROSECS;
81  tmpres /= 10; /*convert into microseconds*/
82  tv->tv_sec = (long)(tmpres / 1000000UL);
83  tv->tv_usec = (long)(tmpres % 1000000UL);
84  }
85 
86  if (NULL != tz)
87  {
88  if (!tzflag)
89  {
90  _tzset();
91  tzflag++;
92  }
93 
94  tz->tz_minuteswest = _timezone / 60;
95  tz->tz_dsttime = _daylight;
96  }
97 
98  return 0;
99  }
100 #endif
101 public:
102  /**
103  * Constructor.
104  */
105  stress_test();
106 
107  /**
108  * Destructor.
109  */
110  virtual ~stress_test();
111 
112  /**
113  * Goes through the list of files, loads each file and normalizes the
114  * mathematical expressions in the contained model.
115  */
116  void run(const std::vector<std::string>& filenames);
117 
118 protected:
119  /**
120  * Loads an sbml model from the given file and
121  * normalized all mathematical expressions in the SBML model.
122  */
123  void normalizeMath(const std::string& filename);
124 
125  /**
126  * Normalizes all expressions but the function definitions in the given
127  * model.
128  void normalizeExpressions(const Model* pModel);
129  */
130 
131  /**
132  * Normalizes the function definitions in the given model.
133  void normalizeFunctionDefinitions(const Model* pModel);
134  */
135 
136  /**
137  * Normalizes all expressions but the function definitions in the given
138  * model.
139  */
140  void normalizeAndSimplifyExpressions(const Model* pModel);
141 
142  /**
143  * Normalizes the function definitions in the given model.
144  */
145  void normalizeAndSimplifyFunctionDefinitions(const Model* pModel);
146 
147  /**
148  * Normalizes COPASIs function database.
149  */
150  void normalizeFunctionDB();
151 
152  static bool normalize_names(ASTNode* pNode, const Reaction* pReaction, const Model* pModel);
153 
154 protected:
156  unsigned int mNumExceededFunctions;
157  unsigned int mNumFailedFunctions;
158  unsigned int mNumExpressions;
159  unsigned int mNumExceeded;
160  unsigned int mNumFailed;
161  unsigned int mNumCOPASIFunctions;
164  unsigned int mNumFiles;
165  unsigned int mNumKineticFunctions;
170  std::vector<CNormalFraction*> mNormalizedExpressions;
171  std::vector<std::pair<std::string, CNormalFraction*> > mNormalizedFunctionDefinitions;
172  std::multimap<std::string, CNormalFraction*> mNormalizedCOPASIFunctionDefinitions;
173  std::vector<std::string> mUnreadableFiles;
174  std::map<std::string, unsigned int> mExpressionMappings;
175  std::map<int, std::vector<CNormalFraction*> > mSBOMap;
176  std::map<CNormalFraction*, int> mUnknownCategories;
177  unsigned int mDifferentNormalform;
178  unsigned int mNumSBO;
180  struct timeval mTV1;
181  struct timezone mTZ1;
182  struct timeval mTV2;
183  struct timezone mTZ2;
184  std::set<double> mProcessTimes;
185 };
186 
187 #endif // STRESS_TEST_H__
void normalizeFunctionDB()
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)
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
void normalizeMath(const std::string &filename)
void normalizeAndSimplifyExpressions(const Model *pModel)
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
struct timeval mTV1
Definition: stress_test.h:180
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
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
virtual ~stress_test()
Definition: stress_test.cpp:85
unsigned int mNumFunctionDefinitions
Definition: stress_test.h:155
unsigned int mNumFailedFunctions
Definition: stress_test.h:157
unsigned int mNumConstantFluxKinetics
Definition: stress_test.h:167
void normalizeAndSimplifyFunctionDefinitions(const Model *pModel)
std::vector< std::string > mUnreadableFiles
Definition: stress_test.h:173
struct timezone mTZ2
Definition: stress_test.h:183
std::vector< std::pair< std::string, CNormalFraction * > > mNormalizedFunctionDefinitions
Definition: stress_test.h:171
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
std::map< CNormalFraction *, int > mUnknownCategories
Definition: stress_test.h:176