--- trunk/gadget/simann.cc 2015/07/24 18:36:24 12 +++ trunk/gadget/simann.cc 2015/07/30 12:36:46 14 @@ -304,8 +304,6 @@ //// trialx[i] = x[i]; //// } // -//// cout << "param:" << param[l] << "-" << trialx[param[l]] << endl; -// // //Evaluate the function with the trial point trialx and return as -trialf // trialf = EcoSystem->SimulateAndUpdate(trialx); // trialf = -trialf; @@ -326,9 +324,7 @@ // handle.logMessage(LOGINFO, "\nSimulated Annealing finished with a likelihood score of", score); // return; // } -//// cout << "f:" << trialf << endl; // //Accept the new point if the new function value better -//// cout << "mustAccept:" << trialf << "|" << funcval<< endl; // if ((trialf - funcval) > verysmall) { // for (i = 0; i < nvars; i++) // x[i] = trialx[i]; @@ -352,7 +348,6 @@ // nrej++; // } // } -//// cout << "goog VALUE:" << funcval << endl; // // JMB added check for really silly values // if (isZero(trialf)) { // handle.logMessage(LOGINFO, "Error in Simulated Annealing optimisation after", iters, "function evaluations, f(x) = 0"); @@ -451,9 +446,10 @@ double tmp, p, pp, ratio, nsdiv; double fopt, funcval, trialf; - int a, i, j, k, l, offset, quit; + int a, i, j, k, l, quit; int rchange, rcheck, rnumber; //Used to randomise the order of the parameters + // store the info of the different threads struct Storage { DoubleVector trialx; double newLikelihood; @@ -474,8 +470,12 @@ IntVector nacp(nvars, 0); EcoSystem->resetVariables(); //JMB need to reset variables in case they have been scaled - if (scale) - EcoSystem->scaleVariables(); + if (scale) { + EcoSystem->scaleVariables(); + int numThr = omp_get_max_threads ( ); + for(i = 0; i < numThr; i++) // scale the variables for the ecosystem of every thread + EcoSystems[i]->scaleVariables(); + } EcoSystem->getOptScaledValues(x); EcoSystem->getOptLowerBounds(lowerb); EcoSystem->getOptUpperBounds(upperb); @@ -511,7 +511,6 @@ //the function is to be minimised so switch the sign of funcval (and trialf) funcval = -funcval; - offset = EcoSystem->getFuncEval(); //number of function evaluations done before loop nacc++; cs /= lratio; //JMB save processing time nsdiv = 1.0 / ns; @@ -530,15 +529,16 @@ for (i=0; iscaleVariables(); #ifndef NO_OPENMP int numThr = omp_get_max_threads ( ); - for(i = 0; i < numThr; i++) + for(i = 0; i < numThr; i++) // scale the variables for the ecosystem of every thread EcoSystems[i]->scaleVariables(); #endif }