COPASI API  4.16.103
CScanMethod.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2013 by Pedro Mendes, Virginia Tech Intellectual
2 // Properties, Inc., University of Heidelberg, and The University
3 // of Manchester.
4 // All rights reserved.
5 
6 // Copyright (C) 2008 - 2009 by Pedro Mendes, Virginia Tech Intellectual
7 // Properties, Inc., EML Research, gGmbH, University of Heidelberg,
8 // and The University of Manchester.
9 // All rights reserved.
10 
11 // Copyright (C) 2003 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 /**
16  * CScanMethod class.
17  * This class describes the method for doing the Scan.
18  */
19 
20 #ifndef COPASI_CScanMethod
21 #define COPASI_CScanMethod
22 
23 #include <string>
24 
28 #include "report/CReport.h"
29 
30 class CScanProblem;
31 class CScanTask;
32 class CSteadyStateTask;
33 class CTrajectory;
34 class CRandom;
35 
36 class CScanItem
37 {
38 protected:
39  size_t mNumSteps;
40 
43 
45 
46  size_t mIndex;
47 
49 
51 
52 public:
53  static
55  CRandom* rg,
56  const bool & continueFromCurrentState);
57 
58  size_t getNumSteps() const;
59 
60  void restoreValue() const;
61 
62  void storeValue();
63 
64  void reset();
65 
66  bool isFinished() const;
67 
68  virtual void step() = 0;
69 
70  virtual bool isNesting() const {return true;};
71 
72  virtual ~CScanItem() {};
73 
74  /**
75  * perform checks. This is used in the method::isValidProblem() method.
76  * It returns false for an invalid ScanItem and generates a CCopasiMessage
77  * @param const bool & continueFromCurrentState
78  */
79  virtual bool isValidScanItem(const bool & continueFromCurrentState);
80 
81  /**
82  * Retrieve the initial object which is scanned.
83  * @return const CCopasiObject * object
84  */
85  const CCopasiObject * getObject() const;
86 
87 protected:
88 
89  CScanItem(CCopasiParameterGroup* si, const bool & continueFromCurrentState);
90 
91  //initObject();
92 
93 private:
94  CScanItem();
95 };
96 
97 //***********************************+
98 
100 {
101 public:
102  CScanItemRepeat(CCopasiParameterGroup* si, const bool & continueFromCurrentState);
103  virtual void step();
104 
105  virtual ~CScanItemRepeat() {};
106 
107  virtual bool isValidScanItem(const bool & continueFromCurrentState);
108 };
109 
110 //***********************************+
111 
113 {
114 private:
116  bool mLog;
117 public:
118  CScanItemLinear(CCopasiParameterGroup* si, const bool & continueFromCurrentState);
119  virtual void step();
120 
121  virtual ~CScanItemLinear() {};
122 
123  virtual bool isValidScanItem(const bool & continueFromCurrentState);
124 };
125 
126 //***********************************+
127 
129 {
130 private:
134  bool mLog;
135 public:
136  CScanItemRandom(CCopasiParameterGroup* si, CRandom* rg, const bool & continueFromCurrentState);
137  virtual ~CScanItemRandom() {};
138 
139  virtual void step();
140  virtual bool isNesting() const {return false;};
141 };
142 
143 //***********************************+
144 
145 /*class CScanItemBreak: public CScanItem
146  {
147  private:
148  size_t mPlotB, mReportB;
149  CScanTask* mST;
150  public:
151  CScanItemBreak(const CCopasiParameterGroup* si, CScanTask* st);
152  void step();
153  virtual bool isNesting() const {return false;};
154  };*/
155 
156 //*******************************************+
157 //*******************************************+
158 
160 {
161 protected:
162  /**
163  * A pointer to the trajectory problem.
164  */
166 
167  /**
168  * A pointer to the scan Task.
169  */
171 
172  /**
173  * A pointer to the random number generator
174  */
176 
177  std::vector<CScanItem*> mScanItems;
178 
179  std::vector< Refresh * > mInitialRefreshes;
180 
181  //std::vector< Refresh * > mTransientRefreshes;
182 
183  size_t mTotalSteps;
184 
185  /**
186  * the index of the last item that has several subitems,
187  * also the last item that need to generate output separators
188  */
190 
191  /**
192  * Variable indicating whether the subtask shall continue from the current state
193  * or the initial state
194  */
196 
197  // Operations
198 private:
199  /**
200  * Default constructor.
201  */
202  CScanMethod();
203 
204 protected:
205  /**
206  * Specific constructor.
207  * @param CCopasiMethod::SubType subType
208  * @param const CCopasiContainer * pParent (default: NULL)
209  */
211  const CCopasiContainer * pParent = NULL);
212 
213 public:
214  /**
215  * Create a trajectory method.
216  * Note: the returned object has to be released after use with delete
217  */
219 
220  /**
221  * Copy constructor.
222  * @param "const CTrajectoryMethod &" src
223  */
224  //CScanMethod(const CScanMethod & src,
225  // const CCopasiContainer * pParent = NULL);
226 
227  /**
228  * Destructor.
229  */
230  ~CScanMethod();
231 
232  /**
233  * Set a pointer to the problem.
234  * This method is used by CTrajectory
235  * @param "CTrajectoryProblem *" problem
236  */
237  void setProblem(CScanProblem * problem);
238 
239  bool init();
240 
241  bool scan();
242 
243  size_t getTotalNumberOfSteps() const {return mTotalSteps;};
244 
245  /**
246  * The main scan method.
247  */
248  //void scan(size_t s, bool C_UNUSED(nl), void (*pCallback)(CReport *), CReport *pReport);
249 
250  /**
251  * Check if the method is suitable for this problem
252  * @return bool suitability of the method
253  */
254  virtual bool isValidProblem(const CCopasiProblem * pProblem);
255 
256 private:
257 
258  bool cleanupScanItems();
259 
260  bool loop(size_t level);
261 
262  bool calculate();
263 
264  /**
265  * Set the value of the scan parameter based on the distribution
266  * @param size_t i where to start in the distribution
267  * @param size_t first first parameter in the set of Master/Slaves
268  * @param size_t last last parameter in the set of Master/Slaves
269  */
270  //void setScanParameterValue(size_t i,
271  // size_t first,
272  // size_t last);
273 };
274 
275 #endif // COPASI_CTrajectoryMethod
C_FLOAT64 mMax
Definition: CScanMethod.h:131
virtual ~CScanItemRepeat()
Definition: CScanMethod.h:105
virtual bool isValidScanItem(const bool &continueFromCurrentState)
void setProblem(CScanProblem *problem)
C_FLOAT64 mMax
Definition: CScanMethod.h:115
static CScanMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::scanMethod)
bool isFinished() const
CCopasiObject * mpInitialObject
Definition: CScanMethod.h:42
virtual bool isValidProblem(const CCopasiProblem *pProblem)
size_t mLastNestingItem
Definition: CScanMethod.h:189
virtual bool isNesting() const
Definition: CScanMethod.h:140
bool mIsStateVariable
Definition: CScanMethod.h:50
bool calculate()
C_FLOAT64 mMin
Definition: CScanMethod.h:115
CScanItemRandom(CCopasiParameterGroup *si, CRandom *rg, const bool &continueFromCurrentState)
virtual void step()
std::vector< CScanItem * > mScanItems
Definition: CScanMethod.h:177
virtual bool isValidScanItem(const bool &continueFromCurrentState)
bool cleanupScanItems()
#define C_INT32
Definition: copasi.h:90
unsigned C_INT32 mRandomType
Definition: CScanMethod.h:133
CScanProblem * mpProblem
Definition: CScanMethod.h:165
virtual bool isNesting() const
Definition: CScanMethod.h:70
std::vector< Refresh * > mInitialRefreshes
Definition: CScanMethod.h:179
virtual bool isValidScanItem(const bool &continueFromCurrentState)
C_FLOAT64 mStoreValue
Definition: CScanMethod.h:44
virtual void step()
size_t mNumSteps
Definition: CScanMethod.h:39
void storeValue()
CScanItemRepeat(CCopasiParameterGroup *si, const bool &continueFromCurrentState)
bool mFlagFinished
Definition: CScanMethod.h:48
C_FLOAT64 mMin
Definition: CScanMethod.h:131
size_t mIndex
Definition: CScanMethod.h:46
virtual ~CScanItem()
Definition: CScanMethod.h:72
CScanTask * mpTask
Definition: CScanMethod.h:170
CRandom * mRg
Definition: CScanMethod.h:132
virtual ~CScanItemRandom()
Definition: CScanMethod.h:137
virtual void step()=0
#define C_FLOAT64
Definition: copasi.h:92
CRandom * mpRandomGenerator
Definition: CScanMethod.h:175
CScanItemLinear(CCopasiParameterGroup *si, const bool &continueFromCurrentState)
void reset()
const CCopasiObject * getObject() const
size_t getTotalNumberOfSteps() const
Definition: CScanMethod.h:243
size_t getNumSteps() const
virtual void step()
void restoreValue() const
virtual ~CScanItemLinear()
Definition: CScanMethod.h:121
static CScanItem * createScanItemFromParameterGroup(CCopasiParameterGroup *si, CRandom *rg, const bool &continueFromCurrentState)
Definition: CScanMethod.cpp:48
bool loop(size_t level)
C_FLOAT64 mFaktor
Definition: CScanMethod.h:115
CCopasiObject * mpObject
Definition: CScanMethod.h:41
bool mContinueFromCurrentState
Definition: CScanMethod.h:195
size_t mTotalSteps
Definition: CScanMethod.h:183
C_FLOAT64 mFaktor
Definition: CScanMethod.h:131