BayesOpt
bo_oned.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 "testfunctions.hpp"
24 #include "param_loader.hpp"
25 
26 int main(int nargs, char *args[])
27 {
28  bayesopt::Parameters parameters;
29  if(nargs > 1){
30  if(!bayesopt::utils::ParamLoader::load(args[1], parameters)){
31  std::cout << "ERROR: provided file \"" << args[1] << "\" does not exist" << std::endl;
32  return -1;
33  }
34  }
35  else{
36  parameters.n_init_samples = 10;
37  parameters.n_iterations = 300;
38 
39  parameters.crit_name = "cHedge(cEI,cLCB,cExpReturn,cOptimisticSampling)";
40  //bayesopt::utils::ParamLoader::save("bo_oned.txt", parameters);
41  }
42 
43  ExampleOneD opt(parameters);
44  vectord result(1);
45  opt.optimize(result);
46 
47  std::cout << "Result:" << result << std::endl;
48  opt.printOptimal();
49 
50  return 0;
51 }
size_t n_init_samples
Number of samples before optimization.
Definition: parameters.hpp:68
size_t n_iterations
Maximum BayesOpt evaluations (budget)
Definition: parameters.hpp:66
std::string crit_name
Name of the criterion.
Definition: parameters.hpp:110
Allows to load parameters from file.