Commits

Ruben Martinez-Cantin  committed 51ca0f1

Added tolerance based stopping criteria for NLOPT. It fixes issue with BOBYQA. Fixed typo in docs.

  • Participants
  • Parent commits b11c37d

Comments (0)

Files changed (3)

File doxygen/branin.jpg

Removed
Old image

File doxygen/using.dox

   - 0 -> Warning -> stdout
   - 1 -> Info -> stdout
   - 2 -> Debug -> stdout
-  - 3 -> Error -> log file
-  - 4 -> Warning -> log file
-  - 5 -> Info -> log file
-  - >5 -> Debug -> log file
+  - 3 -> Warning -> log file
+  - 4 -> Info -> log file
+  - 5 -> Debug -> log file
+  - >5 -> Error -> log file
 
 - \b log_filename: Name/path of the log file (if applicable,
   verbose_level>=3) [Default "bayesopt.log"]

File src/inneroptimization.cpp

 		   vectord& Xnext, int maxf, const std::vector<double>& vd, 
 		   const std::vector<double>& vu, void* objPointer)
   {
-    double fmin;
+    double fmin = 0.0;
     size_t n = Xnext.size(); 
     nlopt::opt opt (algo,n);
 
     opt.set_lower_bounds(vd);
     opt.set_upper_bounds(vu);
     opt.set_min_objective(fpointer, objPointer);
-    opt.set_maxeval(maxf) ;
+    opt.set_maxeval(maxf);
     
+    // It seems BOBYQA can be unstable if the same point is repeated
+    // tested over and over. NLOPT bug?
+    opt.set_ftol_rel(1e-12);	
+    opt.set_ftol_abs(1e-12);
+
     std::copy(Xnext.begin(),Xnext.end(),xstd.begin());
       
     try 
 	FILE_LOG(logDEBUG) << "NLOPT Warning: Potential roundoff error. " 
 			   << "In general, this can be ignored.";
       }
-    
+
     std::copy(xstd.begin(),xstd.end(),Xnext.begin());
     return fmin;
   }
     if (maxf2)
       {
 	//If the point is exactly at the limit, we may have trouble.
-	for (size_t i = 0; i < n; ++i) 
+    	for (size_t i = 0; i < n; ++i) 
 	  {
 	    if (Xnext(i)-mDown[i] < 0.0001) Xnext(i) += 0.0001;
 	    if (mUp[i] - Xnext(i) < 0.0001) Xnext(i) -= 0.0001;
 	  }
+
 	fmin = run_nlopt(nlopt::LN_BOBYQA,fpointer,Xnext,maxf2,
 			 mDown,mUp,objPointer);
 	FILE_LOG(logDEBUG) << "2nd opt " << maxf2 << "-> " << Xnext 
 
     void *objPointer = my_func_data;
     RBOptimizableWrapper* OPTIMIZER = static_cast<RBOptimizableWrapper*>(objPointer);
-    
+
     return OPTIMIZER->evaluate(vx);
   } /* evaluate_criteria_nlopt */