COPASI API  4.16.103
COptItem.h
Go to the documentation of this file.
1 // Copyright (C) 2010 - 2014 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_COptItem
16 #define COPASI_COptItem
17 
18 #include <vector>
19 
23 
24 class CCopasiObjectName;
25 class COptProblem;
26 class CRandom;
27 class CCopasiDataModel;
28 
30 {
31  //Operations
32 protected:
33  /**
34  * Default constructor
35  */
36  COptItem();
37 
38 public:
39  /**
40  * Specific constructor
41  * @param const CCopasiContainer * pParent
42  * @param const std::string & name (default: OptimizationItem)
43  */
44  COptItem(const CCopasiContainer * pParent,
45  const std::string & name = "OptimizationItem");
46 
47  /**
48  * Copy constructor
49  * @param const COptItem & src
50  * @param const CCopasiContainer * pParent (default: src data model)
51  */
52  COptItem(const COptItem & src,
53  const CCopasiContainer * pParent = NULL);
54 
55  /**
56  * Specific constructor used for reading COPASI files
57  * @param const CCopasiParameterGroup & group
58  * @param const CCopasiContainer * pParent (default: group data model)
59  */
60  COptItem(const CCopasiParameterGroup & group,
61  const CCopasiContainer * pParent = NULL);
62 
63  /**
64  * Destructor
65  */
66  virtual ~COptItem();
67 
68  /**
69  * Set the object of the optimization item.
70  * @param const CCopasiObjectName & objectCN
71  * @return bool success
72  */
73  bool setObjectCN(const CCopasiObjectName & objectCN);
74 
75  /**
76  * Retrieve the object of the optimization item.
77  * @return const CCopasiObjectName objectCN
78  */
79  const CCopasiObjectName getObjectCN() const;
80 
81  /**
82  * Retrieve the item object. This may only be called after compile
83  * @return const CCopasiObject *
84  */
85  const CCopasiObject * getObject() const;
86 
87  /**
88  * Retrieve the display name of the optimization item.
89  * @return std::string displayName
90  */
91  std::string getObjectDisplayName() const;
92 
93  /**
94  * Set the lower bound.
95  * @param const CCopasiObjectName & lowerBound
96  * @return bool success
97  */
98  bool setLowerBound(const CCopasiObjectName & lowerBound);
99 
100  /**
101  * Retrieve the lower bound.
102  * @return const std::string lowerBound
103  */
104  const std::string getLowerBound() const;
105 
106  /**
107  * Set the upper bound.
108  * @param const CCopasiObjectName & upperBound
109  * @return bool success
110  */
111  bool setUpperBound(const CCopasiObjectName & upperBound);
112 
113  /**
114  * Retrieve the upper bound.
115  * @return const std::string upperBound
116  */
117  const std::string getUpperBound() const;
118 
119  /**
120  * Retrieve the update method
121  * @return UpdateMethod * pUpdateMethod
122  */
123  virtual UpdateMethod * getUpdateMethod() const;
124 
125  /**
126  * Check the validity of the optimization item.
127  */
128  virtual bool isValid() const;
129 
130  /**
131  * Check whether the group describes a valid optimization item.
132  * @return bool isValid
133  */
134  static bool isValid(CCopasiParameterGroup & group);
135 
136  /**
137  * Compile the optimization item. This function must be called
138  * before any of the check functions are called.
139  * @param const std::vector< CCopasiContainer * > listOfContainer
140  * @return bool success
141  */
142  virtual bool compile(const std::vector< CCopasiContainer * > listOfContainer =
144 
145  /**
146  * This functions check whether the current value is within the limits
147  * of the optimization item.
148  * @return C_INT32 result (-1: to small, 0: within boundaries, 1 to large)
149  */
150  virtual C_INT32 checkConstraint() const;
151 
152  /**
153  * Retrieve the magnitude of the constraint violation
154  * This is always a positive number
155  * @return C_FLOAT64 constraintViolation;
156  */
157  virtual C_FLOAT64 getConstraintViolation() const;
158 
159  /**
160  * This functions check whether the value is within the limits
161  * of the optimization item.
162  * @param const C_FLOAT64 & value
163  * @return C_INT32 result (-1: to small, 0: within boundaries, 1 to large)
164  */
165  C_INT32 checkConstraint(const C_FLOAT64 & value) const;
166 
167  /**
168  * Checks whether the value fulfills the lower bound constraint.
169  * @param const C_FLOAT64 & value
170  * @return bool fulfills
171  */
172  bool checkLowerBound(const C_FLOAT64 & value) const;
173 
174  /**
175  * Checks whether the value fulfills the upper bound constraint.
176  * @param const C_FLOAT64 & value
177  * @return bool fulfills
178  */
179  bool checkUpperBound(const C_FLOAT64 & value) const;
180 
181  /**
182  * Retrieve the value of the optimization object.
183  * @return const C_FLOAT64 * objectValue
184  */
185  virtual const C_FLOAT64 * getObjectValue() const;
186 
187  /**
188  * Retrieve the value of the lower bound.
189  * @return const C_FLOAT64 * lowerBoundValue
190  */
191  inline const C_FLOAT64 * getLowerBoundValue() const
192  {return mpLowerBound;}
193 
194  /**
195  * Retrieve the value of the upper bound.
196  * @return const C_FLOAT64 * upperBoundValue
197  */
198  inline const C_FLOAT64 * getUpperBoundValue() const
199  {return mpUpperBound;}
200 
201  /**
202  * Set the value start value.
203  * @param const C_FLOAT64 & startValue
204  * @return bool success
205  */
206  bool setStartValue(const C_FLOAT64 & value);
207 
208  /**
209  * Retrieve the start value of the optimization object.
210  * @return const C_FLOAT64 & startValue
211  */
212  const C_FLOAT64 & getStartValue() const;
213 
214  /**
215  * Retrieve the start value use in the last optimization.
216  * @return const C_FLOAT64 & startValue
217  */
218  const C_FLOAT64 & getLastStartValue() const;
219 
220  /**
221  * Remember the current start value
222  */
223  void rememberStartValue();
224 
225  /**
226  * Retrieve a random value in the interval (lower bound, upper bound).
227  * Optionally one may provide a random number generator to be used
228  * to create the random value.
229  * @param CRandom * pRandom (default: NULL)
230  * @return C_FLOAT64 randomValue
231  */
232  C_FLOAT64 getRandomValue(CRandom * pRandom = NULL);
233 
234  /**
235  * Output stream operator
236  * @param ostream & os
237  * @param const COptItem & A
238  * @return ostream & os
239  */
240  friend std::ostream &operator<<(std::ostream &os, const COptItem & o);
241 
242 private:
243  /**
244  * Allocates all group parameters and assures that they are
245  * properly initialized.
246  */
247  void initializeParameter();
248 
249  /**
250  * Compile the lower bound to hold the value given by the bound
251  * @param const std::vector< CCopasiContainer * > & listOfContainer
252  * @return bool success
253  */
254  bool compileLowerBound(const std::vector< CCopasiContainer * > & listOfContainer);
255 
256  /**
257  * Compile the upper bound to hold the value given by the bound
258  * @param const std::vector< CCopasiContainer * > & listOfContainer
259  * @return bool success
260  */
261  bool compileUpperBound(const std::vector< CCopasiContainer * > & listOfContainer);
262 
263  //Attributes:
264 protected:
265  /**
266  * A pointer to the value of the CCopasiParameter holding the ObjectCN
267  */
268  std::string * mpParmObjectCN;
269 
270  /**
271  * A pointer to the value of the CCopasiParameter holding the LowerBound
272  */
273  std::string * mpParmLowerBound;
274 
275  /**
276  * A pointer to the value of the CCopasiParameter holding the UpperBound
277  */
278  std::string * mpParmUpperBound;
279 
280  /**
281  * A pointer to the value of the CCopasiParameter holding the start value
282  */
284 
285  /**
286  * A pointer to the object
287  */
289 
290  /**
291  * A pointer to the object update method
292  */
294 
295  /**
296  * A pointer to the object value
297  */
299 
300  /**
301  * A pointer to the object for the lower bound
302  */
304 
305  /**
306  * A pointer to the lower bound value
307  */
309 
310  /**
311  * The value of the lower bound (only if not on object)
312  */
314 
315  /**
316  * A pointer to the object for the upper bound
317  */
319 
320  /**
321  * A pointer to the upper bound value
322  */
324 
325  /**
326  * The value of the upper bound (only if not on object)
327  */
329 
330  /**
331  * The start value use for last calculation
332  */
334 
335  /**
336  * A pointer to the random number generator used in randomizeStartValue
337  */
338  static CRandom * mpRandom;
339 };
340 
341 #endif // COPASI_COptItem
virtual C_INT32 checkConstraint() const
Definition: COptItem.cpp:401
virtual const C_FLOAT64 * getObjectValue() const
Definition: COptItem.cpp:441
const CCopasiObjectName getObjectCN() const
Definition: COptItem.cpp:131
friend std::ostream & operator<<(std::ostream &os, const COptItem &o)
Definition: COptItem.cpp:505
bool checkLowerBound(const C_FLOAT64 &value) const
Definition: COptItem.cpp:435
virtual C_FLOAT64 getConstraintViolation() const
Definition: COptItem.cpp:410
const CCopasiObject * getObject() const
Definition: COptItem.cpp:128
bool setLowerBound(const CCopasiObjectName &lowerBound)
Definition: COptItem.cpp:142
const std::string getUpperBound() const
Definition: COptItem.cpp:189
const CCopasiObject * mpLowerObject
Definition: COptItem.h:303
static CRandom * mpRandom
Definition: COptItem.h:338
const C_FLOAT64 & getLastStartValue() const
Definition: COptItem.cpp:220
bool setObjectCN(const CCopasiObjectName &objectCN)
Definition: COptItem.cpp:111
#define C_INT32
Definition: copasi.h:90
bool setUpperBound(const CCopasiObjectName &upperBound)
Definition: COptItem.cpp:167
const C_FLOAT64 * mpUpperBound
Definition: COptItem.h:323
bool compileLowerBound(const std::vector< CCopasiContainer * > &listOfContainer)
Definition: COptItem.cpp:444
bool checkUpperBound(const C_FLOAT64 &value) const
Definition: COptItem.cpp:438
static const std::vector< CCopasiContainer * > EmptyList
virtual ~COptItem()
Definition: COptItem.cpp:96
C_FLOAT64 * mpParmStartValue
Definition: COptItem.h:283
const C_FLOAT64 * getLowerBoundValue() const
Definition: COptItem.h:191
bool setStartValue(const C_FLOAT64 &value)
Definition: COptItem.cpp:192
UpdateMethod * mpMethod
Definition: COptItem.h:293
const CCopasiObject * mpUpperObject
Definition: COptItem.h:318
Header file of class CCopasiContainer.
virtual bool compile(const std::vector< CCopasiContainer * > listOfContainer=CCopasiContainer::EmptyList)
Definition: COptItem.cpp:336
const CCopasiObject * mpObject
Definition: COptItem.h:288
virtual UpdateMethod * getUpdateMethod() const
Definition: COptItem.cpp:313
const C_FLOAT64 * mpLowerBound
Definition: COptItem.h:308
std::string * mpParmUpperBound
Definition: COptItem.h:278
std::string * mpParmLowerBound
Definition: COptItem.h:273
const C_FLOAT64 & getStartValue() const
Definition: COptItem.cpp:199
C_FLOAT64 mUpperBound
Definition: COptItem.h:328
const std::string getLowerBound() const
Definition: COptItem.cpp:164
void initializeParameter()
Definition: COptItem.cpp:99
#define C_FLOAT64
Definition: copasi.h:92
const C_FLOAT64 * getUpperBoundValue() const
Definition: COptItem.h:198
C_FLOAT64 mLastStartValue
Definition: COptItem.h:333
void rememberStartValue()
Definition: COptItem.cpp:225
C_FLOAT64 getRandomValue(CRandom *pRandom=NULL)
Definition: COptItem.cpp:230
virtual bool isValid() const
Definition: COptItem.cpp:316
const C_FLOAT64 * mpObjectValue
Definition: COptItem.h:298
std::string * mpParmObjectCN
Definition: COptItem.h:268
std::string getObjectDisplayName() const
Definition: COptItem.cpp:134
bool compileUpperBound(const std::vector< CCopasiContainer * > &listOfContainer)
Definition: COptItem.cpp:474
C_FLOAT64 mLowerBound
Definition: COptItem.h:313