--- trunk/gadget/hooke.cc 2015/09/01 19:14:33 15 +++ trunk/gadget/hooke.cc 2015/10/13 11:29:01 16 @@ -139,12 +139,12 @@ #include "ecosystem.h" #include "global.h" -#ifndef NO_OPENMP +#ifdef _OPENMP #include "omp.h" #endif extern Ecosystem* EcoSystem; -#ifndef NO_OPENMP +#ifdef _OPENMP extern Ecosystem** EcoSystems; #endif @@ -178,7 +178,7 @@ } /* given a point, look for a better one nearby, one coord at a time */ -#ifndef NO_OPENMP +#ifdef _OPENMP /* * function bestBeraby parallelized with OpenMP * ยท 2 threads per coord to parallelize the calculation of +delta/-delta @@ -289,7 +289,7 @@ IntVector trapped(nvars, 0); EcoSystem->scaleVariables(); -#ifndef NO_OPENMP +#ifdef _OPENMP int numThr = omp_get_max_threads ( ); for (i = 0; i < numThr; i++) // scale the variables for the ecosystem of every thread EcoSystems[i]->scaleVariables(); @@ -334,7 +334,7 @@ while (1) { if (isZero(bestf)) { -#ifdef NO_OPENMP +#ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0"); @@ -359,7 +359,7 @@ /* find best new point, one coord at a time */ for (i = 0; i < nvars; i++) trialx[i] = x[i]; -#ifndef NO_OPENMP +#ifdef _OPENMP newf = this->bestNearbyRepro(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); @@ -371,7 +371,7 @@ #endif /* if too many function evaluations occur, terminate the algorithm */ -#ifdef NO_OPENMP +#ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (iters > hookeiter) { @@ -441,7 +441,7 @@ /* only move forward if this is really an improvement */ oldf = newf; newf = EcoSystem->SimulateAndUpdate(trialx); -#ifndef NO_OPENMP +#ifdef _OPENMP iters++; #endif if ((isEqual(newf, oldf)) || (newf > oldf)) { @@ -454,7 +454,7 @@ for (i = 0; i < nvars; i++) x[i] = trialx[i]; -#ifndef NO_OPENMP +#ifdef _OPENMP newf = this->bestNearbyRepro(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); @@ -468,7 +468,7 @@ break; /* if too many function evaluations occur, terminate the algorithm */ -#ifdef NO_OPENMP +#ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (iters > hookeiter) { @@ -485,9 +485,9 @@ EcoSystem->storeVariables(score, bestx); return; } - } + } // while (newf < bestf) -#ifdef NO_OPENMP +#ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (newf < bestf) { @@ -678,7 +678,7 @@ while (1) { if (isZero(bestf)) { - #ifdef NO_OPENMP + #ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0"); @@ -703,7 +703,7 @@ /* find best new point, one coord at a time */ for (i = 0; i < nvars; i++) trialx[i] = x[i]; - #ifndef NO_OPENMP + #ifdef _OPENMP newf = this->bestNearbySpec(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); @@ -715,7 +715,7 @@ #endif /* if too many function evaluations occur, terminate the algorithm */ - #ifdef NO_OPENMP + #ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (iters > hookeiter) { @@ -785,7 +785,7 @@ /* only move forward if this is really an improvement */ oldf = newf; newf = EcoSystem->SimulateAndUpdate(trialx); - #ifndef NO_OPENMP + #ifdef _OPENMP iters++; #endif if ((isEqual(newf, oldf)) || (newf > oldf)) { @@ -798,7 +798,7 @@ for (i = 0; i < nvars; i++) x[i] = trialx[i]; - #ifndef NO_OPENMP + #ifdef _OPENMP newf = this->bestNearbySpec(delta, trialx, bestf, param); if (newf == -1) { handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n"); @@ -812,7 +812,7 @@ break; /* if too many function evaluations occur, terminate the algorithm */ - #ifdef NO_OPENMP + #ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (iters > hookeiter) { @@ -831,7 +831,7 @@ } } - #ifdef NO_OPENMP + #ifndef _OPENMP iters = EcoSystem->getFuncEval() - offset; #endif if (newf < bestf) {