COPASI API  4.16.103
COptMethodSRES.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) 2006 - 2007 by Pedro Mendes, Virginia Tech Intellectual
12 // Properties, Inc. and EML Research, gGmbH.
13 // All rights reserved.
14 
15 #ifndef COPASI_COptMethodSRES
16 #define COPASI_COptMethodSRES
17 
19 #include "utilities/CVector.h"
20 
21 class CRandom;
22 
23 /**
24  * COptMethodSRES class
25  */
26 
27 class COptMethodSRES : public COptMethod
28 {
30 
31  // Operations
32 public:
33  /**
34  * Copy Constructor
35  * @param const COptMethodSRES & src
36  * @param const CCopasiContainer * pParent (default: NULL)
37  */
38  COptMethodSRES(const COptMethodSRES & src,
39  const CCopasiContainer * pParent = NULL);
40 
41  /**
42  * Destructor
43  */
44  virtual ~COptMethodSRES();
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  COptMethodSRES(const CCopasiContainer * pParent = NULL);
60 
61  /**
62  * Initialize contained objects.
63  */
64  void initObjects();
65 
66  /**
67  * Initialize arrays and pointer.
68  * @return bool success
69  */
70  virtual bool initialize();
71 
72  /**
73  * Cleanup arrays and pointers.
74  * @return bool success
75  */
76  virtual bool cleanup();
77 
78  /**
79  * Evaluate the fitness of one individual
80  * @param const CVector< C_FLOAT64 > & individual
81  * @return bool continue
82  */
83  bool evaluate(const CVector< C_FLOAT64 > & individual);
84 
85  /**
86  * Swap individuals from and to
87  * @param size_t from
88  * @param size_t to
89  * @return bool success
90  */
91  bool swap(size_t from, size_t to);
92 
93  /**
94  * Replicate the individuals with crossover
95  * @return bool continue
96  */
97  bool replicate();
98 
99  /**
100  * Mutate the new generation
101  */
102  bool mutate();
103 
104  /**
105  * Select surviving population
106  * @return success
107  */
108  void select();
109 
110  /**
111  * Find the best individual at this generation
112  * @return size_t fittest
113  */
114  size_t fittest();
115 
116  /**
117  * Initialise the population
118  * @param size_t first
119  * @return bool continue
120  */
121  bool creation(size_t first);
122 
123  /**
124  * For Stochastic Ranking, evaluate the distance ofparameters to boundaries
125  * @return C_FLOAT64 phiVal
126  */
127  C_FLOAT64 phi(size_t indvNum);
128 
129  // Attributes
130 private:
131  /**
132  * number of generations
133  */
135 
136  /**
137  * Handle to the process report item "Current Generation"
138  */
140 
141  /**
142  * size of the population
143  */
145 
146  /**
147  * a pointer to the randomnumber generator.
148  */
150 
151  /**
152  * Probability value used for SR ****
153  */
155 
156  /**
157  * number of parameters
158  */
160 
161  /**
162  * for array of individuals w/ candidate values for the parameters
163  */
164  std::vector< CVector < C_FLOAT64 > * > mIndividual;
165 
166  /**
167  * For Stochastic Ranking. Used for array of Phi values for the individuals
168  */
170 
171  /**
172  * for array of variances w/ variance values for the parameters
173  */
174  std::vector< CVector < C_FLOAT64 > * > mVariance;
175 
176  /**
177  * A vector of maximal variances
178  */
180 
181  /**
182  * The value of the last evaluation.
183  */
185 
186  /**
187  * array of values of objective function f/ individuals
188  */
190 
192 
194 
195  double mTau; // parameter for updating variances
196 
197  double mTauPrime; // parameter for updating variances
198 };
199 
200 #endif // COPASI_COptMethodSRES
C_FLOAT64 phi(size_t indvNum)
CVector< C_FLOAT64 > mValue
unsigned C_INT32 mPopulationSize
std::vector< CVector< C_FLOAT64 > * > mVariance
C_FLOAT64 mEvaluationValue
virtual bool optimise()
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
virtual bool cleanup()
unsigned C_INT32 mGenerations
CRandom * mpRandom
virtual ~COptMethodSRES()
#define C_INT32
Definition: copasi.h:90
std::vector< CVector< C_FLOAT64 > * > mIndividual
bool swap(size_t from, size_t to)
C_FLOAT64 mBestValue
CVector< C_FLOAT64 > mMaxVariance
unsigned C_INT32 mGeneration
#define C_FLOAT64
Definition: copasi.h:92
CVector< C_FLOAT64 > mPhi
virtual bool initialize()
bool creation(size_t first)
bool evaluate(const CVector< C_FLOAT64 > &individual)
COptMethodSRES(const COptMethodSRES &src, const CCopasiContainer *pParent=NULL)