BayesOpt
criteria_thompson.hpp
Go to the documentation of this file.
1 
3 /*
4 -------------------------------------------------------------------------
5  This file is part of BayesOpt, an efficient C++ library for
6  Bayesian optimization.
7 
8  Copyright (C) 2011-2015 Ruben Martinez-Cantin <rmcantin@unizar.es>
9 
10  BayesOpt is free software: you can redistribute it and/or modify it
11  under the terms of the GNU Affero General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  BayesOpt is distributed in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Affero General Public License for more details.
19 
20  You should have received a copy of the GNU Affero General Public License
21  along with BayesOpt. If not, see <http://www.gnu.org/licenses/>.
22 ------------------------------------------------------------------------
23 */
24 
25 #ifndef _CRITERIA_THOMPSON_HPP_
26 #define _CRITERIA_THOMPSON_HPP_
27 
28 #include "criteria_functors.hpp"
29 
30 namespace bayesopt
31 {
32 
35 
37  class ThompsonSampling: public Criteria
38  {
39  public:
40  ThompsonSampling() {};
41  virtual ~ThompsonSampling(){};
42  void setParameters(const vectord &params) { };
43  size_t nParameters() {return 0;};
44  double operator() (const vectord &x)
45  {
46  ProbabilityDistribution* d_ = mProc->prediction(x);
47  return d_->sample_query();
48  };
49  std::string name() {return "cThompsonSampling";};
50  };
51 
58  {
59  public:
60  OptimisticSampling() {};
61  virtual ~OptimisticSampling(){};
62  void setParameters(const vectord &params) {};
63  size_t nParameters() {return 0;};
64  double operator() (const vectord &x)
65  {
66  ProbabilityDistribution* d_ = mProc->prediction(x);
67  const double yStar = d_->sample_query();
68  const double yPred = d_->getMean();
69  return (std::min)(yPred,yStar);
70  };
71  std::string name() {return "cOptimisticSampling";};
72  };
73 
74 
76 
77 } //namespace bayesopt
78 
79 
80 #endif
Namespace of the library interface.
Definition: using.dox:1
virtual double sample_query()=0
Sample outcome acording to the marginal distribution at the query point.
Thompson sampling. Picks a random sample of the surrogate model.
virtual ProbabilityDistribution * prediction(const vectord &query)=0
Function that returns the prediction of the GP for a query point in the hypercube [0...
Abstract interface for criteria functors.
Abstract and factory modules for criteria.