COPASI API  4.16.103
CSensMethod.h
Go to the documentation of this file.
1 // Begin CVS Header
2 // $Source: /Volumes/Home/Users/shoops/cvs/copasi_dev/copasi/sensitivities/CSensMethod.h,v $
3 // $Revision: 1.15 $
4 // $Name: $
5 // $Author: shoops $
6 // $Date: 2011/03/07 19:33:42 $
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 // Copyright (C) 2001 - 2007 by Pedro Mendes, Virginia Tech Intellectual
20 // Properties, Inc. and EML Research, gGmbH.
21 // All rights reserved.
22 
23 #ifndef COPASI_SENSMethod
24 #define COPASI_SENSMethod
25 
26 #include <string>
27 
30 
31 class CSensProblem;
32 //class CProcessReport;
33 
35 {
36 public:
39 
40  std::vector<CCopasiObject*> variables;
41 
42  /**
43  * holds the index in the index array corresponding to the given level.
44  * I.e. which dimension of the result array the variables correspond to.
45  */
46  size_t index;
47 };
48 
49 class CSensMethod : public CCopasiMethod
50 {
51  // Operations
52 private:
53  /**
54  * Default constructor.
55  */
56  CSensMethod();
57 
58 protected:
59  /**
60  * Specific constructor.
61  * @param CCopasiMethod::SubType subType
62  * @param const CCopasiContainer * pParent (default: NULL)
63  */
64  explicit CSensMethod(CCopasiMethod::SubType subType,
65  const CCopasiContainer * pParent = NULL);
66 
67 public:
68  /**
69  * Create a trajectory method.
70  * Note: the returned object has to be released after use with delete
71  */
72  static CSensMethod *
75 
76  /**
77  * Copy constructor.
78  * @param "const CTSSMethod &" src
79  * @param const CCopasiContainer * pParent (default: NULL)
80  */
81  CSensMethod(const CSensMethod & src,
82  const CCopasiContainer * pParent = NULL);
83 
84  /**
85  * Destructor.
86  */
87  ~CSensMethod();
88 
89  /**
90  */
91  bool process(CProcessReport * handler);
92 
93  /**
94  * initializes the subtask, creates the internal data structures of the method,
95  * resizes the result arrays and creates the array annotations
96  */
97  bool initialize(CSensProblem* problem);
98 
99  /**
100  * Do all necessary restore procedures so that the
101  * model is in the same state as before
102  * @param const bool & updateModel
103  * @result bool success
104  */
105  bool restore(const bool & updateModel);
106 
107  /**
108  * Check if the method is suitable for this problem
109  * @return bool suitability of the method
110  */
111  virtual bool isValidProblem(const CCopasiProblem * pProblem);
112 
113  /**
114  * estimate how many calls to the subtask are necessary. Works only after
115  * initialize() was called.
116  */
118 
119 protected:
120 
121  bool calculate_one_level(size_t level, CCopasiArray & result);
122  bool do_target_calculation(CCopasiArray & result, bool first);
123 
125 
126  /**
127  * wraps the CCopasiObject::setObjectValue() method so we can add special treatment
128  * of concentrations
129  */
130  void setValue(CCopasiObject* variable, C_FLOAT64 value);
131 
132  void calculate_difference(size_t level, const C_FLOAT64 & delta,
133  CCopasiArray & result, CCopasiArray::index_type & resultindex);
134 
135  /**
136  * calculate the scaled sensitivities. Calls scaling_variables().
137  * It is assumed that the scaled result array is already of the correct size
138  * (this is done in initialize()).
139  */
140  void do_scaling();
141 
142  /**
143  * This contains the loop over the target functions for scaling the sensitivities
144  */
145  void scaling_targetfunction(const C_FLOAT64 & factor,
146  CCopasiArray::index_type & resultindex);
147 
148  /**
149  * This contains the loop over the variables for scaling the sensitivities. Works recursively
150  * and calls scaling_targetfunction() in the end.
151  */
152  void scaling_variables(size_t level, const C_FLOAT64 & factor,
153  CCopasiArray::index_type & resultindex);
154 
155  /**
156  * collapse the first dimension of the scaled result (by
157  * calculating the 2-norm over the target functions)
158  */
159  void do_collapsing();
160 
162 
163  // Attributes
164 protected:
165  /**
166  * A pointer to the sensitivities problem.
167  */
169 
170  std::vector<CSensMethodLocalData> mLocalData;
171 
172  std::vector<CCopasiObject*> mTargetfunctionPointers;
173 
175 
176  std::vector< Refresh * > mInitialRefreshes;
177 
180 
181  ///stores the update model flag of the subtask
183 
184 private:
186  unsigned C_INT32 mProgress;
187 
188  size_t mCounter;
190 };
191 
192 #endif
void calculate_difference(size_t level, const C_FLOAT64 &delta, CCopasiArray &result, CCopasiArray::index_type &resultindex)
void do_scaling()
C_FLOAT64 * mpDeltaFactor
Definition: CSensMethod.h:178
void scaling_targetfunction(const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
std::vector< CCopasiObject * > mTargetfunctionPointers
Definition: CSensMethod.h:172
bool restore(const bool &updateModel)
std::vector< CSensMethodLocalData > mLocalData
Definition: CSensMethod.h:170
std::vector< size_t > index_type
Definition: CCopasiArray.h:34
#define C_INT32
Definition: copasi.h:90
void scaling_variables(size_t level, const C_FLOAT64 &factor, CCopasiArray::index_type &resultindex)
C_FLOAT64 do_variation(CCopasiObject *variable)
virtual bool isValidProblem(const CCopasiProblem *pProblem)
size_t mFailedCounter
Definition: CSensMethod.h:189
size_t mProgressHandler
Definition: CSensMethod.h:185
bool process(CProcessReport *handler)
void do_collapsing()
static CSensMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::sensMethod)
Definition: CSensMethod.cpp:34
CSensProblem * mpProblem
Definition: CSensMethod.h:168
bool do_target_calculation(CCopasiArray &result, bool first)
C_FLOAT64 do_collapsing_innerloop(CCopasiArray::index_type &fullindex)
size_t getNumberOfSubtaskCalculations()
void setValue(CCopasiObject *variable, C_FLOAT64 value)
std::vector< CCopasiObject * > variables
Definition: CSensMethod.h:40
CCopasiArray tmp2
Definition: CSensMethod.h:38
std::vector< Refresh * > mInitialRefreshes
Definition: CSensMethod.h:176
Header file of class CArrayAnnotation.
bool initialize(CSensProblem *problem)
#define C_FLOAT64
Definition: copasi.h:92
C_FLOAT64 * mpMinDelta
Definition: CSensMethod.h:179
bool mStoreSubtasktUpdateFlag
stores the update model flag of the subtask
Definition: CSensMethod.h:182
CCopasiArray tmp1
Definition: CSensMethod.h:37
size_t mCounter
Definition: CSensMethod.h:188
CCopasiTask * mpSubTask
Definition: CSensMethod.h:174
unsigned C_INT32 mProgress
Definition: CSensMethod.h:186
bool calculate_one_level(size_t level, CCopasiArray &result)