Log In | Get Help   
Home My Page Projects Code Snippets Project Openings Mareframe
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files
[mareframe] Diff of /trunk/gadget/hooke.cc
[mareframe] / trunk / gadget / hooke.cc Repository:
ViewVC logotype

Diff of /trunk/gadget/hooke.cc

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 25, Fri May 5 14:38:16 2017 UTC revision 26, Mon May 8 07:59:53 2017 UTC
# Line 328  Line 328 
328    
329    while (1) {    while (1) {
330      if (isZero(bestf)) {      if (isZero(bestf)) {
331        iters = EcoSystem->getFuncEval() - offset;  //      iters = EcoSystem->getFuncEval() - offset;
332        handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0");        handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0");
333        converge = -1;        converge = -1;
334        return;        return;
# Line 359  Line 359 
359      }      }
360      /* if too many function evaluations occur, terminate the algorithm */      /* if too many function evaluations occur, terminate the algorithm */
361    
362      iters = EcoSystem->getFuncEval() - offset;  //    iters = EcoSystem->getFuncEval() - offset;
363      if (iters > hookeiter) {      if (iters > hookeiter) {
364        handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");        handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
365        handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");        handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");
# Line 448  Line 448 
448          break;          break;
449    
450        /* if too many function evaluations occur, terminate the algorithm */        /* if too many function evaluations occur, terminate the algorithm */
451        iters = EcoSystem->getFuncEval() - offset;  //      iters = EcoSystem->getFuncEval() - offset;
452        if (iters > hookeiter) {        if (iters > hookeiter) {
453          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
454          handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");          handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");
# Line 465  Line 465 
465        }        }
466      } // while (newf < bestf)      } // while (newf < bestf)
467    
468      iters = EcoSystem->getFuncEval() - offset;  //    iters = EcoSystem->getFuncEval() - offset;
469      if (newf < bestf) {      if (newf < bestf) {
470        for (i = 0; i < nvars; i++)        for (i = 0; i < nvars; i++)
471          bestx[i] = x[i] * init[i];          bestx[i] = x[i] * init[i];
# Line 878  Line 878 
878    
879             while (1) {             while (1) {
880               if (isZero(bestf)) {               if (isZero(bestf)) {
881           #ifndef _OPENMP  //       #ifndef _OPENMP
882                 iters = EcoSystem->getFuncEval() - offset;  //             iters = EcoSystem->getFuncEval() - offset;
883           #endif  //       #endif
884                 handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0");                 handle.logMessage(LOGINFO, "Error in Hooke & Jeeves optimisation after", iters, "function evaluations, f(x) = 0");
885                 converge = -1;                 converge = -1;
886                 return;                 return;
# Line 903  Line 903 
903               /* find best new point, one coord at a time */               /* find best new point, one coord at a time */
904               for (i = 0; i < nvars; i++)               for (i = 0; i < nvars; i++)
905                 trialx[i] = x[i];                 trialx[i] = x[i];
906           #ifdef _OPENMP  //       #ifdef _OPENMP
907               newf = this->bestNearbySpec(delta, trialx, bestf, param);               newf = this->bestNearbySpec(delta, trialx, bestf, param);
908               if (newf == -1) {               if (newf == -1) {
909                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                  handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
910                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");                  handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");
911                  return;                  return;
912               }               }
913           #else  //       #else
914               newf = this->bestNearby(delta, trialx, bestf, param);  //           newf = this->bestNearby(delta, trialx, bestf, param);
915           #endif  //       #endif
916               /* if too many function evaluations occur, terminate the algorithm */               /* if too many function evaluations occur, terminate the algorithm */
917    
918           #ifndef _OPENMP  //       #ifndef _OPENMP
919               iters = EcoSystem->getFuncEval() - offset;  //           iters = EcoSystem->getFuncEval() - offset;
920           #endif  //       #endif
921               if (iters > hookeiter) {               if (iters > hookeiter) {
922                 handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                 handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
923                 handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");                 handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");
# Line 985  Line 985 
985                 /* only move forward if this is really an improvement    */                 /* only move forward if this is really an improvement    */
986                 oldf = newf;                 oldf = newf;
987                 newf = EcoSystem->SimulateAndUpdate(trialx);                 newf = EcoSystem->SimulateAndUpdate(trialx);
988           #ifdef _OPENMP  //       #ifdef _OPENMP
989                 iters++;                 iters++;
990           #endif  //       #endif
991                 if ((isEqual(newf, oldf)) || (newf > oldf)) {                 if ((isEqual(newf, oldf)) || (newf > oldf)) {
992                   newf = oldf;  //JMB no improvement, so reset the value of newf                   newf = oldf;  //JMB no improvement, so reset the value of newf
993                   break;                   break;
# Line 998  Line 998 
998                 for (i = 0; i < nvars; i++)                 for (i = 0; i < nvars; i++)
999                   x[i] = trialx[i];                   x[i] = trialx[i];
1000    
1001           #ifdef _OPENMP  //       #ifdef _OPENMP
1002                 newf = this->bestNearbySpec(delta, trialx, bestf, param);                 newf = this->bestNearbySpec(delta, trialx, bestf, param);
1003                 if (newf == -1) {                 if (newf == -1) {
1004                          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                          handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
1005                          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");                          handle.logMessage(LOGINFO, "\nThe number of threads must be a multiple of 2\n");
1006                          return;                          return;
1007                     }                     }
1008           #else  //       #else
1009                 newf = this->bestNearby(delta, trialx, bestf, param);  //             newf = this->bestNearby(delta, trialx, bestf, param);
1010           #endif  //       #endif
1011                 if (isEqual(newf, bestf))                 if (isEqual(newf, bestf))
1012                   break;                   break;
1013    
1014                 /* if too many function evaluations occur, terminate the algorithm */                 /* if too many function evaluations occur, terminate the algorithm */
1015           #ifndef _OPENMP  //       #ifndef _OPENMP
1016                 iters = EcoSystem->getFuncEval() - offset;  //             iters = EcoSystem->getFuncEval() - offset;
1017           #endif  //       #endif
1018                 if (iters > hookeiter) {                 if (iters > hookeiter) {
1019                   handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");                   handle.logMessage(LOGINFO, "\nStopping Hooke & Jeeves optimisation algorithm\n");
1020                   handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");                   handle.logMessage(LOGINFO, "The optimisation stopped after", iters, "function evaluations");
# Line 1031  Line 1031 
1031                 }                 }
1032               }               }
1033    
1034           #ifndef _OPENMP  //       #ifndef _OPENMP
1035               iters = EcoSystem->getFuncEval() - offset;  //           iters = EcoSystem->getFuncEval() - offset;
1036           #endif  //       #endif
1037               if (newf < bestf) {               if (newf < bestf) {
1038                 for (i = 0; i < nvars; i++)                 for (i = 0; i < nvars; i++)
1039                   bestx[i] = x[i] * init[i];                   bestx[i] = x[i] * init[i];

Legend:
Removed from v.25  
changed lines
  Added in v.26

root@forge.cesga.es
ViewVC Help
Powered by ViewVC 1.0.0  

Powered By FusionForge