COPASI API  4.16.103
COptMethodSS.h
Go to the documentation of this file.
1 // Copyright (C) 2013 - 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 /**
7  * COptMethodSS class
8  */
9 
10 #ifndef COPASI_COptMethodSS
11 #define COPASI_COptMethodSS
12 #include <limits>
13 
16 #include "utilities/CVector.h"
17 
18 class CRandom;
19 
20 class COptMethodSS : public COptMethod
21 {
23 
24  // Operations
25 public:
26  /**
27  * Copy Constructor
28  * @param const COptMethodSS & src
29  * @param const CCopasiContainer * pParent (default: NULL)
30  */
31  COptMethodSS(const COptMethodSS & src,
32  const CCopasiContainer * pParent = NULL);
33 
34  /**
35  * Destructor
36  */
37  virtual ~COptMethodSS();
38 
39  /**
40  * This methods must be called to elevate subgroups to
41  * derived objects. The default implementation does nothing.
42  * @return bool success
43  */
44  virtual bool elevateChildren();
45 
46  /**
47  * Execute the optimization algorithm calling simulation routine
48  * when needed. It is noted that this procedure can give feedback
49  * of its progress by the callback function set with SetCallback.
50  * @ return success;
51  */
52  virtual bool optimise();
53 
54 private:
55  /**
56  * Default Constructor
57  * @param const CCopasiContainer * pParent (default: NULL)
58  */
59  COptMethodSS(const CCopasiContainer * pParent = NULL);
60 
61  /**
62  * Serialize the pool for debug
63  * @param size_t first
64  * @param size_t last (default: pool size)
65  * @return bool success
66  */
67  bool serializepool(size_t first, size_t last);
68 
69  /**
70  * Serialize the refset for debug
71  * @param size_t first
72  * @param size_t last (default: population size)
73  * @return bool success
74  */
75  bool serializerefset(C_INT32 first, C_INT32 last);
76 
77  /**
78  * Serialize a vector to the refset file ,for debug
79  * @param x the vector
80  * @param xval function value for that vector
81  * @return bool success
82  */
84 
85  /**
86  * write informative messages about the refset
87  * @param size_t type
88  * @return bool success
89  */
90  bool inforefset(C_INT32 type, C_INT32 element);
91 
92  /**
93  * Serialize the children for debug
94  * @param size_t first
95  * @param size_t last (default: population size)
96  * @return bool success
97  */
98  bool serializechildren(size_t first, size_t last);
99 
100  /**
101  * Serialize the probability table for debug
102  * @return bool success
103  */
104  bool serializeprob(void);
105 
106  /**
107  * Initialize contained objects.
108  */
109  void initObjects();
110 
111  /**
112  * Initialize arrays and pointer.
113  * @return bool success
114  */
115  virtual bool initialize();
116 
117  /**
118  * Cleanup arrays and pointers.
119  * @return bool success
120  */
121  virtual bool cleanup();
122 
123  /**
124  * Evaluate the fitness of one individual
125  * @param const CVector< C_FLOAT64 > & individual
126  * @return bool continue
127  */
128  bool evaluate(const CVector< C_FLOAT64 > & individual);
129 
130  /**
131  * Find a local minimum
132  * @param CVector< C_FLOAT64 > & solution
133  * @param C_FLOAT64 & fval
134  * @return bool continue
135  */
136  bool localmin(CVector< C_FLOAT64 > & solution, C_FLOAT64 & fval);
137 
138  /**
139  * minimize the best child if within criteria
140  * @return bool continue
141  */
142  bool childLocalMin(void);
143 
144  /**
145  * Initialise the population
146  * @return bool continue
147  */
148  bool creation(void);
149 
150  /**
151  * create new individuals with the combination method
152  * @return bool continue
153  */
154  bool combination(void);
155 
156  /**
157  * sort the RefSet array between position lower and upper
158  */
159  void sortRefSet(C_INT32 lower, C_INT32 upper);
160 
161  /**
162  * randomize an element of the RefSet
163  */
164  bool randomize(C_INT32 i);
165 
166  /**
167  * check if two vectors in RefSet are close
168  */
169  bool closerRefSet(C_INT32 i, C_INT32 j, C_FLOAT64 dist);
170 
171  /**
172  * check if two child vectors are close
173  * (one vector in mChild, the other in mPool, where previous child are stored)
174  */
175  bool closerChild(C_INT32 i, C_INT32 j, C_FLOAT64 dist);
176 
177  // Attributes
178 private:
179  /**
180  * Number of generations.
181  */
183 
184  /**
185  * Size of the population (b in Rodriguez-Fernandez et al).
186  */
188 
189  /**
190  * Number of parameters.
191  */
193 
194  /**
195  * Number of iterations between local searches.
196  */
197  unsigned C_INT32 mLocalFreq;
198 
199  /**
200  * Counts iterations between local searches.
201  */
202  unsigned C_INT32 mLocalIter;
203 
204  /**
205  * Number of local minimizations stored
206  */
208 
209  /**
210  * True if there were children produced
211  */
213 
214  /**
215  * Array of candidate solutions in the RefSet.
216  */
217  std::vector< CVector < C_FLOAT64 > * > mRefSet;
218 
219  /**
220  * Array of objective function values of the RefSet.
221  */
223 
224  /**
225  * Array of integers to count number of iterations that
226  * candidate solutions have not changed in the RefSet.
227  */
229 
230  /**
231  * Array of children for the candidate solutions in the RefSet.
232  */
233  std::vector< CVector < C_FLOAT64 > * > mChild;
234 
235  /**
236  * Array of objective function values of the Children.
237  */
239 
240  /**
241  * Pool of candidate solutions to be incorporated in RefSet
242  * (S in Rodriguez-Fernandez et al.).
243  */
244  std::vector< CVector < C_FLOAT64 > * > mPool;
245 
246  /**
247  * Function values of candidate solutions in the Pool.
248  */
250 
251  /**
252  * Size of the Pool.
253  */
254  size_t mPoolSize;
255 
256  /**
257  * Array to store frequencies.
258  */
259  std::vector< CVector < C_INT32 > * > mFreq;
260 
261  /**
262  * Array to store probabilities.
263  */
265 
266  /**
267  * The value of the last evaluation.
268  */
270 
271  /**
272  * Counter for iterations.
273  */
274  unsigned C_INT32 mIteration;
275 
276  /**
277  * The best value so far
278  */
280 
281  /**
282  * index of the best value so far
283  */
284  size_t mBestIndex;
285 
286  /**
287  * Threshold to decide a solution is too close to another
288  */
290 
291  /**
292  * Handle to the process report item "Current Iteration".
293  */
294  size_t mhIterations;
295 
296  /**
297  * a pointer to the randomnumber generator.
298  */
300 
301  /**
302  * a pointer to an opt problem used for local minimization
303  */
305 
306  /**
307  * a pointer to an opt method used for local minimization
308  */
310 };
311 
312 #endif // COPASI_COptMethodSS
C_FLOAT64 mCloseValue
Definition: COptMethodSS.h:289
std::vector< CVector< C_INT32 > * > mFreq
Definition: COptMethodSS.h:259
bool closerRefSet(C_INT32 i, C_INT32 j, C_FLOAT64 dist)
unsigned C_INT32 mIterations
Definition: COptMethodSS.h:182
bool serializechildren(size_t first, size_t last)
CVector< C_FLOAT64 > mProb
Definition: COptMethodSS.h:264
virtual bool elevateChildren()
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
bool creation(void)
bool serializeprob(void)
CRandom * mpRandom
Definition: COptMethodSS.h:299
void sortRefSet(C_INT32 lower, C_INT32 upper)
CVector< C_FLOAT64 > mChildVal
Definition: COptMethodSS.h:238
std::vector< CVector< C_FLOAT64 > * > mChild
Definition: COptMethodSS.h:233
#define C_INT32
Definition: copasi.h:90
bool inforefset(C_INT32 type, C_INT32 element)
bool mChildrenGenerated
Definition: COptMethodSS.h:212
CVector< C_INT32 > mStuck
Definition: COptMethodSS.h:228
virtual bool cleanup()
C_INT32 mPopulationSize
Definition: COptMethodSS.h:187
bool evaluate(const CVector< C_FLOAT64 > &individual)
std::vector< CVector< C_FLOAT64 > * > mPool
Definition: COptMethodSS.h:244
virtual ~COptMethodSS()
bool childLocalMin(void)
COptMethod * mpLocalMinimizer
Definition: COptMethodSS.h:309
unsigned C_INT32 mVariableSize
Definition: COptMethodSS.h:192
size_t mhIterations
Definition: COptMethodSS.h:294
bool localmin(CVector< C_FLOAT64 > &solution, C_FLOAT64 &fval)
COptMethodSS(const COptMethodSS &src, const CCopasiContainer *pParent=NULL)
COptProblem * mpOptProblemLocal
Definition: COptMethodSS.h:304
bool serializevector(CVector< C_FLOAT64 > x, C_FLOAT64 xval)
CVector< C_FLOAT64 > mPoolVal
Definition: COptMethodSS.h:249
bool randomize(C_INT32 i)
unsigned C_INT32 mLocalStored
Definition: COptMethodSS.h:207
bool closerChild(C_INT32 i, C_INT32 j, C_FLOAT64 dist)
bool serializerefset(C_INT32 first, C_INT32 last)
unsigned C_INT32 mLocalIter
Definition: COptMethodSS.h:202
#define C_FLOAT64
Definition: copasi.h:92
CVector< C_FLOAT64 > mRefSetVal
Definition: COptMethodSS.h:222
size_t mPoolSize
Definition: COptMethodSS.h:254
bool serializepool(size_t first, size_t last)
virtual bool initialize()
bool combination(void)
C_FLOAT64 mEvaluationValue
Definition: COptMethodSS.h:269
unsigned C_INT32 mIteration
Definition: COptMethodSS.h:274
std::vector< CVector< C_FLOAT64 > * > mRefSet
Definition: COptMethodSS.h:217
void initObjects()
size_t mBestIndex
Definition: COptMethodSS.h:284
C_FLOAT64 mBestValue
Definition: COptMethodSS.h:279
virtual bool optimise()
unsigned C_INT32 mLocalFreq
Definition: COptMethodSS.h:197