COPASI API  4.16.103
CFitItem.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) 2005 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_CFitItem
16 #define COPASI_CFitItem
17 
18 #include "optimization/COptItem.h"
19 
20 class CCopasiDataModel;
21 
22 class CFitItem : public COptItem
23 {
24  friend class CFitProblem;
25 
26  //Operations
27 protected:
28  /**
29  * Default constructor
30  */
31  CFitItem();
32 
33 public:
34  /**
35  * Specific constructor
36  * @param const CCopasiContainer * pParent (default: NULL)
37  * @param const std::string & name (default: FitItem)
38  */
39  CFitItem(const CCopasiContainer * pParent,
40  const std::string & name = "FitItem");
41 
42  /**
43  * Copy constructor
44  * @param const CFitItem & src
45  * @param const CCopasiContainer * pParent (default: src data model)
46  */
47  CFitItem(const CFitItem & src,
48  const CCopasiContainer * pParent = NULL);
49 
50  /**
51  * Specific constructor used for reading COPASI files
52  * @param const CCopasiParameterGroup & group
53  * @param const CCopasiContainer * pParent (default: group data model)
54  */
55  CFitItem(const CCopasiParameterGroup & group,
56  const CCopasiContainer * pParent = NULL);
57 
58  /**
59  * Destructor
60  */
61  virtual ~CFitItem();
62 
63  /**
64  * This methods must be called to elevate subgroups to
65  * derived objects. The default implementation does nothing.
66  * @return bool success
67  */
68  virtual bool elevateChildren();
69 
70  /**
71  * Retrieve the update method
72  * @return UpdateMethod * pUpdateMethod
73  */
74  virtual UpdateMethod * getUpdateMethod() const;
75 
76  /**
77  * Check the validity of the optimization item.
78  * @return bool isValid
79  */
80  virtual bool isValid() const;
81 
82  /**
83  * Check whether the group describes a valid optimization item.
84  * @param CCopasiParameterGroup & group
85  * @return bool isValid
86  */
87  static bool isValid(CCopasiParameterGroup & group);
88 
89  /**
90  * Compile the optimization item. This function must be called
91  * before any of the check functions are called.
92  * @param const std::vector< CCopasiContainer * > listOfContainer
93  * @return bool success
94  */
95  virtual bool compile(const std::vector< CCopasiContainer * > listOfContainer =
97 
98  /**
99  * This functions check whether the current value is within the limits
100  * of the optimization item.
101  * @return C_INT32 result (-1: to small, 0: within boundaries, 1 to large)
102  */
103  virtual C_INT32 checkConstraint() const;
104 
105  /**
106  * Retrieve the magnitude of the constraint violation
107  * This is always a positive number
108  * @return C_FLOAT64 constraintViolation;
109  */
110  virtual C_FLOAT64 getConstraintViolation() const;
111 
112  /**
113  * Output stream operator
114  * @param ostream & os
115  * @param const CFitItem & A
116  * @return ostream & os
117  */
118  friend std::ostream &operator<<(std::ostream &os, const CFitItem & o);
119 
120  /**
121  * Set the local value.
122  * @param const C_FLOAT64 & value
123  */
124  void setLocalValue(const C_FLOAT64 & value);
125 
126  /**
127  * Retreive the local value.
128  * @return const C_FLOAT64 & value
129  */
130  const C_FLOAT64 & getLocalValue() const;
131 
132  /**
133  * Retrieve the value of the optimization object.
134  * @return const C_FLOAT64 * objectValue
135  */
136  virtual const C_FLOAT64 * getObjectValue() const;
137 
138  /**
139  * Add an experiment to the list of affected experiments.
140  * @param const std::string & key
141  * @return bool success
142  */
143  bool addExperiment(const std::string & key);
144 
145  /**
146  * Retreive the key of the indexed experiment.
147  * @param const size_t & index
148  * @return const std::string & key
149  */
150  const std::string & getExperiment(const size_t & index) const;
151 
152  /**
153  * Remove the indexed experiment from the affected experiments
154  * @param const size_t & index
155  * @return bool success
156  */
157  bool removeExperiment(const size_t & index);
158 
159  /**
160  * Retrieve the number of experiments
161  * @return size_t size
162  */
163  size_t getExperimentCount() const;
164 
165  /**
166  * Retrieve a string listing all experiments the item applies to
167  * @return std::string experiments
168  */
169  std::string getExperiments() const;
170 
171  /**
172  * Add an experiment to the list of affected cross validations.
173  * @param const std::string & key
174  * @return bool success
175  */
176  bool addCrossValidation(const std::string & key);
177 
178  /**
179  * Retreive the key of the indexed experiment.
180  * @param const size_t & index
181  * @return const std::string & key
182  */
183  const std::string & getCrossValidation(const size_t & index) const;
184 
185  /**
186  * Remove the indexed experiment from the affected cross validations
187  * @param const size_t & index
188  * @return bool success
189  */
190  bool removeCrossValidation(const size_t & index);
191 
192  /**
193  * Retrieve the number of cross validations
194  * @return size_t size
195  */
196  size_t getCrossValidationCount() const;
197 
198  /**
199  * Retrieve a string listing all cross validations the item applies to
200  * @return std::string crossValidations
201  */
202  std::string getCrossValidations() const;
203 
204  /**
205  * Update bounds
206  * @param std::vector<COptItem * >::iterator it
207  * @return bool success
208  */
209  bool updateBounds(std::vector<COptItem * >::iterator it);
210 
211 private:
212  /**
213  * Allocates all group parameters and assures that they are
214  * properly initialized.
215  */
216  void initializeParameter();
217 
218 protected:
219  // Attributes
220  /**
221  * A pointer to the value of the CCopasiParameterGroup holding the
222  * list of AffectedExperiments
223  */
225 
226  /**
227  * A pointer to the value of the CCopasiParameterGroup holding the
228  * list of Affected Validation Experiments
229  */
231 
232  /**
233  * The value for local items, which affect the experiments in the list.
234  */
236 
237  /**
238  * A pointer to the local update method
239  */
241 };
242 
243 class CFitConstraint : public CFitItem
244 {
245  //Operations
246 protected:
247  /**
248  * Default constructor
249  */
250  CFitConstraint();
251 
252 public:
253  /**
254  * Specific constructor
255  * @param const CCopasiContainer * pParent
256  * @param const std::string & name (default: FitItem)
257  */
258  CFitConstraint(const CCopasiContainer * pParent,
259  const std::string & name = "FitItem");
260 
261  /**
262  * Copy constructor
263  * @param const CFitItem & src
264  * @param const CCopasiContainer * pParent (default: src data model)
265  */
266  CFitConstraint(const CFitConstraint & src,
267  const CCopasiContainer * pParent = NULL);
268 
269  /**
270  * Specific constructor used for reading COPASI files
271  * @param const CCopasiParameterGroup & group
272  * @param const CCopasiContainer * pParent (default: group data model)
273  */
275  const CCopasiContainer * pParent = NULL);
276 
277  /**
278  * Destructor
279  */
280  virtual ~CFitConstraint();
281 
282  /**
283  * Reset the constraint violation
284  */
286 
287  /**
288  * Calculate and save the constraint violation
289  */
291 
292  /**
293  * This functions check whether the current value is within the limits
294  * of the constraint. The result depends on last performed
295  * calculateConstraintViolation, i.e., it may not be trusted.
296  * @return C_INT32 result (-1: to small, 0: within boundaries, 1 to large)
297  */
298  virtual C_INT32 checkConstraint() const;
299 
300  /**
301  * Retrieve the magnitude of the constraint violation
302  * This is always a positive number or 0. It is the sum of all
303  * constraint violation for a single function evaluation.
304  * @return C_FLOAT64 constraintViolation;
305  */
306  virtual C_FLOAT64 getConstraintViolation() const;
307 
308  // Attributes
309 private:
310  /**
311  * The value that will be returned by checkConstraint
312  */
314 
315  /**
316  * The value that will be returned by getConstraintViolation
317  */
319 };
320 
321 #endif // COPASI_CFitItem
const std::string & getExperiment(const size_t &index) const
Definition: CFitItem.cpp:194
virtual const C_FLOAT64 * getObjectValue() const
Definition: CFitItem.cpp:178
CCopasiParameterGroup * mpGrpAffectedCrossValidations
Definition: CFitItem.h:230
CCopasiParameterGroup * mpGrpAffectedExperiments
Definition: CFitItem.h:224
virtual ~CFitConstraint()
Definition: CFitItem.cpp:316
C_FLOAT64 mLocalValue
Definition: CFitItem.h:235
UpdateMethod * mpLocalMethod
Definition: CFitItem.h:240
bool removeCrossValidation(const size_t &index)
Definition: CFitItem.cpp:254
void setLocalValue(const C_FLOAT64 &value)
Definition: CFitItem.cpp:169
virtual UpdateMethod * getUpdateMethod() const
Definition: CFitItem.cpp:181
void initializeParameter()
Definition: CFitItem.cpp:57
virtual C_INT32 checkConstraint() const
Definition: CFitItem.cpp:111
bool addExperiment(const std::string &key)
Definition: CFitItem.cpp:184
void resetConstraintViolation()
Definition: CFitItem.cpp:318
#define C_INT32
Definition: copasi.h:90
friend std::ostream & operator<<(std::ostream &os, const CFitItem &o)
Definition: CFitItem.cpp:136
const C_FLOAT64 & getLocalValue() const
Definition: CFitItem.cpp:175
void calculateConstraintViolation()
Definition: CFitItem.cpp:324
virtual bool elevateChildren()
Definition: CFitItem.cpp:66
std::string getCrossValidations() const
Definition: CFitItem.cpp:260
static const std::vector< CCopasiContainer * > EmptyList
virtual C_FLOAT64 getConstraintViolation() const
Definition: CFitItem.cpp:348
virtual C_INT32 checkConstraint() const
Definition: CFitItem.cpp:345
C_FLOAT64 mConstraintViolation
Definition: CFitItem.h:318
size_t getCrossValidationCount() const
Definition: CFitItem.cpp:257
#define C_FLOAT64
Definition: copasi.h:92
bool updateBounds(std::vector< COptItem * >::iterator it)
Definition: CFitItem.cpp:279
virtual C_FLOAT64 getConstraintViolation() const
Definition: CFitItem.cpp:120
bool removeExperiment(const size_t &index)
Definition: CFitItem.cpp:204
std::string getExperiments() const
Definition: CFitItem.cpp:210
virtual bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: CFitItem.cpp:102
C_INT32 mCheckConstraint
Definition: CFitItem.h:313
virtual ~CFitItem()
Definition: CFitItem.cpp:54
const std::string & getCrossValidation(const size_t &index) const
Definition: CFitItem.cpp:244
size_t getExperimentCount() const
Definition: CFitItem.cpp:207
bool addCrossValidation(const std::string &key)
Definition: CFitItem.cpp:234
virtual bool isValid() const
Definition: CFitItem.cpp:92