1 |
#include "ecosystem.h" |
#include "ecosystem.h" |
2 |
#include "runid.h" |
#include "runid.h" |
3 |
#include "global.h" |
#include "global.h" |
4 |
|
#ifndef NO_OPENMP |
5 |
|
#include <omp.h> |
6 |
|
#endif |
7 |
|
|
8 |
|
#ifndef NO_OPENMP |
9 |
|
extern Ecosystem** EcoSystems; |
10 |
|
//extern StochasticData* data; |
11 |
|
#endif |
12 |
|
|
13 |
Ecosystem::Ecosystem(const MainInfo& main) : printinfo(main.getPI()) { |
Ecosystem::Ecosystem(const MainInfo& main) : printinfo(main.getPI()) { |
14 |
|
|
40 |
infile.open(filename, ios::in); |
infile.open(filename, ios::in); |
41 |
handle.checkIfFailure(infile, filename); |
handle.checkIfFailure(infile, filename); |
42 |
handle.Open(filename); |
handle.Open(filename); |
43 |
this->readOptimisation(commin); |
unsigned seed; |
44 |
|
main.getForcePrint(); |
45 |
|
this->readOptimisation(commin, main.getSeed()); |
46 |
handle.Close(); |
handle.Close(); |
47 |
infile.close(); |
infile.close(); |
48 |
infile.clear(); |
infile.clear(); |
111 |
void Ecosystem::Optimise() { |
void Ecosystem::Optimise() { |
112 |
int i; |
int i; |
113 |
for (i = 0; i < optvec.Size(); i++) { |
for (i = 0; i < optvec.Size(); i++) { |
114 |
|
#ifndef NO_OPENMP |
115 |
|
int j, numThr = omp_get_max_threads ( ); |
116 |
|
DoubleVector v = this->getValues(); |
117 |
|
for (j = 0; j < numThr; j++) |
118 |
|
EcoSystems[j]->Update(v); |
119 |
|
#endif |
120 |
|
#ifdef GADGET_OPENMP |
121 |
|
optvec[i]->OptimiseLikelihoodOMP(); |
122 |
|
#else |
123 |
optvec[i]->OptimiseLikelihood(); |
optvec[i]->OptimiseLikelihood(); |
124 |
|
#endif |
125 |
this->writeOptValues(); |
this->writeOptValues(); |
126 |
} |
} |
127 |
} |
} |
168 |
for (i = 0; i < likevec.Size(); i++) |
for (i = 0; i < likevec.Size(); i++) |
169 |
tmpvec[i] = likevec[i]->getUnweightedLikelihood(); |
tmpvec[i] = likevec[i]->getUnweightedLikelihood(); |
170 |
|
|
171 |
handle.logMessage(LOGINFO, "\nAfter a total of", funceval, "function evaluations the best point found is"); |
int iters = 0; |
172 |
|
#ifndef NO_OPENMP |
173 |
|
int numThr = omp_get_max_threads ( ); |
174 |
|
for (i = 0; i < numThr; i++) |
175 |
|
iters += EcoSystems[i]->getFuncEval(); |
176 |
|
#endif |
177 |
|
handle.logMessage(LOGINFO, "\nAfter a total of", funceval+iters, "function evaluations the best point found is"); |
178 |
keeper->writeBestValues(); |
keeper->writeBestValues(); |
179 |
handle.logMessage(LOGINFO, "\nThe scores from each likelihood component are"); |
handle.logMessage(LOGINFO, "\nThe scores from each likelihood component are"); |
180 |
handle.logMessage(LOGINFO, tmpvec); |
handle.logMessage(LOGINFO, tmpvec); |