5 |
#include "doublematrix.h" |
#include "doublematrix.h" |
6 |
#include "doublevector.h" |
#include "doublevector.h" |
7 |
#include "intvector.h" |
#include "intvector.h" |
8 |
|
#include "seq_optimize_template.h" |
9 |
|
|
10 |
enum OptType { OPTHOOKE = 1, OPTSIMANN, OPTBFGS }; |
enum OptType { OPTHOOKE = 1, OPTSIMANN, OPTBFGS }; |
11 |
|
|
42 |
*/ |
*/ |
43 |
virtual void OptimiseLikelihood() {}; |
virtual void OptimiseLikelihood() {}; |
44 |
/** |
/** |
45 |
|
* \brief This is the function used to call the optimisation algorithms parallelized with OpenMP of the reproducible version |
46 |
|
*/ |
47 |
|
virtual void OptimiseLikelihoodOMP() {}; |
48 |
|
/** |
49 |
|
* \brief This function set the seeds used in SA |
50 |
|
* \param val array of unsigned int with the seeds |
51 |
|
*/ |
52 |
|
void setSeed(unsigned* val) {seed = val[0]; seedM = val[1]; seedP = val[2];}; |
53 |
|
/** |
54 |
* \brief This will return the type of optimisation class |
* \brief This will return the type of optimisation class |
55 |
* \return type |
* \return type |
56 |
*/ |
*/ |
72 |
* \brief This denotes what type of optimisation class has been created |
* \brief This denotes what type of optimisation class has been created |
73 |
*/ |
*/ |
74 |
OptType type; |
OptType type; |
75 |
|
/** |
76 |
|
* \brief This is the seed used for the calculation of the new value of the parameters |
77 |
|
*/ |
78 |
|
unsigned seed; |
79 |
|
/** |
80 |
|
* \brief This is the seed used for the acceptance of the metropolis |
81 |
|
*/ |
82 |
|
unsigned seedM; |
83 |
|
/** |
84 |
|
* \brief This is the seed used to change the order of the parameters |
85 |
|
*/ |
86 |
|
unsigned seedP; |
87 |
}; |
}; |
88 |
|
|
89 |
/** |
/** |
121 |
* \brief This is the function that will calculate the likelihood score using the Hooke & Jeeves optimiser |
* \brief This is the function that will calculate the likelihood score using the Hooke & Jeeves optimiser |
122 |
*/ |
*/ |
123 |
virtual void OptimiseLikelihood(); |
virtual void OptimiseLikelihood(); |
124 |
|
#ifdef SPECULATIVE |
125 |
|
/** |
126 |
|
* \brief This is the function that will calculate the likelihood score using the Hooke & Jeeves optimiser parallelized with the reproducible version implemented OpenMP |
127 |
|
*/ |
128 |
|
virtual void OptimiseLikelihoodOMP(); |
129 |
|
#endif |
130 |
private: |
private: |
131 |
/** |
/** |
132 |
* \brief This function will calculate the best point that can be found close to the current point |
* \brief This function will calculate the best point that can be found close to the current point |
138 |
*/ |
*/ |
139 |
double bestNearby(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param); |
double bestNearby(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param); |
140 |
/** |
/** |
141 |
|
* \brief This function implemented the reproducible version with OpenMP will calculate the best point that can be found close to the current point |
142 |
|
* \param delta is the DoubleVector of the steps to take when looking for the best point |
143 |
|
* \param point is the DoubleVector that will contain the parameters corresponding to the best function value found from the search |
144 |
|
* \param prevbest is the current best point value |
145 |
|
* \param param is the IntVector containing the order that the parameters should be searched in |
146 |
|
* \return the best function value found from the search |
147 |
|
*/ |
148 |
|
double bestNearbyRepro(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param); |
149 |
|
/** |
150 |
|
* \brief This function implemented the speculative version with OpenMP will calculate the best point that can be found close to the current point |
151 |
|
* \param delta is the DoubleVector of the steps to take when looking for the best point |
152 |
|
* \param point is the DoubleVector that will contain the parameters corresponding to the best function value found from the search |
153 |
|
* \param prevbest is the current best point value |
154 |
|
* \param param is the IntVector containing the order that the parameters should be searched in |
155 |
|
* \return the best function value found from the search |
156 |
|
*/ |
157 |
|
double bestNearbySpec(DoubleVector& delta, DoubleVector& point, double prevbest, IntVector& param); |
158 |
|
/** |
159 |
* \brief This is the maximum number of iterations for the Hooke & Jeeves optimisation |
* \brief This is the maximum number of iterations for the Hooke & Jeeves optimisation |
160 |
*/ |
*/ |
161 |
int hookeiter; |
int hookeiter; |
211 |
* \brief This is the function that will calculate the likelihood score using the Simulated Annealing optimiser |
* \brief This is the function that will calculate the likelihood score using the Simulated Annealing optimiser |
212 |
*/ |
*/ |
213 |
virtual void OptimiseLikelihood(); |
virtual void OptimiseLikelihood(); |
214 |
|
#ifdef SPECULATIVE |
215 |
|
/** |
216 |
|
* \brief This is the function that will calculate the likelihood score using the Simulated Annealing optimiser parallelized with the reproducible version implemented OpenMP |
217 |
|
*/ |
218 |
|
virtual void OptimiseLikelihoodOMP(); |
219 |
|
#endif |
220 |
|
/** |
221 |
|
* \brief This function calculate a new valor for the parameter l |
222 |
|
* \param nvars the number of variables to be optimised |
223 |
|
* \param l the parameter to change |
224 |
|
* \param param IntVector with the order of the parameters |
225 |
|
* \param trialx DoubleVector that storage the values of the parameters to evaluate during this iteration |
226 |
|
* \param x DoubleVector that storage the best values of the parameters |
227 |
|
* \param lowerb DoubleVector with the lower bounds of the variables to be optimised |
228 |
|
* \param upperb DoubleVector with the upper bounds of the variables to be optimised |
229 |
|
* \param vm DoubleVector with the value for the maximum step length for each parameter |
230 |
|
*/ |
231 |
|
virtual void newValue(int nvars, int l, IntVector& param, DoubleVector& trialx, |
232 |
|
DoubleVector& x, DoubleVector& lowerb, DoubleVector& upperb, DoubleVector& vm); |
233 |
private: |
private: |
234 |
/** |
/** |
235 |
* \brief This is the temperature reduction factor |
* \brief This is the temperature reduction factor |
315 |
* \brief This is the function that will calculate the likelihood score using the BFGS optimiser |
* \brief This is the function that will calculate the likelihood score using the BFGS optimiser |
316 |
*/ |
*/ |
317 |
virtual void OptimiseLikelihood(); |
virtual void OptimiseLikelihood(); |
318 |
|
#ifdef SPECULATIVE |
319 |
|
/** |
320 |
|
* \brief This function call the sequential function. BFGS isn't implemented with OpenMP |
321 |
|
*/ |
322 |
|
virtual void OptimiseLikelihoodOMP(); |
323 |
|
#endif |
324 |
private: |
private: |
325 |
/** |
/** |
326 |
* \brief This function will numerically calculate the gradient of the function at the current point |
* \brief This function will numerically calculate the gradient of the function at the current point |