Commits

Ruben Martinez-Cantin committed 55e2db7

Solved bug in gaussian process

  • Participants
  • Parent commits 3cefb79

Comments (0)

Files changed (3)

File app/bo_display.cpp

 	z[i] = GLOBAL_MODEL->evaluateSample(q);
       }
     //plot
-    subplot(3,1,1);
+    subplot(2,1,1);
     title("press r to run and stop");
     plot(x,y);
+    plot(lx,ly);set("k");set("*");
     plot(x,su);set("g");
     plot(x,sl);set("g");
     plot(x,z);set("r");
    
-    subplot(3,1,2);
-    axis(0,1,-10,10);
-    plot(lx,ly);set("k");set("*");
-
-    //mesh
-    subplot(3,1,3);
+    subplot(2,1,2);
     plot(x,c);
 
 }
       GLOBAL_MODEL->stepOptimization(state_ii); 
       vectord last(1);
       double res = GLOBAL_MODEL->getSurrogateModel()->getLastSample(last);
-      std::cout << res << last(0) <<","<< ly.size() <<","<< lx.size() << std::endl;
       ly.push_back(res);
       lx.push_back(last(0));
     
   size_t dim = 1;
   bopt_params parameters = initialize_parameters_to_default();
   parameters.n_init_samples = 10;
-  parameters.n_iterations = 300;
-  parameters.kernel.hp_mean[0] = 0.5;
-  parameters.kernel.hp_std[0] = 100.0;
-  parameters.kernel.n_hp = 1;
-  parameters.mean.name = "mZero";
-  parameters.crit_name = "cHedge(cEI,cLCB,cExpReturn,cOptimisticSampling)";
-  parameters.epsilon = 0.0;
+  parameters.n_iterations = 100;
+  parameters.surr_name = S_GAUSSIAN_PROCESS;
+  // parameters.kernel.hp_mean[0] = 0.5;
+  // parameters.kernel.hp_std[0] = 100.0;
+  // parameters.kernel.n_hp = 1;
+  // parameters.mean.name = "mZero";
+  //  parameters.crit_name = "cHedge(cEI,cLCB,cExpReturn,cOptimisticSampling)";
+  // parameters.epsilon = 0.0;
 
   state_ii = 0;
 

File app/bo_oned.cpp

   bopt_params parameters = initialize_parameters_to_default();
   parameters.n_init_samples = 10;
   parameters.n_iterations = 300;
-  parameters.kernel.hp_mean[0] = 1.0;
+  parameters.surr_name = S_GAUSSIAN_PROCESS_ML;
+  /*  parameters.kernel.hp_mean[0] = 1.0;
   parameters.kernel.hp_std[0] = 100.0;
   parameters.kernel.n_hp = 1;
   parameters.crit_name = "cHedge(cEI,cLCB,cExpReturn,cOptimisticSampling)";
-  parameters.epsilon = 0.0;
+  parameters.epsilon = 0.0;*/
 
   ExampleOneD opt(dim,parameters);
   vectord result(dim);

File src/gaussian_process.cpp

   {
     const double kq = (*mKernel)(query, query);
     const vectord kn = computeCrossCorrelation(query);
+    
 
     vectord vd(kn);
-    ublas::inplace_solve(mL,vd,ublas::lower_tag());
-    double yPred = ublas::inner_prod(vd,mAlphaV);
+    inplace_solve(mL,vd,ublas::lower_tag());
+    double basisPred = ublas::inner_prod(mMu,mMean->getFeatures(query));
+    double yPred = basisPred + ublas::inner_prod(vd,mAlphaV);
     double sPred = sqrt(mSigma*(kq - ublas::inner_prod(vd,vd)));
-
+    
     d_->setMeanAndStd(yPred,sPred);
     return d_;
   }
   
     mAlphaV.resize(n,false);
     mAlphaV = mGPY-prod(mMu,mFeatM);
-    utils::cholesky_solve(mL,mAlphaV,ublas::lower());
+    inplace_solve(mL,mAlphaV,ublas::lower_tag());
 
     return 1; 
   }