COPASI API  4.16.103
COptMethodGASR.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 /**
16  * COptMethodGASR class
17  */
18 
19 #ifndef COPASI_COptMethodGASR
20 #define COPASI_COptMethodGASR
21 
22 #include <limits>
23 
25 #include "utilities/CVector.h"
26 
27 class CRandom;
28 class CPermutation;
29 
30 class COptMethodGASR : public COptMethod
31 {
33 
34  // Operations
35 public:
36  /**
37  * Copy Constructor
38  * @param const COptMethodGASR & src
39  * @param const CCopasiContainer * pParent (default: NULL)
40  */
41  COptMethodGASR(const COptMethodGASR & src,
42  const CCopasiContainer * pParent = NULL);
43 
44  /**
45  * Destructor
46  */
47  virtual ~COptMethodGASR();
48 
49  /**
50  * Execute the optimization algorithm calling simulation routine
51  * when needed. It is noted that this procedure can give feedback
52  * of its progress by the callback function set with SetCallback.
53  * @ return success;
54  */
55  virtual bool optimise();
56 
57 private:
58  /**
59  * Default Constructor
60  * @param const CCopasiContainer * pParent (default: NULL)
61  */
62  COptMethodGASR(const CCopasiContainer * pParent = NULL);
63 
64  /**
65  * Initialize contained objects.
66  */
67  void initObjects();
68 
69  /**
70  * Initialize arrays and pointer.
71  * @return bool success
72  */
73  virtual bool initialize();
74 
75  /**
76  * Cleanup arrays and pointers.
77  * @return bool success
78  */
79  virtual bool cleanup();
80 
81  /**
82  * Evaluate the fitness of one individual
83  * @param const CVector< C_FLOAT64 > & individual
84  * @return bool continue
85  */
86  bool evaluate(const CVector< C_FLOAT64 > & individual);
87 
88  /**
89  * Swap individuals from and to
90  * @param size_t from
91  * @param size_t to
92  * @return bool success
93  */
94  bool swap(size_t from, size_t to);
95 
96  /**
97  * fm one individual
98  * @param CVector< C_FLOAT64 > & individual
99  * @return bool success
100  */
101  bool mutate(CVector< C_FLOAT64 > & individual);
102 
103  /**
104  * @param const CVector< C_FLOAT64 > & parent1
105  * @param const CVector< C_FLOAT64 > & parent2
106  * @param CVector< C_FLOAT64 > & child1
107  * @param CVector< C_FLOAT64 > & child2
108  */
109  bool crossover(const CVector< C_FLOAT64 > & parent1,
110  const CVector< C_FLOAT64 > & parent2,
111  CVector< C_FLOAT64 > & child1,
112  CVector< C_FLOAT64 > & child2);
113 
114  /**
115  * Replicate the individuals with crossover
116  * @return bool continue
117  */
118  bool replicate();
119 
120  /**
121  * Select surviving population
122  * @return bool success
123  */
124  bool select();
125 
126  /**
127  * Find the best individual at this generation
128  * @return size_t fittest
129  */
130  size_t fittest();
131 
132  /**
133  * Initialise the population
134  * @param size_t first
135  * @param size_t last (default: population size)
136  * @return bool success
137  */
138  bool creation(size_t first, size_t last = std::numeric_limits<size_t>::max());
139 
140  /**
141  * For Stochastic Ranking, evaluate the distance ofparameters to boundaries
142  * @return C_FLOAT64 phiVal
143  */
144  C_FLOAT64 phi(size_t indvNum);
145 
146  // Attributes
147 private:
148  /**
149  * number of generations
150  */
152 
153  /**
154  * Handle to the process report item "Current Generation"
155  */
157 
158  /**
159  * size of the population
160  */
162 
163  /**
164  * a pointer to the randomnumber generator.
165  */
167 
168  /**
169  * Probability value used for SR ****
170  */
172 
173  /**
174  * number of parameters
175  */
177 
178  /**
179  * for array of individuals w/ candidate values for the parameters
180  */
181  std::vector< CVector < C_FLOAT64 > * > mIndividual;
182 
183  /**
184  * For Stochastic Ranking. Used for array of Phi values for the individuals
185  */
187 
188  /**
189  * Vector used to initialize the crossover point to false
190  */
192 
193  /**
194  * Vector of crossover points.
195  */
197 
198  /**
199  * array of values of objective function f/ individuals
200  */
202 
203  /**
204  * A permutation of integers used to create the informants;
205  */
207 
208  /**
209  * number of wins of each individual in the tournament
210  */
212 
213  /**
214  * variance for mutations
215  */
217 
218  /**
219  * The value of the last evaluation.
220  */
222 
223  /**
224  * The best value so far.
225  */
227  size_t mBestIndex;
229 };
230 
231 #endif // COPASI_COptMethodGASR
bool mutate(CVector< C_FLOAT64 > &individual)
virtual bool cleanup()
C_FLOAT64 mBestValue
C_FLOAT64 phi(size_t indvNum)
CVector< C_FLOAT64 > mPhi
virtual bool optimise()
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
CRandom * mpRandom
unsigned C_INT32 mPopulationSize
virtual ~COptMethodGASR()
#define C_INT32
Definition: copasi.h:90
CPermutation * mpPermutation
std::vector< CVector< C_FLOAT64 > * > mIndividual
unsigned C_INT32 mGenerations
C_FLOAT64 mEvaluationValue
CVector< C_FLOAT64 > mValue
COptMethodGASR(const COptMethodGASR &src, const CCopasiContainer *pParent=NULL)
C_FLOAT64 mMutationVarians
CVector< bool > mCrossOver
virtual bool initialize()
CVector< size_t > mWins
#define C_FLOAT64
Definition: copasi.h:92
bool evaluate(const CVector< C_FLOAT64 > &individual)
bool crossover(const CVector< C_FLOAT64 > &parent1, const CVector< C_FLOAT64 > &parent2, CVector< C_FLOAT64 > &child1, CVector< C_FLOAT64 > &child2)
CVector< bool > mCrossOverFalse
bool swap(size_t from, size_t to)
unsigned C_INT32 mGeneration
bool creation(size_t first, size_t last=std::numeric_limits< size_t >::max())
#define max(a, b)
Definition: f2c.h:176