23 #include <boost/numeric/ublas/matrix_proxy.hpp> 32 double testFunction(
unsigned int n,
const double *x,
37 for (
unsigned int i = 0; i < n; ++i)
39 f += (x[i] - .53) * (x[i] - .53);
55 for (
size_t i = 0; i < Xi.size(); ++i)
59 return testFunction(Xi.size(),x,NULL,NULL);
67 int main(
int nargs,
char *args[])
80 const size_t nPoints = 1000;
86 matrixd xPoints(nPoints,n);
96 double xPointsArray[6000];
98 const size_t nPinArr = n*nPoints;
99 double xPointsArray[nPinArr];
107 for(
size_t i = 0; i<nPoints; ++i)
109 vectord point = row(xPoints,i);
111 for(
size_t j=0; j<n; ++j)
113 xPointsArray[i*n+j] = point(j);
120 std::cout <<
"Running C++ interface" << std::endl;
127 std::cout <<
"Running C interface" << std::endl;
128 double x[128], fmin[128];
130 x, fmin, par.generate_bopt_params());
136 for(
size_t i = 1; i<nPoints; ++i)
138 vectord point = row(xPoints,i);
143 std::cout << i <<
"," << minvalue << std::endl;
147 std::cout <<
"Final result C++: " << result <<
" | Value:" << opt.
evaluateSample(result) << std::endl;
148 std::cout <<
"Final result C: ["<< n <<
"](";
149 for (
int i = 0; i < n; i++ )
150 std::cout << x[i] <<
", ";
151 std::cout <<
")" <<
" | Value:" << fmin[0] << std::endl;
152 std::cout <<
"Optimal: " << row(xPoints,min) <<
" | Value:" << minvalue << std::endl;
Boost vector and matrix types.
DiscreteModel()
Default constructor forbidden.
BAYESOPT_API 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.
size_t n_init_samples
Number of samples before optimization.
BayesOpt main C++ interface.
BayesOpt wrapper for C interface.
Latin Hypercube Sampling.
void lhs(M &Result, randEngine &mtRandom)
Latin hypercube sampling It is used to generate a uniform Latin hypercube.
double evaluateSample(const vectord &Xi)
Function that defines the actual function to be optimized.
size_t n_iterations
Maximum BayesOpt evaluations (budget)
void optimize(vectord &bestPoint)
Execute the optimization process of the function defined in evaluateSample.
std::string surr_name
Name of the surrogate function.
Bayesian optimization for functions in discrete spaces.
double noise
Variance of observation noise (and nugget)
bool checkReachability(const vectord &query)
This function checks if the query is valid or not.