COPASI API  4.16.103
COptMethodPS.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 /**
16  * COptMethodPS class
17  */
18 
19 #ifndef COPASI_COptMethodPS
20 #define COPASI_COptMethodPS
21 
23 #include "utilities/CVector.h"
24 #include "utilities/CMatrix.h"
25 
26 class CRandom;
27 class CPermutation;
28 
29 class COptMethodPS : public COptMethod
30 {
32 
33  // Operations
34 public:
35  /**
36  * Copy Constructor
37  * @param const COptMethodPS & src
38  * @param const CCopasiContainer * pParent (default: NULL)
39  */
40  COptMethodPS(const COptMethodPS & src,
41  const CCopasiContainer * pParent = NULL);
42 
43  /**
44  * Destructor
45  */
46  virtual ~COptMethodPS();
47 
48  /**
49  * Execute the optimization algorithm calling simulation routine
50  * when needed. It is noted that this procedure can give feedback
51  * of its progress by the callback function set with SetCallback.
52  * @ return success;
53  */
54  virtual bool optimise();
55 
56 private:
57  /**
58  * Default Constructor
59  * @param const CCopasiContainer * pParent (default: NULL)
60  */
61  COptMethodPS(const CCopasiContainer * pParent = NULL);
62 
63  /**
64  * Initialize contained objects.
65  */
66  void initObjects();
67 
68  /**
69  * Initialize arrays and pointer.
70  * @return bool success
71  */
72  virtual bool initialize();
73 
74  /**
75  * Cleanup arrays and pointers.
76  * @return bool success
77  */
78  virtual bool cleanup();
79 
80  /**
81  * Evaluate the fitness of one individual
82  * @return const C_FLOAT64 value
83  */
84  const C_FLOAT64 & evaluate();
85 
86  /**
87  * Move the indexed individual in the swarm
88  * @param const size_t & index
89  * @return bool continue
90  */
91  bool move(const size_t & index);
92 
93  /**
94  * Create the indexed individual in the swarm
95  * @param const size_t & index
96  * @return bool continue
97  */
98  bool create(const size_t & index);
99 
100  /**
101  * create the informant for each individual
102  */
103  void buildInformants();
104 
105  bool reachedStdDeviation();
106 
107  // Attributes
108 private:
109  /**
110  * maximal number of iterations
111  */
113 
114  /**
115  * size of the population
116  */
117  unsigned C_INT32 mSwarmSize;
118 
119  /**
120  * The variance acceptable for the solution
121  */
123 
124  /**
125  * a pointer to the random number generator.
126  */
128 
129  /**
130  * current iterations
131  */
132  unsigned C_INT32 mIteration;
133 
134  /**
135  * Handle to the process report item "Current Iteration"
136  */
137  size_t mhIteration;
138 
139  /**
140  * number of parameters
141  */
143 
144  /**
145  * Matrix of individuals with candidate values for the parameters
146  */
148 
149  /**
150  * Vector of values of objective function of each individual
151  */
153 
154  /**
155  * Matrix of individual velocities
156  */
158 
159  /**
160  * Vector of individual best values.
161  */
163 
164  /**
165  * Matrix of best positions for each individual
166  */
168 
169  /**
170  * A permutation of integers used to create the informants;
171  */
173 
174  /**
175  * Vector containing the set of informants for each individual.
176  */
177  std::vector< std::set< size_t > > mInformants;
178 
179  /**
180  * The minimal number of individuals informed by each individual
181  */
183 
184  /**
185  * The number of individual informed by each individual
186  */
187  size_t mNumInformed;
188 
189  /**
190  * Index of the best solution found so far.
191  */
192  size_t mBestIndex;
193 
194  /**
195  * The value of the last evaluation.
196  */
198 
199  /**
200  * Indicates whether calculation shall continue
201  */
202  bool mContinue;
203 };
204 
205 #endif // COPASI_COptMethodPS
unsigned C_INT32 mIteration
Definition: COptMethodPS.h:132
const C_FLOAT64 & evaluate()
C_FLOAT64 mEvaluationValue
Definition: COptMethodPS.h:197
size_t mNumInformedMin
Definition: COptMethodPS.h:182
bool move(const size_t &index)
size_t mVariableSize
Definition: COptMethodPS.h:142
void initObjects()
static COptMethod * createMethod(CCopasiMethod::SubType subType=CCopasiMethod::RandomSearch)
Definition: COptMethod.cpp:50
bool create(const size_t &index)
#define C_INT32
Definition: copasi.h:90
CMatrix< C_FLOAT64 > mBestPositions
Definition: COptMethodPS.h:167
unsigned C_INT32 mIterationLimit
Definition: COptMethodPS.h:112
CVector< C_FLOAT64 > mValues
Definition: COptMethodPS.h:152
size_t mNumInformed
Definition: COptMethodPS.h:187
CPermutation * mpPermutation
Definition: COptMethodPS.h:172
void buildInformants()
bool reachedStdDeviation()
unsigned C_INT32 mSwarmSize
Definition: COptMethodPS.h:117
size_t mBestIndex
Definition: COptMethodPS.h:192
#define C_FLOAT64
Definition: copasi.h:92
std::vector< std::set< size_t > > mInformants
Definition: COptMethodPS.h:177
COptMethodPS(const COptMethodPS &src, const CCopasiContainer *pParent=NULL)
CVector< CVector< C_FLOAT64 > > mIndividuals
Definition: COptMethodPS.h:147
C_FLOAT64 mVariance
Definition: COptMethodPS.h:122
virtual bool optimise()
virtual ~COptMethodPS()
CRandom * mpRandom
Definition: COptMethodPS.h:127
size_t mhIteration
Definition: COptMethodPS.h:137
CMatrix< C_FLOAT64 > mVelocities
Definition: COptMethodPS.h:157
virtual bool cleanup()
virtual bool initialize()
CVector< C_FLOAT64 > mBestValues
Definition: COptMethodPS.h:162