25 void mexFunction(
int nlhs, mxArray *plhs[],
26 int nrhs,
const mxArray *prhs[])
30 const mxArray *func_name, *params;
39 CHECK0(nlhs != 2 || nrhs != 3,
"wrong number of arguments");
48 if (mxIsChar(func_name))
50 CHECK0(mxGetString(func_name, udata.f, FLEN) == 0,
51 "error reading function name string (too long?)");
56 else if (mxIsFunctionHandle(func_name))
58 udata.prhs[0] = (mxArray *)func_name;
59 strcpy(udata.f,
"feval");
66 mexErrMsgTxt(
"First term should be a function name " 67 "(Matlab/Octave) or function handle (Matlab)");
71 CHECK0(mxIsDouble(prhs[1]) && !mxIsComplex(prhs[1]) &&
72 mxGetNumberOfDimensions(prhs[1]) == 2,
73 "The set of values must be a 2D real matrix.");
75 nDim = mxGetM(prhs[1]);
76 nPoints = mxGetN(prhs[1]);
77 xset = mxGetPr(prhs[1]);
78 mexPrintf(
"Loading set of values. nDims=%i, nPoints=%i\n",nDim,nPoints);
80 udata.prhs[udata.xrhs] = mxCreateDoubleMatrix(1, nDim, mxREAL);
82 xopt = mxCreateDoubleMatrix(1, nDim, mxREAL);
89 CHECK0(mxIsStruct(prhs[2]),
"3rd element must be a struct");
94 params = mxCreateStructMatrix(1,1,0,NULL);
97 parameters = load_parameters(params);
100 xptr,&fmin,parameters);
102 mxDestroyArray(udata.prhs[udata.xrhs]);
106 plhs[1] = mxCreateDoubleMatrix(1, 1, mxREAL);
107 *(mxGetPr(plhs[1])) = fmin;
112 plhs[2] = mxCreateDoubleMatrix(1, 1, mxREAL);
113 *(mxGetPr(plhs[2])) = (
double)(error_code);
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.
Configuration parameters.