BayesOpt
criteria_mi.hpp
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_MI_HPP_
25 #define _CRITERIA_MI_HPP_
26 
27 #include "criteria_functors.hpp"
28 
29 namespace bayesopt
30 {
31 
34 
37  {
38  public:
39  virtual ~MutualInformation(){};
40  void init(NonParametricProcess* proc)
41  {
42  mProc = proc;
43  mSqAlpha = sqrt(std::log(2/1e-6)); // See [Contal et al., 2014].
44  mGamma = 0.0;
45  };
46  void setParameters(const vectord &params)
47  { mSqAlpha = sqrt(params(0)); };
48 
49  size_t nParameters() {return 1;};
50 
51  double operator() (const vectord &x)
52  {
53  ProbabilityDistribution* d = mProc->prediction(x);
54  double mu = d->getMean();
55  double sigma2 = d->getStd() * d->getStd();
56  return mu + mSqAlpha * (sqrt(sigma2+mGamma) - sqrt(mGamma));
57  };
58  void update(const vectord &x)
59  {
60  ProbabilityDistribution* d = mProc->prediction(x);
61  double mu = d->getMean();
62  double sigma2 = d->getStd() * d->getStd();
63  mGamma += sigma2;
64  }
65  std::string name() {return "cMI";};
66  private:
67  double mSqAlpha;
68  double mGamma;
69  };
70 
72 
73 } //namespace bayesopt
74 
75 
76 #endif
Namespace of the library interface.
Definition: using.dox:1
Abstract class to implement Bayesian regressors.
Mutual Information bound criterion b [Contal et al., 2014].
Definition: criteria_mi.hpp:36
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.