Commits

Ruben Martinez-Cantin  committed 53e29d1

Forced epsilon-greedy jumps

  • Participants
  • Parent commits 7a60000

Comments (0)

Files changed (2)

File include/bayesoptbase.hpp

 
   private:
     boost::scoped_ptr<PosteriorModel> mModel;
-
+	double mYPrev;
+	size_t mCounterStuck;
   private:
 
     BayesOptBase();

File src/bayesoptbase.cpp

   void BayesOptBase::stepOptimization()
   {
     // Find what is the next point.
-    const vectord xNext = nextPoint(); 
-    const double yNext = evaluateSampleInternal(xNext);
+    vectord xNext = nextPoint(); 
+    double yNext = evaluateSampleInternal(xNext);
+
+	if (std::pow(mYPrev - yNext,2) < mParameters.noise)
+	{
+		mCounterStuck++;
+		FILE_LOG(logINFO) << "Stuck for "<< mCounterStuck << " steps";
+	}
+	else
+	{
+		mCounterStuck = 0;
+	}
+	mYPrev = yNext;
+
+	// If we are stuck in the same point for several iterations, try a random jump!
+	if (mCounterStuck > 5)
+	{
+		FILE_LOG(logINFO) << "Epsilon-greedy random query!";
+		xNext = samplePoint();
+		yNext = evaluateSampleInternal(xNext);
+		mCounterStuck = 0;
+	}
 
     if (yNext == HUGE_VAL)
       {
     mModel->updateHyperParameters();
     mModel->fitSurrogateModel();
     mCurrentIter = 0;
+
+	mCounterStuck = 0;
+	mYPrev = 0.0;
   }
 
 
    
     bestPoint = getFinalResult();
   } // optimize
-  
 
   vectord BayesOptBase::nextPoint()
   {