156 |
DoubleVector z(point); |
DoubleVector z(point); |
157 |
|
|
158 |
minf = prevbest; |
minf = prevbest; |
|
// for (int k=0;k<point.Size(); k++) |
|
|
// cout << z[k] ; |
|
|
// cout << endl; |
|
159 |
for (i = 0; i < point.Size(); i++) { |
for (i = 0; i < point.Size(); i++) { |
|
|
|
|
// for (int k=0;k<point.Size(); k++) |
|
|
// cout << z[k] << " " ; |
|
|
//cout << endl; |
|
160 |
z[param[i]] = point[param[i]] + delta[param[i]]; |
z[param[i]] = point[param[i]] + delta[param[i]]; |
161 |
ftmp = EcoSystem->SimulateAndUpdate(z); |
ftmp = EcoSystem->SimulateAndUpdate(z); |
|
// cout << i <<"-z["<< param[i]<<"]:" <<z[param[i]] << " - " << ftmp << endl; |
|
162 |
if (ftmp < minf) { |
if (ftmp < minf) { |
163 |
minf = ftmp; |
minf = ftmp; |
164 |
} else { |
} else { |
170 |
else |
else |
171 |
z[param[i]] = point[param[i]]; |
z[param[i]] = point[param[i]]; |
172 |
} |
} |
|
// cout << i <<"-z["<< param[i]<<"]:" <<z[param[i]] << " - " << ftmp <<" - " << prevbest << endl; |
|
173 |
} |
} |
174 |
|
|
175 |
for (i = 0; i < point.Size(); i++) |
for (i = 0; i < point.Size(); i++) |
213 |
if ((i + paral_tokens -1) >= nvars) |
if ((i + paral_tokens -1) >= nvars) |
214 |
paral_tokens = nvars - i; |
paral_tokens = nvars - i; |
215 |
omp_set_dynamic(0); |
omp_set_dynamic(0); |
216 |
omp_set_nested(1); |
omp_set_nested(1); //permit the nested parallelization |
217 |
#pragma omp parallel for num_threads(paral_tokens) private(k) |
#pragma omp parallel for num_threads(paral_tokens) private(k) //parallelize the parameters (numThr/2) |
218 |
for (j = 0; j < paral_tokens; ++j) { |
for (j = 0; j < paral_tokens; ++j) { |
219 |
storage[j].z = z; |
storage[j].z = z; |
220 |
storage[j].delta = delta; |
storage[j].delta = delta; |
224 |
v1[k] += delta[k]; |
v1[k] += delta[k]; |
225 |
v2[k] -= delta[k]; |
v2[k] -= delta[k]; |
226 |
|
|
227 |
#pragma omp parallel sections num_threads(2) |
#pragma omp parallel sections num_threads(2) //parrallelize the +/- delta simulation for each parameter |
228 |
{ |
{ |
229 |
#pragma omp section |
#pragma omp section |
230 |
{ |
{ |
291 |
EcoSystem->scaleVariables(); |
EcoSystem->scaleVariables(); |
292 |
#ifndef NO_OPENMP |
#ifndef NO_OPENMP |
293 |
int numThr = omp_get_max_threads ( ); |
int numThr = omp_get_max_threads ( ); |
294 |
for (i = 0; i < numThr; i++) |
for (i = 0; i < numThr; i++) // scale the variables for the ecosystem of every thread |
295 |
EcoSystems[i]->scaleVariables(); |
EcoSystems[i]->scaleVariables(); |
296 |
#endif |
#endif |
297 |
EcoSystem->getOptScaledValues(x); |
EcoSystem->getOptScaledValues(x); |
635 |
IntVector trapped(nvars, 0); |
IntVector trapped(nvars, 0); |
636 |
|
|
637 |
EcoSystem->scaleVariables(); |
EcoSystem->scaleVariables(); |
|
#ifndef NO_OPENMP |
|
638 |
int numThr = omp_get_max_threads ( ); |
int numThr = omp_get_max_threads ( ); |
639 |
for (i = 0; i < numThr; i++) |
for (i = 0; i < numThr; i++) // scale the variables for the ecosystem of every thread |
640 |
EcoSystems[i]->scaleVariables(); |
EcoSystems[i]->scaleVariables(); |
|
#endif |
|
641 |
EcoSystem->getOptScaledValues(x); |
EcoSystem->getOptScaledValues(x); |
642 |
EcoSystem->getOptLowerBounds(lowerb); |
EcoSystem->getOptLowerBounds(lowerb); |
643 |
EcoSystem->getOptUpperBounds(upperb); |
EcoSystem->getOptUpperBounds(upperb); |