BayesOpt
criteria_hedge.hpp
Go to the documentation of this file.
1 
3 /*
4 -------------------------------------------------------------------------
5  This file is part of BayesOpt, an efficient C++ library for
6  Bayesian optimization.
7 
8  Copyright (C) 2011-2015 Ruben Martinez-Cantin <rmcantin@unizar.es>
9 
10  BayesOpt is free software: you can redistribute it and/or modify it
11  under the terms of the GNU Affero General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  BayesOpt is distributed in the hope that it will be useful, but
16  WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  GNU Affero General Public License for more details.
19 
20  You should have received a copy of the GNU Affero General Public License
21  along with BayesOpt. If not, see <http://www.gnu.org/licenses/>.
22 ------------------------------------------------------------------------
23 */
24 
25 #ifndef _CRITERIA_HEDGE_HPP_
26 #define _CRITERIA_HEDGE_HPP_
27 
28 #include "criteria_combined.hpp"
29 
30 
31 namespace bayesopt
32 {
35 
43  class GP_Hedge: public CombinedCriteria
44  {
45  public:
46  GP_Hedge();
47  virtual ~GP_Hedge() {};
48  void init(NonParametricProcess *proc);
49 
50  double operator() (const vectord &x) { return (*mCurrentCriterium)(x); };
51 
52  bool requireComparison(){ return true; };
53  void initialCriteria();
54  bool rotateCriteria(); //Returns false if NOT rotated -> end of list
55  void pushResult(const vectord& prevResult);
56  std::string getBestCriteria(vectord& best);
57 
58  std::string name() {return "cHedge";};
59  protected:
60  int update_hedge();
61 
62  vectord loss_, gain_, prob_, cumprob_;
63  Criteria* mCurrentCriterium;
64  std::vector<vectord> mBestLists;
65  size_t mIndex;
66 
67  virtual double computeLoss(const vectord& query)
68  { return mProc->prediction(query)->getMean(); }
69  };
70 
75  class GP_Hedge_Random: public GP_Hedge
76  {
77  public:
78  virtual ~GP_Hedge_Random() {};
79  std::string name() {return "cHedgeRandom";};
80 
81  protected:
82  virtual double computeLoss(const vectord& query)
83  { return mProc->prediction(query)->sample_query(); }
84  };
85 
86 
88 
89 } //namespace bayesopt
90 
91 
92 #endif
Namespace of the library interface.
Definition: using.dox:1
Abstract class to implement Bayesian regressors.
GP_Hedge model as describen in Hoffman et al.
Abstract class for combined criteria functions.
Modification of the GP_Hedge algorithm where the bandit gains are random outcomes (like Thompson samp...
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 module for combined criteria.