BayesOpt
posterior_fixed.cpp
1 /*
2 -------------------------------------------------------------------------
3  This file is part of BayesOpt, an efficient C++ library for
4  Bayesian optimization.
5 
6  Copyright (C) 2011-2015 Ruben Martinez-Cantin <rmcantin@unizar.es>
7 
8  BayesOpt is free software: you can redistribute it and/or modify it
9  under the terms of the GNU Affero General Public License as published by
10  the Free Software Foundation, either version 3 of the License, or
11  (at your option) any later version.
12 
13  BayesOpt is distributed in the hope that it will be useful, but
14  WITHOUT ANY WARRANTY; without even the implied warranty of
15  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  GNU Affero General Public License for more details.
17 
18  You should have received a copy of the GNU Affero General Public License
19  along with BayesOpt. If not, see <http://www.gnu.org/licenses/>.
20 ------------------------------------------------------------------------
21 */
22 
23 #include "log.hpp"
24 #include "posterior_fixed.hpp"
25 
26 namespace bayesopt
27 {
28 
29 
30  PosteriorFixed::PosteriorFixed(size_t dim, Parameters parameters,
31  randEngine& eng):
32  PosteriorModel(dim,parameters,eng)
33  {
34  // Configure Surrogate and Criteria Functions
35  setSurrogateModel(eng);
36  setCriteria(eng);
37  }
38 
40  { } // Default destructor
41 
42 
43  void PosteriorFixed::setSurrogateModel(randEngine& eng)
44  {
46  mData,mMean,eng));
47  } // setSurrogateModel
48 
49  void PosteriorFixed::setCriteria(randEngine& eng)
50  {
51  CriteriaFactory mCFactory;
52 
53  mCrit.reset(mCFactory.create(mParameters.crit_name,mGP.get()));
54  mCrit->setRandomEngine(eng);
55 
56  if (mCrit->nParameters() == mParameters.crit_params.size())
57  {
58  mCrit->setParameters(mParameters.crit_params);
59  }
60  else // If the number of paramerters is different, use default.
61  {
62  if (mParameters.crit_params.size() != 0)
63  {
64  FILE_LOG(logERROR) << "Expected " << mCrit->nParameters()
65  << " parameters. Got "
66  << mParameters.crit_params.size() << " instead.";
67  }
68  FILE_LOG(logINFO) << "Using default parameters for criteria.";
69  }
70  } // setCriteria
71 
72 
73 } //namespace bayesopt
74 
Factory model for criterion functions This factory is based on the libgp library by Manuel Blum https...
static NonParametricProcess * create(size_t dim, Parameters parameters, const Dataset &data, MeanModel &mean, randEngine &eng)
Factory model generator for surrogate models.
Namespace of the library interface.
Definition: using.dox:1
Parameters mParameters
Configuration parameters.
boost::scoped_ptr< Criteria > mCrit
Metacriteria model.
vectord crit_params
Criterion hyperparameters (if needed)
Definition: parameters.hpp:111
Criteria * create(std::string name, NonParametricProcess *proc)
Factory model for criterion functions This function is based on the libgp library by Manuel Blum http...
size_t mDims
Number of dimensions.
Posterior model based on fixed kernel parameters.
std::string crit_name
Name of the criterion.
Definition: parameters.hpp:110
boost::scoped_ptr< NonParametricProcess > mGP
Pointer to surrogate model.
virtual ~PosteriorFixed()
Default destructor.
Modules and helper macros for logging.
Dataset mData
Dataset (x-> inputs, y-> labels/output)
Bayesian optimization using different non-parametric processes as distributions over surrogate functi...