BayesOpt
posteriormodel.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 
25 #ifndef _POSTERIORMODEL_HPP_
26 #define _POSTERIORMODEL_HPP_
27 
28 #include "prob_distribution.hpp"
29 #include "dataset.hpp"
30 #include "mean_functors.hpp"
31 
32 namespace bayesopt {
33 
38 
44  {
45  public:
46  static PosteriorModel* create(size_t dim, Parameters params,
47  randEngine& eng);
48 
53  PosteriorModel(size_t dim, Parameters params, randEngine& eng);
54 
58  virtual ~PosteriorModel();
59 
60 
61  virtual void updateHyperParameters() = 0;
62  virtual void fitSurrogateModel() = 0;
63  virtual void updateSurrogateModel() = 0;
64 
65  virtual double evaluateCriteria(const vectord& query) = 0;
66  virtual void updateCriteria(const vectord& query) = 0;
67 
68  virtual bool criteriaRequiresComparison() = 0;
69  virtual void setFirstCriterium() = 0;
70  virtual bool setNextCriterium(const vectord& prevResult) = 0;
71  virtual std::string getBestCriteria(vectord& best) = 0;
72 
73 
74  void setSamples(const matrixd &x, const vectord &y);
75  void setSamples(const matrixd &x);
76  void setSamples(const vectord &y);
77  void setSample(const vectord &x, double y);
78  void addSample(const vectord &x, double y);
79  double getValueAtMinimum();
80  vectord getPointAtMinimum();
81 
82  void plotDataset(TLogLevel level);
83 
84  const Dataset* getData();
85  virtual ProbabilityDistribution* getPrediction(const vectord& query) = 0;
86 
87 
88  protected:
90  size_t mDims;
92  MeanModel mMean;
93 
94  private:
96  };
97 
98  inline vectord PosteriorModel::getPointAtMinimum()
99  { return mData.getPointAtMinimum(); };
100 
101  inline double PosteriorModel::getValueAtMinimum()
102  { return mData.getValueAtMinimum(); };
103 
104  inline void PosteriorModel::plotDataset(TLogLevel level)
105  { mData.plotData(level); }
106 
107  inline const Dataset* PosteriorModel::getData()
108  { return &mData; }
109 
110 } //namespace bayesopt
111 
112 
113 #endif
Dataset model.
Namespace of the library interface.
Definition: using.dox:1
Parameters mParameters
Configuration parameters.
Interface for probability models.
size_t mDims
Number of dimensions.
Dataset model to deal with the vector (real) based datasets.
Definition: dataset.hpp:40
Dataset mData
Dataset (x-> inputs, y-> labels/output)
Bayesian optimization using different non-parametric processes as distributions over surrogate functi...
Mean (parametric) functions.
virtual ~PosteriorModel()
Default destructor.