BayesOpt
criteria_ei.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_EI_HPP_
25 #define _CRITERIA_EI_HPP_
26 
27 #include "criteria_functors.hpp"
28 #include "prob_distribution.hpp"
29 
30 namespace bayesopt
31 {
32 
35 
38  {
39  public:
40  virtual ~ExpectedImprovement(){};
41  void init(NonParametricProcess* proc)
42  {
43  mProc = proc;
44  mExp = 1;
45  };
46 
47  void setParameters(const vectord &params)
48  { mExp = static_cast<size_t>(params(0)); };
49 
50  size_t nParameters() {return 1;};
51 
52  double operator() (const vectord &x)
53  {
54  const double min = mProc->getValueAtMinimum();
55  return mProc->prediction(x)->negativeExpectedImprovement(min,mExp);
56  };
57 
58  std::string name() {return "cEI";};
59 
60  private:
61  size_t mExp;
62  };
63 
66  {
67  public:
68  virtual ~BiasedExpectedImprovement(){};
69  void init(NonParametricProcess* proc)
70  {
71  mProc = proc;
72  mBias = 0.01;
73  mExp = 1;
74  };
75 
76  void setParameters(const vectord &params)
77  {
78  mExp = static_cast<size_t>(params(0));
79  mBias = params(1);
80  };
81 
82  size_t nParameters() {return 2;};
83 
84  double operator() (const vectord &x)
85  {
86  const double sigma = mProc->getSignalVariance();
87  const double min = mProc->getValueAtMinimum() - mBias/sigma;
88  return mProc->prediction(x)->negativeExpectedImprovement(min,mExp);
89  };
90  std::string name() {return "cBEI";};
91  private:
92  double mBias;
93  size_t mExp;
94  };
95 
96 
99  {
100  public:
101  virtual ~AnnealedExpectedImprovement(){};
102  void init(NonParametricProcess* proc)
103  {
104  mProc = proc;
105  reset();
106  };
107 
108  void setParameters(const vectord &params)
109  { mExp = static_cast<size_t>(params(0)); };
110 
111  size_t nParameters() {return 1;};
112  void reset() { nCalls = 1; mExp = 10;};
113  double operator() (const vectord &x)
114  {
115  ProbabilityDistribution* d_ = mProc->prediction(x);
116  const double min = mProc->getValueAtMinimum();
117  return d_->negativeExpectedImprovement(min,mExp);
118  };
119  void update(const vectord &x)
120  {
121  ++nCalls;
122  if (nCalls % 10)
123  mExp = static_cast<size_t>(ceil(mExp/2.0));
124  }
125  std::string name() {return "cEIa";};
126  private:
127  size_t mExp;
128  unsigned int nCalls;
129  };
130 
131 
132 
134 
135 } //namespace bayesopt
136 
137 
138 #endif
Namespace of the library interface.
Definition: using.dox:1
Expected improvement criterion by Mockus .
Definition: criteria_ei.hpp:37
Expected improvement criterion using Schonlau annealing. .
Definition: criteria_ei.hpp:98
Abstract class to implement Bayesian regressors.
Interface for probability models.
virtual double negativeExpectedImprovement(double min, size_t g)=0
Expected Improvement algorithm for minimization.
Expected improvement criterion modification by Lizotte.
Definition: criteria_ei.hpp:65
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.