30 static const int BAYESOPT_FAILURE = -1;
31 static const int BAYESOPT_INVALID_ARGS = -2;
32 static const int BAYESOPT_OUT_OF_MEMORY = -3;
33 static const int BAYESOPT_RUNTIME_ERROR = -4;
49 int n =
static_cast<int>(Xi.size());
50 return mF(n,&Xi[0],NULL,mOtherData);
53 void set_eval_funct(eval_func f)
57 void save_other_data(
void* other_data)
58 { mOtherData = other_data; }
73 DiscreteModel(validX, params)
77 DiscreteModel(categories, params)
82 int n =
static_cast<int>(Xi.size());
83 return mF(n,&Xi[0],NULL,mOtherData);
86 void set_eval_funct(eval_func f)
90 void save_other_data(
void* other_data)
91 { mOtherData = other_data; }
99 const double *lb,
const double *ub,
102 vectord result(nDim);
104 vectord lowerBound = bayesopt::utils::array2vector(lb,nDim);
105 vectord upperBound = bayesopt::utils::array2vector(ub,nDim);
111 optimizer.set_eval_funct(f);
112 optimizer.save_other_data(f_data);
116 std::copy(result.begin(), result.end(), x);
118 *minf = optimizer.getValueAtMinimum();
120 catch (std::bad_alloc& e)
122 FILE_LOG(logERROR) << e.what();
123 return BAYESOPT_OUT_OF_MEMORY;
125 catch (std::invalid_argument& e)
127 FILE_LOG(logERROR) << e.what();
128 return BAYESOPT_INVALID_ARGS;
130 catch (std::runtime_error& e)
132 FILE_LOG(logERROR) << e.what();
133 return BAYESOPT_RUNTIME_ERROR;
137 FILE_LOG(logERROR) <<
"Unknown error";
138 return BAYESOPT_FAILURE;
144 double *valid_x,
size_t n_points,
147 vectord result(nDim);
151 for(
size_t i = 0; i<n_points;++i)
153 for(
int j = 0; j<nDim; ++j)
155 input(j) = valid_x[i*nDim+j];
157 xSet.push_back(input);
170 optimizer.set_eval_funct(f);
171 optimizer.save_other_data(f_data);
174 std::copy(result.begin(), result.end(), x);
176 *minf = optimizer.getValueAtMinimum();
178 catch (std::bad_alloc& e)
180 FILE_LOG(logERROR) << e.what();
181 return BAYESOPT_OUT_OF_MEMORY;
183 catch (std::invalid_argument& e)
185 FILE_LOG(logERROR) << e.what();
186 return BAYESOPT_INVALID_ARGS;
188 catch (std::runtime_error& e)
190 FILE_LOG(logERROR) << e.what();
191 return BAYESOPT_RUNTIME_ERROR;
195 FILE_LOG(logERROR) <<
"Unknown error";
196 return BAYESOPT_FAILURE;
204 int *categories,
double *x,
207 vectord result(nDim);
210 std::copy(categories,categories+nDim,cat.begin());
216 optimizer.set_eval_funct(f);
217 optimizer.save_other_data(f_data);
220 std::copy(result.begin(), result.end(), x);
222 *minf = optimizer.getValueAtMinimum();
224 catch (std::bad_alloc& e)
226 FILE_LOG(logERROR) << e.what();
227 return BAYESOPT_OUT_OF_MEMORY;
229 catch (std::invalid_argument& e)
231 FILE_LOG(logERROR) << e.what();
232 return BAYESOPT_INVALID_ARGS;
234 catch (std::runtime_error& e)
236 FILE_LOG(logERROR) << e.what();
237 return BAYESOPT_RUNTIME_ERROR;
241 FILE_LOG(logERROR) <<
"Unknown error";
242 return BAYESOPT_FAILURE;
Boost vector and matrix types.
size_t n_iterations
Maximum BayesOpt evaluations (budget)
int bayes_optimization(int nDim, eval_func f, void *f_data, const double *lb, const double *ub, double *x, double *minf, bopt_params parameters)
C wrapper for the Bayesian optimization algorithm.
double evaluateSample(const vectord &Xi)
Function that defines the actual function to be optimized.
Version of ContinuousModel for the C wrapper.
Bayesian optimization for functions in continuous input spaces.
ContinuousModel()
Default constructor forbidden.
double evaluateSample(const vectord &Xi)
Function that defines the actual function to be optimized.
int bayes_optimization_disc(int nDim, eval_func f, void *f_data, double *valid_x, size_t n_points, double *x, double *minf, bopt_params parameters)
C wrapper for the Bayesian optimization algorithm.
BayesOpt main C++ interface.
BayesOpt wrapper for C interface.
size_t n_init_samples
Number of samples before optimization.
void setBoundingBox(const vectord &lowerBound, const vectord &upperBound)
Sets the bounding box.
void optimize(vectord &bestPoint)
Execute the optimization process of the function defined in evaluateSample.
Configuration parameters.
Version of DiscreteModel for the C wrapper.
Bayesian optimization for functions in discrete spaces.
int bayes_optimization_categorical(int nDim, eval_func f, void *f_data, int *categories, double *x, double *minf, bopt_params parameters)
C wrapper for the Bayesian optimization algorithm.
Modules and helper macros for logging.