BayesOpt
posterior_fixed.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 _POSTERIOR_FIXED_HPP_
26 #define _POSTERIOR_FIXED_HPP_
27 
28 #include <boost/scoped_ptr.hpp>
29 #include "inneroptimization.hpp"
30 #include "criteria_functors.hpp"
31 #include "posteriormodel.hpp"
32 
33 
34 namespace bayesopt {
35 
40 
46  {
47  public:
52  PosteriorFixed(size_t dim, Parameters params, randEngine& eng);
53 
57  virtual ~PosteriorFixed();
58 
59  void updateHyperParameters();
60  void fitSurrogateModel();
61  void updateSurrogateModel();
62 
63  double evaluateCriteria(const vectord& query);
64  void updateCriteria(const vectord& query);
65 
66  bool criteriaRequiresComparison();
67  void setFirstCriterium();
68  bool setNextCriterium(const vectord& prevResult);
69  std::string getBestCriteria(vectord& best);
70 
71  ProbabilityDistribution* getPrediction(const vectord& query);
72 
73  private:
75 
76  void setSurrogateModel(randEngine& eng);
77  void setCriteria(randEngine& eng);
78 
79  private: // Members
80  boost::scoped_ptr<NonParametricProcess> mGP;
81  boost::scoped_ptr<Criteria> mCrit;
82  };
83 
86  inline void PosteriorFixed::updateHyperParameters()
87  { /* Fixed model. Does not require updates */ };
88 
89  inline void PosteriorFixed::fitSurrogateModel()
90  { mGP->fitSurrogateModel(); };
91 
92  inline void PosteriorFixed::updateSurrogateModel()
93  { mGP->updateSurrogateModel(); };
94 
95  inline double PosteriorFixed::evaluateCriteria(const vectord& query)
96  { return (*mCrit)(query); };
97 
98  inline void PosteriorFixed::updateCriteria(const vectord& query)
99  { return mCrit->update(query); };
100 
101  inline bool PosteriorFixed::criteriaRequiresComparison()
102  {return mCrit->requireComparison(); };
103 
104  inline void PosteriorFixed::setFirstCriterium()
105  { mCrit->initialCriteria(); };
106 
107  inline bool PosteriorFixed::setNextCriterium(const vectord& prevResult)
108  {
109  mCrit->pushResult(prevResult);
110  return mCrit->rotateCriteria();
111  };
112 
113  inline std::string PosteriorFixed::getBestCriteria(vectord& best)
114  { return mCrit->getBestCriteria(best); };
115 
116  inline ProbabilityDistribution* PosteriorFixed::getPrediction(const vectord& query)
117  { return mGP->prediction(query); };
118 
119 
120 } //namespace bayesopt
121 
122 
123 #endif
Namespace of the library interface.
Definition: using.dox:1
boost::scoped_ptr< Criteria > mCrit
Metacriteria model.
Abstract interface for posterior model/criteria.
Abstract and factory modules for criteria.
boost::scoped_ptr< NonParametricProcess > mGP
Pointer to surrogate model.
Bayesian optimization using different non-parametric processes as distributions over surrogate functi...
C++ wrapper of the NLOPT library.
virtual ~PosteriorFixed()
Default destructor.
Bayesian optimization using different non-parametric processes as distributions over surrogate functi...