Source

BayesOpt / src / bayesoptbase.cpp

Diff from to

src/bayesoptbase.cpp

 ------------------------------------------------------------------------
 */
 
+#include <cstdlib>
 #include "log.hpp"
 #include "bayesoptbase.hpp"
 
     if (mGP == NULL) 
       {
 	FILE_LOG(logERROR) << "Error setting the surrogate function"; 
-	return -1;
+	exit(EXIT_FAILURE);
       } 
     return 0;
   } // setSurrogateModel
   int BayesOptBase::setCriteria()
   {
     mCrit.reset(mCFactory.create(mParameters.crit_name,mGP.get()));
-    if ((mCrit == NULL) || (mCrit->nParameters() != mParameters.n_crit_params))
+    if (mCrit == NULL)
       {
 	FILE_LOG(logERROR) << "Error in criterium"; 
-	if (mCrit->nParameters() != mParameters.n_crit_params)
+	exit(EXIT_FAILURE);
+      }
+    
+    if (mCrit->nParameters() != mParameters.n_crit_params)
+      {
+	if (mParameters.n_crit_params != 0)
 	  {
 	    FILE_LOG(logERROR) << "Expected " << mCrit->nParameters() 
 			       << " parameters. Got " 
 			       << mParameters.n_crit_params << " instead.";
 	  }
-	return -1;
+	FILE_LOG(logINFO) << "Usign default parameters for criteria.";
+	return 0;
       }
+      
+    // If we have the correct number of parameters.
     vectord critParams = utils::array2vector(mParameters.crit_params,
-					     mParameters.n_crit_params);
+					       mParameters.n_crit_params);
     mCrit->setParameters(critParams);
     return 0;
   } // setCriteria
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.