BayesOpt
criteria_lcb.hpp
Go to the documentation of this file.
1 
2 /*
3 -------------------------------------------------------------------------
4  This file is part of BayesOpt, an efficient C++ library for
5  Bayesian optimization.
6 
7  Copyright (C) 2011-2015 Ruben Martinez-Cantin <rmcantin@unizar.es>
8 
9  BayesOpt is free software: you can redistribute it and/or modify it
10  under the terms of the GNU Affero General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  BayesOpt is distributed in the hope that it will be useful, but
15  WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU Affero General Public License for more details.
18 
19  You should have received a copy of the GNU Affero General Public License
20  along with BayesOpt. If not, see <http://www.gnu.org/licenses/>.
21 ------------------------------------------------------------------------
22 */
23 
24 #ifndef _CRITERIA_LCB_HPP_
25 #define _CRITERIA_LCB_HPP_
26 
27 #include "criteria_functors.hpp"
28 
29 namespace bayesopt
30 {
31 
34 
37  {
38  public:
39  virtual ~LowerConfidenceBound(){};
40  void init(NonParametricProcess* proc)
41  {
42  mProc = proc;
43  mBeta = 1.0;
44  };
45  void setParameters(const vectord &params)
46  { mBeta = params(0); };
47 
48  size_t nParameters() {return 1;};
49 
50  double operator() (const vectord &x)
51  {
52  return mProc->prediction(x)->lowerConfidenceBound(mBeta);
53  };
54  std::string name() {return "cLCB";};
55  private:
56  double mBeta;
57  };
58 
59 
62  {
63  public:
64  virtual ~AnnealedLowerConfindenceBound(){};
65  void init(NonParametricProcess* proc)
66  {
67  mProc = proc;
68  reset();
69  };
70 
71  void setParameters(const vectord &params)
72  { mCoef = params(0); };
73 
74  size_t nParameters() {return 1;};
75  void reset() { nCalls = 1; mCoef = 5.0;};
76  double operator() (const vectord &x)
77  {
78  size_t nDims = x.size();
79 
80  double beta = sqrt(2*log(static_cast<double>(nCalls*nCalls))*(nDims+1)
81  + log(static_cast<double>(nDims))*nDims*mCoef);
82  ProbabilityDistribution* d_ = mProc->prediction(x);
83  return d_->lowerConfidenceBound(beta);
84  };
85  void update(const vectord &x) { ++nCalls; }
86 
87  std::string name() {return "cLCBa";};
88  private:
89  double mCoef;
90  unsigned int nCalls;
91  };
92 
94 
95 } //namespace bayesopt
96 
97 
98 #endif
virtual double lowerConfidenceBound(double beta=1)=0
Lower confindence bound.
Namespace of the library interface.
Definition: using.dox:1
Abstract class to implement Bayesian regressors.
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.
Lower (upper) confidence bound using Srinivas annealing .
Lower (upper) confidence bound criterion by [Cox and John, 1992].