BayesOpt
kernel_polynomial.hpp
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 #ifndef _KERNEL_POLYNOMIAL_HPP_
24 #define _KERNEL_POLYNOMIAL_HPP_
25 
27 
28 namespace bayesopt
29 {
30 
33 
35  class Polynomial: public AtomicKernel
36  {
37  public:
38  Polynomial(){ mExp = 1; };
39 
40  void init(size_t input_dim)
41  { n_params = 2; n_inputs = input_dim; };
42 
43  double operator()( const vectord &x1, const vectord &x2)
44  {
45  double xx = boost::numeric::ublas::inner_prod(x1,x2);
46  return params(0)*params(0) * std::pow((params(1)+xx),static_cast<int>(mExp));
47  };
48 
49  //TODO:
50  double gradient( const vectord &x1, const vectord &x2,
51  size_t component)
52  { assert(false); return 0.0; };
53  protected:
54  size_t mExp;
55  };
56 
57  class Polynomial2: public Polynomial { public: Polynomial2(){ mExp = 2;};};
58  class Polynomial3: public Polynomial { public: Polynomial3(){ mExp = 3;};};
59  class Polynomial4: public Polynomial { public: Polynomial4(){ mExp = 4;};};
60  class Polynomial5: public Polynomial { public: Polynomial5(){ mExp = 5;};};
61  class Polynomial6: public Polynomial { public: Polynomial6(){ mExp = 6;};};
62  class Polynomial7: public Polynomial { public: Polynomial7(){ mExp = 7;};};
63 
65 
66 } //namespace bayesopt
67 
68 #endif
Namespace of the library interface.
Definition: using.dox:1
Polynomial covariance function.
Atomic (simple) kernel functions.
Abstract class for an atomic kernel.